From ec8e320b6c9bae97ceb2b43cdaeb388168a51dd9 Mon Sep 17 00:00:00 2001 From: goat <16760685+goaaats@users.noreply.github.com> Date: Mon, 5 Apr 2021 18:39:44 +0200 Subject: [PATCH] feat: scale window size in Window by GlobalScale --- Dalamud/Interface/Windowing/Window.cs | 31 ++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/Dalamud/Interface/Windowing/Window.cs b/Dalamud/Interface/Windowing/Window.cs index 81f4373de..31a3d075c 100644 --- a/Dalamud/Interface/Windowing/Window.cs +++ b/Dalamud/Interface/Windowing/Window.cs @@ -9,7 +9,8 @@ namespace Dalamud.Interface.Windowing /// public abstract class Window { - private bool internalIsOpen; + private bool internalLastIsOpen = false; + private bool internalIsOpen = false; /// /// Initializes a new instance of the class. @@ -99,6 +100,16 @@ namespace Dalamud.Interface.Windowing /// public abstract void Draw(); + /// + /// Code to be executed when the window is opened. + /// + public virtual void OnOpen() { } + + /// + /// Code to be executed when the window is closed. + /// + public virtual void OnClose() { } + /// /// Draw the window via ImGui. /// @@ -116,6 +127,20 @@ namespace Dalamud.Interface.Windowing ImGui.End(); } + + if (this.internalLastIsOpen != this.internalIsOpen) + { + if (this.internalIsOpen) + { + this.OnOpen(); + } + else + { + this.OnClose(); + } + } + + this.internalLastIsOpen = this.internalIsOpen; } private void ApplyConditionals() @@ -127,7 +152,7 @@ namespace Dalamud.Interface.Windowing if (this.Size.HasValue) { - ImGui.SetNextWindowPos(this.Size.Value, this.SizeCondition); + ImGui.SetNextWindowPos(this.Size.Value * ImGuiHelpers.GlobalScale, this.SizeCondition); } if (this.Collapsed.HasValue) @@ -137,7 +162,7 @@ namespace Dalamud.Interface.Windowing if (this.SizeConstraintsMin.HasValue && this.SizeConstraintsMax.HasValue) { - ImGui.SetNextWindowSizeConstraints(this.SizeConstraintsMin.Value, this.SizeConstraintsMax.Value); + ImGui.SetNextWindowSizeConstraints(this.SizeConstraintsMin.Value * ImGuiHelpers.GlobalScale, this.SizeConstraintsMax.Value * ImGuiHelpers.GlobalScale); } } }