From 21c742bd8a2d2b5f55d916649d9fab1d75af8586 Mon Sep 17 00:00:00 2001 From: davevanegdom Date: Thu, 21 Sep 2023 14:54:57 +0200 Subject: [PATCH 1/3] Customizable statusbar --- Source/Editor/Editor.cs | 6 ++- Source/Editor/GUI/StatusBar.cs | 2 +- .../Editor/Modules/ProgressReportingModule.cs | 1 + Source/Editor/Modules/UIModule.cs | 16 ++++++-- Source/Editor/Options/OptionsModule.cs | 9 +++++ Source/Engine/Scripting/Scripting.cs | 8 ++++ Source/Engine/UI/GUI/Style.cs | 38 +++++++++++++++++++ 7 files changed, 74 insertions(+), 6 deletions(-) diff --git a/Source/Editor/Editor.cs b/Source/Editor/Editor.cs index 7f0359331..308e40bc1 100644 --- a/Source/Editor/Editor.cs +++ b/Source/Editor/Editor.cs @@ -568,7 +568,8 @@ namespace FlaxEditor BackgroundColorSelected = Color.Transparent, BorderColorHighlighted = Color.Transparent, Text = "Save Now", - TooltipText = "Saves now and restarts the auto save timer." + TooltipText = "Saves now and restarts the auto save timer.", + TextColor = Style.Current.Statusbar.TextColor }; _saveNowButton.LocalX += 120; _saveNowButton.Clicked += () => _autoSaveNow = true; @@ -590,7 +591,8 @@ namespace FlaxEditor BackgroundColorSelected = Color.Transparent, BorderColorHighlighted = Color.Transparent, Text = "Cancel", - TooltipText = "Cancels this auto save." + TooltipText = "Cancels this auto save.", + TextColor = Style.Current.Statusbar.TextColor }; _cancelSaveButton.LocalX += 180; _cancelSaveButton.Clicked += () => diff --git a/Source/Editor/GUI/StatusBar.cs b/Source/Editor/GUI/StatusBar.cs index f8f7ae839..93c8f7218 100644 --- a/Source/Editor/GUI/StatusBar.cs +++ b/Source/Editor/GUI/StatusBar.cs @@ -33,7 +33,7 @@ namespace FlaxEditor.GUI /// /// Gets or sets the status text color /// - public Color TextColor { get; set; } = Style.Current.Foreground; + public Color TextColor { get; set; } = Style.Current.Statusbar.TextColor; /// /// Initializes a new instance of the class. diff --git a/Source/Editor/Modules/ProgressReportingModule.cs b/Source/Editor/Modules/ProgressReportingModule.cs index 16acd7f8b..22ae5ea98 100644 --- a/Source/Editor/Modules/ProgressReportingModule.cs +++ b/Source/Editor/Modules/ProgressReportingModule.cs @@ -129,6 +129,7 @@ namespace FlaxEditor.Modules else { Editor.UI.UpdateProgress(string.Empty, 0); + Editor.UI.UpdateStatusBar(); } } diff --git a/Source/Editor/Modules/UIModule.cs b/Source/Editor/Modules/UIModule.cs index 08ec09de8..a4a96d075 100644 --- a/Source/Editor/Modules/UIModule.cs +++ b/Source/Editor/Modules/UIModule.cs @@ -279,9 +279,9 @@ namespace FlaxEditor.Modules Color color; if (Editor.StateMachine.IsPlayMode) - color = Color.OrangeRed; + color = Style.Current.Statusbar.PlayMode; else - color = Style.Current.BackgroundSelected; + color = Style.Current.Statusbar.Normal; string text; if (_statusMessages != null && _statusMessages.Count != 0) @@ -293,6 +293,11 @@ namespace FlaxEditor.Modules else text = "Ready"; + if(ProgressVisible) + { + color = Style.Current.Statusbar.Loading; + } + StatusBar.Text = text; StatusBar.StatusColor = color; _contentStats = contentStats; @@ -338,7 +343,7 @@ namespace FlaxEditor.Modules internal void ProgressFailed(string message) { _progressFailed = true; - StatusBar.StatusColor = Color.Red; + StatusBar.StatusColor = Style.Current.Statusbar.Failed; StatusBar.Text = message; _outputLogButton.Visible = true; } @@ -391,6 +396,10 @@ namespace FlaxEditor.Modules { UpdateStatusBar(); } + else if(ProgressVisible) + { + UpdateStatusBar(); + } } private class CustomWindowBorderControl : Control @@ -753,6 +762,7 @@ namespace FlaxEditor.Modules AnchorPreset = AnchorPresets.HorizontalStretchMiddle, Parent = progressPanel, Offsets = new Margin(progressBarRightMargin, progressBarWidth + progressBarLeftMargin + progressBarRightMargin, 0, 0), + TextColor = Style.Current.Statusbar.TextColor }; UpdateStatusBar(); diff --git a/Source/Editor/Options/OptionsModule.cs b/Source/Editor/Options/OptionsModule.cs index 68aa11626..4584395be 100644 --- a/Source/Editor/Options/OptionsModule.cs +++ b/Source/Editor/Options/OptionsModule.cs @@ -244,6 +244,15 @@ namespace FlaxEditor.Options CollectionBackgroundColor = Color.FromBgra(0x14CCCCCC), ProgressNormal = Color.FromBgra(0xFF0ad328), + Statusbar = new Style.StatusbarStyle() + { + TextColor = Color.White, + Normal = Color.FromBgra(0xFF007ACC), + PlayMode = Color.ParseHex("#2f9135"), + Failed = Color.ParseHex("#9c2424"), + Loading = Color.ParseHex("#2d2d30") + }, + // Fonts FontTitle = options.Interface.TitleFont.GetFont(), FontLarge = options.Interface.LargeFont.GetFont(), diff --git a/Source/Engine/Scripting/Scripting.cs b/Source/Engine/Scripting/Scripting.cs index 68da64bf7..4215f09b3 100644 --- a/Source/Engine/Scripting/Scripting.cs +++ b/Source/Engine/Scripting/Scripting.cs @@ -277,6 +277,14 @@ namespace FlaxEngine TextBoxBackgroundSelected = Color.FromBgra(0xFF3F3F46), CollectionBackgroundColor = Color.FromBgra(0x14CCCCCC), SharedTooltip = new Tooltip(), + Statusbar = new Style.StatusbarStyle() + { + TextColor = Color.White, + Normal = Color.FromBgra(0xFF007ACC), + PlayMode = Color.ParseHex("#2f9135"), + Failed = Color.ParseHex("#9c2424"), + Loading = Color.ParseHex("#2d2d30") + } }; style.DragWindow = style.BackgroundSelected * 0.7f; diff --git a/Source/Engine/UI/GUI/Style.cs b/Source/Engine/UI/GUI/Style.cs index fac65e22f..c98c37b78 100644 --- a/Source/Engine/UI/GUI/Style.cs +++ b/Source/Engine/UI/GUI/Style.cs @@ -164,6 +164,12 @@ namespace FlaxEngine.GUI [EditorOrder(200)] public Color ProgressNormal; + /// + /// The status bar style + /// + [EditorOrder(210)] + public StatusbarStyle Statusbar; + /// /// The arrow right icon. /// @@ -241,5 +247,37 @@ namespace FlaxEngine.GUI /// [EditorOrder(340)] public Tooltip SharedTooltip; + + /// + /// Style for the Statusbar + /// + [System.Serializable, ShowInEditor] + public struct StatusbarStyle + { + /// + /// Color of the text in the Statusbar + /// + public Color TextColor; + + /// + /// Color of the Statusbar in its default state + /// + public Color Normal; + + /// + /// Color of the Statusbar when in Play Mode + /// + public Color PlayMode; + + /// + /// Color of the Statusbar when in loading state (e.g. when importing assets) + /// + public Color Loading; + + /// + /// Color of the Statusbar in its failed state (e.g. with compilation errors) + /// + public Color Failed; + } } } From 80a3bb2ae21bc93d6f6559103a29b46e2fcedc6f Mon Sep 17 00:00:00 2001 From: davevanegdom Date: Thu, 21 Sep 2023 17:10:49 +0200 Subject: [PATCH 2/3] Replaced string color lookups --- Source/Editor/Options/OptionsModule.cs | 6 +++--- Source/Engine/Scripting/Scripting.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/Editor/Options/OptionsModule.cs b/Source/Editor/Options/OptionsModule.cs index 4584395be..05a75fa4a 100644 --- a/Source/Editor/Options/OptionsModule.cs +++ b/Source/Editor/Options/OptionsModule.cs @@ -248,9 +248,9 @@ namespace FlaxEditor.Options { TextColor = Color.White, Normal = Color.FromBgra(0xFF007ACC), - PlayMode = Color.ParseHex("#2f9135"), - Failed = Color.ParseHex("#9c2424"), - Loading = Color.ParseHex("#2d2d30") + PlayMode = Color.FromBgra(0xFF2F9135), + Failed = Color.FromBgra(0xFF9C2424), + Loading = Color.FromBgra(0xFF2D2D30) }, // Fonts diff --git a/Source/Engine/Scripting/Scripting.cs b/Source/Engine/Scripting/Scripting.cs index 4215f09b3..7e3226412 100644 --- a/Source/Engine/Scripting/Scripting.cs +++ b/Source/Engine/Scripting/Scripting.cs @@ -281,9 +281,9 @@ namespace FlaxEngine { TextColor = Color.White, Normal = Color.FromBgra(0xFF007ACC), - PlayMode = Color.ParseHex("#2f9135"), - Failed = Color.ParseHex("#9c2424"), - Loading = Color.ParseHex("#2d2d30") + PlayMode = Color.FromBgra(0xFF2F9135), + Failed = Color.FromBgra(0xFF9C2424), + Loading = Color.FromBgra(0xFF2D2D30) } }; style.DragWindow = style.BackgroundSelected * 0.7f; From 5fc9176ce7110030a96c728a46d1eb9e37765200 Mon Sep 17 00:00:00 2001 From: davevanegdom Date: Thu, 21 Sep 2023 23:18:46 +0200 Subject: [PATCH 3/3] Removed customization for "Normal" and "TextColor" --- Source/Editor/Editor.cs | 6 ++---- Source/Editor/GUI/StatusBar.cs | 2 +- Source/Editor/Modules/UIModule.cs | 5 ++--- Source/Editor/Options/OptionsModule.cs | 2 -- Source/Engine/Scripting/Scripting.cs | 2 -- Source/Engine/UI/GUI/Style.cs | 10 ---------- 6 files changed, 5 insertions(+), 22 deletions(-) diff --git a/Source/Editor/Editor.cs b/Source/Editor/Editor.cs index 308e40bc1..7f0359331 100644 --- a/Source/Editor/Editor.cs +++ b/Source/Editor/Editor.cs @@ -568,8 +568,7 @@ namespace FlaxEditor BackgroundColorSelected = Color.Transparent, BorderColorHighlighted = Color.Transparent, Text = "Save Now", - TooltipText = "Saves now and restarts the auto save timer.", - TextColor = Style.Current.Statusbar.TextColor + TooltipText = "Saves now and restarts the auto save timer." }; _saveNowButton.LocalX += 120; _saveNowButton.Clicked += () => _autoSaveNow = true; @@ -591,8 +590,7 @@ namespace FlaxEditor BackgroundColorSelected = Color.Transparent, BorderColorHighlighted = Color.Transparent, Text = "Cancel", - TooltipText = "Cancels this auto save.", - TextColor = Style.Current.Statusbar.TextColor + TooltipText = "Cancels this auto save." }; _cancelSaveButton.LocalX += 180; _cancelSaveButton.Clicked += () => diff --git a/Source/Editor/GUI/StatusBar.cs b/Source/Editor/GUI/StatusBar.cs index 93c8f7218..f8f7ae839 100644 --- a/Source/Editor/GUI/StatusBar.cs +++ b/Source/Editor/GUI/StatusBar.cs @@ -33,7 +33,7 @@ namespace FlaxEditor.GUI /// /// Gets or sets the status text color /// - public Color TextColor { get; set; } = Style.Current.Statusbar.TextColor; + public Color TextColor { get; set; } = Style.Current.Foreground; /// /// Initializes a new instance of the class. diff --git a/Source/Editor/Modules/UIModule.cs b/Source/Editor/Modules/UIModule.cs index a4a96d075..69e610c07 100644 --- a/Source/Editor/Modules/UIModule.cs +++ b/Source/Editor/Modules/UIModule.cs @@ -281,7 +281,7 @@ namespace FlaxEditor.Modules if (Editor.StateMachine.IsPlayMode) color = Style.Current.Statusbar.PlayMode; else - color = Style.Current.Statusbar.Normal; + color = Style.Current.BackgroundSelected; string text; if (_statusMessages != null && _statusMessages.Count != 0) @@ -761,8 +761,7 @@ namespace FlaxEditor.Modules HorizontalAlignment = TextAlignment.Far, AnchorPreset = AnchorPresets.HorizontalStretchMiddle, Parent = progressPanel, - Offsets = new Margin(progressBarRightMargin, progressBarWidth + progressBarLeftMargin + progressBarRightMargin, 0, 0), - TextColor = Style.Current.Statusbar.TextColor + Offsets = new Margin(progressBarRightMargin, progressBarWidth + progressBarLeftMargin + progressBarRightMargin, 0, 0) }; UpdateStatusBar(); diff --git a/Source/Editor/Options/OptionsModule.cs b/Source/Editor/Options/OptionsModule.cs index 05a75fa4a..c2d744239 100644 --- a/Source/Editor/Options/OptionsModule.cs +++ b/Source/Editor/Options/OptionsModule.cs @@ -246,8 +246,6 @@ namespace FlaxEditor.Options Statusbar = new Style.StatusbarStyle() { - TextColor = Color.White, - Normal = Color.FromBgra(0xFF007ACC), PlayMode = Color.FromBgra(0xFF2F9135), Failed = Color.FromBgra(0xFF9C2424), Loading = Color.FromBgra(0xFF2D2D30) diff --git a/Source/Engine/Scripting/Scripting.cs b/Source/Engine/Scripting/Scripting.cs index 7e3226412..d43804586 100644 --- a/Source/Engine/Scripting/Scripting.cs +++ b/Source/Engine/Scripting/Scripting.cs @@ -279,8 +279,6 @@ namespace FlaxEngine SharedTooltip = new Tooltip(), Statusbar = new Style.StatusbarStyle() { - TextColor = Color.White, - Normal = Color.FromBgra(0xFF007ACC), PlayMode = Color.FromBgra(0xFF2F9135), Failed = Color.FromBgra(0xFF9C2424), Loading = Color.FromBgra(0xFF2D2D30) diff --git a/Source/Engine/UI/GUI/Style.cs b/Source/Engine/UI/GUI/Style.cs index c98c37b78..8f34a703c 100644 --- a/Source/Engine/UI/GUI/Style.cs +++ b/Source/Engine/UI/GUI/Style.cs @@ -254,16 +254,6 @@ namespace FlaxEngine.GUI [System.Serializable, ShowInEditor] public struct StatusbarStyle { - /// - /// Color of the text in the Statusbar - /// - public Color TextColor; - - /// - /// Color of the Statusbar in its default state - /// - public Color Normal; - /// /// Color of the Statusbar when in Play Mode ///