From 08ebd99ed4d234c976c322c973ff4e435d46cac4 Mon Sep 17 00:00:00 2001 From: David Conway Date: Thu, 24 Dec 2020 18:02:26 +1100 Subject: [PATCH 1/4] Add ToolStrip and Toolbox icon scaling settings --- Source/Editor/GUI/ToolStrip.cs | 7 +++++-- Source/Editor/Options/InterfaceOptions.cs | 14 ++++++++++++++ Source/Editor/Windows/ToolboxWindow.cs | 3 ++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Source/Editor/GUI/ToolStrip.cs b/Source/Editor/GUI/ToolStrip.cs index e3c0a82e1..20c0ae9a1 100644 --- a/Source/Editor/GUI/ToolStrip.cs +++ b/Source/Editor/GUI/ToolStrip.cs @@ -1,6 +1,7 @@ // Copyright (c) 2012-2020 Wojciech Figat. All rights reserved. using System; +using FlaxEditor.Options; using FlaxEngine; using FlaxEngine.GUI; @@ -20,7 +21,7 @@ namespace FlaxEditor.GUI /// /// The default margin horizontally. /// - public const int DefaultMarginH = 2; + public const int DefaultMarginH = 4; /// /// Event fired when button gets clicked. @@ -63,13 +64,15 @@ namespace FlaxEditor.GUI /// /// Gets the height for the items. /// - public float ItemsHeight => Height - 2 * DefaultMarginV; + public float ItemsHeight => Height - itemScale * DefaultMarginV; + private float itemScale = 2; /// /// Initializes a new instance of the class. /// public ToolStrip() { + itemScale = Editor.Instance.Options.Options.Interface.ToolStripScale; AutoFocus = false; AnchorPreset = AnchorPresets.HorizontalStretchTop; BackgroundColor = Style.Current.LightBackground; diff --git a/Source/Editor/Options/InterfaceOptions.cs b/Source/Editor/Options/InterfaceOptions.cs index 981e4a653..287e27c85 100644 --- a/Source/Editor/Options/InterfaceOptions.cs +++ b/Source/Editor/Options/InterfaceOptions.cs @@ -44,6 +44,20 @@ namespace FlaxEditor.Options [EditorDisplay("Interface"), EditorOrder(10), Tooltip("Editor User Interface scale. Applied to all UI elements, windows and text. Can be used to scale the interface up on a bigger display. Editor restart required.")] public float InterfaceScale { get; set; } = 1.0f; + /// + /// Gets or sets the ToolStrip item scale. Applied to ToolStrip UI elements, windows and text. Can be used to scale the toolstrip size to fit display needs. Editor restart required.. + /// + [DefaultValue(2.0f), Limit(1f, 10.0f)] + [EditorDisplay("Interface"), EditorOrder(20), Tooltip("Editor ToolStrip scale. Applied to ToolStrip UI elements, windows and text. Can be used to scale the toolstrip size to fit display needs. Editor restart required.")] + public float ToolStripScale { get; set; } = 2.0f; + + /// + /// Gets or sets the ToolBox Icon scale. Editor ToolBox Icon scale. Applied to ToolBox Icon UI elements. Can be used to scale the toolbox icon size to fit display needs. Editor restart required. + /// + [DefaultValue(32.0f), Limit(1f, 64.0f)] + [EditorDisplay("Interface"), EditorOrder(30), Tooltip("Editor ToolBox Icon scale. Applied to ToolBox Icon UI elements. Can be used to scale the toolbox icon size to fit display needs. Editor restart required.")] + public float ToolBoxIconScale { get; set; } = 32.0f; + /// /// Gets or sets a value indicating whether use native window title bar. Editor restart required. /// diff --git a/Source/Editor/Windows/ToolboxWindow.cs b/Source/Editor/Windows/ToolboxWindow.cs index ef2937e84..478692ff1 100644 --- a/Source/Editor/Windows/ToolboxWindow.cs +++ b/Source/Editor/Windows/ToolboxWindow.cs @@ -308,11 +308,12 @@ namespace FlaxEditor.Windows /// public override void OnInit() { + float tabSize = Editor.Instance.Options.Options.Interface.ToolBoxIconScale; TabsControl = new Tabs { AnchorPreset = AnchorPresets.StretchAll, Offsets = Margin.Zero, - TabsSize = new Vector2(48, 48), + TabsSize = new Vector2(tabSize, tabSize), Parent = this }; From 16fab80f86688a805a7e86e123347b63618ce502 Mon Sep 17 00:00:00 2001 From: David Conway Date: Thu, 24 Dec 2020 18:18:41 +1100 Subject: [PATCH 2/4] Change how settings are accessed in ToolBox Window --- Source/Editor/Windows/ToolboxWindow.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Editor/Windows/ToolboxWindow.cs b/Source/Editor/Windows/ToolboxWindow.cs index 478692ff1..7f4069475 100644 --- a/Source/Editor/Windows/ToolboxWindow.cs +++ b/Source/Editor/Windows/ToolboxWindow.cs @@ -308,7 +308,7 @@ namespace FlaxEditor.Windows /// public override void OnInit() { - float tabSize = Editor.Instance.Options.Options.Interface.ToolBoxIconScale; + float tabSize = Editor.Options.Options.Interface.ToolBoxIconScale; TabsControl = new Tabs { AnchorPreset = AnchorPresets.StretchAll, From c0cc89201ea28eeb0e4fd2ff147f40141476c4cd Mon Sep 17 00:00:00 2001 From: David Conway Date: Thu, 24 Dec 2020 19:52:06 +1100 Subject: [PATCH 3/4] Move icon settings to styles --- Source/Editor/GUI/ToolStrip.cs | 8 ++++---- Source/Editor/Options/InterfaceOptions.cs | 14 -------------- Source/Editor/Windows/ToolboxWindow.cs | 2 +- Source/Engine/UI/GUI/Style.cs | 6 ++++++ 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/Source/Editor/GUI/ToolStrip.cs b/Source/Editor/GUI/ToolStrip.cs index 20c0ae9a1..56bf3e278 100644 --- a/Source/Editor/GUI/ToolStrip.cs +++ b/Source/Editor/GUI/ToolStrip.cs @@ -64,15 +64,15 @@ namespace FlaxEditor.GUI /// /// Gets the height for the items. /// - public float ItemsHeight => Height - itemScale * DefaultMarginV; + public float ItemsHeight => Height + itemScale * DefaultMarginV; - private float itemScale = 2; - /// + private float itemScale; + /// class. /// public ToolStrip() { - itemScale = Editor.Instance.Options.Options.Interface.ToolStripScale; + itemScale = Style.Current.IconSizeExtra; AutoFocus = false; AnchorPreset = AnchorPresets.HorizontalStretchTop; BackgroundColor = Style.Current.LightBackground; diff --git a/Source/Editor/Options/InterfaceOptions.cs b/Source/Editor/Options/InterfaceOptions.cs index 287e27c85..981e4a653 100644 --- a/Source/Editor/Options/InterfaceOptions.cs +++ b/Source/Editor/Options/InterfaceOptions.cs @@ -44,20 +44,6 @@ namespace FlaxEditor.Options [EditorDisplay("Interface"), EditorOrder(10), Tooltip("Editor User Interface scale. Applied to all UI elements, windows and text. Can be used to scale the interface up on a bigger display. Editor restart required.")] public float InterfaceScale { get; set; } = 1.0f; - /// - /// Gets or sets the ToolStrip item scale. Applied to ToolStrip UI elements, windows and text. Can be used to scale the toolstrip size to fit display needs. Editor restart required.. - /// - [DefaultValue(2.0f), Limit(1f, 10.0f)] - [EditorDisplay("Interface"), EditorOrder(20), Tooltip("Editor ToolStrip scale. Applied to ToolStrip UI elements, windows and text. Can be used to scale the toolstrip size to fit display needs. Editor restart required.")] - public float ToolStripScale { get; set; } = 2.0f; - - /// - /// Gets or sets the ToolBox Icon scale. Editor ToolBox Icon scale. Applied to ToolBox Icon UI elements. Can be used to scale the toolbox icon size to fit display needs. Editor restart required. - /// - [DefaultValue(32.0f), Limit(1f, 64.0f)] - [EditorDisplay("Interface"), EditorOrder(30), Tooltip("Editor ToolBox Icon scale. Applied to ToolBox Icon UI elements. Can be used to scale the toolbox icon size to fit display needs. Editor restart required.")] - public float ToolBoxIconScale { get; set; } = 32.0f; - /// /// Gets or sets a value indicating whether use native window title bar. Editor restart required. /// diff --git a/Source/Editor/Windows/ToolboxWindow.cs b/Source/Editor/Windows/ToolboxWindow.cs index 7f4069475..31690fe0a 100644 --- a/Source/Editor/Windows/ToolboxWindow.cs +++ b/Source/Editor/Windows/ToolboxWindow.cs @@ -308,7 +308,7 @@ namespace FlaxEditor.Windows /// public override void OnInit() { - float tabSize = Editor.Options.Options.Interface.ToolBoxIconScale; + float tabSize = 48 + Style.Current.IconSizeExtra; TabsControl = new Tabs { AnchorPreset = AnchorPresets.StretchAll, diff --git a/Source/Engine/UI/GUI/Style.cs b/Source/Engine/UI/GUI/Style.cs index 103954174..09c559d0a 100644 --- a/Source/Engine/UI/GUI/Style.cs +++ b/Source/Engine/UI/GUI/Style.cs @@ -68,6 +68,12 @@ namespace FlaxEngine.GUI set => _fontSmall = new FontReference(value); } + /// + /// Size of toolbar icons + /// + [EditorOrder(50)] + public int IconSizeExtra; + /// /// The background color. /// From c6664c7d1ea376e18b26274e32728316888db246 Mon Sep 17 00:00:00 2001 From: David Conway Date: Sat, 26 Dec 2020 04:40:42 +1100 Subject: [PATCH 4/4] Fix xml summary in ToolStrip.cs --- Source/Editor/GUI/ToolStrip.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Editor/GUI/ToolStrip.cs b/Source/Editor/GUI/ToolStrip.cs index 56bf3e278..48d2a1101 100644 --- a/Source/Editor/GUI/ToolStrip.cs +++ b/Source/Editor/GUI/ToolStrip.cs @@ -65,9 +65,9 @@ namespace FlaxEditor.GUI /// Gets the height for the items. /// public float ItemsHeight => Height + itemScale * DefaultMarginV; - private float itemScale; - /// /// Initializes a new instance of the class. /// public ToolStrip()