From e41755ed7e9d5bc81db2afaa4e9edda6113adb6e Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 31 Dec 2024 15:16:14 +0100 Subject: [PATCH] Freeze the application buttons at the top of the panels. --- Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs | 8 ++- Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs | 13 ++++- Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs | 61 +++++++++++---------- 3 files changed, 47 insertions(+), 35 deletions(-) diff --git a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs index 14a9e11..2549240 100644 --- a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs +++ b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs @@ -154,10 +154,11 @@ public class ActorPanel private unsafe void DrawPanel() { - using var child = ImRaii.Child("##Panel", -Vector2.One, true); - if (!child || !_selector.HasSelection || !_stateManager.GetOrCreate(_identifier, _actor, out _state)) + using var table = ImUtf8.Table("##Panel", 1, ImGuiTableFlags.BordersOuter | ImGuiTableFlags.ScrollY, ImGui.GetContentRegionAvail()); + if (!table || !_selector.HasSelection || !_stateManager.GetOrCreate(_identifier, _actor, out _state)) return; - + ImGui.TableSetupScrollFreeze(0, 1); + ImGui.TableNextColumn(); var transformationId = _actor.IsCharacter ? _actor.AsCharacter->CharacterData.TransformationId : 0; if (transformationId != 0) ImGuiUtil.DrawTextButton($"Currently transformed to Transformation {transformationId}.", @@ -168,6 +169,7 @@ public class ActorPanel DrawApplyToTarget(); RevertButtons(); + ImGui.TableNextColumn(); using var disabled = ImRaii.Disabled(transformationId != 0); if (_state.ModelData.IsHuman) diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index 5fb2d57..26553a7 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -16,6 +16,7 @@ using OtterGui; using OtterGui.Classes; using OtterGui.Raii; using OtterGui.Text; +using OtterGuiInternal.Structs; using Penumbra.GameData.Enums; using static Glamourer.Gui.Tabs.HeaderDrawer; @@ -415,11 +416,16 @@ public class DesignPanel private void DrawPanel() { - using var child = ImRaii.Child("##Panel", -Vector2.One, true); - if (!child || _selector.Selected == null) + using var table = ImUtf8.Table("##Panel", 1, ImGuiTableFlags.BordersOuter | ImGuiTableFlags.ScrollY, ImGui.GetContentRegionAvail()); + if (!table || _selector.Selected == null) + return; + ImGui.TableSetupScrollFreeze(0, 1); + ImGui.TableNextColumn(); + if (_selector.Selected == null) return; - DrawButtonRow(); + ImGui.TableNextColumn(); + DrawCustomize(); DrawEquipment(); DrawCustomizeParameters(); @@ -432,6 +438,7 @@ public class DesignPanel private void DrawButtonRow() { + ImGui.Dummy(Vector2.Zero); DrawApplyToSelf(); ImGui.SameLine(); DrawApplyToTarget(); diff --git a/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs b/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs index 974912e..312bceb 100644 --- a/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs +++ b/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs @@ -11,6 +11,7 @@ using ImGuiNET; using OtterGui; using OtterGui.Classes; using OtterGui.Raii; +using OtterGui.Text; using Penumbra.GameData.Enums; using static Glamourer.Gui.Tabs.HeaderDrawer; @@ -30,8 +31,8 @@ public class NpcPanel private readonly StateManager _state; private readonly ObjectManager _objects; private readonly DesignColors _colors; - private readonly Button[] _leftButtons; - private readonly Button[] _rightButtons; + private readonly Button[] _leftButtons; + private readonly Button[] _rightButtons; public NpcPanel(NpcSelector selector, LocalNpcAppearanceData favorites, @@ -114,11 +115,16 @@ public class NpcPanel private void DrawPanel() { - using var child = ImRaii.Child("##Panel", -Vector2.One, true); - if (!child || !_selector.HasSelection) + using var table = ImUtf8.Table("##Panel", 1, ImGuiTableFlags.BordersOuter | ImGuiTableFlags.ScrollY, ImGui.GetContentRegionAvail()); + if (!table || !_selector.HasSelection) return; + ImGui.TableSetupScrollFreeze(0, 1); + ImGui.TableNextColumn(); + ImGui.Dummy(Vector2.Zero); DrawButtonRow(); + + ImGui.TableNextColumn(); DrawCustomization(); DrawEquipment(); DrawAppearanceInfo(); @@ -133,10 +139,9 @@ public class NpcPanel private void DrawCustomization() { - var header = _selector.Selection.ModelId == 0 - ? "Customization" - : $"Customization (Model Id #{_selector.Selection.ModelId})###Customization"; - using var h = ImRaii.CollapsingHeader(header); + using var h = _selector.Selection.ModelId == 0 + ? ImUtf8.CollapsingHeaderId("Customization"u8) + : ImUtf8.CollapsingHeaderId($"Customization (Model Id #{_selector.Selection.ModelId})###Customization"); if (!h) return; @@ -146,7 +151,7 @@ public class NpcPanel private void DrawEquipment() { - using var h = ImRaii.CollapsingHeader("Equipment"); + using var h = ImUtf8.CollapsingHeaderId("Equipment"u8); if (!h) return; @@ -185,9 +190,7 @@ public class NpcPanel private void DrawApplyToSelf() { var (id, data) = _objects.PlayerData; - if (!ImGuiUtil.DrawDisabledButton("Apply to Yourself", Vector2.Zero, - "Apply the current NPC appearance to your character.\nHold Control to only apply gear.\nHold Shift to only apply customizations.", - !data.Valid)) + 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)) return; if (_state.GetOrCreate(id, data.Objects[0], out var state)) @@ -202,10 +205,10 @@ public class NpcPanel var (id, data) = _objects.TargetData; var tt = id.IsValid ? data.Valid - ? "Apply the current NPC appearance to your current target.\nHold Control to only apply gear.\nHold Shift to only apply customizations." - : "The current target can not be manipulated." - : "No valid target selected."; - if (!ImGuiUtil.DrawDisabledButton("Apply to Target", Vector2.Zero, tt, !data.Valid)) + ? "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."u8 + : "No valid target selected."u8; + if (!ImUtf8.ButtonEx("Apply to Target"u8, tt, Vector2.Zero, !data.Valid)) return; if (_state.GetOrCreate(id, data.Objects[0], out var state)) @@ -218,28 +221,28 @@ public class NpcPanel private void DrawAppearanceInfo() { - using var h = ImRaii.CollapsingHeader("Appearance Details"); + using var h = ImUtf8.CollapsingHeaderId("Appearance Details"u8); if (!h) return; - using var table = ImRaii.Table("Details", 2); + using var table = ImUtf8.Table("Details"u8, 2); if (!table) return; using var style = ImRaii.PushStyle(ImGuiStyleVar.ButtonTextAlign, new Vector2(0, 0.5f)); - ImGui.TableSetupColumn("Type", ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("Last Update Datem").X); - ImGui.TableSetupColumn("Data", ImGuiTableColumnFlags.WidthStretch); + ImUtf8.TableSetupColumn("Type"u8, ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("Last Update Datem").X); + ImUtf8.TableSetupColumn("Data"u8, ImGuiTableColumnFlags.WidthStretch); var selection = _selector.Selection; - CopyButton("NPC Name", selection.Name); - CopyButton("NPC ID", selection.Id.Id.ToString()); + CopyButton("NPC Name"u8, selection.Name); + CopyButton("NPC ID"u8, selection.Id.Id.ToString()); ImGuiUtil.DrawFrameColumn("NPC Type"); ImGui.TableNextColumn(); var width = ImGui.GetContentRegionAvail().X; ImGuiUtil.DrawTextButton(selection.Kind is ObjectKind.BattleNpc ? "Battle NPC" : "Event NPC", new Vector2(width, 0), ImGui.GetColorU32(ImGuiCol.FrameBg)); - ImGuiUtil.DrawFrameColumn("Color"); + ImUtf8.DrawFrameColumn("Color"u8); var color = _favorites.GetColor(selection); var colorName = color.Length == 0 ? DesignColors.AutomaticName : color; ImGui.TableNextColumn(); @@ -272,18 +275,18 @@ public class NpcPanel var size = new Vector2(ImGui.GetFrameHeight()); using var font = ImRaii.PushFont(UiBuilder.IconFont); 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; - static void CopyButton(string label, string text) + static void CopyButton(ReadOnlySpan label, string text) { - ImGuiUtil.DrawFrameColumn(label); + ImUtf8.DrawFrameColumn(label); ImGui.TableNextColumn(); - if (ImGui.Button(text, new Vector2(ImGui.GetContentRegionAvail().X, 0))) - ImGui.SetClipboardText(text); - ImGuiUtil.HoverTooltip("Click to copy to clipboard."); + if (ImUtf8.Button(text, new Vector2(ImGui.GetContentRegionAvail().X, 0))) + ImUtf8.SetClipboardText(text); + ImUtf8.HoverTooltip("Click to copy to clipboard."u8); } }