diff --git a/src/gui/cursor.cpp b/src/gui/cursor.cpp index de8f7b8c4..1357fa937 100644 --- a/src/gui/cursor.cpp +++ b/src/gui/cursor.cpp @@ -211,7 +211,7 @@ void FurnaceGUI::finishSelection() { } void FurnaceGUI::moveCursor(int x, int y, bool select) { - if (y>=editStepCoarse || y<=-editStepCoarse || x<=-5 || x>=5 ) { + if (y>=editStepCoarse || y<=-editStepCoarse || x<=-5 || x>=5) { makeCursorUndo(); } if (!select) { diff --git a/src/gui/editing.cpp b/src/gui/editing.cpp index 1c61a422b..37eeb2b44 100644 --- a/src/gui/editing.cpp +++ b/src/gui/editing.cpp @@ -1894,6 +1894,73 @@ void FurnaceGUI::doDrag() { } void FurnaceGUI::moveSelected(int x, int y) { + SelectionPoint selStartOld, selEndOld, selStartNew, selEndNew; + selStartOld=selStart; + selEndOld=selEnd; + + // move selection + DETERMINE_FIRST_LAST; + + bool outOfBounds=false; + + if (x>0) { + for (int i=0; i=lastChannel) { + outOfBounds=true; + break; + } + } while (!e->curSubSong->chanShow[selStart.xCoarse]); + + do { + selEnd.xCoarse++; + if (selEnd.xCoarse>=lastChannel) { + outOfBounds=true; + break; + } + } while (!e->curSubSong->chanShow[selEnd.xCoarse]); + + if (outOfBounds) break; + } + } else if (x<0) { + for (int i=0; i<-x; i++) { + do { + selStart.xCoarse--; + if (selStart.xCoarsecurSubSong->chanShow[selStart.xCoarse]); + + do { + selEnd.xCoarse--; + if (selEnd.xCoarsecurSubSong->chanShow[selEnd.xCoarse]); + + if (outOfBounds) break; + } + } + + selStart.y+=y; + selEnd.y+=y; + + if (selStart.y<0 || selStart.y>=e->curSubSong->patLen) outOfBounds=true; + if (selEnd.y<0 || selEnd.y>=e->curSubSong->patLen) outOfBounds=true; + + selStartNew=selStart; + selEndNew=selEnd; + + selStart=selStartOld; + selEnd=selEndOld; + + if (outOfBounds) { + return; + } + prepareUndo(GUI_UNDO_PATTERN_DRAG); // copy and clear @@ -1901,11 +1968,11 @@ void FurnaceGUI::moveSelected(int x, int y) { logV(_("copy: %s"),c); + // move + selStart=selStartNew; + selEnd=selEndNew; + // replace - selStart.xCoarse+=x; - selEnd.xCoarse+=x; - selStart.y+=y; - selEnd.y+=y; cursor=selStart; doPaste(GUI_PASTE_MODE_NORMAL,0,false,c); @@ -2111,4 +2178,4 @@ if (cursorRedoHist.empty()) return; // apply spot applyCursorJumpPoint(cursorRedoHist.back()); cursorRedoHist.pop_back(); -} \ No newline at end of file +}