From 24152d62a10ff3bda7abe34677df09c0906657d5 Mon Sep 17 00:00:00 2001 From: Anna Date: Wed, 10 Apr 2024 21:56:56 -0400 Subject: [PATCH] fix: properly line-wrap buttons --- client/EorzeaVotes/Ui/Tabs/Questions.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/client/EorzeaVotes/Ui/Tabs/Questions.cs b/client/EorzeaVotes/Ui/Tabs/Questions.cs index 7b84a1e..637c1c9 100644 --- a/client/EorzeaVotes/Ui/Tabs/Questions.cs +++ b/client/EorzeaVotes/Ui/Tabs/Questions.cs @@ -34,6 +34,8 @@ internal class QuestionsTab { ImGui.TextUnformatted("There is no active question at the moment."); } else { ImGui.TextUnformatted(active.Text); + + var availableWidth = ImGui.GetContentRegionAvail().X; for (var i = 0; i < active.Answers.Length; i++) { if (i != 0) { ImGui.SameLine(); @@ -41,17 +43,15 @@ internal class QuestionsTab { var label = active.Answers[i]; var buttonSize = ImGuiHelpers.GetButtonSize(label); - var xPosAfter = ImGui.GetCursorPosX() - + buttonSize.X - + ImGui.GetStyle().ItemSpacing.X; - if (i != 0 && xPosAfter > ImGui.GetContentRegionAvail().X) { + var xPosAfter = ImGui.GetCursorPosX() + buttonSize.X; + if (i != 0 && xPosAfter > availableWidth) { ImGui.Dummy(Vector2.Zero); } var disabled = this._voting || active is FullQuestion; using var endDisabled = ImGuiHelper.WithDisabled(disabled); - if (!ImGui.Button(active.Answers[i])) { + if (!ImGui.Button(label)) { continue; }