feat: scale window size in Window by GlobalScale

This commit is contained in:
goat 2021-04-05 18:39:44 +02:00
parent 7ef0456582
commit ec8e320b6c

View file

@ -9,7 +9,8 @@ namespace Dalamud.Interface.Windowing
/// </summary> /// </summary>
public abstract class Window public abstract class Window
{ {
private bool internalIsOpen; private bool internalLastIsOpen = false;
private bool internalIsOpen = false;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Window"/> class. /// Initializes a new instance of the <see cref="Window"/> class.
@ -99,6 +100,16 @@ namespace Dalamud.Interface.Windowing
/// </summary> /// </summary>
public abstract void Draw(); public abstract void Draw();
/// <summary>
/// Code to be executed when the window is opened.
/// </summary>
public virtual void OnOpen() { }
/// <summary>
/// Code to be executed when the window is closed.
/// </summary>
public virtual void OnClose() { }
/// <summary> /// <summary>
/// Draw the window via ImGui. /// Draw the window via ImGui.
/// </summary> /// </summary>
@ -116,6 +127,20 @@ namespace Dalamud.Interface.Windowing
ImGui.End(); ImGui.End();
} }
if (this.internalLastIsOpen != this.internalIsOpen)
{
if (this.internalIsOpen)
{
this.OnOpen();
}
else
{
this.OnClose();
}
}
this.internalLastIsOpen = this.internalIsOpen;
} }
private void ApplyConditionals() private void ApplyConditionals()
@ -127,7 +152,7 @@ namespace Dalamud.Interface.Windowing
if (this.Size.HasValue) if (this.Size.HasValue)
{ {
ImGui.SetNextWindowPos(this.Size.Value, this.SizeCondition); ImGui.SetNextWindowPos(this.Size.Value * ImGuiHelpers.GlobalScale, this.SizeCondition);
} }
if (this.Collapsed.HasValue) if (this.Collapsed.HasValue)
@ -137,7 +162,7 @@ namespace Dalamud.Interface.Windowing
if (this.SizeConstraintsMin.HasValue && this.SizeConstraintsMax.HasValue) 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);
} }
} }
} }