diff --git a/Source/Editor/CustomEditors/CustomEditor.cs b/Source/Editor/CustomEditors/CustomEditor.cs index 2bc9aaac8..05ab5d7b2 100644 --- a/Source/Editor/CustomEditors/CustomEditor.cs +++ b/Source/Editor/CustomEditors/CustomEditor.cs @@ -296,6 +296,16 @@ namespace FlaxEditor.CustomEditors _values.Set(_parent.Values, value); } + private bool SyncParent() + { + // TODO: add attribute for types that want to sync their contents with a parent + var type = Values.Type.Type; + if (type == typeof(LocalizedString) || + type == typeof(FontReference)) + return true; + return _parent != null && !(_parent is SyncPointEditor); + } + internal virtual void RefreshInternal() { if (_values == null) @@ -317,7 +327,7 @@ namespace FlaxEditor.CustomEditors // Propagate values up (eg. when member of structure gets modified, also structure should be updated as a part of the other object) var obj = _parent; - while (obj._parent != null && !(obj._parent is SyncPointEditor)) + while (obj.SyncParent()) { obj.Values.Set(obj._parent.Values, obj.Values); obj = obj._parent; diff --git a/Source/Engine/Render2D/FontReference.cs b/Source/Engine/Render2D/FontReference.cs index 1fcf6711f..b53fedb60 100644 --- a/Source/Engine/Render2D/FontReference.cs +++ b/Source/Engine/Render2D/FontReference.cs @@ -90,7 +90,7 @@ namespace FlaxEngine /// /// The size of the font characters. /// - [EditorOrder(10), Limit(1, 500, 0.1f), Tooltip("The size of the font characters.")] + [EditorOrder(10), Limit(1, 500, 0.5f), Tooltip("The size of the font characters.")] public float Size { get => _size; diff --git a/Source/Engine/UI/GUI/Common/Label.cs b/Source/Engine/UI/GUI/Common/Label.cs index fcd66ff59..0fd3a87b0 100644 --- a/Source/Engine/UI/GUI/Common/Label.cs +++ b/Source/Engine/UI/GUI/Common/Label.cs @@ -57,12 +57,9 @@ namespace FlaxEngine.GUI get => _text; set { - if (_text != value) - { - _text = value; - _textSize = Float2.Zero; - PerformLayout(); - } + _text = value; + _textSize = Float2.Zero; + PerformLayout(); } } @@ -129,15 +126,11 @@ namespace FlaxEngine.GUI get => _font; set { - if (_font != value) + _font = value; + if (_autoWidth || _autoHeight || _autoFitText) { - _font = value; - - if (_autoWidth || _autoHeight || _autoFitText) - { - _textSize = Float2.Zero; - PerformLayout(); - } + _textSize = Float2.Zero; + PerformLayout(); } } } @@ -161,9 +154,9 @@ namespace FlaxEngine.GUI public bool ClipText { get; set; } /// - /// Gets or sets a value indicating whether set automatic width based on text contents. + /// Gets or sets a value indicating whether set automatic width based on text contents. Control size is modified relative to the Pivot. /// - [EditorOrder(85), DefaultValue(false), Tooltip("If checked, the control width will be based on text contents.")] + [EditorOrder(85), DefaultValue(false), Tooltip("If checked, the control width will be based on text contents. Control size is modified relative to the Pivot.")] public bool AutoWidth { get => _autoWidth; @@ -178,9 +171,9 @@ namespace FlaxEngine.GUI } /// - /// Gets or sets a value indicating whether set automatic height based on text contents. + /// Gets or sets a value indicating whether set automatic height based on text contents. Control size is modified relative to the Pivot. /// - [EditorOrder(90), DefaultValue(false), Tooltip("If checked, the control height will be based on text contents.")] + [EditorOrder(90), DefaultValue(false), Tooltip("If checked, the control height will be based on text contents. Control size is modified relative to the Pivot.")] public bool AutoHeight { get => _autoHeight; @@ -336,7 +329,9 @@ namespace FlaxEngine.GUI size.X = _textSize.X + Margin.Width; if (_autoHeight) size.Y = _textSize.Y + Margin.Height; + var pivotRelative = PivotRelative; Size = size; + PivotRelative = pivotRelative; } } } diff --git a/Source/Engine/UI/GUI/Control.Bounds.cs b/Source/Engine/UI/GUI/Control.Bounds.cs index cbb3ba80b..ff548c669 100644 --- a/Source/Engine/UI/GUI/Control.Bounds.cs +++ b/Source/Engine/UI/GUI/Control.Bounds.cs @@ -234,6 +234,11 @@ namespace FlaxEngine.GUI if (_bounds.Size.Equals(ref value)) return; var bounds = new Rectangle(_bounds.Location, value); + if (_pivotRelativeSizing) + { + var delta = _bounds.Size - value; + bounds.Location += delta * Pivot; + } SetBounds(ref bounds); } } @@ -566,7 +571,7 @@ 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. + /// Sets the anchor preset for the control. Can be used 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.