settings: properly EndChild

This commit is contained in:
goat 2024-05-09 00:43:16 +02:00
parent a355ba863b
commit 9f32b05587
2 changed files with 27 additions and 26 deletions

View file

@ -152,12 +152,12 @@ internal class SettingsWindow : Window
settingsTab.OnOpen();
}
if (ImGui.BeginChild($"###settings_scrolling_{settingsTab.Title}", new Vector2(-1, -1), false))
{
using var tabChild = ImRaii.Child(
$"###settings_scrolling_{settingsTab.Title}",
new Vector2(-1, -1),
false);
if (tabChild)
settingsTab.Draw();
}
ImGui.EndChild();
}
else if (settingsTab.IsOpen)
{
@ -207,33 +207,34 @@ internal class SettingsWindow : Window
ImGui.SetCursorPos(windowSize - ImGuiHelpers.ScaledVector2(70));
if (ImGui.BeginChild("###settingsFinishButton"))
using (var buttonChild = ImRaii.Child("###settingsFinishButton"))
{
using var disabled = ImRaii.Disabled(this.tabs.Any(x => x.Entries.Any(y => !y.IsValid)));
using (ImRaii.PushStyle(ImGuiStyleVar.FrameRounding, 100f))
if (buttonChild)
{
using var font = ImRaii.PushFont(InterfaceManager.IconFont);
using var disabled = ImRaii.Disabled(this.tabs.Any(x => x.Entries.Any(y => !y.IsValid)));
if (ImGui.Button(FontAwesomeIcon.Save.ToIconString(), new Vector2(40)))
using (ImRaii.PushStyle(ImGuiStyleVar.FrameRounding, 100f))
{
this.Save();
using var font = ImRaii.PushFont(InterfaceManager.IconFont);
if (!ImGui.IsKeyDown(ImGuiKey.ModShift))
this.IsOpen = false;
if (ImGui.Button(FontAwesomeIcon.Save.ToIconString(), new Vector2(40)))
{
this.Save();
if (!ImGui.IsKeyDown(ImGuiKey.ModShift))
this.IsOpen = false;
}
}
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip(!ImGui.IsKeyDown(ImGuiKey.ModShift)
? Loc.Localize("DalamudSettingsSaveAndExit", "Save changes and close")
: Loc.Localize("DalamudSettingsSave", "Save changes"));
}
}
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip(!ImGui.IsKeyDown(ImGuiKey.ModShift)
? Loc.Localize("DalamudSettingsSaveAndExit", "Save changes and close")
: Loc.Localize("DalamudSettingsSave", "Save changes"));
}
}
ImGui.EndChild();
ImGui.SetCursorPos(new Vector2(windowSize.X - 250, ImGui.GetTextLineHeightWithSpacing() + (ImGui.GetStyle().FramePadding.Y * 2)));
ImGui.SetNextItemWidth(240);
ImGui.InputTextWithHint("###searchInput", "Search for settings...", ref this.searchInput, 100);

View file

@ -234,7 +234,9 @@ Contribute at: https://github.com/goatcorp/Dalamud
{
var windowSize = ImGui.GetWindowSize();
ImGui.BeginChild("scrolling", Vector2.Zero, false, ImGuiWindowFlags.NoScrollbar);
using var child = ImRaii.Child("scrolling", new Vector2(-1, -10 * ImGuiHelpers.GlobalScale), false, ImGuiWindowFlags.NoScrollbar);
if (!child)
return;
if (this.resetNow)
{
@ -295,8 +297,6 @@ Contribute at: https://github.com/goatcorp/Dalamud
}
}
ImGui.EndChild();
base.Draw();
}