fix(Window): use a struct for SizeConstraints, you can't set them separately

This commit is contained in:
goat 2021-08-09 21:06:37 +02:00
parent 53c29c1991
commit ac83077863
No known key found for this signature in database
GPG key ID: F18F057873895461
2 changed files with 25 additions and 10 deletions

View file

@ -31,7 +31,11 @@ namespace Dalamud.Interface.Internal.Windows
this.dalamud = dalamud; this.dalamud = dalamud;
this.documents.Add(new ScratchpadDocument()); 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); this.Execution = new ScratchExecutionManager(dalamud);
} }

View file

@ -61,14 +61,9 @@ namespace Dalamud.Interface.Windowing
public ImGuiCond SizeCondition { get; set; } public ImGuiCond SizeCondition { get; set; }
/// <summary> /// <summary>
/// Gets or sets the minimum size of this window. /// Gets or sets the size constraints of the window.
/// </summary> /// </summary>
public Vector2? SizeConstraintsMin { get; set; } public WindowSizeConstraints? SizeConstraints { get; set; }
/// <summary>
/// Gets or sets the maximum size of this window.
/// </summary>
public Vector2? SizeConstraintsMax { get; set; }
/// <summary> /// <summary>
/// Gets or sets a value indicating whether or not this window is collapsed. /// 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); 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) if (this.BgAlpha.HasValue)
@ -229,5 +224,21 @@ namespace Dalamud.Interface.Windowing
ImGui.SetNextWindowBgAlpha(this.BgAlpha.Value); ImGui.SetNextWindowBgAlpha(this.BgAlpha.Value);
} }
} }
/// <summary>
/// Structure detailing the size constraints of a window.
/// </summary>
public struct WindowSizeConstraints
{
/// <summary>
/// Gets or sets the minimum size of the window.
/// </summary>
public Vector2 MinimumSize { get; set; }
/// <summary>
/// Gets or sets the maximum size of the window.
/// </summary>
public Vector2 MaximumSize { get; set; }
}
} }
} }