From ad28a3fdbfb0cd3590e4cc727501a16f9e5a28b9 Mon Sep 17 00:00:00 2001 From: Luke Schneider Date: Wed, 27 Sep 2023 21:54:34 -0500 Subject: [PATCH 1/3] Better light theme (Style) support, and a Default light theme (as a secondary option) 1) Added ForegroundViewport as a new color. It is used in the main game viewport (ViewportWidgetButton), and the viewport for rendering of particles and materials. It is needed because the default foreground in a Light theme is black, but black does not work well in a viewport. A new color seemed appropriate. 2) Fixed the profiler window to use the Foreground color in multiple text elements, instead of Color.White (or no default TitleColor). This includes the Row class, Asset class, SingleChart class, Timeline Class, and more. 3) Added a second theme/Style (DefaultLight) to include with the engine. It uses RGB float values because those were easier to transfer from the saved values that I had created (and they're easier for me to edit if necessary). I tried to emulate how the Default theme is created/loaded/etc as closely as possible. --- Source/Editor/GUI/Row.cs | 2 +- Source/Editor/Options/OptionsModule.cs | 66 ++++++++++++++++++- Source/Editor/Options/ThemeOptions.cs | 5 +- .../Viewport/Widgets/ViewportWidgetButton.cs | 4 +- Source/Editor/Windows/Profiler/Assets.cs | 5 ++ Source/Editor/Windows/Profiler/CPU.cs | 7 ++ Source/Editor/Windows/Profiler/GPU.cs | 7 ++ Source/Editor/Windows/Profiler/MemoryGPU.cs | 4 ++ Source/Editor/Windows/Profiler/Network.cs | 6 ++ Source/Editor/Windows/Profiler/SingleChart.cs | 6 +- Source/Editor/Windows/Profiler/Timeline.cs | 4 +- Source/Engine/Scripting/Scripting.cs | 1 + Source/Engine/UI/GUI/Style.cs | 6 ++ 13 files changed, 111 insertions(+), 12 deletions(-) diff --git a/Source/Editor/GUI/Row.cs b/Source/Editor/GUI/Row.cs index 8dad8b20d..4526e60ac 100644 --- a/Source/Editor/GUI/Row.cs +++ b/Source/Editor/GUI/Row.cs @@ -95,7 +95,7 @@ namespace FlaxEditor.GUI rect.Width -= leftDepthMargin; Render2D.PushClip(rect); - Render2D.DrawText(style.FontMedium, text, rect, Color.White, column.CellAlignment, TextAlignment.Center); + Render2D.DrawText(style.FontMedium, text, rect, Style.Current.Foreground, column.CellAlignment, TextAlignment.Center); Render2D.PopClip(); x += width; diff --git a/Source/Editor/Options/OptionsModule.cs b/Source/Editor/Options/OptionsModule.cs index 68aa11626..da293ec47 100644 --- a/Source/Editor/Options/OptionsModule.cs +++ b/Source/Editor/Options/OptionsModule.cs @@ -208,13 +208,20 @@ namespace FlaxEditor.Options // If a non-default style was chosen, switch to that style string styleName = themeOptions.SelectedStyle; - if (styleName != "Default" && themeOptions.Styles.TryGetValue(styleName, out var style) && style != null) + if (styleName != "Default" && styleName != "LightDefault" && themeOptions.Styles.TryGetValue(styleName, out var style) && style != null) { Style.Current = style; } else { - Style.Current = CreateDefaultStyle(); + if (styleName == "LightDefault") + { + Style.Current = CreateLightStyle(); + } + else + { + Style.Current = CreateDefaultStyle(); + } } } @@ -233,6 +240,7 @@ namespace FlaxEditor.Options Foreground = Color.FromBgra(0xFFFFFFFF), ForegroundGrey = Color.FromBgra(0xFFA9A9B3), ForegroundDisabled = Color.FromBgra(0xFF787883), + ForegroundViewport = Color.FromBgra(0xFFFFFFFF), BackgroundHighlighted = Color.FromBgra(0xFF54545C), BorderHighlighted = Color.FromBgra(0xFF6A6A75), BackgroundSelected = Color.FromBgra(0xFF007ACC), @@ -271,6 +279,60 @@ namespace FlaxEditor.Options return style; } + /// + /// Creates the light style (2nd default). + /// + /// The style object. + public Style CreateLightStyle() + { + // Metro Style colors + var options = Options; + var style = new Style + { + Background = new Color(0.92f, 0.92f, 0.92f, 1f), + LightBackground = new Color(0.84f, 0.84f, 0.88f, 1f), + DragWindow = new Color(0.0f, 0.26f, 0.43f, 0.70f), + Foreground = new Color(0.0f, 0.0f, 0.0f, 1f), + ForegroundGrey = new Color(0.30f, 0.30f, 0.31f, 1f), + ForegroundDisabled = new Color(0.45f, 0.45f, 0.49f, 1f), + ForegroundViewport = new Color(1.0f, 1.0f, 1.0f, 1f), + BackgroundHighlighted = new Color(0.59f, 0.59f, 0.64f, 1f), + BorderHighlighted = new Color(0.50f, 0.50f, 0.55f, 1f), + BackgroundSelected = new Color(0.00f, 0.46f, 0.78f, 0.78f), + BorderSelected = new Color(0.11f, 0.57f, 0.88f, 0.65f), + BackgroundNormal = new Color(0.67f, 0.67f, 0.75f, 1f), + BorderNormal = new Color(0.59f, 0.59f, 0.64f, 1f), + TextBoxBackground = new Color(0.75f, 0.75f, 0.81f, 1f), + TextBoxBackgroundSelected = new Color(0.73f, 0.73f, 0.80f, 1f), + CollectionBackgroundColor = new Color(0.25f, 0.25f, 0.25f, 1f), + ProgressNormal = new Color(0.03f, 0.65f, 0.12f, 1f), + + // Fonts + FontTitle = options.Interface.TitleFont.GetFont(), + FontLarge = options.Interface.LargeFont.GetFont(), + FontMedium = options.Interface.MediumFont.GetFont(), + FontSmall = options.Interface.SmallFont.GetFont(), + + // Icons + ArrowDown = Editor.Icons.ArrowDown12, + ArrowRight = Editor.Icons.ArrowRight12, + Search = Editor.Icons.Search12, + Settings = Editor.Icons.Settings12, + Cross = Editor.Icons.Cross12, + CheckBoxIntermediate = Editor.Icons.CheckBoxIntermediate12, + CheckBoxTick = Editor.Icons.CheckBoxTick12, + StatusBarSizeGrip = Editor.Icons.WindowDrag12, + Translate = Editor.Icons.Translate32, + Rotate = Editor.Icons.Rotate32, + Scale = Editor.Icons.Scale32, + Scalar = Editor.Icons.Scalar32, + + SharedTooltip = new Tooltip() + }; + + return style; + } + /// public override void OnInit() { diff --git a/Source/Editor/Options/ThemeOptions.cs b/Source/Editor/Options/ThemeOptions.cs index 243918939..a033b34da 100644 --- a/Source/Editor/Options/ThemeOptions.cs +++ b/Source/Editor/Options/ThemeOptions.cs @@ -63,13 +63,14 @@ namespace FlaxEditor.Options private void ReloadOptions(ComboBox obj) { var themeOptions = (ThemeOptions)ParentEditor.Values[0]; - var options = new string[themeOptions.Styles.Count + 1]; + var options = new string[themeOptions.Styles.Count + 2]; options[0] = "Default"; + options[1] = "LightDefault"; int i = 0; foreach (var styleName in themeOptions.Styles.Keys) { - options[i + 1] = styleName; + options[i + 2] = styleName; i++; } _combobox.ComboBox.SetItems(options); diff --git a/Source/Editor/Viewport/Widgets/ViewportWidgetButton.cs b/Source/Editor/Viewport/Widgets/ViewportWidgetButton.cs index 481bc3f1b..544489208 100644 --- a/Source/Editor/Viewport/Widgets/ViewportWidgetButton.cs +++ b/Source/Editor/Viewport/Widgets/ViewportWidgetButton.cs @@ -112,7 +112,7 @@ namespace FlaxEditor.Viewport.Widgets if (Icon.IsValid) { // Draw icon - Render2D.DrawSprite(Icon, iconRect, style.Foreground); + Render2D.DrawSprite(Icon, iconRect, style.ForegroundViewport); // Update text rectangle textRect.Location.X += iconSize; @@ -120,7 +120,7 @@ namespace FlaxEditor.Viewport.Widgets } // Draw text - Render2D.DrawText(style.FontMedium, _text, textRect, style.Foreground * (IsMouseOver ? 1.0f : 0.9f), TextAlignment.Center, TextAlignment.Center); + Render2D.DrawText(style.FontMedium, _text, textRect, style.ForegroundViewport * (IsMouseOver ? 1.0f : 0.9f), TextAlignment.Center, TextAlignment.Center); } /// diff --git a/Source/Editor/Windows/Profiler/Assets.cs b/Source/Editor/Windows/Profiler/Assets.cs index e2a65d496..39c5644c8 100644 --- a/Source/Editor/Windows/Profiler/Assets.cs +++ b/Source/Editor/Windows/Profiler/Assets.cs @@ -63,6 +63,7 @@ namespace FlaxEditor.Windows.Profiler // Table var headerColor = Style.Current.LightBackground; + var textColor = Style.Current.Foreground; _table = new Table { Columns = new[] @@ -73,22 +74,26 @@ namespace FlaxEditor.Windows.Profiler CellAlignment = TextAlignment.Near, Title = "Resource", TitleBackgroundColor = headerColor, + TitleColor = textColor, }, new ColumnDefinition { Title = "Type", CellAlignment = TextAlignment.Center, TitleBackgroundColor = headerColor, + TitleColor = textColor, }, new ColumnDefinition { Title = "References", TitleBackgroundColor = headerColor, + TitleColor = textColor, }, new ColumnDefinition { Title = "Memory Usage", TitleBackgroundColor = headerColor, + TitleColor = textColor, FormatValue = v => Utilities.Utils.FormatBytesCount((ulong)v), }, }, diff --git a/Source/Editor/Windows/Profiler/CPU.cs b/Source/Editor/Windows/Profiler/CPU.cs index fd4061276..df4d5b59b 100644 --- a/Source/Editor/Windows/Profiler/CPU.cs +++ b/Source/Editor/Windows/Profiler/CPU.cs @@ -93,6 +93,7 @@ namespace FlaxEditor.Windows.Profiler // Table var headerColor = Style.Current.LightBackground; + var textColor = Style.Current.Foreground; _table = new Table { Columns = new[] @@ -103,36 +104,42 @@ namespace FlaxEditor.Windows.Profiler CellAlignment = TextAlignment.Near, Title = "Event", TitleBackgroundColor = headerColor, + TitleColor = textColor, }, new ColumnDefinition { Title = "Total", TitleBackgroundColor = headerColor, FormatValue = FormatCellPercentage, + TitleColor = textColor, }, new ColumnDefinition { Title = "Self", TitleBackgroundColor = headerColor, FormatValue = FormatCellPercentage, + TitleColor = textColor, }, new ColumnDefinition { Title = "Time ms", TitleBackgroundColor = headerColor, FormatValue = FormatCellMs, + TitleColor = textColor, }, new ColumnDefinition { Title = "Self ms", TitleBackgroundColor = headerColor, FormatValue = FormatCellMs, + TitleColor = textColor, }, new ColumnDefinition { Title = "Memory", TitleBackgroundColor = headerColor, FormatValue = FormatCellBytes, + TitleColor = textColor, }, }, Parent = layout, diff --git a/Source/Editor/Windows/Profiler/GPU.cs b/Source/Editor/Windows/Profiler/GPU.cs index 4ed18691a..e6a93df72 100644 --- a/Source/Editor/Windows/Profiler/GPU.cs +++ b/Source/Editor/Windows/Profiler/GPU.cs @@ -64,6 +64,7 @@ namespace FlaxEditor.Windows.Profiler // Table var headerColor = Style.Current.LightBackground; + var textColor = Style.Current.Foreground; _table = new Table { Columns = new[] @@ -74,35 +75,41 @@ namespace FlaxEditor.Windows.Profiler CellAlignment = TextAlignment.Near, Title = "Event", TitleBackgroundColor = headerColor, + TitleColor = textColor, }, new ColumnDefinition { Title = "Total", TitleBackgroundColor = headerColor, + TitleColor = textColor, FormatValue = (x) => ((float)x).ToString("0.0") + '%', }, new ColumnDefinition { Title = "GPU ms", TitleBackgroundColor = headerColor, + TitleColor = textColor, FormatValue = (x) => ((float)x).ToString("0.000"), }, new ColumnDefinition { Title = "Draw Calls", TitleBackgroundColor = headerColor, + TitleColor = textColor, FormatValue = FormatCountLong, }, new ColumnDefinition { Title = "Triangles", TitleBackgroundColor = headerColor, + TitleColor = textColor, FormatValue = FormatCountLong, }, new ColumnDefinition { Title = "Vertices", TitleBackgroundColor = headerColor, + TitleColor = textColor, FormatValue = FormatCountLong, }, }, diff --git a/Source/Editor/Windows/Profiler/MemoryGPU.cs b/Source/Editor/Windows/Profiler/MemoryGPU.cs index 20a7898e0..e894ef0e2 100644 --- a/Source/Editor/Windows/Profiler/MemoryGPU.cs +++ b/Source/Editor/Windows/Profiler/MemoryGPU.cs @@ -64,6 +64,7 @@ namespace FlaxEditor.Windows.Profiler // Table var headerColor = Style.Current.LightBackground; + var textColor = Style.Current.Foreground; _table = new Table { Columns = new[] @@ -74,18 +75,21 @@ namespace FlaxEditor.Windows.Profiler CellAlignment = TextAlignment.Near, Title = "Resource", TitleBackgroundColor = headerColor, + TitleColor = textColor, }, new ColumnDefinition { Title = "Type", CellAlignment = TextAlignment.Center, TitleBackgroundColor = headerColor, + TitleColor = textColor, }, new ColumnDefinition { Title = "Memory Usage", TitleBackgroundColor = headerColor, FormatValue = v => Utilities.Utils.FormatBytesCount((ulong)v), + TitleColor = textColor, }, }, Parent = layout, diff --git a/Source/Editor/Windows/Profiler/Network.cs b/Source/Editor/Windows/Profiler/Network.cs index dbee0e8e7..b29173e76 100644 --- a/Source/Editor/Windows/Profiler/Network.cs +++ b/Source/Editor/Windows/Profiler/Network.cs @@ -205,6 +205,7 @@ namespace FlaxEditor.Windows.Profiler private static Table InitTable(ContainerControl parent, string name) { var headerColor = Style.Current.LightBackground; + var textColor = Style.Current.Foreground; var table = new Table { Columns = new[] @@ -215,28 +216,33 @@ namespace FlaxEditor.Windows.Profiler CellAlignment = TextAlignment.Near, Title = name, TitleBackgroundColor = headerColor, + TitleColor = textColor, }, new ColumnDefinition { Title = "Count", TitleBackgroundColor = headerColor, + TitleColor = textColor, }, new ColumnDefinition { Title = "Data Size", TitleBackgroundColor = headerColor, + TitleColor = textColor, FormatValue = FormatCellBytes, }, new ColumnDefinition { Title = "Message Size", TitleBackgroundColor = headerColor, + TitleColor = textColor, FormatValue = FormatCellBytes, }, new ColumnDefinition { Title = "Receivers", TitleBackgroundColor = headerColor, + TitleColor = textColor, }, }, Splits = new[] diff --git a/Source/Editor/Windows/Profiler/SingleChart.cs b/Source/Editor/Windows/Profiler/SingleChart.cs index e14480bee..29780150a 100644 --- a/Source/Editor/Windows/Profiler/SingleChart.cs +++ b/Source/Editor/Windows/Profiler/SingleChart.cs @@ -105,7 +105,7 @@ namespace FlaxEditor.Windows.Profiler if (_selectedSampleIndex != -1) { float selectedX = Width - (_samples.Count - _selectedSampleIndex - 1) * PointsOffset; - Render2D.DrawLine(new Float2(selectedX, 0), new Float2(selectedX, chartHeight), Color.White, 1.5f); + Render2D.DrawLine(new Float2(selectedX, 0), new Float2(selectedX, chartHeight), Style.Current.Foreground, 1.5f); } int samplesInViewCount = Math.Min((int)(Width / PointsOffset), _samples.Count) - 1; @@ -138,8 +138,8 @@ namespace FlaxEditor.Windows.Profiler var headerRect = new Rectangle(0, chartHeight, Width, TitleHeight); var headerTextRect = new Rectangle(2, chartHeight, Width - 4, TitleHeight); Render2D.FillRectangle(headerRect, style.BackgroundNormal); - Render2D.DrawText(style.FontMedium, Title, headerTextRect, Color.White * 0.8f, TextAlignment.Near, TextAlignment.Center); - Render2D.DrawText(style.FontMedium, _sample, headerTextRect, Color.White, TextAlignment.Far, TextAlignment.Center); + Render2D.DrawText(style.FontMedium, Title, headerTextRect, Style.Current.ForegroundGrey, TextAlignment.Near, TextAlignment.Center); + Render2D.DrawText(style.FontMedium, _sample, headerTextRect, Style.Current.Foreground, TextAlignment.Far, TextAlignment.Center); } private void OnClick(ref Float2 location) diff --git a/Source/Editor/Windows/Profiler/Timeline.cs b/Source/Editor/Windows/Profiler/Timeline.cs index a61ca1d05..59a7a0e26 100644 --- a/Source/Editor/Windows/Profiler/Timeline.cs +++ b/Source/Editor/Windows/Profiler/Timeline.cs @@ -90,7 +90,7 @@ namespace FlaxEditor.Windows.Profiler if (_nameLength < bounds.Width + 4) { Render2D.PushClip(bounds); - Render2D.DrawText(style.FontMedium, _name, bounds, Color.White, TextAlignment.Center, TextAlignment.Center); + Render2D.DrawText(style.FontMedium, _name, bounds, Style.Current.Foreground, TextAlignment.Center, TextAlignment.Center); Render2D.PopClip(); } } @@ -115,7 +115,7 @@ namespace FlaxEditor.Windows.Profiler var style = Style.Current; var rect = new Rectangle(Float2.Zero, Size); Render2D.PushClip(rect); - Render2D.DrawText(style.FontMedium, Name, rect, Color.White, TextAlignment.Center, TextAlignment.Center, TextWrapping.WrapChars); + Render2D.DrawText(style.FontMedium, Name, rect, Style.Current.Foreground, TextAlignment.Center, TextAlignment.Center, TextWrapping.WrapChars); Render2D.PopClip(); } } diff --git a/Source/Engine/Scripting/Scripting.cs b/Source/Engine/Scripting/Scripting.cs index 68da64bf7..e2e6b514a 100644 --- a/Source/Engine/Scripting/Scripting.cs +++ b/Source/Engine/Scripting/Scripting.cs @@ -266,6 +266,7 @@ namespace FlaxEngine Foreground = Color.FromBgra(0xFFFFFFFF), ForegroundGrey = Color.FromBgra(0xFFA9A9B3), ForegroundDisabled = Color.FromBgra(0xFF787883), + ForegroundViewport = Color.FromBgra(0xFFFFFFFF), BackgroundHighlighted = Color.FromBgra(0xFF54545C), BorderHighlighted = Color.FromBgra(0xFF6A6A75), BackgroundSelected = Color.FromBgra(0xFF007ACC), diff --git a/Source/Engine/UI/GUI/Style.cs b/Source/Engine/UI/GUI/Style.cs index fac65e22f..5e8b1c57f 100644 --- a/Source/Engine/UI/GUI/Style.cs +++ b/Source/Engine/UI/GUI/Style.cs @@ -104,6 +104,12 @@ namespace FlaxEngine.GUI [EditorOrder(110)] public Color ForegroundDisabled; + /// + /// The foreground color in viewports (usually have a dark background) + /// + [EditorOrder(115)] + public Color ForegroundViewport; + /// /// The background highlighted color. /// From b7b8213179ff05edbea38a3385e1af9efe2ccdd4 Mon Sep 17 00:00:00 2001 From: Luke Schneider Date: Fri, 29 Sep 2023 07:43:59 -0500 Subject: [PATCH 2/3] Some additional fixes to light theme support Fixed some issues with light theme support: 1) Icons in content tree nodes (Folder icons) now use the foreground color. I did not find a case where the content tree is used for other icons. 2) The asset picker now uses the Background Normal color (instead of a very transparent dark gray) for the background, and Orange for the text. Did not seem like it warranted adding a new color, and Orange works in both dark and light styles. 3) The platform selector icons are now hard-coded instead of based on the style. This may sound odd, but the icons are colored, so they should always use White as the fully active color. Previously they worked with a dark theme because the Foreground was set to white. 4) Fixed the CollectionBackgroundColor in the light theme being dark gray instead of light gray like it should be. This fixes certain lists of things having a dark background in the light theme. --- Source/Editor/Content/Tree/ContentTreeNode.cs | 1 + Source/Editor/GUI/AssetPicker.cs | 4 ++-- Source/Editor/GUI/PlatformSelector.cs | 7 ++++--- Source/Editor/Options/OptionsModule.cs | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Source/Editor/Content/Tree/ContentTreeNode.cs b/Source/Editor/Content/Tree/ContentTreeNode.cs index 2f6651b14..0c0fc6a51 100644 --- a/Source/Editor/Content/Tree/ContentTreeNode.cs +++ b/Source/Editor/Content/Tree/ContentTreeNode.cs @@ -86,6 +86,7 @@ namespace FlaxEditor.Content Folder.ParentFolder = parent.Folder; Parent = parent; } + IconColor = Style.Current.Foreground; } /// diff --git a/Source/Editor/GUI/AssetPicker.cs b/Source/Editor/GUI/AssetPicker.cs index 3e5d22eb0..87346d817 100644 --- a/Source/Editor/GUI/AssetPicker.cs +++ b/Source/Editor/GUI/AssetPicker.cs @@ -395,8 +395,8 @@ namespace FlaxEditor.GUI else { // No element selected - Render2D.FillRectangle(iconRect, new Color(0.2f)); - Render2D.DrawText(style.FontMedium, "No asset\nselected", iconRect, Color.Wheat, TextAlignment.Center, TextAlignment.Center, TextWrapping.NoWrap, 1.0f, Height / DefaultIconSize); + Render2D.FillRectangle(iconRect, Style.Current.BackgroundNormal); + Render2D.DrawText(style.FontMedium, "No asset\nselected", iconRect, Color.Orange, TextAlignment.Center, TextAlignment.Center, TextWrapping.NoWrap, 1.0f, Height / DefaultIconSize); } // Check if drag is over diff --git a/Source/Editor/GUI/PlatformSelector.cs b/Source/Editor/GUI/PlatformSelector.cs index 1e03a9677..a29f62805 100644 --- a/Source/Editor/GUI/PlatformSelector.cs +++ b/Source/Editor/GUI/PlatformSelector.cs @@ -100,9 +100,10 @@ namespace FlaxEditor.GUI AutoResize = true; Offsets = new Margin(0, 0, 0, IconSize); - _mouseOverColor = style.Foreground; - _selectedColor = style.Foreground; - _defaultColor = style.ForegroundGrey; + // Ignoring style on purpose (style would make sense if the icons were white, but they are colored) + _mouseOverColor = new Color(0.8f, 0.8f, 0.8f, 1f); + _selectedColor = Color.White; + _defaultColor = new Color(0.7f, 0.7f, 0.7f, 0.5f); for (int i = 0; i < platforms.Length; i++) { diff --git a/Source/Editor/Options/OptionsModule.cs b/Source/Editor/Options/OptionsModule.cs index da293ec47..4ed3b02e1 100644 --- a/Source/Editor/Options/OptionsModule.cs +++ b/Source/Editor/Options/OptionsModule.cs @@ -304,7 +304,7 @@ namespace FlaxEditor.Options BorderNormal = new Color(0.59f, 0.59f, 0.64f, 1f), TextBoxBackground = new Color(0.75f, 0.75f, 0.81f, 1f), TextBoxBackgroundSelected = new Color(0.73f, 0.73f, 0.80f, 1f), - CollectionBackgroundColor = new Color(0.25f, 0.25f, 0.25f, 1f), + CollectionBackgroundColor = new Color(0.85f, 0.85f, 0.88f, 1f), ProgressNormal = new Color(0.03f, 0.65f, 0.12f, 1f), // Fonts From 618273977c7bc2bba2dc061b2d02a8f8fca9d21c Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 13 Nov 2023 17:17:05 +0100 Subject: [PATCH 3/3] Minor improvements to code style #1541 --- Source/Editor/GUI/AssetPicker.cs | 2 +- Source/Editor/GUI/Row.cs | 2 +- Source/Editor/GUI/Timeline/Timeline.cs | 9 +++++---- Source/Editor/Options/OptionsModule.cs | 10 +++------- Source/Editor/Options/ThemeOptions.cs | 7 +++++-- Source/Editor/Windows/Profiler/Assets.cs | 5 +++-- Source/Editor/Windows/Profiler/CPU.cs | 5 +++-- Source/Editor/Windows/Profiler/GPU.cs | 5 +++-- Source/Editor/Windows/Profiler/MemoryGPU.cs | 5 +++-- Source/Editor/Windows/Profiler/Network.cs | 5 +++-- Source/Editor/Windows/Profiler/SingleChart.cs | 6 +++--- 11 files changed, 33 insertions(+), 28 deletions(-) diff --git a/Source/Editor/GUI/AssetPicker.cs b/Source/Editor/GUI/AssetPicker.cs index 7e7b9816f..84f58daf1 100644 --- a/Source/Editor/GUI/AssetPicker.cs +++ b/Source/Editor/GUI/AssetPicker.cs @@ -173,7 +173,7 @@ namespace FlaxEditor.GUI else { // No element selected - Render2D.FillRectangle(iconRect, Style.Current.BackgroundNormal); + Render2D.FillRectangle(iconRect, style.BackgroundNormal); Render2D.DrawText(style.FontMedium, "No asset\nselected", iconRect, Color.Orange, TextAlignment.Center, TextAlignment.Center, TextWrapping.NoWrap, 1.0f, Height / DefaultIconSize); } diff --git a/Source/Editor/GUI/Row.cs b/Source/Editor/GUI/Row.cs index 81a9d459d..f6bd5b02a 100644 --- a/Source/Editor/GUI/Row.cs +++ b/Source/Editor/GUI/Row.cs @@ -98,7 +98,7 @@ namespace FlaxEditor.GUI rect.Width -= leftDepthMargin; Render2D.PushClip(rect); - Render2D.DrawText(style.FontMedium, text, rect, Style.Current.Foreground, column.CellAlignment, TextAlignment.Center); + Render2D.DrawText(style.FontMedium, text, rect, style.Foreground, column.CellAlignment, TextAlignment.Center); Render2D.PopClip(); x += width; diff --git a/Source/Editor/GUI/Timeline/Timeline.cs b/Source/Editor/GUI/Timeline/Timeline.cs index a32b35692..6b4d7bf4c 100644 --- a/Source/Editor/GUI/Timeline/Timeline.cs +++ b/Source/Editor/GUI/Timeline/Timeline.cs @@ -627,10 +627,11 @@ namespace FlaxEditor.GUI.Timeline Parent = this }; + var style = Style.Current; var headerTopArea = new ContainerControl { AutoFocus = false, - BackgroundColor = Style.Current.LightBackground, + BackgroundColor = style.LightBackground, AnchorPreset = AnchorPresets.HorizontalStretchTop, Offsets = new Margin(0, 0, 0, HeaderTopAreaHeight), Parent = _splitter.Panel1 @@ -683,7 +684,7 @@ namespace FlaxEditor.GUI.Timeline { AutoFocus = false, ClipChildren = false, - BackgroundColor = Style.Current.LightBackground, + BackgroundColor = style.LightBackground, AnchorPreset = AnchorPresets.HorizontalStretchBottom, Offsets = new Margin(0, 0, -playbackButtonsSize, playbackButtonsSize), Parent = _splitter.Panel1 @@ -845,7 +846,7 @@ namespace FlaxEditor.GUI.Timeline _timeIntervalsHeader = new TimeIntervalsHeader(this) { AutoFocus = false, - BackgroundColor = Style.Current.Background.RGBMultiplied(0.9f), + BackgroundColor = style.Background.RGBMultiplied(0.9f), AnchorPreset = AnchorPresets.HorizontalStretchTop, Offsets = new Margin(0, 0, 0, HeaderTopAreaHeight), Parent = _splitter.Panel2 @@ -854,7 +855,7 @@ namespace FlaxEditor.GUI.Timeline { AutoFocus = false, ClipChildren = false, - BackgroundColor = Style.Current.Background.RGBMultiplied(0.7f), + BackgroundColor = style.Background.RGBMultiplied(0.7f), AnchorPreset = AnchorPresets.StretchAll, Offsets = new Margin(0, 0, HeaderTopAreaHeight, 0), Parent = _splitter.Panel2 diff --git a/Source/Editor/Options/OptionsModule.cs b/Source/Editor/Options/OptionsModule.cs index 51aa70257..1137e4c37 100644 --- a/Source/Editor/Options/OptionsModule.cs +++ b/Source/Editor/Options/OptionsModule.cs @@ -208,13 +208,13 @@ namespace FlaxEditor.Options // If a non-default style was chosen, switch to that style string styleName = themeOptions.SelectedStyle; - if (styleName != "Default" && styleName != "LightDefault" && themeOptions.Styles.TryGetValue(styleName, out var style) && style != null) + if (styleName != ThemeOptions.DefaultName && styleName != ThemeOptions.LightDefault && themeOptions.Styles.TryGetValue(styleName, out var style) && style != null) { Style.Current = style; } else { - if (styleName == "LightDefault") + if (styleName == ThemeOptions.LightDefault) { Style.Current = CreateLightStyle(); } @@ -231,7 +231,6 @@ namespace FlaxEditor.Options /// The style object. public Style CreateDefaultStyle() { - // Metro Style colors var options = Options; var style = new Style { @@ -282,7 +281,6 @@ namespace FlaxEditor.Options SharedTooltip = new Tooltip(), }; style.DragWindow = style.BackgroundSelected * 0.7f; - return style; } @@ -292,7 +290,6 @@ namespace FlaxEditor.Options /// The style object. public Style CreateLightStyle() { - // Metro Style colors var options = Options; var style = new Style { @@ -334,9 +331,8 @@ namespace FlaxEditor.Options Scale = Editor.Icons.Scale32, Scalar = Editor.Icons.Scalar32, - SharedTooltip = new Tooltip() + SharedTooltip = new Tooltip(), }; - return style; } diff --git a/Source/Editor/Options/ThemeOptions.cs b/Source/Editor/Options/ThemeOptions.cs index a033b34da..674e281af 100644 --- a/Source/Editor/Options/ThemeOptions.cs +++ b/Source/Editor/Options/ThemeOptions.cs @@ -15,6 +15,9 @@ namespace FlaxEditor.Options [CustomEditor(typeof(ThemeOptionsEditor))] public sealed class ThemeOptions { + internal const string DefaultName = "Default"; + internal const string LightDefault = "LightDefault"; + internal class ThemeOptionsEditor : Editor { private LabelElement _infoLabel; @@ -64,8 +67,8 @@ namespace FlaxEditor.Options { var themeOptions = (ThemeOptions)ParentEditor.Values[0]; var options = new string[themeOptions.Styles.Count + 2]; - options[0] = "Default"; - options[1] = "LightDefault"; + options[0] = DefaultName; + options[1] = LightDefault; int i = 0; foreach (var styleName in themeOptions.Styles.Keys) diff --git a/Source/Editor/Windows/Profiler/Assets.cs b/Source/Editor/Windows/Profiler/Assets.cs index b8b898246..536d65a74 100644 --- a/Source/Editor/Windows/Profiler/Assets.cs +++ b/Source/Editor/Windows/Profiler/Assets.cs @@ -62,8 +62,9 @@ namespace FlaxEditor.Windows.Profiler _memoryUsageChart.SelectedSampleChanged += OnSelectedSampleChanged; // Table - var headerColor = Style.Current.LightBackground; - var textColor = Style.Current.Foreground; + var style = Style.Current; + var headerColor = style.LightBackground; + var textColor = style.Foreground; _table = new Table { Columns = new[] diff --git a/Source/Editor/Windows/Profiler/CPU.cs b/Source/Editor/Windows/Profiler/CPU.cs index df4d5b59b..0cbb3fa9b 100644 --- a/Source/Editor/Windows/Profiler/CPU.cs +++ b/Source/Editor/Windows/Profiler/CPU.cs @@ -92,8 +92,9 @@ namespace FlaxEditor.Windows.Profiler }; // Table - var headerColor = Style.Current.LightBackground; - var textColor = Style.Current.Foreground; + var style = Style.Current; + var headerColor = style.LightBackground; + var textColor = style.Foreground; _table = new Table { Columns = new[] diff --git a/Source/Editor/Windows/Profiler/GPU.cs b/Source/Editor/Windows/Profiler/GPU.cs index e6a93df72..d2c34d335 100644 --- a/Source/Editor/Windows/Profiler/GPU.cs +++ b/Source/Editor/Windows/Profiler/GPU.cs @@ -63,8 +63,9 @@ namespace FlaxEditor.Windows.Profiler }; // Table - var headerColor = Style.Current.LightBackground; - var textColor = Style.Current.Foreground; + var style = Style.Current; + var headerColor = style.LightBackground; + var textColor = style.Foreground; _table = new Table { Columns = new[] diff --git a/Source/Editor/Windows/Profiler/MemoryGPU.cs b/Source/Editor/Windows/Profiler/MemoryGPU.cs index e894ef0e2..e7c085362 100644 --- a/Source/Editor/Windows/Profiler/MemoryGPU.cs +++ b/Source/Editor/Windows/Profiler/MemoryGPU.cs @@ -63,8 +63,9 @@ namespace FlaxEditor.Windows.Profiler _memoryUsageChart.SelectedSampleChanged += OnSelectedSampleChanged; // Table - var headerColor = Style.Current.LightBackground; - var textColor = Style.Current.Foreground; + var style = Style.Current; + var headerColor = style.LightBackground; + var textColor = style.Foreground; _table = new Table { Columns = new[] diff --git a/Source/Editor/Windows/Profiler/Network.cs b/Source/Editor/Windows/Profiler/Network.cs index 669cf4a65..1ac9777c1 100644 --- a/Source/Editor/Windows/Profiler/Network.cs +++ b/Source/Editor/Windows/Profiler/Network.cs @@ -252,8 +252,9 @@ namespace FlaxEditor.Windows.Profiler private static Table InitTable(ContainerControl parent, string name) { - var headerColor = Style.Current.LightBackground; - var textColor = Style.Current.Foreground; + var style = Style.Current; + var headerColor = style.LightBackground; + var textColor = style.Foreground; var table = new Table { Columns = new[] diff --git a/Source/Editor/Windows/Profiler/SingleChart.cs b/Source/Editor/Windows/Profiler/SingleChart.cs index 29780150a..4f36692e5 100644 --- a/Source/Editor/Windows/Profiler/SingleChart.cs +++ b/Source/Editor/Windows/Profiler/SingleChart.cs @@ -105,7 +105,7 @@ namespace FlaxEditor.Windows.Profiler if (_selectedSampleIndex != -1) { float selectedX = Width - (_samples.Count - _selectedSampleIndex - 1) * PointsOffset; - Render2D.DrawLine(new Float2(selectedX, 0), new Float2(selectedX, chartHeight), Style.Current.Foreground, 1.5f); + Render2D.DrawLine(new Float2(selectedX, 0), new Float2(selectedX, chartHeight), style.Foreground, 1.5f); } int samplesInViewCount = Math.Min((int)(Width / PointsOffset), _samples.Count) - 1; @@ -138,8 +138,8 @@ namespace FlaxEditor.Windows.Profiler var headerRect = new Rectangle(0, chartHeight, Width, TitleHeight); var headerTextRect = new Rectangle(2, chartHeight, Width - 4, TitleHeight); Render2D.FillRectangle(headerRect, style.BackgroundNormal); - Render2D.DrawText(style.FontMedium, Title, headerTextRect, Style.Current.ForegroundGrey, TextAlignment.Near, TextAlignment.Center); - Render2D.DrawText(style.FontMedium, _sample, headerTextRect, Style.Current.Foreground, TextAlignment.Far, TextAlignment.Center); + Render2D.DrawText(style.FontMedium, Title, headerTextRect, style.ForegroundGrey, TextAlignment.Near, TextAlignment.Center); + Render2D.DrawText(style.FontMedium, _sample, headerTextRect, style.Foreground, TextAlignment.Far, TextAlignment.Center); } private void OnClick(ref Float2 location)