diff --git a/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs b/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs
index e176f2b70..95f06c3f4 100644
--- a/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs
+++ b/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs
@@ -39,6 +39,8 @@ namespace FlaxEditor.CustomEditors.Dedicated
public bool IsSelected;
+ public bool SupportsShiftModulation;
+
private void OnPresetsChanged()
{
TooltipText = CustomEditorsUtil.GetPropertyNameUI(_presets.ToString());
@@ -79,6 +81,15 @@ namespace FlaxEditor.CustomEditors.Dedicated
borderColor = BorderColorHighlighted;
}
+ if (Input.GetKey(KeyboardKeys.Shift) && SupportsShiftModulation)
+ {
+ backgroundColor = BackgroundColorSelected;
+ }
+ if (Input.GetKey(KeyboardKeys.Control) && SupportsShiftModulation)
+ {
+ borderColor = BackgroundColorSelected;
+ }
+
// Calculate fill area
float fillSize = rect.Width / 3;
Rectangle fillArea;
@@ -166,12 +177,17 @@ namespace FlaxEditor.CustomEditors.Dedicated
const float DialogWidth = ButtonsSize * 4 + ButtonsMargin * 5 + ButtonsMarginStretch;
const float DialogHeight = TitleHeight + ButtonsSize * 4 + ButtonsMargin * 5 + ButtonsMarginStretch;
+ bool SupportsShiftModulation = false;
+
///
/// Initializes a new instance of the class.
///
/// The initial value.
- public AnchorPresetsEditorPopup(AnchorPresets presets)
+ /// If the popup should react to shift
+ public AnchorPresetsEditorPopup(AnchorPresets presets, bool supportsShiftModulation)
{
+ SupportsShiftModulation = supportsShiftModulation;
+
var style = FlaxEngine.GUI.Style.Current;
Tag = presets;
Size = new Vector2(DialogWidth, DialogHeight);
@@ -219,6 +235,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
Parent = this,
Presets = presets,
IsSelected = presets == (AnchorPresets)Tag,
+ SupportsShiftModulation = SupportsShiftModulation,
Tag = presets,
};
button.ButtonClicked += OnButtonClicked;
@@ -278,7 +295,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
private void OnButtonClicked()
{
var location = _button.Center + new Vector2(3.0f);
- var editor = new AnchorPresetsEditorPopup(_button.Presets);
+ var editor = new AnchorPresetsEditorPopup(_button.Presets, true);
editor.VisibleChanged += OnEditorVisibleChanged;
editor.Show(_button.Parent, location);
}
diff --git a/Source/Engine/UI/GUI/Control.Bounds.cs b/Source/Engine/UI/GUI/Control.Bounds.cs
index e4e2eafcc..658115f43 100644
--- a/Source/Engine/UI/GUI/Control.Bounds.cs
+++ b/Source/Engine/UI/GUI/Control.Bounds.cs
@@ -465,8 +465,9 @@ namespace FlaxEngine.GUI
/// Sets the anchor preset for the control. Can be use to auto-place the control for a given preset or can preserve the current control bounds.
///
/// The anchor preset to set.
- /// True if preserve current control bounds, otherwise will align control position accordingly to the anchor location.
- public void SetAnchorPreset(AnchorPresets anchorPreset, bool preserveBounds)
+ /// True if preserve current control bounds, otherwise will align control position accordingly to the anchor location.
+ /// True if pivot should be set too
+ public void SetAnchorPreset(AnchorPresets anchorPreset, bool centerToPosition, bool setPivotToo)
{
for (int i = 0; i < AnchorPresetsData.Length; i++)
{
@@ -484,13 +485,13 @@ namespace FlaxEngine.GUI
_anchorMin = anchorMin;
_anchorMax = anchorMax;
- if (preserveBounds)
+ if (!centerToPosition)
{
UpdateBounds();
Bounds = bounds;
}
}
- if (!preserveBounds)
+ if (centerToPosition)
{
if (_parent != null)
{
@@ -558,6 +559,10 @@ namespace FlaxEngine.GUI
}
SetBounds(ref bounds);
}
+ if (setPivotToo)
+ {
+ Pivot = (anchorMin + anchorMax) / 2;
+ }
_parent?.PerformLayout();
return;
}
diff --git a/Source/Engine/UI/GUI/Control.cs b/Source/Engine/UI/GUI/Control.cs
index 96b7bf22b..6a1e1cca8 100644
--- a/Source/Engine/UI/GUI/Control.cs
+++ b/Source/Engine/UI/GUI/Control.cs
@@ -193,7 +193,7 @@ namespace FlaxEngine.GUI
}
return result;
}
- set => SetAnchorPreset(value, false);
+ set => SetAnchorPreset(value, Input.GetKey(KeyboardKeys.Shift), Input.GetKey(KeyboardKeys.Control));
}
///