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.
107 lines
3.3 KiB
C#
107 lines
3.3 KiB
C#
// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
|
|
|
|
using System.Collections.Generic;
|
|
using FlaxEditor.CustomEditors;
|
|
using FlaxEditor.CustomEditors.Elements;
|
|
using FlaxEditor.GUI;
|
|
using FlaxEngine;
|
|
using FlaxEngine.GUI;
|
|
|
|
namespace FlaxEditor.Options
|
|
{
|
|
/// <summary>
|
|
/// Theme options data container object.
|
|
/// </summary>
|
|
[CustomEditor(typeof(ThemeOptionsEditor))]
|
|
public sealed class ThemeOptions
|
|
{
|
|
internal class ThemeOptionsEditor : Editor<ThemeOptions>
|
|
{
|
|
private LabelElement _infoLabel;
|
|
|
|
/// <inheritdoc />
|
|
public override void Initialize(LayoutElementsContainer layout)
|
|
{
|
|
_infoLabel = layout.Label("Editor restart is required to apply style changes.", TextAlignment.Center);
|
|
_infoLabel.Label.Visible = false;
|
|
|
|
base.Initialize(layout);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Deinitialize()
|
|
{
|
|
_infoLabel = null;
|
|
|
|
base.Deinitialize();
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override bool OnDirty(CustomEditor editor, object value, object token = null)
|
|
{
|
|
_infoLabel.Label.Visible = true;
|
|
return base.OnDirty(editor, value, token);
|
|
}
|
|
}
|
|
|
|
internal class StyleOptionsEditor : CustomEditor
|
|
{
|
|
private ComboBoxElement _combobox;
|
|
|
|
/// <inheritdoc />
|
|
public override DisplayStyle Style => DisplayStyle.Inline;
|
|
|
|
/// <inheritdoc />
|
|
public override void Initialize(LayoutElementsContainer layout)
|
|
{
|
|
_combobox = layout.ComboBox();
|
|
ReloadOptions(_combobox.ComboBox);
|
|
_combobox.ComboBox.SelectedIndexChanged += OnComboBoxSelectedIndexChanged;
|
|
_combobox.ComboBox.PopupShowing += ReloadOptions;
|
|
}
|
|
|
|
private void ReloadOptions(ComboBox obj)
|
|
{
|
|
var themeOptions = (ThemeOptions)ParentEditor.Values[0];
|
|
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 + 2] = styleName;
|
|
i++;
|
|
}
|
|
_combobox.ComboBox.SetItems(options);
|
|
_combobox.ComboBox.SelectedItem = (string)Values[0];
|
|
}
|
|
|
|
private void OnComboBoxSelectedIndexChanged(ComboBox combobox)
|
|
{
|
|
SetValue(combobox.SelectedItem);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override void Refresh()
|
|
{
|
|
_combobox.ComboBox.SelectedItem = (string)Values[0];
|
|
|
|
base.Refresh();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Currently selected style.
|
|
/// </summary>
|
|
[CustomEditor(typeof(StyleOptionsEditor))]
|
|
[Tooltip("Restart Editor to apply style")]
|
|
public string SelectedStyle = "Default";
|
|
|
|
/// <summary>
|
|
/// All available styles.
|
|
/// </summary>
|
|
public Dictionary<string, Style> Styles { get; set; } = new Dictionary<string, Style>();
|
|
}
|
|
}
|