GUI: fix macro list jumping around

in single macro editor layout
This commit is contained in:
tildearrow 2025-03-23 03:30:31 -05:00
parent 34f311fa76
commit f919d1779a

View file

@ -2678,8 +2678,8 @@ void FurnaceGUI::drawMacros(std::vector<FurnaceGUIMacroDesc>& macros, FurnaceGUI
} }
case 3: { case 3: {
if (ImGui::BeginTable("MacroList",2,ImGuiTableFlags_Borders)) { if (ImGui::BeginTable("MacroList",2,ImGuiTableFlags_Borders)) {
ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed); ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthStretch,0.2f);
ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch); ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,0.8f);
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableNextColumn(); ImGui::TableNextColumn();
@ -2695,12 +2695,8 @@ void FurnaceGUI::drawMacros(std::vector<FurnaceGUIMacroDesc>& macros, FurnaceGUI
} else { } else {
snprintf(buf,255,"%s",macros[i].displayName); snprintf(buf,255,"%s",macros[i].displayName);
} }
float stretchX=ImGui::CalcTextSize(buf).x;
if (ImGui::Selectable(buf,state.selectedMacro==(int)i)) {
ImVec2 size=ImGui::CalcTextSize(buf);
size.x=MAX(stretchX,size.x);
if (ImGui::Selectable(buf,state.selectedMacro==(int)i,0,size)) {
state.selectedMacro=i; state.selectedMacro=i;
} }
} }
@ -2776,6 +2772,7 @@ void FurnaceGUI::drawMacros(std::vector<FurnaceGUIMacroDesc>& macros, FurnaceGUI
ImGui::TableNextRow(); ImGui::TableNextRow();
if (showLen) { if (showLen) {
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::AlignTextToFramePadding();
ImGui::Text(shortLabels ? _("Len##macroEditLengthShortLabel") : _("Length")); ImGui::Text(shortLabels ? _("Len##macroEditLengthShortLabel") : _("Length"));
if (shortLabels && ImGui::IsItemHovered()) ImGui::SetTooltip("%s", _("Length")); if (shortLabels && ImGui::IsItemHovered()) ImGui::SetTooltip("%s", _("Length"));
ImGui::SameLine(); ImGui::SameLine();
@ -2788,6 +2785,7 @@ void FurnaceGUI::drawMacros(std::vector<FurnaceGUIMacroDesc>& macros, FurnaceGUI
} }
} }
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::AlignTextToFramePadding();
ImGui::Text(shortLabels ? _("SLen##macroEditStepLenShortLabel") : _("StepLen")); ImGui::Text(shortLabels ? _("SLen##macroEditStepLenShortLabel") : _("StepLen"));
if (shortLabels && ImGui::IsItemHovered()) ImGui::SetTooltip("%s", _("StepLen")); if (shortLabels && ImGui::IsItemHovered()) ImGui::SetTooltip("%s", _("StepLen"));
ImGui::SameLine(); ImGui::SameLine();
@ -2797,6 +2795,7 @@ void FurnaceGUI::drawMacros(std::vector<FurnaceGUIMacroDesc>& macros, FurnaceGUI
MARK_MODIFIED; MARK_MODIFIED;
} }
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::AlignTextToFramePadding();
ImGui::Text(shortLabels ? _("Del##macroEditDelayShortLabel") : _("Delay")); ImGui::Text(shortLabels ? _("Del##macroEditDelayShortLabel") : _("Delay"));
if (shortLabels && ImGui::IsItemHovered()) ImGui::SetTooltip("%s", _("Delay")); if (shortLabels && ImGui::IsItemHovered()) ImGui::SetTooltip("%s", _("Delay"));
ImGui::SameLine(); ImGui::SameLine();