From ac83077863f82aaf011f36295ee416c0803c3d9a Mon Sep 17 00:00:00 2001 From: goat <16760685+goaaats@users.noreply.github.com> Date: Mon, 9 Aug 2021 21:06:37 +0200 Subject: [PATCH] fix(Window): use a struct for SizeConstraints, you can't set them separately --- .../Internal/Windows/ScratchpadWindow.cs | 6 +++- Dalamud/Interface/Windowing/Window.cs | 29 +++++++++++++------ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/Dalamud/Interface/Internal/Windows/ScratchpadWindow.cs b/Dalamud/Interface/Internal/Windows/ScratchpadWindow.cs index 198ac0cf6..1f420f1e8 100644 --- a/Dalamud/Interface/Internal/Windows/ScratchpadWindow.cs +++ b/Dalamud/Interface/Internal/Windows/ScratchpadWindow.cs @@ -31,7 +31,11 @@ namespace Dalamud.Interface.Internal.Windows this.dalamud = dalamud; this.documents.Add(new ScratchpadDocument()); - this.SizeConstraintsMin = new Vector2(400, 400); + this.SizeConstraints = new WindowSizeConstraints + { + MinimumSize = new Vector2(400, 400), + MaximumSize = new Vector2(1000, 1000), + }; this.Execution = new ScratchExecutionManager(dalamud); } diff --git a/Dalamud/Interface/Windowing/Window.cs b/Dalamud/Interface/Windowing/Window.cs index 6a15ef9d5..b87f6e14a 100644 --- a/Dalamud/Interface/Windowing/Window.cs +++ b/Dalamud/Interface/Windowing/Window.cs @@ -61,14 +61,9 @@ namespace Dalamud.Interface.Windowing public ImGuiCond SizeCondition { get; set; } /// - /// Gets or sets the minimum size of this window. + /// Gets or sets the size constraints of the window. /// - public Vector2? SizeConstraintsMin { get; set; } - - /// - /// Gets or sets the maximum size of this window. - /// - public Vector2? SizeConstraintsMax { get; set; } + public WindowSizeConstraints? SizeConstraints { get; set; } /// /// Gets or sets a value indicating whether or not this window is collapsed. @@ -219,9 +214,9 @@ namespace Dalamud.Interface.Windowing ImGui.SetNextWindowCollapsed(this.Collapsed.Value, this.CollapsedCondition); } - if (this.SizeConstraintsMin.HasValue && this.SizeConstraintsMax.HasValue) + if (this.SizeConstraints.HasValue) { - ImGui.SetNextWindowSizeConstraints(this.SizeConstraintsMin.Value * ImGuiHelpers.GlobalScale, this.SizeConstraintsMax.Value * ImGuiHelpers.GlobalScale); + ImGui.SetNextWindowSizeConstraints(this.SizeConstraints.Value.MinimumSize * ImGuiHelpers.GlobalScale, this.SizeConstraints.Value.MaximumSize * ImGuiHelpers.GlobalScale); } if (this.BgAlpha.HasValue) @@ -229,5 +224,21 @@ namespace Dalamud.Interface.Windowing ImGui.SetNextWindowBgAlpha(this.BgAlpha.Value); } } + + /// + /// Structure detailing the size constraints of a window. + /// + public struct WindowSizeConstraints + { + /// + /// Gets or sets the minimum size of the window. + /// + public Vector2 MinimumSize { get; set; } + + /// + /// Gets or sets the maximum size of the window. + /// + public Vector2 MaximumSize { get; set; } + } } }