asset directories, part 3 - DO NOT USE

IT CRASHES
This commit is contained in:
tildearrow 2023-05-15 17:43:27 -05:00
parent 51b4492746
commit c523d80fc3
4 changed files with 63 additions and 34 deletions

View file

@ -30,7 +30,36 @@ const char* sampleNote[12]={
"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"
}; };
void FurnaceGUI::insListItem(int i) { #define DRAG_SOURCE(_d,_a) \
if (ImGui::BeginDragDropSource()) { \
dirToMove=_d; \
assetToMove=_a; \
ImGui::SetDragDropPayload("FUR_DIR",NULL,0,ImGuiCond_Once); \
ImGui::Button(ICON_FA_ARROWS "##AssetDrag"); \
ImGui::EndDragDropSource(); \
}
#define DRAG_TARGET(_d,_a,_type) \
if (ImGui::BeginDragDropTarget()) { \
const ImGuiPayload* dragItem=ImGui::AcceptDragDropPayload("FUR_DIR"); \
if (dragItem!=NULL) { \
if (dragItem->IsDataType("FUR_DIR")) { \
if (dirToMove!=_d || assetToMove!=_a) { \
logV("%d/%d -> %d/%d",dirToMove,assetToMove,_d,_a); \
e->lockEngine([&]() { \
int val=e->song.insDir[dirToMove].entries[assetToMove]; \
e->song.insDir[dirToMove].entries.erase(e->song.insDir[dirToMove].entries.begin()+assetToMove); \
e->song.insDir[_d].entries.insert(e->song.insDir[_d].entries.begin()+_a,val); \
}); \
} \
dirToMove=-1; \
assetToMove=-1; \
} \
} \
ImGui::EndDragDropTarget(); \
}
void FurnaceGUI::insListItem(int i, int dir, int asset) {
ImGui::PushID(i); ImGui::PushID(i);
String name=ICON_FA_CIRCLE_O; String name=ICON_FA_CIRCLE_O;
const char* insType="Bug!"; const char* insType="Bug!";
@ -270,24 +299,8 @@ void FurnaceGUI::insListItem(int i) {
} }
if (i>=0) { if (i>=0) {
if (insListDir) { if (insListDir) {
if (ImGui::BeginDragDropSource()) { DRAG_SOURCE(dir,asset);
chanToMove=i; DRAG_TARGET(dir,asset,e->song.insDir);
ImGui::SetDragDropPayload("FUR_DIR",NULL,0,ImGuiCond_Once);
//ImGui::Button(ICON_FA_ARROWS "##ChanDrag");
ImGui::EndDragDropSource();
}
if (ImGui::BeginDragDropTarget()) {
const ImGuiPayload* dragItem=ImGui::AcceptDragDropPayload("FUR_DIR");
if (dragItem!=NULL) {
if (dragItem->IsDataType("FUR_DIR")) {
if (chanToMove!=i && chanToMove>=0) {
}
logV("TO %d",i);
chanToMove=-1;
}
}
ImGui::EndDragDropTarget();
}
} }
if (ImGui::BeginPopupContextItem("InsRightMenu")) { if (ImGui::BeginPopupContextItem("InsRightMenu")) {
@ -562,14 +575,20 @@ void FurnaceGUI::drawInsList(bool asChild) {
if (insListDir) { if (insListDir) {
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableNextColumn(); ImGui::TableNextColumn();
insListItem(-1); insListItem(-1,-1,-1);
int dirIndex=0;
for (DivAssetDir& i: e->song.insDir) { for (DivAssetDir& i: e->song.insDir) {
if (ImGui::TreeNode(i.name.empty()?"<uncategorized>":i.name.c_str())) { if (ImGui::TreeNode(i.name.empty()?"<uncategorized>":i.name.c_str())) {
int assetIndex=0;
for (int j: i.entries) { for (int j: i.entries) {
insListItem(j); insListItem(j,dirIndex,assetIndex);
assetIndex++;
} }
ImGui::TreePop(); ImGui::TreePop();
} }
DRAG_SOURCE(dirIndex,-1);
DRAG_TARGET(dirIndex,-1,e->song.insDir);
dirIndex++;
} }
} else { } else {
int curRow=0; int curRow=0;
@ -580,7 +599,7 @@ void FurnaceGUI::drawInsList(bool asChild) {
} else if (curRow==0) { } else if (curRow==0) {
ImGui::TableNextColumn(); ImGui::TableNextColumn();
} }
insListItem(i); insListItem(i,-1,-1);
if (settings.horizontalDataView) { if (settings.horizontalDataView) {
if (++curRow>=availableRows) curRow=0; if (++curRow>=availableRows) curRow=0;
} }

View file

@ -561,17 +561,17 @@ void FurnaceGUI::doAction(int what) {
doFlip(); doFlip();
break; break;
case GUI_ACTION_PAT_COLLAPSE_ROWS: case GUI_ACTION_PAT_COLLAPSE_ROWS:
doCollapse(2,selStart,selEnd); doCollapse(collapseAmount,selStart,selEnd);
break; break;
case GUI_ACTION_PAT_EXPAND_ROWS: case GUI_ACTION_PAT_EXPAND_ROWS:
doExpand(2,selStart,selEnd); doExpand(collapseAmount,selStart,selEnd);
break; break;
case GUI_ACTION_PAT_COLLAPSE_PAT: { case GUI_ACTION_PAT_COLLAPSE_PAT: {
SelectionPoint selEndPat; SelectionPoint selEndPat;
selEndPat.xCoarse=e->getTotalChannelCount()-1; selEndPat.xCoarse=e->getTotalChannelCount()-1;
selEndPat.xFine=2+e->curPat[selEndPat.xCoarse].effectCols*2; selEndPat.xFine=2+e->curPat[selEndPat.xCoarse].effectCols*2;
selEndPat.y=e->curSubSong->patLen-1; selEndPat.y=e->curSubSong->patLen-1;
doCollapse(2,SelectionPoint(0,0,0),selEndPat); doCollapse(collapseAmount,SelectionPoint(0,0,0),selEndPat);
break; break;
} }
case GUI_ACTION_PAT_EXPAND_PAT: { case GUI_ACTION_PAT_EXPAND_PAT: {
@ -579,14 +579,14 @@ void FurnaceGUI::doAction(int what) {
selEndPat.xCoarse=e->getTotalChannelCount()-1; selEndPat.xCoarse=e->getTotalChannelCount()-1;
selEndPat.xFine=2+e->curPat[selEndPat.xCoarse].effectCols*2; selEndPat.xFine=2+e->curPat[selEndPat.xCoarse].effectCols*2;
selEndPat.y=e->curSubSong->patLen-1; selEndPat.y=e->curSubSong->patLen-1;
doExpand(2,SelectionPoint(0,0,0),selEndPat); doExpand(collapseAmount,SelectionPoint(0,0,0),selEndPat);
break; break;
} }
case GUI_ACTION_PAT_COLLAPSE_SONG: case GUI_ACTION_PAT_COLLAPSE_SONG:
doCollapseSong(2); doCollapseSong(collapseAmount);
break; break;
case GUI_ACTION_PAT_EXPAND_SONG: case GUI_ACTION_PAT_EXPAND_SONG:
doExpandSong(2); doExpandSong(collapseAmount);
break; break;
case GUI_ACTION_PAT_LATCH: // TODO case GUI_ACTION_PAT_LATCH: // TODO
break; break;

View file

@ -2852,8 +2852,14 @@ void FurnaceGUI::editOptions(bool topMenu) {
ImGui::Separator(); ImGui::Separator();
if (ImGui::MenuItem("flip selection",BIND_FOR(GUI_ACTION_PAT_FLIP_SELECTION))) doFlip(); if (ImGui::MenuItem("flip selection",BIND_FOR(GUI_ACTION_PAT_FLIP_SELECTION))) doFlip();
if (ImGui::MenuItem("collapse",BIND_FOR(GUI_ACTION_PAT_COLLAPSE_ROWS))) doCollapse(2,selStart,selEnd);
if (ImGui::MenuItem("expand",BIND_FOR(GUI_ACTION_PAT_EXPAND_ROWS))) doExpand(2,selStart,selEnd); ImGui::SetNextItemWidth(120.0f*dpiScale);
if (ImGui::InputInt("collapse/expand amount##CollapseAmount",&collapseAmount,1,1)) {
if (collapseAmount<2) collapseAmount=2;
if (collapseAmount>256) collapseAmount=256;
}
if (ImGui::MenuItem("collapse",BIND_FOR(GUI_ACTION_PAT_COLLAPSE_ROWS))) doCollapse(collapseAmount,selStart,selEnd);
if (ImGui::MenuItem("expand",BIND_FOR(GUI_ACTION_PAT_EXPAND_ROWS))) doExpand(collapseAmount,selStart,selEnd);
if (topMenu) { if (topMenu) {
ImGui::Separator(); ImGui::Separator();
@ -6720,11 +6726,14 @@ FurnaceGUI::FurnaceGUI():
sysToMove(-1), sysToMove(-1),
sysToDelete(-1), sysToDelete(-1),
opToMove(-1), opToMove(-1),
assetToMove(-1),
dirToMove(-1),
transposeAmount(0), transposeAmount(0),
randomizeMin(0), randomizeMin(0),
randomizeMax(255), randomizeMax(255),
fadeMin(0), fadeMin(0),
fadeMax(255), fadeMax(255),
collapseAmount(2),
scaleMax(100.0f), scaleMax(100.0f),
fadeMode(false), fadeMode(false),
randomMode(false), randomMode(false),

View file

@ -1792,6 +1792,7 @@ class FurnaceGUI {
std::map<FurnaceGUIImages,FurnaceGUIImage*> images; std::map<FurnaceGUIImages,FurnaceGUIImage*> images;
int chanToMove, sysToMove, sysToDelete, opToMove; int chanToMove, sysToMove, sysToDelete, opToMove;
int assetToMove, dirToMove;
ImVec2 patWindowPos, patWindowSize; ImVec2 patWindowPos, patWindowSize;
@ -1800,7 +1801,7 @@ class FurnaceGUI {
ImVec2 noteCellSize, insCellSize, volCellSize, effectCellSize, effectValCellSize; ImVec2 noteCellSize, insCellSize, volCellSize, effectCellSize, effectValCellSize;
SelectionPoint sel1, sel2; SelectionPoint sel1, sel2;
int dummyRows, demandX; int dummyRows, demandX;
int transposeAmount, randomizeMin, randomizeMax, fadeMin, fadeMax; int transposeAmount, randomizeMin, randomizeMax, fadeMin, fadeMax, collapseAmount;
float scaleMax; float scaleMax;
bool fadeMode, randomMode, haveHitBounds, pendingStepUpdate; bool fadeMode, randomMode, haveHitBounds, pendingStepUpdate;
@ -2000,9 +2001,9 @@ class FurnaceGUI {
void actualWaveList(); void actualWaveList();
void actualSampleList(); void actualSampleList();
void insListItem(int index); void insListItem(int index, int dir, int asset);
void waveListItem(int index); void waveListItem(int index, int dir, int asset);
void sampleListItem(int index); void sampleListItem(int index, int dir, int asset);
void toggleMobileUI(bool enable, bool force=false); void toggleMobileUI(bool enable, bool force=false);