From 035ac2978ff1144b79eaae2c05688138f5922dcf Mon Sep 17 00:00:00 2001 From: Adam Lederer Date: Wed, 11 Sep 2024 11:52:42 -0700 Subject: [PATCH 1/3] macro editor: add scaling option, show macro len * extend "autoMacroStepSize" setting to include an option to set the horizontal scale in the macro view based on the longest macro (of the current tab). this means that you'll have a consistent horizontal scale across all the macros, rather than changing for each macro. existing options are unaffected. * in "single" macro view, i noticed that there was no way of knowing which macros were actually being used (i.e. non-zero len) without selecting each of them individually and then trying to remember. so i added a len readout per macro to the listing. --- src/gui/insEdit.cpp | 35 ++++++++++++++++++++++++++++------- src/gui/settings.cpp | 18 ++++++++++++++---- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/src/gui/insEdit.cpp b/src/gui/insEdit.cpp index 8086210d8..a0b3de1f6 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -1780,7 +1780,7 @@ void FurnaceGUI::drawMacroEdit(FurnaceGUIMacroDesc& i, int totalFit, float avail if ((i.macro->vScroll+i.macro->vZoom)>(i.max-i.min)) { i.macro->vScroll=(i.max-i.min)-i.macro->vZoom; } - } else if (!settings.autoMacroStepSize) { + } else if (settings.autoMacroStepSize==0) { macroPointSize+=wheelY; if (macroPointSize<1) macroPointSize=1; if (macroPointSize>256) macroPointSize=256; @@ -2148,6 +2148,8 @@ void FurnaceGUI::drawMacroEdit(FurnaceGUIMacroDesc& i, int totalFit, float avail void FurnaceGUI::drawMacros(std::vector& macros, FurnaceGUIMacroEditState& state) { int index=0; + int maxMacroLen = 0; + for (FurnaceGUIMacroDesc& macro : macros) { maxMacroLen = MAX(maxMacroLen, macro.macro->len); } float reservedSpace=(settings.oldMacroVSlider)?(20.0f*dpiScale+ImGui::GetStyle().ItemSpacing.x):ImGui::GetStyle().ScrollbarSize; switch (settings.macroLayout) { case 0: { @@ -2163,7 +2165,7 @@ void FurnaceGUI::drawMacros(std::vector& macros, FurnaceGUI ImGui::TableNextColumn(); float lenAvail=ImGui::GetContentRegionAvail().x; //ImGui::Dummy(ImVec2(120.0f*dpiScale,dpiScale)); - if (!settings.autoMacroStepSize) { + if (settings.autoMacroStepSize==0) { ImGui::SetNextItemWidth(120.0f*dpiScale); if (ImGui::InputInt("##MacroPointSize",¯oPointSize,1,4)) { if (macroPointSize<1) macroPointSize=1; @@ -2174,11 +2176,13 @@ void FurnaceGUI::drawMacros(std::vector& macros, FurnaceGUI float availableWidth=ImGui::GetContentRegionAvail().x-reservedSpace; int totalFit=MIN(255,availableWidth/MAX(1,macroPointSize*dpiScale)); int scrollMax=0; - if (settings.autoMacroStepSize) totalFit=1; + if (settings.autoMacroStepSize!=0) totalFit=1; for (FurnaceGUIMacroDesc& i: macros) { if (i.macro->len>scrollMax) scrollMax=i.macro->len; - if (settings.autoMacroStepSize) { + if (settings.autoMacroStepSize==1) { if ((i.macro->open&6)==0 && totalFitlen) totalFit=i.macro->len; + } else if (settings.autoMacroStepSize==2) { + if ((i.macro->open&6)==0 && totalFit& macros, FurnaceGUI ImGui::TableNextRow(); ImGui::TableNextColumn(); for (size_t i=0; ilen>0) { + snprintf(buf, sizeof(buf)/sizeof(char), "%s [%d]", macros[i].displayName, macros[i].macro->len); + } else { + snprintf(buf, sizeof(buf)/sizeof(char), "%s", macros[i].displayName); + } + + ImVec2 size=ImGui::CalcTextSize(buf); + size.x=MAX(stretchX, size.x); + if (ImGui::Selectable(buf,state.selectedMacro==(int)i,0,size)) { state.selectedMacro=i; } } @@ -2359,7 +2379,8 @@ void FurnaceGUI::drawMacros(std::vector& macros, FurnaceGUI for (FurnaceGUIMacroDesc& i: macros) { if (i.macro->len>scrollMax) scrollMax=i.macro->len; } - if (settings.autoMacroStepSize) totalFit=MAX(1,m.macro->len); + if (settings.autoMacroStepSize==1) totalFit=MAX(1,m.macro->len); + else if (settings.autoMacroStepSize==2) totalFit=MAX(1,maxMacroLen); scrollMax-=totalFit; if (scrollMax<0) scrollMax=0; if (macroDragScroll>scrollMax) { @@ -2373,7 +2394,7 @@ void FurnaceGUI::drawMacros(std::vector& macros, FurnaceGUI } ImGui::EndDisabled(); - if (!settings.autoMacroStepSize) { + if (settings.autoMacroStepSize==0) { ImGui::SameLine(); ImGui::Button(ICON_FA_SEARCH_PLUS "##MacroZoomB"); if (ImGui::BeginPopupContextItem("MacroZoomP",ImGuiPopupFlags_MouseButtonLeft)) { diff --git a/src/gui/settings.cpp b/src/gui/settings.cpp index 628550e13..9de964b3d 100644 --- a/src/gui/settings.cpp +++ b/src/gui/settings.cpp @@ -3640,11 +3640,21 @@ void FurnaceGUI::drawSettings() { } ImGui::BeginDisabled(settings.macroLayout==2); - bool autoMacroStepSizeB=settings.autoMacroStepSize; - if (ImGui::Checkbox(_("Automatic macro step size/horizontal zoom"),&autoMacroStepSizeB)) { - settings.autoMacroStepSize=autoMacroStepSizeB; + ImGui::Text(_("Macro step size/horizontal zoom:")); + ImGui::Indent(); + if (ImGui::RadioButton(_("Manual"),settings.autoMacroStepSize==0)) { + settings.autoMacroStepSize=0; settingsChanged=true; } + if (ImGui::RadioButton(_("Automatic per macro"),settings.autoMacroStepSize==1)) { + settings.autoMacroStepSize=1; + settingsChanged=true; + } + if (ImGui::RadioButton(_("Automatic (use longest macro)"),settings.autoMacroStepSize==2)) { + settings.autoMacroStepSize=2; + settingsChanged=true; + } + ImGui::Unindent(); ImGui::EndDisabled(); // SUBSECTION WAVE EDITOR @@ -5295,7 +5305,7 @@ void FurnaceGUI::readConfig(DivConfig& conf, FurnaceGUISettingGroups groups) { clampSetting(settings.backupInterval,10,86400); clampSetting(settings.backupMaxCopies,1,100); clampSetting(settings.autoFillSave,0,1); - clampSetting(settings.autoMacroStepSize,0,1); + clampSetting(settings.autoMacroStepSize,0,2); clampSetting(settings.s3mOPL3,0,1); if (settings.exportLoops<0.0) settings.exportLoops=0.0; From e4f5c7d13ab71cf8a4364c4a809424c44c689f87 Mon Sep 17 00:00:00 2001 From: Adam Lederer Date: Wed, 11 Sep 2024 14:30:32 -0700 Subject: [PATCH 2/3] update settings.md --- doc/2-interface/settings.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/2-interface/settings.md b/doc/2-interface/settings.md index 9dd473737..647240bed 100644 --- a/doc/2-interface/settings.md +++ b/doc/2-interface/settings.md @@ -505,7 +505,10 @@ below all the binds, select a key from the dropdown list to add it. it will appe - **Grid** - **Single (with list)** - **Use classic macro editor vertical slider** -- **Automatic macro step size/horizontal zoom** +- **Macro step size/horizontal zoom:** + - **Manual** + - **Automatic per macro** + - **Automatic (use longest macro) ### Wave Editor From 609efd7b1bfdd644700bf20153a7a23118857aa0 Mon Sep 17 00:00:00 2001 From: Adam Lederer Date: Wed, 11 Sep 2024 14:31:43 -0700 Subject: [PATCH 3/3] md fix --- doc/2-interface/settings.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/2-interface/settings.md b/doc/2-interface/settings.md index 647240bed..066d34e49 100644 --- a/doc/2-interface/settings.md +++ b/doc/2-interface/settings.md @@ -508,7 +508,7 @@ below all the binds, select a key from the dropdown list to add it. it will appe - **Macro step size/horizontal zoom:** - **Manual** - **Automatic per macro** - - **Automatic (use longest macro) + - **Automatic (use longest macro)** ### Wave Editor