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.");
} 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;
}