Code style formatting and minor tweaks

#2800
This commit is contained in:
Wojtek Figat
2026-02-11 17:15:15 +01:00
parent 0bea701a83
commit 273b110db4
41 changed files with 108 additions and 116 deletions

View File

@@ -279,7 +279,7 @@ namespace FlaxEditor.GUI.ContextMenu
_window.GotFocus += OnWindowGotFocus;
_window.LostFocus += OnWindowLostFocus;
}
#if USE_IS_FOREGROUND && USE_SDL_WORKAROUNDS
// The focus between popup and parent windows doesn't change, force hide the popup when clicked on parent
parentWin.Window.MouseDown += OnWindowMouseDown;

View File

@@ -50,7 +50,7 @@ namespace FlaxEditor.GUI.Docking
/// The mouse position.
/// </summary>
public Float2 MousePosition = Float2.Minimum;
/// <summary>
/// The mouse position.
/// </summary>

View File

@@ -193,6 +193,7 @@ namespace FlaxEditor.GUI.Docking
{
CreateFloating(Float2.Zero, Float2.Zero);
}
/// <summary>
/// Creates the window in a floating state.
/// </summary>

View File

@@ -14,13 +14,13 @@ namespace FlaxEditor.GUI.Docking
private class FloatWindowDecorations : WindowDecorations
{
private FloatWindowDockPanel _panel;
public FloatWindowDecorations(FloatWindowDockPanel panel)
: base(panel.RootWindow)
{
_panel = panel;
}
/// <inheritdoc />
public override bool OnMouseDown(Float2 location, MouseButton button)
{
@@ -76,19 +76,19 @@ namespace FlaxEditor.GUI.Docking
Parent = window;
_window.Window.Closing += OnClosing;
_window.Window.LeftButtonHit += OnLeftButtonHit;
if (Utilities.Utils.UseCustomWindowDecorations())
{
var decorations = Parent.AddChild(new FloatWindowDecorations(this));
decorations.SetAnchorPreset(AnchorPresets.HorizontalStretchTop, false);
}
}
/// <inheritdoc />
protected override void PerformLayoutBeforeChildren()
{
base.PerformLayoutBeforeChildren();
var decorations = Parent.GetChild<FloatWindowDecorations>();
if (decorations != null)
{
@@ -143,7 +143,7 @@ namespace FlaxEditor.GUI.Docking
settings.ShowAfterFirstPaint = false;
settings.ShowInTaskbar = true;
settings.StartPosition = startPosition;
if (Utilities.Utils.UseCustomWindowDecorations())
{
settings.HasBorder = false;

View File

@@ -322,7 +322,7 @@ namespace FlaxEditor.GUI.Input
#else
/// <inheritdoc />
public override void OnMouseMoveRelative(Float2 mouseMotion)
public override void OnMouseMoveRelative(Float2 motion)
{
var location = Root.TrackingMouseOffset;
if (_isSliding)
@@ -344,7 +344,7 @@ namespace FlaxEditor.GUI.Input
_cursorChanged = false;
}
base.OnMouseMoveRelative(mouseMotion);
base.OnMouseMoveRelative(motion);
}
#endif

View File

@@ -1,8 +1,5 @@
// Copyright (c) Wojciech Figat. All rights reserved.
using System;
using FlaxEditor.GUI.Docking;
using FlaxEditor.Options;
using FlaxEngine;
using FlaxEngine.GUI;
@@ -26,12 +23,12 @@ public class WindowDecorations : ContainerControl
/// The title label in the title bar.
/// </summary>
public Label Title => _title;
/// <summary>
/// The icon used in the title bar.
/// </summary>
public Image Icon => _icon;
/// <summary>
/// The tooltip shown when hovering over the icon.
/// </summary>
@@ -54,7 +51,7 @@ public class WindowDecorations : ContainerControl
: base(0, 0, 0, 20)
{
_window = window.RootWindow.Window;
AutoFocus = false;
AnchorPreset = AnchorPresets.HorizontalStretchTop;
BackgroundColor = Color.Transparent;
@@ -75,13 +72,13 @@ public class WindowDecorations : ContainerControl
{
_icon.Margin = new Margin(6, 6, 6, 6);
Height = 28;
_window.HitTest += OnHitTest;
_window.Closed += OnWindowClosed;
FontAsset windowIconsFont = FlaxEngine.Content.LoadAsyncInternal<FontAsset>(EditorAssets.WindowIconsFont);
Font iconFont = windowIconsFont?.CreateFont(9);
_title = new Label(0, 0, Width, Height)
{
Text = _window.Title,
@@ -150,7 +147,7 @@ public class WindowDecorations : ContainerControl
_charChromeMaximize = ((char)EditorAssets.SegMDL2Icons.ChromeMaximize).ToString();
}
}
/// <inheritdoc />
public override void Update(float deltaTime)
{
@@ -216,20 +213,20 @@ public class WindowDecorations : ContainerControl
if (pos.Y > winSize.Y - distance)
return WindowHitCodes.Bottom;
}
var controlUnderMouse = GetChildAt(pos, control => control != _title);
if (_title.Bounds.Contains(pos) && controlUnderMouse == null)
return WindowHitCodes.Caption;
return WindowHitCodes.Client;
}
/// <inheritdoc />
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
{
// These may not work with main window due to SDL not passing mouse events
// when interacting with hit tests on caption area...
if (Title.Bounds.Contains(location) && button == MouseButton.Left)
{
if (_window.IsMaximized)
@@ -251,7 +248,7 @@ public class WindowDecorations : ContainerControl
{
// Calculate extents for title bounds area excluding the icon and main menu area
float x = 0;
// Icon
if (_icon != null)
{
@@ -273,7 +270,7 @@ public class WindowDecorations : ContainerControl
}
}
}
// Buttons
float rightMostButtonX = Width;
if (_closeButton != null)
@@ -302,7 +299,7 @@ public class WindowDecorations : ContainerControl
_title.Bounds = new Rectangle(x, 0, rightMostButtonX - x, Height);
}
}
/// <inheritdoc />
public override void Draw()
{
@@ -321,7 +318,7 @@ public class WindowDecorations : ContainerControl
if (Editor.Instance.UI.StatusBar == null)
return;
const float thickness = 1.0f;
Color color = Editor.Instance.UI.StatusBar.StatusColor;
Rectangle rect = new Rectangle(thickness * 0.5f, thickness * 0.5f, Parent.Width - thickness, Parent.Height - thickness);