Add IconsScale to editor interface options

This commit is contained in:
Wojtek Figat
2021-01-03 22:13:31 +01:00
parent 4043e35b10
commit bf9204f146
12 changed files with 24 additions and 27 deletions

View File

@@ -27,6 +27,8 @@ namespace FlaxEditor.GUI
/// <inheritdoc />
protected override void Arrange()
{
base.Arrange();
// Arrange buttons
float x = DefaultButtonsMargin;
for (int i = 0; i < _children.Count; i++)
@@ -50,10 +52,11 @@ namespace FlaxEditor.GUI
return;
var lastToolstripButton = toolstrip.LastButton;
var parentSize = Parent.Size;
Bounds = new Rectangle
(
new Vector2(lastToolstripButton.Right + 8.0f, 0),
new Vector2(Parent.Width - X - 8.0f, 32)
new Vector2(parentSize.X - X - 8.0f, toolstrip.Height)
);
}
}

View File

@@ -1,7 +1,6 @@
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
using System;
using FlaxEditor.Options;
using FlaxEngine;
using FlaxEngine.GUI;
@@ -21,7 +20,7 @@ namespace FlaxEditor.GUI
/// <summary>
/// The default margin horizontally.
/// </summary>
public const int DefaultMarginH = 4;
public const int DefaultMarginH = 2;
/// <summary>
/// Event fired when button gets clicked.
@@ -64,18 +63,19 @@ namespace FlaxEditor.GUI
/// <summary>
/// Gets the height for the items.
/// </summary>
public float ItemsHeight => Height + itemScale * DefaultMarginV;
private float itemScale;
public float ItemsHeight => Height - 2 * DefaultMarginV;
/// <summary>
/// Initializes a new instance of the <see cref="ToolStrip"/> class.
/// </summary>
public ToolStrip()
/// <param name="height">The toolstrip height.</param>
/// <param name="y">The toolstrip Y position.</param>
public ToolStrip(float height = 32.0f, float y = 0)
{
itemScale = Style.Current.IconSizeExtra;
AutoFocus = false;
AnchorPreset = AnchorPresets.HorizontalStretchTop;
BackgroundColor = Style.Current.LightBackground;
Offsets = new Margin(0, 0, y, height * Editor.Instance.Options.Options.Interface.IconsScale);
}
/// <summary>

View File

@@ -493,10 +493,9 @@ namespace FlaxEditor.Modules
private void InitToolstrip(RootControl mainWindow)
{
ToolStrip = new ToolStrip
ToolStrip = new ToolStrip(34.0f, MainMenu.Bottom)
{
Parent = mainWindow,
Bounds = new Rectangle(0, MainMenu.Bottom, mainWindow.Width, 34),
};
_toolStripSaveAll = (ToolStripButton)ToolStrip.AddButton(Editor.Icons.Save32, Editor.SaveAll).LinkTooltip("Save all (Ctrl+S)");

View File

@@ -71,6 +71,13 @@ namespace FlaxEditor.Options
[DefaultValue(TimestampsFormats.None)]
[EditorDisplay("Interface"), EditorOrder(210), Tooltip("The timestamps prefix mode for debug log messages.")]
public TimestampsFormats DebugLogTimestampsFormat { get; set; } = TimestampsFormats.None;
/// <summary>
/// Gets or sets the editor icons scale. Editor restart required.
/// </summary>
[DefaultValue(1.0f), Limit(0.1f, 4.0f, 0.01f)]
[EditorDisplay("Interface"), EditorOrder(250), Tooltip("Editor icons scale. Editor restart required.")]
public float IconsScale { get; set; } = 1.0f;
/// <summary>
/// Gets or sets the timestamps prefix mode for output log messages.
@@ -131,7 +138,7 @@ namespace FlaxEditor.Options
/// Gets or sets a value indicating whether auto-focus game window on play mode start.
/// </summary>
[DefaultValue(true)]
[EditorDisplay("Play In-Editor", "Focus Game Window On Play"), EditorOrder(200), Tooltip("Determines whether auto-focus game window on play mode start.")]
[EditorDisplay("Play In-Editor", "Focus Game Window On Play"), EditorOrder(400), Tooltip("Determines whether auto-focus game window on play mode start.")]
public bool FocusGameWinOnPlay { get; set; } = true;
private static FontAsset DefaultFont => FlaxEngine.Content.LoadAsyncInternal<FontAsset>(EditorAssets.PrimaryFont);

View File

@@ -51,7 +51,6 @@ namespace FlaxEditor.Windows.Assets
_toolstrip = new ToolStrip
{
Offsets = new Margin(0, 0, 0, 32),
Parent = this
};
_toolstrip.AddButton(editor.Icons.Find32, () => Editor.Windows.ContentWin.Select(_item)).LinkTooltip("Show and select in Content Window");

View File

@@ -72,10 +72,9 @@ namespace FlaxEditor.Windows
editor.ContentDatabase.ItemRemoved += ContentDatabaseOnItemRemoved;
// Toolstrip
_toolStrip = new ToolStrip
_toolStrip = new ToolStrip(34.0f)
{
Parent = this,
Bounds = new Rectangle(0, 0, Width, 34),
};
_importButton = (ToolStripButton)_toolStrip.AddButton(Editor.Icons.Import32, () => Editor.ContentImporting.ShowImportFileDialog(CurrentViewFolder)).LinkTooltip("Import content");
_toolStrip.AddSeparator();

View File

@@ -282,9 +282,8 @@ namespace FlaxEditor.Windows
OnEditorOptionsChanged(Editor.Options.Options);
// Toolstrip
var toolstrip = new ToolStrip
var toolstrip = new ToolStrip(22.0f)
{
Offsets = new Margin(0, 0, 0, 22),
Parent = this,
};
toolstrip.AddButton("Clear", Clear).LinkTooltip("Clears all log entries");

View File

@@ -36,7 +36,6 @@ namespace FlaxEditor.Windows
var toolstrip = new ToolStrip
{
Offsets = new Margin(0, 0, 0, 32),
Parent = this
};
_saveButton = (ToolStripButton)toolstrip.AddButton(editor.Icons.Save32, SaveData).LinkTooltip("Save");

View File

@@ -90,7 +90,6 @@ namespace FlaxEditor.Windows.Profiler
var toolstrip = new ToolStrip
{
Offsets = new Margin(0, 0, 0, 32),
Parent = this,
};
_liveRecordingButton = toolstrip.AddButton(editor.Icons.Play32);

View File

@@ -308,7 +308,7 @@ namespace FlaxEditor.Windows
/// <inheritdoc />
public override void OnInit()
{
float tabSize = 48 + Style.Current.IconSizeExtra;
float tabSize = 48 * Editor.Options.Options.Interface.IconsScale;
TabsControl = new Tabs
{
AnchorPreset = AnchorPresets.StretchAll,

View File

@@ -399,7 +399,6 @@ namespace FlaxEditor.Windows
var toolstrip = new ToolStrip
{
Offsets = new Margin(0, 0, 0, 32),
Parent = this
};
toolstrip.AddButton(editor.Icons.Docs32, () => Platform.OpenUrl(Utilities.Constants.DocsUrl + "manual/scripting/visual/index.html")).LinkTooltip("See documentation to learn more");
@@ -416,7 +415,7 @@ namespace FlaxEditor.Windows
var tabs = new Tabs
{
AnchorPreset = AnchorPresets.StretchAll,
Offsets = new Margin(0, 0, 32, 0),
Offsets = new Margin(0, 0, toolstrip.Bottom, 0),
TabsSize = new Vector2(80, 20),
TabsTextHorizontalAlignment = TextAlignment.Center,
UseScroll = true,

View File

@@ -68,12 +68,6 @@ namespace FlaxEngine.GUI
set => _fontSmall = new FontReference(value);
}
/// <summary>
/// Size of toolbar icons
/// </summary>
[EditorOrder(50)]
public int IconSizeExtra;
/// <summary>
/// The background color.
/// </summary>