Freeze the application buttons at the top of the panels.

This commit is contained in:
Ottermandias 2024-12-31 15:16:14 +01:00
parent 71e80740f6
commit e41755ed7e
3 changed files with 47 additions and 35 deletions

View file

@ -154,10 +154,11 @@ public class ActorPanel
private unsafe void DrawPanel() private unsafe void DrawPanel()
{ {
using var child = ImRaii.Child("##Panel", -Vector2.One, true); using var table = ImUtf8.Table("##Panel", 1, ImGuiTableFlags.BordersOuter | ImGuiTableFlags.ScrollY, ImGui.GetContentRegionAvail());
if (!child || !_selector.HasSelection || !_stateManager.GetOrCreate(_identifier, _actor, out _state)) if (!table || !_selector.HasSelection || !_stateManager.GetOrCreate(_identifier, _actor, out _state))
return; return;
ImGui.TableSetupScrollFreeze(0, 1);
ImGui.TableNextColumn();
var transformationId = _actor.IsCharacter ? _actor.AsCharacter->CharacterData.TransformationId : 0; var transformationId = _actor.IsCharacter ? _actor.AsCharacter->CharacterData.TransformationId : 0;
if (transformationId != 0) if (transformationId != 0)
ImGuiUtil.DrawTextButton($"Currently transformed to Transformation {transformationId}.", ImGuiUtil.DrawTextButton($"Currently transformed to Transformation {transformationId}.",
@ -168,6 +169,7 @@ public class ActorPanel
DrawApplyToTarget(); DrawApplyToTarget();
RevertButtons(); RevertButtons();
ImGui.TableNextColumn();
using var disabled = ImRaii.Disabled(transformationId != 0); using var disabled = ImRaii.Disabled(transformationId != 0);
if (_state.ModelData.IsHuman) if (_state.ModelData.IsHuman)

View file

@ -16,6 +16,7 @@ using OtterGui;
using OtterGui.Classes; using OtterGui.Classes;
using OtterGui.Raii; using OtterGui.Raii;
using OtterGui.Text; using OtterGui.Text;
using OtterGuiInternal.Structs;
using Penumbra.GameData.Enums; using Penumbra.GameData.Enums;
using static Glamourer.Gui.Tabs.HeaderDrawer; using static Glamourer.Gui.Tabs.HeaderDrawer;
@ -415,11 +416,16 @@ public class DesignPanel
private void DrawPanel() private void DrawPanel()
{ {
using var child = ImRaii.Child("##Panel", -Vector2.One, true); using var table = ImUtf8.Table("##Panel", 1, ImGuiTableFlags.BordersOuter | ImGuiTableFlags.ScrollY, ImGui.GetContentRegionAvail());
if (!child || _selector.Selected == null) if (!table || _selector.Selected == null)
return;
ImGui.TableSetupScrollFreeze(0, 1);
ImGui.TableNextColumn();
if (_selector.Selected == null)
return; return;
DrawButtonRow(); DrawButtonRow();
ImGui.TableNextColumn();
DrawCustomize(); DrawCustomize();
DrawEquipment(); DrawEquipment();
DrawCustomizeParameters(); DrawCustomizeParameters();
@ -432,6 +438,7 @@ public class DesignPanel
private void DrawButtonRow() private void DrawButtonRow()
{ {
ImGui.Dummy(Vector2.Zero);
DrawApplyToSelf(); DrawApplyToSelf();
ImGui.SameLine(); ImGui.SameLine();
DrawApplyToTarget(); DrawApplyToTarget();

View file

@ -11,6 +11,7 @@ using ImGuiNET;
using OtterGui; using OtterGui;
using OtterGui.Classes; using OtterGui.Classes;
using OtterGui.Raii; using OtterGui.Raii;
using OtterGui.Text;
using Penumbra.GameData.Enums; using Penumbra.GameData.Enums;
using static Glamourer.Gui.Tabs.HeaderDrawer; using static Glamourer.Gui.Tabs.HeaderDrawer;
@ -114,11 +115,16 @@ public class NpcPanel
private void DrawPanel() private void DrawPanel()
{ {
using var child = ImRaii.Child("##Panel", -Vector2.One, true); using var table = ImUtf8.Table("##Panel", 1, ImGuiTableFlags.BordersOuter | ImGuiTableFlags.ScrollY, ImGui.GetContentRegionAvail());
if (!child || !_selector.HasSelection) if (!table || !_selector.HasSelection)
return; return;
ImGui.TableSetupScrollFreeze(0, 1);
ImGui.TableNextColumn();
ImGui.Dummy(Vector2.Zero);
DrawButtonRow(); DrawButtonRow();
ImGui.TableNextColumn();
DrawCustomization(); DrawCustomization();
DrawEquipment(); DrawEquipment();
DrawAppearanceInfo(); DrawAppearanceInfo();
@ -133,10 +139,9 @@ public class NpcPanel
private void DrawCustomization() private void DrawCustomization()
{ {
var header = _selector.Selection.ModelId == 0 using var h = _selector.Selection.ModelId == 0
? "Customization" ? ImUtf8.CollapsingHeaderId("Customization"u8)
: $"Customization (Model Id #{_selector.Selection.ModelId})###Customization"; : ImUtf8.CollapsingHeaderId($"Customization (Model Id #{_selector.Selection.ModelId})###Customization");
using var h = ImRaii.CollapsingHeader(header);
if (!h) if (!h)
return; return;
@ -146,7 +151,7 @@ public class NpcPanel
private void DrawEquipment() private void DrawEquipment()
{ {
using var h = ImRaii.CollapsingHeader("Equipment"); using var h = ImUtf8.CollapsingHeaderId("Equipment"u8);
if (!h) if (!h)
return; return;
@ -185,9 +190,7 @@ public class NpcPanel
private void DrawApplyToSelf() private void DrawApplyToSelf()
{ {
var (id, data) = _objects.PlayerData; var (id, data) = _objects.PlayerData;
if (!ImGuiUtil.DrawDisabledButton("Apply to Yourself", Vector2.Zero, if (!ImUtf8.ButtonEx("Apply to Yourself"u8, "Apply the current NPC appearance to your character.\nHold Control to only apply gear.\nHold Shift to only apply customizations."u8, Vector2.Zero, !data.Valid))
"Apply the current NPC appearance to your character.\nHold Control to only apply gear.\nHold Shift to only apply customizations.",
!data.Valid))
return; return;
if (_state.GetOrCreate(id, data.Objects[0], out var state)) if (_state.GetOrCreate(id, data.Objects[0], out var state))
@ -202,10 +205,10 @@ public class NpcPanel
var (id, data) = _objects.TargetData; var (id, data) = _objects.TargetData;
var tt = id.IsValid var tt = id.IsValid
? data.Valid ? data.Valid
? "Apply the current NPC appearance to your current target.\nHold Control to only apply gear.\nHold Shift to only apply customizations." ? "Apply the current NPC appearance to your current target.\nHold Control to only apply gear.\nHold Shift to only apply customizations."u8
: "The current target can not be manipulated." : "The current target can not be manipulated."u8
: "No valid target selected."; : "No valid target selected."u8;
if (!ImGuiUtil.DrawDisabledButton("Apply to Target", Vector2.Zero, tt, !data.Valid)) if (!ImUtf8.ButtonEx("Apply to Target"u8, tt, Vector2.Zero, !data.Valid))
return; return;
if (_state.GetOrCreate(id, data.Objects[0], out var state)) if (_state.GetOrCreate(id, data.Objects[0], out var state))
@ -218,28 +221,28 @@ public class NpcPanel
private void DrawAppearanceInfo() private void DrawAppearanceInfo()
{ {
using var h = ImRaii.CollapsingHeader("Appearance Details"); using var h = ImUtf8.CollapsingHeaderId("Appearance Details"u8);
if (!h) if (!h)
return; return;
using var table = ImRaii.Table("Details", 2); using var table = ImUtf8.Table("Details"u8, 2);
if (!table) if (!table)
return; return;
using var style = ImRaii.PushStyle(ImGuiStyleVar.ButtonTextAlign, new Vector2(0, 0.5f)); using var style = ImRaii.PushStyle(ImGuiStyleVar.ButtonTextAlign, new Vector2(0, 0.5f));
ImGui.TableSetupColumn("Type", ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("Last Update Datem").X); ImUtf8.TableSetupColumn("Type"u8, ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("Last Update Datem").X);
ImGui.TableSetupColumn("Data", ImGuiTableColumnFlags.WidthStretch); ImUtf8.TableSetupColumn("Data"u8, ImGuiTableColumnFlags.WidthStretch);
var selection = _selector.Selection; var selection = _selector.Selection;
CopyButton("NPC Name", selection.Name); CopyButton("NPC Name"u8, selection.Name);
CopyButton("NPC ID", selection.Id.Id.ToString()); CopyButton("NPC ID"u8, selection.Id.Id.ToString());
ImGuiUtil.DrawFrameColumn("NPC Type"); ImGuiUtil.DrawFrameColumn("NPC Type");
ImGui.TableNextColumn(); ImGui.TableNextColumn();
var width = ImGui.GetContentRegionAvail().X; var width = ImGui.GetContentRegionAvail().X;
ImGuiUtil.DrawTextButton(selection.Kind is ObjectKind.BattleNpc ? "Battle NPC" : "Event NPC", new Vector2(width, 0), ImGuiUtil.DrawTextButton(selection.Kind is ObjectKind.BattleNpc ? "Battle NPC" : "Event NPC", new Vector2(width, 0),
ImGui.GetColorU32(ImGuiCol.FrameBg)); ImGui.GetColorU32(ImGuiCol.FrameBg));
ImGuiUtil.DrawFrameColumn("Color"); ImUtf8.DrawFrameColumn("Color"u8);
var color = _favorites.GetColor(selection); var color = _favorites.GetColor(selection);
var colorName = color.Length == 0 ? DesignColors.AutomaticName : color; var colorName = color.Length == 0 ? DesignColors.AutomaticName : color;
ImGui.TableNextColumn(); ImGui.TableNextColumn();
@ -272,18 +275,18 @@ public class NpcPanel
var size = new Vector2(ImGui.GetFrameHeight()); var size = new Vector2(ImGui.GetFrameHeight());
using var font = ImRaii.PushFont(UiBuilder.IconFont); using var font = ImRaii.PushFont(UiBuilder.IconFont);
ImGuiUtil.DrawTextButton(FontAwesomeIcon.ExclamationCircle.ToIconString(), size, 0, _colors.MissingColor); ImGuiUtil.DrawTextButton(FontAwesomeIcon.ExclamationCircle.ToIconString(), size, 0, _colors.MissingColor);
ImGuiUtil.HoverTooltip("The color associated with this design does not exist."); ImUtf8.HoverTooltip("The color associated with this design does not exist."u8);
} }
return; return;
static void CopyButton(string label, string text) static void CopyButton(ReadOnlySpan<byte> label, string text)
{ {
ImGuiUtil.DrawFrameColumn(label); ImUtf8.DrawFrameColumn(label);
ImGui.TableNextColumn(); ImGui.TableNextColumn();
if (ImGui.Button(text, new Vector2(ImGui.GetContentRegionAvail().X, 0))) if (ImUtf8.Button(text, new Vector2(ImGui.GetContentRegionAvail().X, 0)))
ImGui.SetClipboardText(text); ImUtf8.SetClipboardText(text);
ImGuiUtil.HoverTooltip("Click to copy to clipboard."); ImUtf8.HoverTooltip("Click to copy to clipboard."u8);
} }
} }