Merge branch 'ui-resize-update' of https://github.com/Swiggies/FlaxEngine into Swiggies-ui-resize-update
This commit is contained in:
@@ -408,6 +408,8 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
{
|
{
|
||||||
private Type _cachedType;
|
private Type _cachedType;
|
||||||
private bool _anchorDropDownClosed = true;
|
private bool _anchorDropDownClosed = true;
|
||||||
|
private Button _pivotRelativeButton;
|
||||||
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void Initialize(LayoutElementsContainer layout)
|
public override void Initialize(LayoutElementsContainer layout)
|
||||||
@@ -487,10 +489,52 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
|
|
||||||
BuildLocationSizeOffsets(horUp, horDown, _cachedXEq, _cachedYEq, valueTypes);
|
BuildLocationSizeOffsets(horUp, horDown, _cachedXEq, _cachedYEq, valueTypes);
|
||||||
|
|
||||||
|
BuildExtraButtons(group);
|
||||||
|
|
||||||
main.Space(10);
|
main.Space(10);
|
||||||
BuildAnchorsDropper(main, valueTypes);
|
BuildAnchorsDropper(main, valueTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void BuildExtraButtons(VerticalPanelElement group)
|
||||||
|
{
|
||||||
|
(Values[0] as Control).PivotRelative = Editor.Instance.Windows.PropertiesWin.PivotRelativeSize;
|
||||||
|
|
||||||
|
var current = Editor.Instance.Windows.PropertiesWin.PivotRelativeSize;
|
||||||
|
|
||||||
|
var panel = group.CustomContainer<Panel>();
|
||||||
|
panel.CustomControl.Height = TextBoxBase.DefaultHeight;
|
||||||
|
panel.CustomControl.ClipChildren = false;
|
||||||
|
panel.CustomControl.Parent = group.ContainerControl;
|
||||||
|
|
||||||
|
_pivotRelativeButton = new Button()
|
||||||
|
{
|
||||||
|
Parent = panel.ContainerControl,
|
||||||
|
Width = 18,
|
||||||
|
Height = 18,
|
||||||
|
BackgroundBrush = new SpriteBrush(Editor.Instance.Icons.Scale32),
|
||||||
|
AnchorPreset = AnchorPresets.TopRight,
|
||||||
|
X = 77,
|
||||||
|
};
|
||||||
|
|
||||||
|
SetStyle(current);
|
||||||
|
_pivotRelativeButton.Clicked += PivotRelativeClicked;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PivotRelativeClicked()
|
||||||
|
{
|
||||||
|
var current = (Values[0] as Control).PivotRelative;
|
||||||
|
(Values[0] as Control).PivotRelative = !current;
|
||||||
|
Editor.Instance.Windows.PropertiesWin.PivotRelativeSize = !current;
|
||||||
|
SetStyle((Values[0] as Control).PivotRelative);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetStyle(bool current)
|
||||||
|
{
|
||||||
|
var style = FlaxEngine.GUI.Style.Current;
|
||||||
|
var backgroundColor = current ? style.Foreground : style.ForegroundDisabled;
|
||||||
|
_pivotRelativeButton.SetColors(backgroundColor);
|
||||||
|
}
|
||||||
|
|
||||||
private void BuildAnchorsDropper(LayoutElementsContainer main, ScriptType[] valueTypes)
|
private void BuildAnchorsDropper(LayoutElementsContainer main, ScriptType[] valueTypes)
|
||||||
{
|
{
|
||||||
ScriptMemberInfo minInfo = valueTypes[0].GetProperty("AnchorMin");
|
ScriptMemberInfo minInfo = valueTypes[0].GetProperty("AnchorMin");
|
||||||
|
|||||||
@@ -30,6 +30,11 @@ namespace FlaxEditor.Windows
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool ScaleLinked = false;
|
public bool ScaleLinked = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indictation of if UI elements should size relative to the pivot point
|
||||||
|
/// </summary>
|
||||||
|
public bool PivotRelativeSize = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="PropertiesWindow"/> class.
|
/// Initializes a new instance of the <see cref="PropertiesWindow"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
|
// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Runtime.Remoting.Messaging;
|
||||||
|
|
||||||
namespace FlaxEngine.GUI
|
namespace FlaxEngine.GUI
|
||||||
{
|
{
|
||||||
@@ -169,6 +170,16 @@ namespace FlaxEngine.GUI
|
|||||||
set => Bounds = new Rectangle(value + (_parent != null ? _parent.Bounds.Size * (_anchorMax + _anchorMin) * 0.5f : Float2.Zero) - _bounds.Size * _pivot, _bounds.Size);
|
set => Bounds = new Rectangle(value + (_parent != null ? _parent.Bounds.Size * (_anchorMax + _anchorMin) * 0.5f : Float2.Zero) - _bounds.Size * _pivot, _bounds.Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether to resize the UI Control based on where the pivot is rather than just the top-left.
|
||||||
|
/// </summary>
|
||||||
|
[NoSerialize, HideInEditor]
|
||||||
|
public bool PivotRelative
|
||||||
|
{
|
||||||
|
get => _pivotRelativeSizing;
|
||||||
|
set => _pivotRelativeSizing = value;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets width of the control.
|
/// Gets or sets width of the control.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -180,7 +191,13 @@ namespace FlaxEngine.GUI
|
|||||||
{
|
{
|
||||||
if (Mathf.NearEqual(_bounds.Size.X, value))
|
if (Mathf.NearEqual(_bounds.Size.X, value))
|
||||||
return;
|
return;
|
||||||
var bounds = new Rectangle(_bounds.Location, value, _bounds.Size.Y);
|
var rectLocation = _bounds.Location;
|
||||||
|
if (PivotRelative)
|
||||||
|
{
|
||||||
|
var delta = _bounds.Size.X - value;
|
||||||
|
rectLocation.X += delta * Pivot.X;
|
||||||
|
}
|
||||||
|
var bounds = new Rectangle(rectLocation, value, _bounds.Size.Y);
|
||||||
SetBounds(ref bounds);
|
SetBounds(ref bounds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -196,7 +213,13 @@ namespace FlaxEngine.GUI
|
|||||||
{
|
{
|
||||||
if (Mathf.NearEqual(_bounds.Size.Y, value))
|
if (Mathf.NearEqual(_bounds.Size.Y, value))
|
||||||
return;
|
return;
|
||||||
var bounds = new Rectangle(_bounds.Location, _bounds.Size.X, value);
|
var rectLocation = _bounds.Location;
|
||||||
|
if (PivotRelative)
|
||||||
|
{
|
||||||
|
var delta = _bounds.Size.Y - value;
|
||||||
|
rectLocation.Y += delta * Pivot.Y;
|
||||||
|
}
|
||||||
|
var bounds = new Rectangle(rectLocation, _bounds.Size.X, value);
|
||||||
SetBounds(ref bounds);
|
SetBounds(ref bounds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ namespace FlaxEngine.GUI
|
|||||||
private float _rotation;
|
private float _rotation;
|
||||||
internal Matrix3x3 _cachedTransform;
|
internal Matrix3x3 _cachedTransform;
|
||||||
internal Matrix3x3 _cachedTransformInv;
|
internal Matrix3x3 _cachedTransformInv;
|
||||||
|
private bool _pivotRelativeSizing = false;
|
||||||
|
|
||||||
// Style
|
// Style
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user