diff --git a/src/gui/doAction.cpp b/src/gui/doAction.cpp index 975be07b8..7dd184691 100644 --- a/src/gui/doAction.cpp +++ b/src/gui/doAction.cpp @@ -555,6 +555,18 @@ void FurnaceGUI::doAction(int what) { case GUI_ACTION_PAT_SELECTION_DOWN_COARSE: moveCursor(0,editStepCoarse,true); break; + case GUI_ACTION_PAT_MOVE_UP: + moveSelected(0,-1); + break; + case GUI_ACTION_PAT_MOVE_DOWN: + moveSelected(0,1); + break; + case GUI_ACTION_PAT_MOVE_LEFT_CHANNEL: + moveSelected(-1,0); + break; + case GUI_ACTION_PAT_MOVE_RIGHT_CHANNEL: + moveSelected(1,0); + break; case GUI_ACTION_PAT_DELETE: doDelete(); if (settings.stepOnDelete) { diff --git a/src/gui/editing.cpp b/src/gui/editing.cpp index fcd033913..dad5f3efb 100644 --- a/src/gui/editing.cpp +++ b/src/gui/editing.cpp @@ -1842,6 +1842,25 @@ void FurnaceGUI::doDrag() { makeUndo(GUI_UNDO_PATTERN_DRAG); } +void FurnaceGUI::moveSelected(int x, int y) { + prepareUndo(GUI_UNDO_PATTERN_DRAG); + + // copy and clear + String c=doCopy(true,false,selStart,selEnd); + + logV("copy: %s",c); + + // replace + selStart.xCoarse+=x; + selEnd.xCoarse+=x; + selStart.y+=y; + selEnd.y+=y; + cursor=selStart; + doPaste(GUI_PASTE_MODE_NORMAL,0,false,c); + + makeUndo(GUI_UNDO_PATTERN_DRAG); +} + void FurnaceGUI::doUndo() { if (undoHist.empty()) return; UndoStep& us=undoHist.back(); diff --git a/src/gui/gui.h b/src/gui/gui.h index 3b050e066..0f1839130 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -778,6 +778,10 @@ enum FurnaceGUIActions { GUI_ACTION_PAT_SELECTION_END, GUI_ACTION_PAT_SELECTION_UP_COARSE, GUI_ACTION_PAT_SELECTION_DOWN_COARSE, + GUI_ACTION_PAT_MOVE_UP, + GUI_ACTION_PAT_MOVE_DOWN, + GUI_ACTION_PAT_MOVE_LEFT_CHANNEL, + GUI_ACTION_PAT_MOVE_RIGHT_CHANNEL, GUI_ACTION_PAT_DELETE, GUI_ACTION_PAT_PULL_DELETE, GUI_ACTION_PAT_INSERT, @@ -2783,6 +2787,7 @@ class FurnaceGUI { void doDelete(); void doPullDelete(); void doInsert(); + void moveSelected(int x, int y); void doTranspose(int amount, OperationMask& mask); String doCopy(bool cut, bool writeClipboard, const SelectionPoint& sStart, const SelectionPoint& sEnd); void doPasteFurnace(PasteMode mode, int arg, bool readClipboard, String clipb, std::vector data, int startOff, bool invalidData, UndoRegion ur); diff --git a/src/gui/guiConst.cpp b/src/gui/guiConst.cpp index f3ea831df..fccc5b86c 100644 --- a/src/gui/guiConst.cpp +++ b/src/gui/guiConst.cpp @@ -659,6 +659,10 @@ const FurnaceGUIActionDef guiActions[GUI_ACTION_MAX]={ D("PAT_SELECTION_END", "Expand selection to end of pattern", 0), D("PAT_SELECTION_UP_COARSE", "Expand selection upwards (coarse)", FURKMOD_SHIFT|SDLK_PAGEUP), D("PAT_SELECTION_DOWN_COARSE", "Expand selection downwards (coarse)", FURKMOD_SHIFT|SDLK_PAGEDOWN), + D("PAT_MOVE_UP", "Move selection up", FURKMOD_ALT|SDLK_UP), + D("PAT_MOVE_DOWN", "Move selection down", FURKMOD_ALT|SDLK_DOWN), + D("PAT_MOVE_LEFT_CHANNEL", "Move selection to previous channel", FURKMOD_ALT|SDLK_LEFT), + D("PAT_MOVE_RIGHT_CHANNEL", "Move selection to next channel", FURKMOD_ALT|SDLK_RIGHT), D("PAT_DELETE", "Delete", SDLK_DELETE), D("PAT_PULL_DELETE", "Pull delete", SDLK_BACKSPACE), D("PAT_INSERT", "Insert", SDLK_INSERT), diff --git a/src/gui/settings.cpp b/src/gui/settings.cpp index 83ce9ede0..a3281d4a9 100644 --- a/src/gui/settings.cpp +++ b/src/gui/settings.cpp @@ -2106,6 +2106,10 @@ void FurnaceGUI::drawSettings() { UI_KEYBIND_CONFIG(GUI_ACTION_PAT_SELECTION_END); UI_KEYBIND_CONFIG(GUI_ACTION_PAT_SELECTION_UP_COARSE); UI_KEYBIND_CONFIG(GUI_ACTION_PAT_SELECTION_DOWN_COARSE); + UI_KEYBIND_CONFIG(GUI_ACTION_PAT_MOVE_UP); + UI_KEYBIND_CONFIG(GUI_ACTION_PAT_MOVE_DOWN); + UI_KEYBIND_CONFIG(GUI_ACTION_PAT_MOVE_LEFT_CHANNEL); + UI_KEYBIND_CONFIG(GUI_ACTION_PAT_MOVE_RIGHT_CHANNEL); UI_KEYBIND_CONFIG(GUI_ACTION_PAT_DELETE); UI_KEYBIND_CONFIG(GUI_ACTION_PAT_PULL_DELETE); UI_KEYBIND_CONFIG(GUI_ACTION_PAT_INSERT);