diff --git a/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs b/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs index 95f06c3f4..1c0ce7421 100644 --- a/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs +++ b/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs @@ -306,6 +306,29 @@ namespace FlaxEditor.CustomEditors.Dedicated return; SetValue(control.Tag); } + /// + protected override void SynchronizeValue(object value) + { + // Custom anchors editing for Control to handle bounds preservation via key modifiers + if (ParentEditor != null) + { + var centerToPosition = Input.GetKey(KeyboardKeys.Shift); + var setPivot = Input.GetKey(KeyboardKeys.Control); + var editedAny = false; + foreach (var parentValue in ParentEditor.Values) + { + if (parentValue is Control parentControl) + { + parentControl.SetAnchorPreset((AnchorPresets)value, centerToPosition, setPivot); + editedAny = true; + } + } + if (editedAny) + return; + } + + base.SynchronizeValue(value); + } /// public override void Refresh() diff --git a/Source/Engine/UI/GUI/Control.Bounds.cs.rej b/Source/Engine/UI/GUI/Control.Bounds.cs.rej new file mode 100644 index 000000000..7a10f79e7 --- /dev/null +++ b/Source/Engine/UI/GUI/Control.Bounds.cs.rej @@ -0,0 +1,17 @@ +diff a/Source/Engine/UI/GUI/Control.Bounds.cs b/Source/Engine/UI/GUI/Control.Bounds.cs (rejected hunks) +@@ -485,13 +485,13 @@ + + _anchorMin = anchorMin; + _anchorMax = anchorMax; +- if (preserveBounds) ++ if (!centerToPosition) + { + UpdateBounds(); + Bounds = bounds; + } + } +- if (!preserveBounds) ++ if (centerToPosition) + { + if (_parent != null) + { diff --git a/Source/Engine/UI/GUI/Control.cs b/Source/Engine/UI/GUI/Control.cs index 6a1e1cca8..b51fc615a 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, Input.GetKey(KeyboardKeys.Shift), Input.GetKey(KeyboardKeys.Control)); + set => SetAnchorPreset(value, true, false); } ///