mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-22 12:35:11 +00:00
GUI: add action to move selected content
in pattern editor TODO: CHECK FOR CVE
This commit is contained in:
parent
d16e940c4d
commit
542206bbb7
5 changed files with 44 additions and 0 deletions
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<String> data, int startOff, bool invalidData, UndoRegion ur);
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue