Merge branch 'grid-slot-spacing' of https://github.com/Tryibion/FlaxEngine into Tryibion-grid-slot-spacing
This commit is contained in:
@@ -41,6 +41,13 @@ namespace FlaxEditor.CustomEditors.Editors
|
|||||||
public override void Initialize(LayoutElementsContainer layout)
|
public override void Initialize(LayoutElementsContainer layout)
|
||||||
{
|
{
|
||||||
base.Initialize(layout);
|
base.Initialize(layout);
|
||||||
|
|
||||||
|
if (XElement.ValueBox.Parent is UniformGridPanel ug)
|
||||||
|
{
|
||||||
|
ug.Height += 2;
|
||||||
|
ug.SlotSpacing = new Float2(4);
|
||||||
|
ug.SlotPadding = new Margin(0, 0, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
// Override colors
|
// Override colors
|
||||||
var back = FlaxEngine.GUI.Style.Current.TextBoxBackground;
|
var back = FlaxEngine.GUI.Style.Current.TextBoxBackground;
|
||||||
@@ -66,6 +73,13 @@ namespace FlaxEditor.CustomEditors.Editors
|
|||||||
public override void Initialize(LayoutElementsContainer layout)
|
public override void Initialize(LayoutElementsContainer layout)
|
||||||
{
|
{
|
||||||
base.Initialize(layout);
|
base.Initialize(layout);
|
||||||
|
|
||||||
|
if (XElement.ValueBox.Parent is UniformGridPanel ug)
|
||||||
|
{
|
||||||
|
ug.Height += 2;
|
||||||
|
ug.SlotSpacing = new Float2(4);
|
||||||
|
ug.SlotPadding = new Margin(0, 0, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
// Override colors
|
// Override colors
|
||||||
var back = FlaxEngine.GUI.Style.Current.TextBoxBackground;
|
var back = FlaxEngine.GUI.Style.Current.TextBoxBackground;
|
||||||
@@ -122,6 +136,13 @@ namespace FlaxEditor.CustomEditors.Editors
|
|||||||
menu.AddButton("Link", ToggleLink).LinkTooltip("Links scale components for uniform scaling");
|
menu.AddButton("Link", ToggleLink).LinkTooltip("Links scale components for uniform scaling");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (XElement.ValueBox.Parent is UniformGridPanel ug)
|
||||||
|
{
|
||||||
|
ug.Height += 2;
|
||||||
|
ug.SlotSpacing = new Float2(4);
|
||||||
|
ug.SlotPadding = new Margin(0, 0, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
// Override colors
|
// Override colors
|
||||||
var back = FlaxEngine.GUI.Style.Current.TextBoxBackground;
|
var back = FlaxEngine.GUI.Style.Current.TextBoxBackground;
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ namespace FlaxEditor.GUI.Input
|
|||||||
base.Draw();
|
base.Draw();
|
||||||
|
|
||||||
var style = Style.Current;
|
var style = Style.Current;
|
||||||
var r = new Rectangle(2, 2, Width - 4, Height - 4);
|
var r = new Rectangle(0, 0, Width, Height);
|
||||||
|
|
||||||
Render2D.FillRectangle(r, _value);
|
Render2D.FillRectangle(r, _value);
|
||||||
Render2D.DrawRectangle(r, IsMouseOver || IsNavFocused ? style.BackgroundSelected : Color.Black);
|
Render2D.DrawRectangle(r, IsMouseOver || IsNavFocused ? style.BackgroundSelected : Color.Black);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ namespace FlaxEngine.GUI
|
|||||||
{
|
{
|
||||||
private Margin _slotPadding;
|
private Margin _slotPadding;
|
||||||
private int _slotsV, _slotsH;
|
private int _slotsV, _slotsH;
|
||||||
|
private Float2 _slotSpacing;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the padding given to each slot.
|
/// Gets or sets the padding given to each slot.
|
||||||
@@ -62,11 +63,25 @@ namespace FlaxEngine.GUI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets grid slot spacing.
|
||||||
|
/// </summary>
|
||||||
|
[EditorOrder(30), Limit(0), Tooltip("The Grid slot spacing.")]
|
||||||
|
public Float2 SlotSpacing
|
||||||
|
{
|
||||||
|
get => _slotSpacing;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_slotSpacing = value;
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="UniformGridPanel"/> class.
|
/// Initializes a new instance of the <see cref="UniformGridPanel"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public UniformGridPanel()
|
public UniformGridPanel()
|
||||||
: this(2)
|
: this(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,10 +89,11 @@ namespace FlaxEngine.GUI
|
|||||||
/// Initializes a new instance of the <see cref="UniformGridPanel"/> class.
|
/// Initializes a new instance of the <see cref="UniformGridPanel"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="slotPadding">The slot padding.</param>
|
/// <param name="slotPadding">The slot padding.</param>
|
||||||
public UniformGridPanel(float slotPadding = 2)
|
public UniformGridPanel(float slotPadding = 0)
|
||||||
{
|
{
|
||||||
AutoFocus = false;
|
AutoFocus = false;
|
||||||
SlotPadding = new Margin(slotPadding);
|
SlotPadding = new Margin(slotPadding);
|
||||||
|
SlotSpacing = new Float2(2);
|
||||||
_slotsH = _slotsV = 5;
|
_slotsH = _slotsV = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,6 +138,42 @@ namespace FlaxEngine.GUI
|
|||||||
var slotBounds = new Rectangle(slotSize.X * x, slotSize.Y * y, slotSize.X, slotSize.Y);
|
var slotBounds = new Rectangle(slotSize.X * x, slotSize.Y * y, slotSize.X, slotSize.Y);
|
||||||
_slotPadding.ShrinkRectangle(ref slotBounds);
|
_slotPadding.ShrinkRectangle(ref slotBounds);
|
||||||
|
|
||||||
|
if (slotsV > 1)
|
||||||
|
{
|
||||||
|
if (y == 0)
|
||||||
|
{
|
||||||
|
slotBounds.Height -= _slotSpacing.Y * 0.5f;
|
||||||
|
}
|
||||||
|
else if (y == slotsV - 1)
|
||||||
|
{
|
||||||
|
slotBounds.Height -= _slotSpacing.Y * 0.5f;
|
||||||
|
slotBounds.Y += _slotSpacing.Y * 0.5f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
slotBounds.Height -= _slotSpacing.Y;
|
||||||
|
slotBounds.Y += _slotSpacing.Y * 0.5f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (slotsH > 1)
|
||||||
|
{
|
||||||
|
if (x == 0)
|
||||||
|
{
|
||||||
|
slotBounds.Width -= _slotSpacing.X * 0.5f;
|
||||||
|
}
|
||||||
|
else if (x == slotsH - 1)
|
||||||
|
{
|
||||||
|
slotBounds.Width -= _slotSpacing.X * 0.5f;
|
||||||
|
slotBounds.X += _slotSpacing.X * 0.5f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
slotBounds.Width -= _slotSpacing.X;
|
||||||
|
slotBounds.X += _slotSpacing.X * 0.5f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var c = _children[i++];
|
var c = _children[i++];
|
||||||
c.Bounds = slotBounds;
|
c.Bounds = slotBounds;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user