diff --git a/src/gui/cursor.cpp b/src/gui/cursor.cpp index 31faeb310..506aa2026 100644 --- a/src/gui/cursor.cpp +++ b/src/gui/cursor.cpp @@ -21,22 +21,24 @@ #include "../ta-log.h" #include "actionUtil.h" -void FurnaceGUI::startSelection(int xCoarse, int xFine, int y, bool fullRow) { +void FurnaceGUI::startSelection(int xCoarse, int xFine, int y, int ord, bool fullRow) { DETERMINE_FIRST_LAST; - if (xCoarse!=selStart.xCoarse || xFine!=selStart.xFine || y!=selStart.y) { + if (xCoarse!=selStart.xCoarse || xFine!=selStart.xFine || y!=selStart.y || ord!=selStart.order) { curNibble=false; } if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left) && !fullRow && settings.doubleClickColumn) { - if (cursor.xCoarse==xCoarse && cursor.xFine==xFine && cursor.y==y) { + if (cursor.xCoarse==xCoarse && cursor.xFine==xFine && cursor.y==y && cursor.order==ord) { // select entire channel selStart.xCoarse=xCoarse; selStart.xFine=0; selStart.y=0; + selStart.order=ord; selEnd.xCoarse=xCoarse; selEnd.xFine=2+e->curPat[selEnd.xCoarse].effectCols*2; selEnd.y=e->curSubSong->patLen-1; + selEnd.order=ord; finishSelection(); return; @@ -44,17 +46,19 @@ void FurnaceGUI::startSelection(int xCoarse, int xFine, int y, bool fullRow) { } if (((settings.dragMovesSelection==1 || settings.dragMovesSelection==3 || settings.dragMovesSelection==5) || ((settings.dragMovesSelection==2 || settings.dragMovesSelection==4) && (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) || ImGui::IsKeyDown(ImGuiKey_RightCtrl)))) && !fullRow) { - if (xCoarse>=selStart.xCoarse && (xFine>=selStart.xFine || xCoarse>selStart.xCoarse) && y>=selStart.y && - xCoarse<=selEnd.xCoarse && (xFine<=selEnd.xFine || xCoarse=selStart.xCoarse && (xFine>=selStart.xFine || xCoarse>selStart.xCoarse) && (ord>selStart.order || y>=selStart.y) && + xCoarse<=selEnd.xCoarse && (xFine<=selEnd.xFine || xCoarsecurPat[selEnd.xCoarse].effectCols*2; selStart.y=y; selEnd.y=y; + selStart.order=ord; + selEnd.order=ord; } else { - if (xCoarse!=cursor.xCoarse || y!=cursor.y) { + if (xCoarse!=cursor.xCoarse || y!=cursor.y || ord!=cursor.order) { makeCursorUndo(); } cursor.xCoarse=xCoarse; cursor.xFine=xFine; cursor.y=y; + cursor.order=ord; selStart.xCoarse=xCoarse; selStart.xFine=xFine; selStart.y=y; + selStart.order=ord; selEnd.xCoarse=xCoarse; selEnd.xFine=xFine; selEnd.y=y; + selEnd.order=ord; } selecting=true; selectingFull=fullRow; e->setMidiBaseChan(cursor.xCoarse); } -void FurnaceGUI::updateSelection(int xCoarse, int xFine, int y, bool fullRow) { +void FurnaceGUI::updateSelection(int xCoarse, int xFine, int y, int ord, bool fullRow) { if (!selecting) return; if (dragging) { dragDestinationX=xCoarse; if (dragStart.xFine>=3 && dragStart.xCoarse==dragEnd.xCoarse) dragDestinationXFine=(dragSourceXFine&1)?((xFine-1)|1):((xFine+1)&(~1)); dragDestinationY=y; + dragDestinationOrder=ord; cursorDrag.xCoarse=xCoarse; cursorDrag.xFine=xFine; cursorDrag.y=y; + cursorDrag.order=ord; int len=dragEnd.xCoarse-dragStart.xCoarse+1; if (len<0) len=0; @@ -119,6 +130,7 @@ void FurnaceGUI::updateSelection(int xCoarse, int xFine, int y, bool fullRow) { } } + // TODO: new cursor logic if (dragStart.y+(dragDestinationY-dragSourceY)<0) { dragDestinationY=dragSourceY-dragStart.y; } @@ -139,17 +151,26 @@ void FurnaceGUI::updateSelection(int xCoarse, int xFine, int y, bool fullRow) { selEnd.xCoarse=lastChannel-1; selEnd.xFine=2+e->curPat[selEnd.xCoarse].effectCols*2; selEnd.y=y; + selEnd.order=ord; } else { selEnd.xCoarse=xCoarse; selEnd.xFine=xFine; selEnd.y=y; + selEnd.order=ord; } } } void FurnaceGUI::finishSelection() { // swap points if needed - if (selEnd.y=chanCount) selStart.xCoarse=chanCount-1; if (selStart.y<0) selStart.y=0; if (selStart.y>=e->curSubSong->patLen) selStart.y=e->curSubSong->patLen-1; + if (selStart.order<0) selStart.order=0; + if (selStart.order>=e->curSubSong->ordersLen) selStart.order=e->curSubSong->ordersLen-1; if (selEnd.xCoarse<0) selEnd.xCoarse=0; if (selEnd.xCoarse>=chanCount) selEnd.xCoarse=chanCount-1; if (selEnd.y<0) selEnd.y=0; if (selEnd.y>=e->curSubSong->patLen) selEnd.y=e->curSubSong->patLen-1; + if (selEnd.order<0) selEnd.order=0; + if (selEnd.order>=e->curSubSong->ordersLen) selEnd.order=e->curSubSong->ordersLen-1; if (cursor.xCoarse<0) cursor.xCoarse=0; if (cursor.xCoarse>=chanCount) cursor.xCoarse=chanCount-1; if (cursor.y<0) cursor.y=0; if (cursor.y>=e->curSubSong->patLen) cursor.y=e->curSubSong->patLen-1; + if (cursor.order<0) cursor.order=0; + if (cursor.order>=e->curSubSong->ordersLen) cursor.order=e->curSubSong->ordersLen-1; if (e->curSubSong->chanCollapse[selStart.xCoarse]==3) { selStart.xFine=0; @@ -218,7 +245,13 @@ void FurnaceGUI::finishSelection() { selEnd.xFine=2+e->curPat[selEnd.xCoarse].effectCols*2; } - logV(_("finish selection: %d.%d,%d - %d.%d,%d"),selStart.xCoarse,selStart.xFine,selStart.y,selEnd.xCoarse,selEnd.xFine,selEnd.y); + // change order if necessary + if (curOrder!=cursor.order) { + setOrder(cursor.order); + updateScroll(cursor.y); + } + + logV(_("finish selection: %d.%d,%d.%d - %d.%d,%d.%d"),selStart.xCoarse,selStart.xFine,selStart.order,selStart.y,selEnd.xCoarse,selEnd.xFine,selEnd.order,selEnd.y); e->setMidiBaseChan(cursor.xCoarse); } diff --git a/src/gui/doAction.cpp b/src/gui/doAction.cpp index 093e1c1e5..f8bd28e96 100644 --- a/src/gui/doAction.cpp +++ b/src/gui/doAction.cpp @@ -645,7 +645,8 @@ void FurnaceGUI::doAction(int what) { selEndPat.xCoarse=e->getTotalChannelCount()-1; selEndPat.xFine=2+e->curPat[selEndPat.xCoarse].effectCols*2; selEndPat.y=e->curSubSong->patLen-1; - doCollapse(collapseAmount,SelectionPoint(0,0,0),selEndPat); + selEndPat.order=curOrder; + doCollapse(collapseAmount,SelectionPoint(0,0,0,curOrder),selEndPat); break; } case GUI_ACTION_PAT_EXPAND_PAT: { @@ -653,7 +654,8 @@ void FurnaceGUI::doAction(int what) { selEndPat.xCoarse=e->getTotalChannelCount()-1; selEndPat.xFine=2+e->curPat[selEndPat.xCoarse].effectCols*2; selEndPat.y=e->curSubSong->patLen-1; - doExpand(collapseAmount,SelectionPoint(0,0,0),selEndPat); + selEndPat.order=curOrder; + doExpand(collapseAmount,SelectionPoint(0,0,0,curOrder),selEndPat); break; } case GUI_ACTION_PAT_COLLAPSE_SONG: diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index bedc96c18..4a64b8c43 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -8609,9 +8609,13 @@ FurnaceGUI::FurnaceGUI(): wheelX(0), wheelY(0), dragSourceX(0), + dragSourceXFine(0), dragSourceY(0), + dragSourceOrder(0), dragDestinationX(0), + dragDestinationXFine(0), dragDestinationY(0), + dragDestinationOrder(0), oldBeat(-1), oldBar(-1), curGroove(-1), diff --git a/src/gui/gui.h b/src/gui/gui.h index 45975dd35..20745a44a 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -1006,11 +1006,11 @@ enum NoteCtrl { struct SelectionPoint { int xCoarse, xFine; - int y; - SelectionPoint(int xc, int xf, int yp): - xCoarse(xc), xFine(xf), y(yp) {} + int y, order; + SelectionPoint(int xc, int xf, int yp, int o): + xCoarse(xc), xFine(xf), y(yp), order(o) {} SelectionPoint(): - xCoarse(0), xFine(0), y(0) {} + xCoarse(0), xFine(0), y(0), order(0) {} }; struct UndoRegion { @@ -2343,7 +2343,7 @@ class FurnaceGUI { int curIns, curWave, curSample, curOctave, curOrder, playOrder, prevIns, oldRow, editStep, editStepCoarse, soloChan, orderEditMode, orderCursor; int loopOrder, loopRow, loopEnd, isClipping, newSongCategory, latchTarget; - int wheelX, wheelY, dragSourceX, dragSourceXFine, dragSourceY, dragDestinationX, dragDestinationXFine, dragDestinationY, oldBeat, oldBar; + int wheelX, wheelY, dragSourceX, dragSourceXFine, dragSourceY, dragSourceOrder, dragDestinationX, dragDestinationXFine, dragDestinationY, dragDestinationOrder, oldBeat, oldBar; int curGroove, exitDisabledTimer; int curPaletteChoice, curPaletteType; float soloTimeout; @@ -2983,8 +2983,8 @@ class FurnaceGUI { void processDrags(int dragX, int dragY); void processPoint(SDL_Event& ev); - void startSelection(int xCoarse, int xFine, int y, bool fullRow=false); - void updateSelection(int xCoarse, int xFine, int y, bool fullRow=false); + void startSelection(int xCoarse, int xFine, int y, int ord, bool fullRow=false); + void updateSelection(int xCoarse, int xFine, int y, int ord, bool fullRow=false); void finishSelection(); void finishDrag(); diff --git a/src/gui/pattern.cpp b/src/gui/pattern.cpp index e87704f04..002166fa3 100644 --- a/src/gui/pattern.cpp +++ b/src/gui/pattern.cpp @@ -71,7 +71,11 @@ void FurnaceGUI::popPartBlend() { // draw a pattern row inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int chans, int ord, const DivPattern** patCache, bool inhibitSel) { static char id[64]; - bool selectedRow=(i>=sel1.y && i<=sel2.y && !inhibitSel); + bool selectedRow=( + !inhibitSel && + (ord>sel1.order || (ord==sel1.order && i>=sel1.y)) && + (ord=sel1XSum && j32<=sel2XSum); bool selectedIns=selectedRow && (j32+1>=sel1XSum && j32+1<=sel2XSum); bool selectedVol=selectedRow && (j32+2>=sel1XSum && j32+2<=sel2XSum); - bool cursorNote=(cursor.y==i && cursor.xCoarse==j && cursor.xFine==0 && curWindowLast==GUI_WINDOW_PATTERN); - bool cursorIns=(cursor.y==i && cursor.xCoarse==j && cursor.xFine==1 && curWindowLast==GUI_WINDOW_PATTERN); - bool cursorVol=(cursor.y==i && cursor.xCoarse==j && cursor.xFine==2 && curWindowLast==GUI_WINDOW_PATTERN); + bool cursorNote=(cursor.order==ord && cursor.y==i && cursor.xCoarse==j && cursor.xFine==0 && curWindowLast==GUI_WINDOW_PATTERN); + bool cursorIns=(cursor.order==ord && cursor.y==i && cursor.xCoarse==j && cursor.xFine==1 && curWindowLast==GUI_WINDOW_PATTERN); + bool cursorVol=(cursor.order==ord && cursor.y==i && cursor.xCoarse==j && cursor.xFine==2 && curWindowLast==GUI_WINDOW_PATTERN); // note snprintf(id,63,"%.31s###PN_%d_%d",noteName(pat->data[i][0],pat->data[i][1]),i,j); @@ -205,10 +209,10 @@ inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int if (selectedNote) ImGui::PopStyleColor(); } if (ImGui::IsItemClicked()) { - startSelection(j,0,i); + startSelection(j,0,i,ord); } if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) { - updateSelection(j,0,i); + updateSelection(j,0,i,ord); } if (ImGui::IsItemActive() && CHECK_LONG_HOLD) { ImGui::InhibitInertialScroll(); @@ -249,10 +253,10 @@ inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int if (selectedIns) ImGui::PopStyleColor(); } if (ImGui::IsItemClicked()) { - startSelection(j,1,i); + startSelection(j,1,i,ord); } if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) { - updateSelection(j,1,i); + updateSelection(j,1,i,ord); } if (ImGui::IsItemActive() && CHECK_LONG_HOLD) { ImGui::InhibitInertialScroll(); @@ -287,10 +291,10 @@ inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int if (selectedVol) ImGui::PopStyleColor(); } if (ImGui::IsItemClicked()) { - startSelection(j,2,i); + startSelection(j,2,i,ord); } if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) { - updateSelection(j,2,i); + updateSelection(j,2,i,ord); } if (ImGui::IsItemActive() && CHECK_LONG_HOLD) { ImGui::InhibitInertialScroll(); @@ -306,8 +310,8 @@ inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int int index=4+(k<<1); bool selectedEffect=selectedRow && (j32+index-1>=sel1XSum && j32+index-1<=sel2XSum); bool selectedEffectVal=selectedRow && (j32+index>=sel1XSum && j32+index<=sel2XSum); - bool cursorEffect=(cursor.y==i && cursor.xCoarse==j && cursor.xFine==index-1 && curWindowLast==GUI_WINDOW_PATTERN); - bool cursorEffectVal=(cursor.y==i && cursor.xCoarse==j && cursor.xFine==index && curWindowLast==GUI_WINDOW_PATTERN); + bool cursorEffect=(cursor.order==ord && cursor.y==i && cursor.xCoarse==j && cursor.xFine==index-1 && curWindowLast==GUI_WINDOW_PATTERN); + bool cursorEffectVal=(cursor.order==ord && cursor.y==i && cursor.xCoarse==j && cursor.xFine==index && curWindowLast==GUI_WINDOW_PATTERN); // effect if (pat->data[i][index]==-1) { @@ -340,10 +344,10 @@ inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int if (selectedEffect) ImGui::PopStyleColor(); } if (ImGui::IsItemClicked()) { - startSelection(j,index-1,i); + startSelection(j,index-1,i,ord); } if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) { - updateSelection(j,index-1,i); + updateSelection(j,index-1,i,ord); } if (ImGui::IsItemActive() && CHECK_LONG_HOLD) { ImGui::InhibitInertialScroll(); @@ -370,10 +374,10 @@ inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int if (selectedEffectVal) ImGui::PopStyleColor(); } if (ImGui::IsItemClicked()) { - startSelection(j,index,i); + startSelection(j,index,i,ord); } if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) { - updateSelection(j,index,i); + updateSelection(j,index,i,ord); } if (ImGui::IsItemActive() && CHECK_LONG_HOLD) { ImGui::InhibitInertialScroll(); @@ -408,6 +412,7 @@ void FurnaceGUI::drawPattern() { if (oldRowChanged || !e->isStepping()) { if (e->isStepping()) pendingStepUpdate=1; cursor.y=oldRow; + cursor.order=curOrder; if (selStart.xCoarse==selEnd.xCoarse && selStart.xFine==selEnd.xFine && selStart.y==selEnd.y && !selecting) { selStart=cursor; selEnd=cursor; @@ -416,7 +421,14 @@ void FurnaceGUI::drawPattern() { } sel1=selStart; sel2=selEnd; - if (sel2.y=0) for (int i=0; icurPat[i].getPattern(e->curOrders->ord[i][ord-1],true); + patCache[i]=e->curPat[i].getPattern(e->curOrders->ord[i][ord-1],false); } + ImGui::PushStyleVar(ImGuiStyleVar_Alpha,ImGui::GetStyle().Alpha*ImGui::GetStyle().DisabledAlpha); for (int i=0; icurSubSong->patLen+i-dummyRows+1,e->isPlaying(),lineHeight,chans,ord-1,patCache,true); } + ImGui::PopStyleVar(); } else { for (int i=0; icurPat[i].getPattern(e->curOrders->ord[i][ord],true); @@ -1189,14 +1201,15 @@ void FurnaceGUI::drawPattern() { patternRow(i,e->isPlaying(),lineHeight,chans,ord,patCache,false); } // next pattern - ImGui::BeginDisabled(); if (settings.viewPrevPattern) { if ((ord+1)curSubSong->ordersLen) for (int i=0; icurPat[i].getPattern(e->curOrders->ord[i][ord+1],true); } + ImGui::PushStyleVar(ImGuiStyleVar_Alpha,ImGui::GetStyle().Alpha*ImGui::GetStyle().DisabledAlpha); for (int i=0; i<=dummyRows; i++) { - patternRow(i,e->isPlaying(),lineHeight,chans,ord+1,patCache,true); + patternRow(i,e->isPlaying(),lineHeight,chans,ord+1,patCache,false); } + ImGui::PopStyleVar(); } else { for (int i=0; i<=dummyRows; i++) { ImGui::TableNextRow(0,lineHeight); @@ -1204,7 +1217,6 @@ void FurnaceGUI::drawPattern() { } } - ImGui::EndDisabled(); ImGui::PopStyleVar(); if (demandScrollX) { float finalX=-fourChars.x;