From 3f6200aa9a11ebe20c56e749e648b12d582149b2 Mon Sep 17 00:00:00 2001 From: Adam Lederer Date: Thu, 12 Sep 2024 01:04:56 -0700 Subject: [PATCH 1/2] support horizontal mode in wavetable list --- doc/2-interface/settings.md | 2 +- src/gui/dataList.cpp | 59 +++++++++++++++++++++++++++++++++---- src/gui/gui.h | 2 ++ src/gui/settings.cpp | 2 +- 4 files changed, 57 insertions(+), 8 deletions(-) diff --git a/doc/2-interface/settings.md b/doc/2-interface/settings.md index 9dd473737..5637acbe7 100644 --- a/doc/2-interface/settings.md +++ b/doc/2-interface/settings.md @@ -488,7 +488,7 @@ below all the binds, select a key from the dropdown list to add it. it will appe - **Unified instrument/wavetable/sample list**: combines all three types of assets into one list. - the buttons act as appropriate to the currently selected asset or header. -- **Horizontal instrument list**: when there are more instruments than there is room to display them... +- **Horizontal instrument/wavetable list**: when there are more instruments/wavetables than there is room to display them... - if on, scroll horizontally through multiple columns. - if off, scroll vertically in one long column. - only appears if "Unified instrument/wavetable/sample list" is off. diff --git a/src/gui/dataList.cpp b/src/gui/dataList.cpp index b4a475e77..46d286154 100644 --- a/src/gui/dataList.cpp +++ b/src/gui/dataList.cpp @@ -997,6 +997,37 @@ void FurnaceGUI::drawSampleList(bool asChild) { } } +template +void FurnaceGUI::waveListHorizontalGroup(float* wavePreview, int dir, int count, const func_waveItemData& waveItemData) { + if (count==0) return; + + float idealWidthMin=225.0f*dpiScale; + float idealWidthMax=350.0f*dpiScale; + float availX=ImGui::GetContentRegionAvail().x; + int columnCount=CLAMP((int)(availX/idealWidthMin),1,count); + int rowCount=(int)ceilf(count/(float)columnCount); + columnCount=(int)ceilf(count/(float)rowCount); + float columnWidth=MIN(CLAMP(availX/columnCount,idealWidthMin,idealWidthMax),availX); + if (ImGui::BeginTable("##waveListGroupTable", columnCount, ImGuiTableFlags_SizingFixedSame)) { + for (int col=0; col=count) continue; + + int waveIdx, asset; + waveItemData(row + col*rowCount, &waveIdx, &asset); + waveListItem(waveIdx, wavePreview, dir, asset); + } + } + ImGui::EndTable(); + } +} + void FurnaceGUI::actualWaveList() { float wavePreview[257]; @@ -1021,10 +1052,17 @@ void FurnaceGUI::actualWaveList() { ImGui::EndPopup(); } if (treeNode) { - int assetIndex=0; - for (int j: i.entries) { - waveListItem(j,wavePreview,dirIndex,assetIndex); - assetIndex++; + if(settings.horizontalDataView) { + waveListHorizontalGroup(wavePreview, dirIndex, i.entries.size(), [&](int i_, int* waveIdx, int* asset) { + *waveIdx=i.entries[i_]; + *asset=i_; + }); + } else { + int assetIndex=0; + for (int j: i.entries) { + waveListItem(j,wavePreview,dirIndex,assetIndex); + assetIndex++; + } } ImGui::TreePop(); } @@ -1037,10 +1075,19 @@ void FurnaceGUI::actualWaveList() { }); } } else { - for (int i=0; i<(int)e->song.wave.size(); i++) { + if(settings.horizontalDataView) { ImGui::TableNextRow(); ImGui::TableNextColumn(); - waveListItem(i,wavePreview,-1,-1); + waveListHorizontalGroup(wavePreview, -1, (int)e->song.wave.size(), [&](int i, int* waveIdx, int* asset) { + *waveIdx=i; + *asset=-1; + }); + } else { + for (int i=0; i<(int)e->song.wave.size(); i++) { + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + waveListItem(i,wavePreview,-1,-1); + } } } } diff --git a/src/gui/gui.h b/src/gui/gui.h index c48d3615e..4a7e9b40e 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -2817,6 +2817,8 @@ class FurnaceGUI { void actualWaveList(); void actualSampleList(); + template + void waveListHorizontalGroup(float* wavePreview, int dir, int count, const func_waveItemData& waveItemData); void insListItem(int index, int dir, int asset); void waveListItem(int index, float* wavePreview, int dir, int asset); void sampleListItem(int index, int dir, int asset); diff --git a/src/gui/settings.cpp b/src/gui/settings.cpp index 628550e13..70883e530 100644 --- a/src/gui/settings.cpp +++ b/src/gui/settings.cpp @@ -3575,7 +3575,7 @@ void FurnaceGUI::drawSettings() { ImGui::BeginDisabled(settings.unifiedDataView); bool horizontalDataViewB=settings.horizontalDataView; - if (ImGui::Checkbox(_("Horizontal instrument list"),&horizontalDataViewB)) { + if (ImGui::Checkbox(_("Horizontal instrument/wavetable list"),&horizontalDataViewB)) { settings.horizontalDataView=horizontalDataViewB; settingsChanged=true; } From 6c6ea2d54bf69868f0ad5112412e1776ac1d6947 Mon Sep 17 00:00:00 2001 From: Adam Lederer Date: Thu, 12 Sep 2024 13:33:18 -0700 Subject: [PATCH 2/2] keep template<> on same line --- src/gui/dataList.cpp | 3 +-- src/gui/gui.h | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/gui/dataList.cpp b/src/gui/dataList.cpp index 46d286154..eaa364661 100644 --- a/src/gui/dataList.cpp +++ b/src/gui/dataList.cpp @@ -997,8 +997,7 @@ void FurnaceGUI::drawSampleList(bool asChild) { } } -template -void FurnaceGUI::waveListHorizontalGroup(float* wavePreview, int dir, int count, const func_waveItemData& waveItemData) { +template void FurnaceGUI::waveListHorizontalGroup(float* wavePreview, int dir, int count, const func_waveItemData& waveItemData) { if (count==0) return; float idealWidthMin=225.0f*dpiScale; diff --git a/src/gui/gui.h b/src/gui/gui.h index 4a7e9b40e..33d09d9a4 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -2817,8 +2817,7 @@ class FurnaceGUI { void actualWaveList(); void actualSampleList(); - template - void waveListHorizontalGroup(float* wavePreview, int dir, int count, const func_waveItemData& waveItemData); + template void waveListHorizontalGroup(float* wavePreview, int dir, int count, const func_waveItemData& waveItemData); void insListItem(int index, int dir, int asset); void waveListItem(int index, float* wavePreview, int dir, int asset); void sampleListItem(int index, int dir, int asset);