refactor: try table for buttons

This commit is contained in:
Anna 2024-01-03 23:35:13 -05:00
parent 8eed38b67f
commit da918e4bf4
Signed by: anna
GPG Key ID: D0943384CD9F87D1
1 changed files with 27 additions and 13 deletions

View File

@ -109,23 +109,37 @@ internal class QuestionsTab {
}
}
// page buttons
using (ImGuiHelper.WithDisabled(loading || this.Plugin.Manager.Page == 1)) {
if (ImGuiHelper.IconButton(FontAwesomeIcon.ArrowLeft)) {
this.Plugin.Manager.Page -= 1;
}
var heightLeft = ImGui.GetContentRegionAvail().Y;
if (heightLeft > 0) {
heightLeft -= ImGuiHelpers.GetButtonSize("A").Y;
ImGui.Dummy(new Vector2(1, heightLeft));
}
ImGui.SameLine();
if (ImGui.BeginTable("##pagination-controls", 3)) {
ImGui.TableSetupColumn("##prev", ImGuiTableColumnFlags.WidthStretch);
ImGui.TableSetupColumn("##page", ImGuiTableColumnFlags.WidthFixed);
ImGui.TableSetupColumn("##next", ImGuiTableColumnFlags.WidthStretch);
ImGui.TextUnformatted($"{this.Plugin.Manager.Page:N0}");
ImGui.SameLine();
using (ImGuiHelper.WithDisabled(loading || !this.Plugin.Manager.HasNext)) {
if (ImGuiHelper.IconButton(FontAwesomeIcon.ArrowRight)) {
this.Plugin.Manager.Page += 1;
ImGui.TableNextRow();
if (ImGui.TableSetColumnIndex(0)) {
using var endDisabled = ImGuiHelper.WithDisabled(loading || this.Plugin.Manager.Page == 1);
if (ImGuiHelper.IconButton(FontAwesomeIcon.ArrowLeft)) {
this.Plugin.Manager.Page -= 1;
}
}
if (ImGui.TableSetColumnIndex(1)) {
ImGui.TextUnformatted($"{this.Plugin.Manager.Page:N0}");
}
if (ImGui.TableSetColumnIndex(2)) {
using var endDisabled = ImGuiHelper.WithDisabled(loading || !this.Plugin.Manager.HasNext);
if (ImGuiHelper.IconButton(FontAwesomeIcon.ArrowRight)) {
this.Plugin.Manager.Page += 1;
}
}
ImGui.EndTable();
}
}
}