fix: properly line-wrap buttons

This commit is contained in:
Anna 2024-04-10 21:56:56 -04:00
parent 4552183f6a
commit 24152d62a1
Signed by: anna
GPG Key ID: D0943384CD9F87D1
1 changed files with 5 additions and 5 deletions

View File

@ -34,6 +34,8 @@ internal class QuestionsTab {
ImGui.TextUnformatted("There is no active question at the moment."); ImGui.TextUnformatted("There is no active question at the moment.");
} else { } else {
ImGui.TextUnformatted(active.Text); ImGui.TextUnformatted(active.Text);
var availableWidth = ImGui.GetContentRegionAvail().X;
for (var i = 0; i < active.Answers.Length; i++) { for (var i = 0; i < active.Answers.Length; i++) {
if (i != 0) { if (i != 0) {
ImGui.SameLine(); ImGui.SameLine();
@ -41,17 +43,15 @@ internal class QuestionsTab {
var label = active.Answers[i]; var label = active.Answers[i];
var buttonSize = ImGuiHelpers.GetButtonSize(label); var buttonSize = ImGuiHelpers.GetButtonSize(label);
var xPosAfter = ImGui.GetCursorPosX() var xPosAfter = ImGui.GetCursorPosX() + buttonSize.X;
+ buttonSize.X if (i != 0 && xPosAfter > availableWidth) {
+ ImGui.GetStyle().ItemSpacing.X;
if (i != 0 && xPosAfter > ImGui.GetContentRegionAvail().X) {
ImGui.Dummy(Vector2.Zero); ImGui.Dummy(Vector2.Zero);
} }
var disabled = this._voting || active is FullQuestion; var disabled = this._voting || active is FullQuestion;
using var endDisabled = ImGuiHelper.WithDisabled(disabled); using var endDisabled = ImGuiHelper.WithDisabled(disabled);
if (!ImGui.Button(active.Answers[i])) { if (!ImGui.Button(label)) {
continue; continue;
} }