Customizable statusbar

This commit is contained in:
davevanegdom
2023-09-21 14:54:57 +02:00
parent 5c5c64cf76
commit 21c742bd8a
7 changed files with 74 additions and 6 deletions

View File

@@ -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 += () =>

View File

@@ -33,7 +33,7 @@ namespace FlaxEditor.GUI
/// <summary>
/// Gets or sets the status text color
/// </summary>
public Color TextColor { get; set; } = Style.Current.Foreground;
public Color TextColor { get; set; } = Style.Current.Statusbar.TextColor;
/// <summary>
/// Initializes a new instance of the <see cref="StatusBar"/> class.

View File

@@ -129,6 +129,7 @@ namespace FlaxEditor.Modules
else
{
Editor.UI.UpdateProgress(string.Empty, 0);
Editor.UI.UpdateStatusBar();
}
}

View File

@@ -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();

View File

@@ -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(),

View File

@@ -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;

View File

@@ -164,6 +164,12 @@ namespace FlaxEngine.GUI
[EditorOrder(200)]
public Color ProgressNormal;
/// <summary>
/// The status bar style
/// </summary>
[EditorOrder(210)]
public StatusbarStyle Statusbar;
/// <summary>
/// The arrow right icon.
/// </summary>
@@ -241,5 +247,37 @@ namespace FlaxEngine.GUI
/// </summary>
[EditorOrder(340)]
public Tooltip SharedTooltip;
/// <summary>
/// Style for the Statusbar
/// </summary>
[System.Serializable, ShowInEditor]
public struct StatusbarStyle
{
/// <summary>
/// Color of the text in the Statusbar
/// </summary>
public Color TextColor;
/// <summary>
/// Color of the Statusbar in its default state
/// </summary>
public Color Normal;
/// <summary>
/// Color of the Statusbar when in Play Mode
/// </summary>
public Color PlayMode;
/// <summary>
/// Color of the Statusbar when in loading state (e.g. when importing assets)
/// </summary>
public Color Loading;
/// <summary>
/// Color of the Statusbar in its failed state (e.g. with compilation errors)
/// </summary>
public Color Failed;
}
}
}