Cleanup 5
This commit is contained in:
@@ -32,8 +32,11 @@ namespace FlaxEngine.GUI
|
||||
private bool IntersectsChildContent(CanvasRootControl child, ref Ray ray, out Vector2 childSpaceLocation)
|
||||
{
|
||||
// Inline bounds calculations (it will reuse world matrix)
|
||||
OrientedBoundingBox bounds = new OrientedBoundingBox();
|
||||
bounds.Extents = new Vector3(child.Size * 0.5f, Mathf.Epsilon);
|
||||
OrientedBoundingBox bounds = new OrientedBoundingBox
|
||||
{
|
||||
Extents = new Vector3(child.Size * 0.5f, Mathf.Epsilon)
|
||||
};
|
||||
|
||||
child.Canvas.GetWorldMatrix(out var world);
|
||||
Matrix.Translation(bounds.Extents.X, bounds.Extents.Y, 0, out var offset);
|
||||
Matrix.Multiply(ref offset, ref world, out bounds.Transformation);
|
||||
|
||||
@@ -64,8 +64,10 @@ namespace FlaxEngine.GUI
|
||||
VScrollBar = GetChild<VScrollBar>();
|
||||
if (VScrollBar == null)
|
||||
{
|
||||
VScrollBar = new VScrollBar(this, Width - ScrollBar.DefaultSize, Height);
|
||||
VScrollBar.AnchorPreset = AnchorPresets.TopLeft;
|
||||
VScrollBar = new VScrollBar(this, Width - ScrollBar.DefaultSize, Height)
|
||||
{
|
||||
AnchorPreset = AnchorPresets.TopLeft
|
||||
};
|
||||
//VScrollBar.X += VScrollBar.Width;
|
||||
VScrollBar.ValueChanged += () => SetViewOffset(Orientation.Vertical, VScrollBar.Value);
|
||||
}
|
||||
@@ -82,8 +84,10 @@ namespace FlaxEngine.GUI
|
||||
HScrollBar = GetChild<HScrollBar>();
|
||||
if (HScrollBar == null)
|
||||
{
|
||||
HScrollBar = new HScrollBar(this, Height - ScrollBar.DefaultSize, Width);
|
||||
HScrollBar.AnchorPreset = AnchorPresets.TopLeft;
|
||||
HScrollBar = new HScrollBar(this, Height - ScrollBar.DefaultSize, Width)
|
||||
{
|
||||
AnchorPreset = AnchorPresets.TopLeft
|
||||
};
|
||||
//HScrollBar.Y += HScrollBar.Height;
|
||||
//HScrollBar.Offsets += new Margin(0, 0, HScrollBar.Height * 0.5f, 0);
|
||||
HScrollBar.ValueChanged += () => SetViewOffset(Orientation.Horizontal, HScrollBar.Value);
|
||||
|
||||
@@ -234,8 +234,10 @@ namespace FlaxEngine
|
||||
/// </summary>
|
||||
public UICanvas()
|
||||
{
|
||||
_guiRoot = new CanvasRootControl(this);
|
||||
_guiRoot.IsLayoutLocked = false;
|
||||
_guiRoot = new CanvasRootControl(this)
|
||||
{
|
||||
IsLayoutLocked = false
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -245,12 +247,12 @@ namespace FlaxEngine
|
||||
{
|
||||
get
|
||||
{
|
||||
OrientedBoundingBox bounds = new OrientedBoundingBox();
|
||||
bounds.Extents = new Vector3(_guiRoot.Size * 0.5f, Mathf.Epsilon);
|
||||
Matrix world;
|
||||
GetWorldMatrix(out world);
|
||||
Matrix offset;
|
||||
Matrix.Translation(bounds.Extents.X, bounds.Extents.Y, 0, out offset);
|
||||
OrientedBoundingBox bounds = new OrientedBoundingBox
|
||||
{
|
||||
Extents = new Vector3(_guiRoot.Size * 0.5f, Mathf.Epsilon)
|
||||
};
|
||||
GetWorldMatrix(out Matrix world);
|
||||
Matrix.Translation(bounds.Extents.X, bounds.Extents.Y, 0, out Matrix offset);
|
||||
Matrix.Multiply(ref offset, ref world, out bounds.Transformation);
|
||||
return bounds;
|
||||
}
|
||||
|
||||
@@ -161,9 +161,11 @@ namespace FlaxEngine
|
||||
if (!(_control is ContainerControl))
|
||||
throw new InvalidOperationException("To add child to the control it has to be ContainerControl.");
|
||||
|
||||
var child = new UIControl();
|
||||
child.Parent = this;
|
||||
child.Control = (Control)Activator.CreateInstance(typeof(T));
|
||||
var child = new UIControl
|
||||
{
|
||||
Parent = this,
|
||||
Control = (Control)Activator.CreateInstance(typeof(T))
|
||||
};
|
||||
return child;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user