Minor formatting changes

This commit is contained in:
Critical Impact 2025-09-05 16:19:32 +10:00
parent 2dd9ecd8e8
commit 660781393e
6 changed files with 40 additions and 24 deletions

View file

@ -1,7 +1,3 @@
// <copyright file="IWindow.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
using System.Collections.Generic; using System.Collections.Generic;
using System.Numerics; using System.Numerics;
@ -27,7 +23,7 @@ public interface IWindow
string WindowName { get; set; } string WindowName { get; set; }
/// <summary> /// <summary>
/// Gets a value indicating whether the window is focused. /// Gets or sets a value indicating whether the window is focused.
/// </summary> /// </summary>
bool IsFocused { get; set; } bool IsFocused { get; set; }
@ -137,7 +133,7 @@ public interface IWindow
bool IsOpen { get; set; } bool IsOpen { get; set; }
/// <summary> /// <summary>
/// Gets or sets a value indicating whether this window will request focus from the window system next frame /// Gets or sets a value indicating whether this window will request focus from the window system next frame.
/// </summary> /// </summary>
public bool RequestFocus { get; set; } public bool RequestFocus { get; set; }
@ -199,7 +195,7 @@ public interface IWindow
/// <summary> /// <summary>
/// Code to be executed when the window is safe to be disposed or removed from the window system. /// Code to be executed when the window is safe to be disposed or removed from the window system.
/// Doing so in <see cref="WindowHost.OnClose"/> may result in animations not playing correctly. /// Doing so in <see cref="IWindow.OnClose"/> may result in animations not playing correctly.
/// </summary> /// </summary>
void OnSafeToRemove(); void OnSafeToRemove();

View file

@ -1,11 +1,10 @@
// <copyright file="IWindowSystem.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
using System.Collections.Generic; using System.Collections.Generic;
namespace Dalamud.Interface.Windowing; namespace Dalamud.Interface.Windowing;
/// <summary>
/// Class running a WindowSystem using <see cref="IWindow"/> implementations to simplify ImGui windowing.
/// </summary>
public interface IWindowSystem public interface IWindowSystem
{ {
/// <summary> /// <summary>

View file

@ -9,7 +9,7 @@ namespace Dalamud.Interface.Windowing;
public abstract class Window : IWindow public abstract class Window : IWindow
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="WindowHost"/> class. /// Initializes a new instance of the <see cref="Window"/> class.
/// </summary> /// </summary>
/// <param name="name">The name/ID of this window. /// <param name="name">The name/ID of this window.
/// If you have multiple windows with the same name, you will need to /// If you have multiple windows with the same name, you will need to
@ -25,7 +25,7 @@ public abstract class Window : IWindow
} }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="WindowHost"/> class. /// Initializes a new instance of the <see cref="Window"/> class.
/// </summary> /// </summary>
/// <param name="name">The name/ID of this window. /// <param name="name">The name/ID of this window.
/// If you have multiple windows with the same name, you will need to /// If you have multiple windows with the same name, you will need to
@ -36,7 +36,6 @@ public abstract class Window : IWindow
{ {
} }
/// <inheritdoc/> /// <inheritdoc/>
public string? Namespace { get; set; } public string? Namespace { get; set; }

View file

@ -51,6 +51,10 @@ public class WindowHost
private Vector2 fadeOutSize = Vector2.Zero; private Vector2 fadeOutSize = Vector2.Zero;
private Vector2 fadeOutOrigin = Vector2.Zero; private Vector2 fadeOutOrigin = Vector2.Zero;
/// <summary>
/// Initializes a new instance of the <see cref="WindowHost"/> class.
/// </summary>
/// <param name="window">A plugin provided window.</param>
internal WindowHost(IWindow window) internal WindowHost(IWindow window)
{ {
this.Window = window; this.Window = window;
@ -88,10 +92,13 @@ public class WindowHost
IsReducedMotion = 1 << 3, IsReducedMotion = 1 << 3,
} }
private bool CanShowCloseButton => this.Window.ShowCloseButton && !this.internalIsClickthrough; /// <summary>
/// Gets or sets the backing window provided by the plugin.
/// </summary>
public IWindow Window { get; set; } public IWindow Window { get; set; }
private bool CanShowCloseButton => this.Window.ShowCloseButton && !this.internalIsClickthrough;
/// <summary> /// <summary>
/// Draw the window via ImGui. /// Draw the window via ImGui.
/// </summary> /// </summary>
@ -158,12 +165,13 @@ public class WindowHost
UIGlobals.PlaySoundEffect(this.Window.OnOpenSfxId); UIGlobals.PlaySoundEffect(this.Window.OnOpenSfxId);
} }
//TODO: We may have to allow for windows to configure if they should fade // TODO: We may have to allow for windows to configure if they should fade
if (this.internalAlpha.HasValue) if (this.internalAlpha.HasValue)
{ {
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, this.internalAlpha.Value); ImGui.PushStyleVar(ImGuiStyleVar.Alpha, this.internalAlpha.Value);
this.didPushInternalAlpha = true; this.didPushInternalAlpha = true;
} }
this.Window.PreDraw(); this.Window.PreDraw();
this.ApplyConditionals(); this.ApplyConditionals();
@ -404,6 +412,7 @@ public class WindowHost
ImGui.PopStyleVar(); ImGui.PopStyleVar();
this.didPushInternalAlpha = false; this.didPushInternalAlpha = false;
} }
this.Window.PostDraw(); this.Window.PostDraw();
this.PostHandlePreset(persistence); this.PostHandlePreset(persistence);
@ -439,8 +448,7 @@ public class WindowHost
var (min, max) = this.GetValidatedConstraints(this.Window.SizeConstraints.Value); var (min, max) = this.GetValidatedConstraints(this.Window.SizeConstraints.Value);
ImGui.SetNextWindowSizeConstraints( ImGui.SetNextWindowSizeConstraints(
min * ImGuiHelpers.GlobalScale, min * ImGuiHelpers.GlobalScale,
max * ImGuiHelpers.GlobalScale max * ImGuiHelpers.GlobalScale);
);
} }
var maxBgAlpha = this.internalAlpha ?? this.Window.BgAlpha; var maxBgAlpha = this.internalAlpha ?? this.Window.BgAlpha;
@ -460,7 +468,7 @@ public class WindowHost
} }
} }
private (Vector2 min, Vector2 max) GetValidatedConstraints(WindowSizeConstraints constraints) private (Vector2 Min, Vector2 Max) GetValidatedConstraints(WindowSizeConstraints constraints)
{ {
var min = constraints.MinimumSize; var min = constraints.MinimumSize;
var max = constraints.MaximumSize; var max = constraints.MaximumSize;
@ -472,7 +480,6 @@ public class WindowHost
return (min, max); return (min, max);
} }
private void PreHandlePreset(WindowSystemPersistence? persistence) private void PreHandlePreset(WindowSystemPersistence? persistence)
{ {
if (persistence == null || this.hasInitializedFromPreset) if (persistence == null || this.hasInitializedFromPreset)

View file

@ -2,8 +2,25 @@ using System.Numerics;
namespace Dalamud.Interface.Windowing; namespace Dalamud.Interface.Windowing;
/// <summary>
/// Structure detailing the size constraints of a window.
/// </summary>
public struct WindowSizeConstraints public struct WindowSizeConstraints
{ {
/// <summary>
/// Initializes a new instance of the <see cref="WindowSizeConstraints"/> struct.
/// </summary>
public WindowSizeConstraints()
{
}
/// <summary>
/// Gets or sets the minimum size of the window.
/// </summary>
public Vector2 MinimumSize { get; set; } public Vector2 MinimumSize { get; set; }
/// <summary>
/// Gets or sets the maximum size of the window.
/// </summary>
public Vector2 MaximumSize { get; set; } public Vector2 MaximumSize { get; set; }
} }

View file

@ -8,9 +8,7 @@ using Serilog;
namespace Dalamud.Interface.Windowing; namespace Dalamud.Interface.Windowing;
/// <summary> /// <inheritdoc/>
/// Class running a WindowSystem using <see cref="IWindow"/> implementations to simplify ImGui windowing.
/// </summary>
public class WindowSystem : IWindowSystem public class WindowSystem : IWindowSystem
{ {
private static DateTimeOffset lastAnyFocus; private static DateTimeOffset lastAnyFocus;