From 4a6e7fccecd3a7796ebae4c8d25b96f7de286b60 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 11 Jan 2024 13:31:33 +0100 Subject: [PATCH] Fix scrolling weirdness. --- Penumbra/UI/ModsTab/ModPanel.cs | 16 +++++++++++++- Penumbra/UI/Tabs/ModsTab.cs | 37 +++++++++++++++++---------------- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/Penumbra/UI/ModsTab/ModPanel.cs b/Penumbra/UI/ModsTab/ModPanel.cs index f9a3262f..b5542e43 100644 --- a/Penumbra/UI/ModsTab/ModPanel.cs +++ b/Penumbra/UI/ModsTab/ModPanel.cs @@ -1,4 +1,6 @@ +using Dalamud.Interface.Utility.Raii; using Dalamud.Plugin; +using ImGuiNET; using Penumbra.Mods; using Penumbra.Services; using Penumbra.UI.AdvancedWindow; @@ -12,6 +14,7 @@ public class ModPanel : IDisposable private readonly ModEditWindow _editWindow; private readonly ModPanelHeader _header; private readonly ModPanelTabBar _tabs; + private bool _resetCursor; public ModPanel(DalamudPluginInterface pi, ModFileSystemSelector selector, ModEditWindow editWindow, ModPanelTabBar tabs, MultiModPanel multiModPanel, CommunicatorService communicator) @@ -32,8 +35,18 @@ public class ModPanel : IDisposable return; } + if (_resetCursor) + { + _resetCursor = false; + ImGui.SetScrollX(0); + } + _header.Draw(); - _tabs.Draw(_mod); + ImGui.SetCursorPosX(ImGui.GetScrollX() + ImGui.GetCursorPosX()); + using var child = ImRaii.Child("Tabs", + new Vector2(ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X, ImGui.GetContentRegionAvail().Y)); + if (child) + _tabs.Draw(_mod); } public void Dispose() @@ -47,6 +60,7 @@ public class ModPanel : IDisposable private void OnSelectionChange(Mod? old, Mod? mod, in ModFileSystemSelector.ModState _) { + _resetCursor = true; if (mod == null || _selector.Selected == null) { _editWindow.IsOpen = false; diff --git a/Penumbra/UI/Tabs/ModsTab.cs b/Penumbra/UI/Tabs/ModsTab.cs index 7b30f7fc..9f070d35 100644 --- a/Penumbra/UI/Tabs/ModsTab.cs +++ b/Penumbra/UI/Tabs/ModsTab.cs @@ -139,24 +139,6 @@ public class ModsTab : ITab if (hovered) ImGui.SetTooltip($"The supported modifiers for '/penumbra redraw' are:\n{TutorialService.SupportedRedrawModifiers}"); - void DrawButton(Vector2 size, string label, string lower, string additionalTooltip) - { - using (var disabled = ImRaii.Disabled(additionalTooltip.Length > 0)) - { - if (ImGui.Button(label, size)) - { - if (lower.Length > 0) - _redrawService.RedrawObject(lower, RedrawType.Redraw); - else - _redrawService.RedrawAll(RedrawType.Redraw); - } - } - - ImGuiUtil.HoverTooltip(lower.Length > 0 - ? $"Execute '/penumbra redraw {lower}'.{additionalTooltip}" - : $"Execute '/penumbra redraw'.{additionalTooltip}", ImGuiHoveredFlags.AllowWhenDisabled); - } - using var id = ImRaii.PushId("Redraw"); using var disabled = ImRaii.Disabled(_clientState.LocalPlayer == null); ImGui.SameLine(); @@ -185,6 +167,25 @@ public class ModsTab : ITab ? "\nCan currently only be used for indoor furniture." : string.Empty; DrawButton(frameHeight with { X = ImGui.GetContentRegionAvail().X - 1 }, "Furniture", "furniture", tt); + return; + + void DrawButton(Vector2 size, string label, string lower, string additionalTooltip) + { + using (_ = ImRaii.Disabled(additionalTooltip.Length > 0)) + { + if (ImGui.Button(label, size)) + { + if (lower.Length > 0) + _redrawService.RedrawObject(lower, RedrawType.Redraw); + else + _redrawService.RedrawAll(RedrawType.Redraw); + } + } + + ImGuiUtil.HoverTooltip(lower.Length > 0 + ? $"Execute '/penumbra redraw {lower}'.{additionalTooltip}" + : $"Execute '/penumbra redraw'.{additionalTooltip}", ImGuiHoveredFlags.AllowWhenDisabled); + } } private static unsafe bool IsIndoors()