fix: use ImRaii for PI DrawPluginCategories

Prevents mismatched BeginTable/EndTable
This commit is contained in:
goat 2023-06-21 19:13:33 +02:00
parent a954e83976
commit c68793b589
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B

View file

@ -1110,45 +1110,40 @@ internal class PluginInstallerWindow : Window, IDisposable
var useContentWidth = ImGui.GetContentRegionAvail().X; var useContentWidth = ImGui.GetContentRegionAvail().X;
if (ImGui.BeginChild("InstallerCategories", new Vector2(useContentWidth, useContentHeight * ImGuiHelpers.GlobalScale))) using (ImRaii.Child("InstallerCategories", new Vector2(useContentWidth, useContentHeight * ImGuiHelpers.GlobalScale)))
{ {
ImGui.PushStyleVar(ImGuiStyleVar.CellPadding, ImGuiHelpers.ScaledVector2(5, 0)); using var style = ImRaii.PushStyle(ImGuiStyleVar.CellPadding, ImGuiHelpers.ScaledVector2(5, 0));
if (ImGui.BeginTable("##InstallerCategoriesCont", 2, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.Resizable | ImGuiTableFlags.BordersInnerV)) using var table = ImRaii.Table(
"##InstallerCategoriesCont",
2,
ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.Resizable | ImGuiTableFlags.BordersInnerV);
try
{ {
try ImGui.TableSetupColumn("##InstallerCategoriesSelector", ImGuiTableColumnFlags.WidthFixed, useMenuWidth * ImGuiHelpers.GlobalScale);
ImGui.TableSetupColumn("##InstallerCategoriesBody", ImGuiTableColumnFlags.WidthStretch);
ImGui.TableNextRow();
ImGui.TableNextColumn();
this.DrawPluginCategorySelectors();
ImGui.TableNextColumn();
using (ImRaii.Child("ScrollingPlugins", new Vector2(-1, 0), false, ImGuiWindowFlags.NoBackground))
{ {
ImGui.TableSetupColumn("##InstallerCategoriesSelector", ImGuiTableColumnFlags.WidthFixed, useMenuWidth * ImGuiHelpers.GlobalScale); try
ImGui.TableSetupColumn("##InstallerCategoriesBody", ImGuiTableColumnFlags.WidthStretch);
ImGui.TableNextRow();
ImGui.TableNextColumn();
this.DrawPluginCategorySelectors();
ImGui.TableNextColumn();
if (ImGui.BeginChild("ScrollingPlugins", new Vector2(-1, 0), false, ImGuiWindowFlags.NoBackground))
{ {
try this.DrawPluginCategoryContent();
{ }
this.DrawPluginCategoryContent(); catch (Exception ex)
} {
catch (Exception ex) Log.Error(ex, "Could not draw category content");
{
Log.Error(ex, "Could not draw category content");
}
} }
ImGui.EndChild();
} }
catch (Exception ex)
{
Log.Error(ex, "Could not draw plugin categories");
}
ImGui.EndTable();
} }
catch (Exception ex)
ImGui.PopStyleVar(); {
ImGui.EndChild(); Log.Error(ex, "Could not draw plugin categories");
}
} }
} }