mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-15 05:04:15 +01:00
feat: add Namespace, BgAlpha, scaling to WindowSystem
This commit is contained in:
parent
ec8e320b6c
commit
65fb949c61
1 changed files with 45 additions and 6 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using System.Numerics;
|
||||
|
||||
using ImGuiNET;
|
||||
using Serilog;
|
||||
|
||||
namespace Dalamud.Interface.Windowing
|
||||
{
|
||||
|
|
@ -11,6 +12,7 @@ namespace Dalamud.Interface.Windowing
|
|||
{
|
||||
private bool internalLastIsOpen = false;
|
||||
private bool internalIsOpen = false;
|
||||
private bool mainIsOpen = false;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Window"/> class.
|
||||
|
|
@ -28,6 +30,8 @@ namespace Dalamud.Interface.Windowing
|
|||
this.ForceMainWindow = forceMainWindow;
|
||||
}
|
||||
|
||||
public string Namespace { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the window.
|
||||
/// If you have multiple windows with the same name, you will need to
|
||||
|
|
@ -85,13 +89,24 @@ namespace Dalamud.Interface.Windowing
|
|||
/// </summary>
|
||||
public bool ForceMainWindow { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets this window's background alpha value.
|
||||
/// </summary>
|
||||
public float? BgAlpha { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether or not this window will stay open.
|
||||
/// </summary>
|
||||
public bool IsOpen
|
||||
{
|
||||
get => this.internalIsOpen;
|
||||
set => this.internalIsOpen = value;
|
||||
get => this.mainIsOpen;
|
||||
set
|
||||
{
|
||||
if (!value)
|
||||
this.internalIsOpen = true;
|
||||
|
||||
this.mainIsOpen = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -115,6 +130,14 @@ namespace Dalamud.Interface.Windowing
|
|||
/// </summary>
|
||||
internal void DrawInternal()
|
||||
{
|
||||
if (!this.IsOpen)
|
||||
return;
|
||||
|
||||
var hasNamespace = !string.IsNullOrEmpty(this.Namespace);
|
||||
|
||||
if (hasNamespace)
|
||||
ImGui.PushID(this.Namespace);
|
||||
|
||||
this.ApplyConditionals();
|
||||
|
||||
if (this.ForceMainWindow)
|
||||
|
|
@ -124,10 +147,13 @@ namespace Dalamud.Interface.Windowing
|
|||
{
|
||||
// Draw the actual window contents
|
||||
this.Draw();
|
||||
|
||||
ImGui.End();
|
||||
}
|
||||
|
||||
ImGui.End();
|
||||
|
||||
if (hasNamespace)
|
||||
ImGui.PopID();
|
||||
|
||||
if (this.internalLastIsOpen != this.internalIsOpen)
|
||||
{
|
||||
if (this.internalIsOpen)
|
||||
|
|
@ -141,18 +167,26 @@ namespace Dalamud.Interface.Windowing
|
|||
}
|
||||
|
||||
this.internalLastIsOpen = this.internalIsOpen;
|
||||
|
||||
if (this.internalIsOpen != true)
|
||||
this.IsOpen = false;
|
||||
}
|
||||
|
||||
private void ApplyConditionals()
|
||||
{
|
||||
if (this.Position.HasValue)
|
||||
{
|
||||
ImGui.SetNextWindowPos(this.Position.Value, this.PositionCondition);
|
||||
var pos = this.Position.Value;
|
||||
|
||||
if (this.ForceMainWindow)
|
||||
pos += ImGuiHelpers.MainWindowPos;
|
||||
|
||||
ImGui.SetNextWindowPos(pos, this.PositionCondition);
|
||||
}
|
||||
|
||||
if (this.Size.HasValue)
|
||||
{
|
||||
ImGui.SetNextWindowPos(this.Size.Value * ImGuiHelpers.GlobalScale, this.SizeCondition);
|
||||
ImGui.SetNextWindowSize(this.Size.Value * ImGuiHelpers.GlobalScale, this.SizeCondition);
|
||||
}
|
||||
|
||||
if (this.Collapsed.HasValue)
|
||||
|
|
@ -164,6 +198,11 @@ namespace Dalamud.Interface.Windowing
|
|||
{
|
||||
ImGui.SetNextWindowSizeConstraints(this.SizeConstraintsMin.Value * ImGuiHelpers.GlobalScale, this.SizeConstraintsMax.Value * ImGuiHelpers.GlobalScale);
|
||||
}
|
||||
|
||||
if (this.BgAlpha.HasValue)
|
||||
{
|
||||
ImGui.SetNextWindowBgAlpha(this.BgAlpha.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue