Minor improvements to code style #1541

This commit is contained in:
Wojtek Figat
2023-11-13 17:17:05 +01:00
parent 13881c7d97
commit 618273977c
11 changed files with 33 additions and 28 deletions

View File

@@ -173,7 +173,7 @@ namespace FlaxEditor.GUI
else else
{ {
// No element selected // 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); Render2D.DrawText(style.FontMedium, "No asset\nselected", iconRect, Color.Orange, TextAlignment.Center, TextAlignment.Center, TextWrapping.NoWrap, 1.0f, Height / DefaultIconSize);
} }

View File

@@ -98,7 +98,7 @@ namespace FlaxEditor.GUI
rect.Width -= leftDepthMargin; rect.Width -= leftDepthMargin;
Render2D.PushClip(rect); 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(); Render2D.PopClip();
x += width; x += width;

View File

@@ -627,10 +627,11 @@ namespace FlaxEditor.GUI.Timeline
Parent = this Parent = this
}; };
var style = Style.Current;
var headerTopArea = new ContainerControl var headerTopArea = new ContainerControl
{ {
AutoFocus = false, AutoFocus = false,
BackgroundColor = Style.Current.LightBackground, BackgroundColor = style.LightBackground,
AnchorPreset = AnchorPresets.HorizontalStretchTop, AnchorPreset = AnchorPresets.HorizontalStretchTop,
Offsets = new Margin(0, 0, 0, HeaderTopAreaHeight), Offsets = new Margin(0, 0, 0, HeaderTopAreaHeight),
Parent = _splitter.Panel1 Parent = _splitter.Panel1
@@ -683,7 +684,7 @@ namespace FlaxEditor.GUI.Timeline
{ {
AutoFocus = false, AutoFocus = false,
ClipChildren = false, ClipChildren = false,
BackgroundColor = Style.Current.LightBackground, BackgroundColor = style.LightBackground,
AnchorPreset = AnchorPresets.HorizontalStretchBottom, AnchorPreset = AnchorPresets.HorizontalStretchBottom,
Offsets = new Margin(0, 0, -playbackButtonsSize, playbackButtonsSize), Offsets = new Margin(0, 0, -playbackButtonsSize, playbackButtonsSize),
Parent = _splitter.Panel1 Parent = _splitter.Panel1
@@ -845,7 +846,7 @@ namespace FlaxEditor.GUI.Timeline
_timeIntervalsHeader = new TimeIntervalsHeader(this) _timeIntervalsHeader = new TimeIntervalsHeader(this)
{ {
AutoFocus = false, AutoFocus = false,
BackgroundColor = Style.Current.Background.RGBMultiplied(0.9f), BackgroundColor = style.Background.RGBMultiplied(0.9f),
AnchorPreset = AnchorPresets.HorizontalStretchTop, AnchorPreset = AnchorPresets.HorizontalStretchTop,
Offsets = new Margin(0, 0, 0, HeaderTopAreaHeight), Offsets = new Margin(0, 0, 0, HeaderTopAreaHeight),
Parent = _splitter.Panel2 Parent = _splitter.Panel2
@@ -854,7 +855,7 @@ namespace FlaxEditor.GUI.Timeline
{ {
AutoFocus = false, AutoFocus = false,
ClipChildren = false, ClipChildren = false,
BackgroundColor = Style.Current.Background.RGBMultiplied(0.7f), BackgroundColor = style.Background.RGBMultiplied(0.7f),
AnchorPreset = AnchorPresets.StretchAll, AnchorPreset = AnchorPresets.StretchAll,
Offsets = new Margin(0, 0, HeaderTopAreaHeight, 0), Offsets = new Margin(0, 0, HeaderTopAreaHeight, 0),
Parent = _splitter.Panel2 Parent = _splitter.Panel2

View File

@@ -208,13 +208,13 @@ namespace FlaxEditor.Options
// If a non-default style was chosen, switch to that style // If a non-default style was chosen, switch to that style
string styleName = themeOptions.SelectedStyle; 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; Style.Current = style;
} }
else else
{ {
if (styleName == "LightDefault") if (styleName == ThemeOptions.LightDefault)
{ {
Style.Current = CreateLightStyle(); Style.Current = CreateLightStyle();
} }
@@ -231,7 +231,6 @@ namespace FlaxEditor.Options
/// <returns>The style object.</returns> /// <returns>The style object.</returns>
public Style CreateDefaultStyle() public Style CreateDefaultStyle()
{ {
// Metro Style colors
var options = Options; var options = Options;
var style = new Style var style = new Style
{ {
@@ -282,7 +281,6 @@ namespace FlaxEditor.Options
SharedTooltip = new Tooltip(), SharedTooltip = new Tooltip(),
}; };
style.DragWindow = style.BackgroundSelected * 0.7f; style.DragWindow = style.BackgroundSelected * 0.7f;
return style; return style;
} }
@@ -292,7 +290,6 @@ namespace FlaxEditor.Options
/// <returns>The style object.</returns> /// <returns>The style object.</returns>
public Style CreateLightStyle() public Style CreateLightStyle()
{ {
// Metro Style colors
var options = Options; var options = Options;
var style = new Style var style = new Style
{ {
@@ -334,9 +331,8 @@ namespace FlaxEditor.Options
Scale = Editor.Icons.Scale32, Scale = Editor.Icons.Scale32,
Scalar = Editor.Icons.Scalar32, Scalar = Editor.Icons.Scalar32,
SharedTooltip = new Tooltip() SharedTooltip = new Tooltip(),
}; };
return style; return style;
} }

View File

@@ -15,6 +15,9 @@ namespace FlaxEditor.Options
[CustomEditor(typeof(ThemeOptionsEditor))] [CustomEditor(typeof(ThemeOptionsEditor))]
public sealed class ThemeOptions public sealed class ThemeOptions
{ {
internal const string DefaultName = "Default";
internal const string LightDefault = "LightDefault";
internal class ThemeOptionsEditor : Editor<ThemeOptions> internal class ThemeOptionsEditor : Editor<ThemeOptions>
{ {
private LabelElement _infoLabel; private LabelElement _infoLabel;
@@ -64,8 +67,8 @@ namespace FlaxEditor.Options
{ {
var themeOptions = (ThemeOptions)ParentEditor.Values[0]; var themeOptions = (ThemeOptions)ParentEditor.Values[0];
var options = new string[themeOptions.Styles.Count + 2]; var options = new string[themeOptions.Styles.Count + 2];
options[0] = "Default"; options[0] = DefaultName;
options[1] = "LightDefault"; options[1] = LightDefault;
int i = 0; int i = 0;
foreach (var styleName in themeOptions.Styles.Keys) foreach (var styleName in themeOptions.Styles.Keys)

View File

@@ -62,8 +62,9 @@ namespace FlaxEditor.Windows.Profiler
_memoryUsageChart.SelectedSampleChanged += OnSelectedSampleChanged; _memoryUsageChart.SelectedSampleChanged += OnSelectedSampleChanged;
// Table // Table
var headerColor = Style.Current.LightBackground; var style = Style.Current;
var textColor = Style.Current.Foreground; var headerColor = style.LightBackground;
var textColor = style.Foreground;
_table = new Table _table = new Table
{ {
Columns = new[] Columns = new[]

View File

@@ -92,8 +92,9 @@ namespace FlaxEditor.Windows.Profiler
}; };
// Table // Table
var headerColor = Style.Current.LightBackground; var style = Style.Current;
var textColor = Style.Current.Foreground; var headerColor = style.LightBackground;
var textColor = style.Foreground;
_table = new Table _table = new Table
{ {
Columns = new[] Columns = new[]

View File

@@ -63,8 +63,9 @@ namespace FlaxEditor.Windows.Profiler
}; };
// Table // Table
var headerColor = Style.Current.LightBackground; var style = Style.Current;
var textColor = Style.Current.Foreground; var headerColor = style.LightBackground;
var textColor = style.Foreground;
_table = new Table _table = new Table
{ {
Columns = new[] Columns = new[]

View File

@@ -63,8 +63,9 @@ namespace FlaxEditor.Windows.Profiler
_memoryUsageChart.SelectedSampleChanged += OnSelectedSampleChanged; _memoryUsageChart.SelectedSampleChanged += OnSelectedSampleChanged;
// Table // Table
var headerColor = Style.Current.LightBackground; var style = Style.Current;
var textColor = Style.Current.Foreground; var headerColor = style.LightBackground;
var textColor = style.Foreground;
_table = new Table _table = new Table
{ {
Columns = new[] Columns = new[]

View File

@@ -252,8 +252,9 @@ namespace FlaxEditor.Windows.Profiler
private static Table InitTable(ContainerControl parent, string name) private static Table InitTable(ContainerControl parent, string name)
{ {
var headerColor = Style.Current.LightBackground; var style = Style.Current;
var textColor = Style.Current.Foreground; var headerColor = style.LightBackground;
var textColor = style.Foreground;
var table = new Table var table = new Table
{ {
Columns = new[] Columns = new[]

View File

@@ -105,7 +105,7 @@ namespace FlaxEditor.Windows.Profiler
if (_selectedSampleIndex != -1) if (_selectedSampleIndex != -1)
{ {
float selectedX = Width - (_samples.Count - _selectedSampleIndex - 1) * PointsOffset; 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; 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 headerRect = new Rectangle(0, chartHeight, Width, TitleHeight);
var headerTextRect = new Rectangle(2, chartHeight, Width - 4, TitleHeight); var headerTextRect = new Rectangle(2, chartHeight, Width - 4, TitleHeight);
Render2D.FillRectangle(headerRect, style.BackgroundNormal); Render2D.FillRectangle(headerRect, style.BackgroundNormal);
Render2D.DrawText(style.FontMedium, Title, headerTextRect, Style.Current.ForegroundGrey, TextAlignment.Near, TextAlignment.Center); Render2D.DrawText(style.FontMedium, Title, headerTextRect, style.ForegroundGrey, TextAlignment.Near, TextAlignment.Center);
Render2D.DrawText(style.FontMedium, _sample, headerTextRect, Style.Current.Foreground, TextAlignment.Far, TextAlignment.Center); Render2D.DrawText(style.FontMedium, _sample, headerTextRect, style.Foreground, TextAlignment.Far, TextAlignment.Center);
} }
private void OnClick(ref Float2 location) private void OnClick(ref Float2 location)