Merge branch 'ArrayEditorHideSize' of https://github.com/xxSeys1/FlaxEngine into xxSeys1-ArrayEditorHideSize
This commit is contained in:
@@ -450,6 +450,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
protected bool NotNullItems;
|
||||
|
||||
private IntValueBox _sizeBox;
|
||||
private Label _label;
|
||||
private Color _background;
|
||||
private int _elementsCount, _minCount, _maxCount;
|
||||
private bool _readOnly;
|
||||
@@ -566,7 +567,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
Parent = dropPanel,
|
||||
};
|
||||
|
||||
var label = new Label
|
||||
_label = new Label
|
||||
{
|
||||
Text = "Size",
|
||||
AnchorPreset = AnchorPresets.TopRight,
|
||||
@@ -672,8 +673,10 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
Resize(Count + 1);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Layout.ContainerControl.SizeChanged += OnLayoutSizeChanged;
|
||||
}
|
||||
|
||||
private void OnSetupContextMenu(ContextMenu menu, DropPanel panel)
|
||||
{
|
||||
if (menu.Items.Any(x => x is ContextMenuButton b && b.Text.Equals("Open All", StringComparison.Ordinal)))
|
||||
@@ -696,10 +699,24 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
});
|
||||
}
|
||||
|
||||
private void OnLayoutSizeChanged(Control control)
|
||||
{
|
||||
if (Layout.ContainerControl is DropPanel dropPanel)
|
||||
{
|
||||
// Hide "Size" text when array editor title overlaps
|
||||
var headerTextSize = dropPanel.HeaderTextFont.GetFont().MeasureText(dropPanel.HeaderText);
|
||||
if (headerTextSize.X + DropPanel.DropDownIconSize >= _label.Left)
|
||||
_label.TextColor = _label.TextColorHighlighted = Color.Transparent;
|
||||
else
|
||||
_label.TextColor = _label.TextColorHighlighted = FlaxEngine.GUI.Style.Current.Foreground;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Deinitialize()
|
||||
{
|
||||
_sizeBox = null;
|
||||
Layout.ContainerControl.SizeChanged -= OnLayoutSizeChanged;
|
||||
|
||||
base.Deinitialize();
|
||||
}
|
||||
|
||||
@@ -11,6 +11,11 @@ namespace FlaxEngine.GUI
|
||||
[ActorToolbox("GUI")]
|
||||
public class DropPanel : ContainerControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Size of the drop down icon.
|
||||
/// </summary>
|
||||
public const float DropDownIconSize = 14.0f;
|
||||
|
||||
/// <summary>
|
||||
/// The header height.
|
||||
/// </summary>
|
||||
@@ -386,7 +391,7 @@ namespace FlaxEngine.GUI
|
||||
float textLeft = 0;
|
||||
if (EnableDropDownIcon)
|
||||
{
|
||||
textLeft += 14;
|
||||
textLeft += DropDownIconSize;
|
||||
var dropDownRect = new Rectangle(2, (HeaderHeight - 12) / 2, 12, 12);
|
||||
var arrowColor = _mouseOverHeader ? style.Foreground : style.ForegroundGrey;
|
||||
if (_isClosed)
|
||||
|
||||
Reference in New Issue
Block a user