fix: properly line-wrap buttons
This commit is contained in:
parent
4552183f6a
commit
24152d62a1
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue