implement selecting with shift

This commit is contained in:
tildearrow 2022-01-22 03:12:02 -05:00
parent c64c1c1c2d
commit 28c339cb6d
2 changed files with 19 additions and 14 deletions

View file

@ -2469,8 +2469,10 @@ void FurnaceGUI::finishSelection() {
selecting=false; selecting=false;
} }
void FurnaceGUI::moveCursor(int x, int y) { void FurnaceGUI::moveCursor(int x, int y, bool select) {
finishSelection(); if (!select) {
finishSelection();
}
curNibble=false; curNibble=false;
if (x!=0) { if (x!=0) {
if (x>0) { if (x>0) {
@ -2478,7 +2480,7 @@ void FurnaceGUI::moveCursor(int x, int y) {
if (++cursor.xFine>=3+e->song.pat[cursor.xCoarse].effectRows*2) { if (++cursor.xFine>=3+e->song.pat[cursor.xCoarse].effectRows*2) {
cursor.xFine=0; cursor.xFine=0;
if (++cursor.xCoarse>=e->getTotalChannelCount()) { if (++cursor.xCoarse>=e->getTotalChannelCount()) {
if (settings.wrapHorizontal!=0) { if (settings.wrapHorizontal!=0 && !select) {
cursor.xCoarse=0; cursor.xCoarse=0;
if (settings.wrapHorizontal==2) y++; if (settings.wrapHorizontal==2) y++;
} else { } else {
@ -2492,7 +2494,7 @@ void FurnaceGUI::moveCursor(int x, int y) {
for (int i=0; i<-x; i++) { for (int i=0; i<-x; i++) {
if (--cursor.xFine<0) { if (--cursor.xFine<0) {
if (--cursor.xCoarse<0) { if (--cursor.xCoarse<0) {
if (settings.wrapHorizontal!=0) { if (settings.wrapHorizontal!=0 && !select) {
cursor.xCoarse=e->getTotalChannelCount()-1; cursor.xCoarse=e->getTotalChannelCount()-1;
cursor.xFine=2+e->song.pat[cursor.xCoarse].effectRows*2; cursor.xFine=2+e->song.pat[cursor.xCoarse].effectRows*2;
if (settings.wrapHorizontal==2) y--; if (settings.wrapHorizontal==2) y--;
@ -2512,7 +2514,7 @@ void FurnaceGUI::moveCursor(int x, int y) {
for (int i=0; i<y; i++) { for (int i=0; i<y; i++) {
cursor.y++; cursor.y++;
if (cursor.y>=e->song.patLen) { if (cursor.y>=e->song.patLen) {
if (settings.wrapVertical!=0) { if (settings.wrapVertical!=0 && !select) {
cursor.y=0; cursor.y=0;
if (settings.wrapVertical==2) { if (settings.wrapVertical==2) {
if (!e->isPlaying() && e->getOrder()<(e->song.ordersLen-1)) { if (!e->isPlaying() && e->getOrder()<(e->song.ordersLen-1)) {
@ -2530,7 +2532,7 @@ void FurnaceGUI::moveCursor(int x, int y) {
for (int i=0; i<-y; i++) { for (int i=0; i<-y; i++) {
cursor.y--; cursor.y--;
if (cursor.y<0) { if (cursor.y<0) {
if (settings.wrapVertical!=0) { if (settings.wrapVertical!=0 && !select) {
cursor.y=e->song.patLen-1; cursor.y=e->song.patLen-1;
if (settings.wrapVertical==2) { if (settings.wrapVertical==2) {
if (!e->isPlaying() && e->getOrder()>0) { if (!e->isPlaying() && e->getOrder()>0) {
@ -2546,7 +2548,9 @@ void FurnaceGUI::moveCursor(int x, int y) {
} }
} }
} }
selStart=cursor; if (!select) {
selStart=cursor;
}
selEnd=cursor; selEnd=cursor;
updateScroll(cursor.y); updateScroll(cursor.y);
} }
@ -3228,22 +3232,22 @@ void FurnaceGUI::keyDown(SDL_Event& ev) {
edit=!edit; edit=!edit;
break; break;
case SDLK_UP: case SDLK_UP:
moveCursor(0,-1); moveCursor(0,-1,ev.key.keysym.mod&KMOD_SHIFT);
break; break;
case SDLK_DOWN: case SDLK_DOWN:
moveCursor(0,1); moveCursor(0,1,ev.key.keysym.mod&KMOD_SHIFT);
break; break;
case SDLK_LEFT: case SDLK_LEFT:
moveCursor(-1,0); moveCursor(-1,0,ev.key.keysym.mod&KMOD_SHIFT);
break; break;
case SDLK_RIGHT: case SDLK_RIGHT:
moveCursor(1,0); moveCursor(1,0,ev.key.keysym.mod&KMOD_SHIFT);
break; break;
case SDLK_PAGEUP: case SDLK_PAGEUP:
moveCursor(0,-16); moveCursor(0,-16,ev.key.keysym.mod&KMOD_SHIFT);
break; break;
case SDLK_PAGEDOWN: case SDLK_PAGEDOWN:
moveCursor(0,16); moveCursor(0,16,ev.key.keysym.mod&KMOD_SHIFT);
break; break;
case SDLK_HOME: case SDLK_HOME:
moveCursorTop(); moveCursorTop();
@ -3756,6 +3760,7 @@ bool FurnaceGUI::loop() {
macroLoopDragActive=false; macroLoopDragActive=false;
waveDragActive=false; waveDragActive=false;
if (selecting) { if (selecting) {
cursor=selEnd;
finishSelection(); finishSelection();
if (cursor.xCoarse==selStart.xCoarse && cursor.xFine==selStart.xFine && cursor.y==selStart.y && if (cursor.xCoarse==selStart.xCoarse && cursor.xFine==selStart.xFine && cursor.y==selStart.y &&
cursor.xCoarse==selEnd.xCoarse && cursor.xFine==selEnd.xFine && cursor.y==selEnd.y) { cursor.xCoarse==selEnd.xCoarse && cursor.xFine==selEnd.xFine && cursor.y==selEnd.y) {

View file

@ -317,7 +317,7 @@ class FurnaceGUI {
void updateSelection(int xCoarse, int xFine, int y); void updateSelection(int xCoarse, int xFine, int y);
void finishSelection(); void finishSelection();
void moveCursor(int x, int y); void moveCursor(int x, int y, bool select);
void moveCursorTop(); void moveCursorTop();
void moveCursorBottom(); void moveCursorBottom();
void editAdvance(); void editAdvance();