GUI: new pattern cursor logic, part 12
dragging
This commit is contained in:
parent
ae3444566b
commit
0bbdfa877e
|
@ -130,21 +130,42 @@ void FurnaceGUI::updateSelection(int xCoarse, int xFine, int y, int ord, bool fu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: new cursor logic
|
int dragStartYAbs=dragStart.y+(dragStart.order*e->curSubSong->patLen);
|
||||||
if (dragStart.y+(dragDestinationY-dragSourceY)<0) {
|
int dragEndYAbs=dragEnd.y+(dragEnd.order*e->curSubSong->patLen);
|
||||||
dragDestinationY=dragSourceY-dragStart.y;
|
int dragSourceYAbs=dragSourceY+(dragSourceOrder*e->curSubSong->patLen);
|
||||||
}
|
int dragDestinationYAbs=dragDestinationY+(dragDestinationOrder*e->curSubSong->patLen);
|
||||||
|
|
||||||
if (dragEnd.y+(dragDestinationY-dragSourceY)>=e->curSubSong->patLen) {
|
if (e->curSubSong->patLen>0) {
|
||||||
dragDestinationY=e->curSubSong->patLen-(dragEnd.y-dragSourceY)-1;
|
int newSelStartYAbs=dragStartYAbs+(dragDestinationYAbs-dragSourceYAbs);
|
||||||
}
|
int newSelEndYAbs=dragEndYAbs+(dragDestinationYAbs-dragSourceYAbs);
|
||||||
|
|
||||||
selStart.xCoarse=dragStart.xCoarse+(dragDestinationX-dragSourceX);
|
logV("SS: %d SE: %d",newSelStartYAbs,newSelEndYAbs);
|
||||||
selStart.xFine=dragStart.xFine+(dragDestinationXFine-dragSourceXFine);
|
|
||||||
selStart.y=dragStart.y+(dragDestinationY-dragSourceY);
|
if (newSelStartYAbs<0) {
|
||||||
selEnd.xCoarse=dragEnd.xCoarse+(dragDestinationX-dragSourceX);
|
int newDragDestination=dragSourceYAbs-dragStartYAbs;
|
||||||
selEnd.xFine=dragEnd.xFine+(dragDestinationXFine-dragSourceXFine);
|
newSelStartYAbs=0;
|
||||||
selEnd.y=dragEnd.y+(dragDestinationY-dragSourceY);
|
newSelEndYAbs=dragEndYAbs-dragStartYAbs;
|
||||||
|
dragDestinationY=newDragDestination%e->curSubSong->patLen;
|
||||||
|
dragDestinationOrder=newDragDestination/e->curSubSong->patLen;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newSelEndYAbs>=(e->curSubSong->ordersLen*e->curSubSong->patLen)) {
|
||||||
|
int newDragDestination=(e->curSubSong->ordersLen*e->curSubSong->patLen)-(dragEndYAbs-dragSourceYAbs)-1;
|
||||||
|
newSelStartYAbs=(e->curSubSong->ordersLen*e->curSubSong->patLen)-1-(dragEndYAbs-dragStartYAbs);
|
||||||
|
newSelEndYAbs=(e->curSubSong->ordersLen*e->curSubSong->patLen)-1;
|
||||||
|
dragDestinationY=newDragDestination%e->curSubSong->patLen;
|
||||||
|
dragDestinationOrder=newDragDestination/e->curSubSong->patLen;
|
||||||
|
}
|
||||||
|
|
||||||
|
selStart.xCoarse=dragStart.xCoarse+(dragDestinationX-dragSourceX);
|
||||||
|
selStart.xFine=dragStart.xFine+(dragDestinationXFine-dragSourceXFine);
|
||||||
|
selStart.y=newSelStartYAbs%e->curSubSong->patLen;
|
||||||
|
selStart.order=newSelStartYAbs/e->curSubSong->patLen;
|
||||||
|
selEnd.xCoarse=dragEnd.xCoarse+(dragDestinationX-dragSourceX);
|
||||||
|
selEnd.xFine=dragEnd.xFine+(dragDestinationXFine-dragSourceXFine);
|
||||||
|
selEnd.y=newSelEndYAbs%e->curSubSong->patLen;
|
||||||
|
selEnd.order=newSelEndYAbs/e->curSubSong->patLen;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (selectingFull) {
|
if (selectingFull) {
|
||||||
DETERMINE_LAST;
|
DETERMINE_LAST;
|
||||||
|
|
|
@ -626,6 +626,7 @@ void FurnaceGUI::doPasteFurnace(PasteMode mode, int arg, bool readClipboard, Str
|
||||||
DETERMINE_LAST;
|
DETERMINE_LAST;
|
||||||
|
|
||||||
int j=cursor.y;
|
int j=cursor.y;
|
||||||
|
int jOrder=cursor.order;
|
||||||
char note[4];
|
char note[4];
|
||||||
for (size_t i=2; i<data.size() && j<e->curSubSong->patLen; i++) {
|
for (size_t i=2; i<data.size() && j<e->curSubSong->patLen; i++) {
|
||||||
size_t charPos=0;
|
size_t charPos=0;
|
||||||
|
@ -635,7 +636,7 @@ void FurnaceGUI::doPasteFurnace(PasteMode mode, int arg, bool readClipboard, Str
|
||||||
String& line=data[i];
|
String& line=data[i];
|
||||||
|
|
||||||
while (charPos<line.size() && iCoarse<lastChannel) {
|
while (charPos<line.size() && iCoarse<lastChannel) {
|
||||||
DivPattern* pat=e->curPat[iCoarse].getPattern(e->curOrders->ord[iCoarse][curOrder],true);
|
DivPattern* pat=e->curPat[iCoarse].getPattern(e->curOrders->ord[iCoarse][jOrder],true);
|
||||||
if (line[charPos]=='|') {
|
if (line[charPos]=='|') {
|
||||||
iCoarse++;
|
iCoarse++;
|
||||||
if (iCoarse<lastChannel) while (!e->curSubSong->chanShow[iCoarse]) {
|
if (iCoarse<lastChannel) while (!e->curSubSong->chanShow[iCoarse]) {
|
||||||
|
@ -741,9 +742,9 @@ void FurnaceGUI::doPasteFurnace(PasteMode mode, int arg, bool readClipboard, Str
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
j++;
|
j++;
|
||||||
if (mode==GUI_PASTE_MODE_OVERFLOW && j>=e->curSubSong->patLen && curOrder<e->curSubSong->ordersLen-1) {
|
if (mode==GUI_PASTE_MODE_OVERFLOW && j>=e->curSubSong->patLen && jOrder<e->curSubSong->ordersLen-1) {
|
||||||
j=0;
|
j=0;
|
||||||
curOrder++;
|
jOrder++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode==GUI_PASTE_MODE_FLOOD && i==data.size()-1) {
|
if (mode==GUI_PASTE_MODE_FLOOD && i==data.size()-1) {
|
||||||
|
@ -751,8 +752,9 @@ void FurnaceGUI::doPasteFurnace(PasteMode mode, int arg, bool readClipboard, Str
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
curOrder=jOrder;
|
||||||
if (mode==GUI_PASTE_MODE_OVERFLOW && !e->isPlaying()) {
|
if (mode==GUI_PASTE_MODE_OVERFLOW && !e->isPlaying()) {
|
||||||
setOrder(curOrder);
|
setOrder(jOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (readClipboard) {
|
if (readClipboard) {
|
||||||
|
@ -986,6 +988,7 @@ void FurnaceGUI::doPasteMPT(PasteMode mode, int arg, bool readClipboard, String
|
||||||
DETERMINE_LAST;
|
DETERMINE_LAST;
|
||||||
|
|
||||||
int j=cursor.y;
|
int j=cursor.y;
|
||||||
|
int jOrder=cursor.order;
|
||||||
char note[4];
|
char note[4];
|
||||||
bool invalidData=false;
|
bool invalidData=false;
|
||||||
|
|
||||||
|
@ -997,7 +1000,7 @@ void FurnaceGUI::doPasteMPT(PasteMode mode, int arg, bool readClipboard, String
|
||||||
int iFine=0;
|
int iFine=0;
|
||||||
String& line=data[i];
|
String& line=data[i];
|
||||||
while (charPos<line.size() && iCoarse<lastChannel) {
|
while (charPos<line.size() && iCoarse<lastChannel) {
|
||||||
DivPattern* pat=e->curPat[iCoarse].getPattern(e->curOrders->ord[iCoarse][curOrder],true);
|
DivPattern* pat=e->curPat[iCoarse].getPattern(e->curOrders->ord[iCoarse][jOrder],true);
|
||||||
if (line[charPos]=='|' && charPos!=0) { // MPT format starts every pattern line with '|'
|
if (line[charPos]=='|' && charPos!=0) { // MPT format starts every pattern line with '|'
|
||||||
iCoarse++;
|
iCoarse++;
|
||||||
if (iCoarse<lastChannel) {
|
if (iCoarse<lastChannel) {
|
||||||
|
@ -1214,9 +1217,9 @@ void FurnaceGUI::doPasteMPT(PasteMode mode, int arg, bool readClipboard, String
|
||||||
}
|
}
|
||||||
|
|
||||||
j++;
|
j++;
|
||||||
if (mode==GUI_PASTE_MODE_OVERFLOW && j>=e->curSubSong->patLen && curOrder<e->curSubSong->ordersLen-1) {
|
if (mode==GUI_PASTE_MODE_OVERFLOW && j>=e->curSubSong->patLen && jOrder<e->curSubSong->ordersLen-1) {
|
||||||
j=0;
|
j=0;
|
||||||
curOrder++;
|
jOrder++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode==GUI_PASTE_MODE_FLOOD && i==data.size()-1) {
|
if (mode==GUI_PASTE_MODE_FLOOD && i==data.size()-1) {
|
||||||
|
@ -1224,6 +1227,11 @@ void FurnaceGUI::doPasteMPT(PasteMode mode, int arg, bool readClipboard, String
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
curOrder=jOrder;
|
||||||
|
if (mode==GUI_PASTE_MODE_OVERFLOW && !e->isPlaying()) {
|
||||||
|
setOrder(jOrder);
|
||||||
|
}
|
||||||
|
|
||||||
if (readClipboard) {
|
if (readClipboard) {
|
||||||
if (settings.cursorPastePos) {
|
if (settings.cursorPastePos) {
|
||||||
makeCursorUndo();
|
makeCursorUndo();
|
||||||
|
@ -1291,8 +1299,8 @@ void FurnaceGUI::doPaste(PasteMode mode, int arg, bool readClipboard, String cli
|
||||||
UndoRegion ur;
|
UndoRegion ur;
|
||||||
if (mode==GUI_PASTE_MODE_OVERFLOW) {
|
if (mode==GUI_PASTE_MODE_OVERFLOW) {
|
||||||
int rows=cursor.y;
|
int rows=cursor.y;
|
||||||
int firstPattern=curOrder;
|
int firstPattern=cursor.order;
|
||||||
int lastPattern=curOrder;
|
int lastPattern=cursor.order;
|
||||||
rows+=data.size();
|
rows+=data.size();
|
||||||
while (rows>=e->curSubSong->patLen) {
|
while (rows>=e->curSubSong->patLen) {
|
||||||
lastPattern++;
|
lastPattern++;
|
||||||
|
@ -2010,7 +2018,8 @@ void FurnaceGUI::doDrag(bool copy) {
|
||||||
|
|
||||||
// replace
|
// replace
|
||||||
cursor=selStart;
|
cursor=selStart;
|
||||||
doPaste(GUI_PASTE_MODE_NORMAL,0,false,c);
|
doPaste(GUI_PASTE_MODE_OVERFLOW,0,false,c);
|
||||||
|
updateScroll(cursor.y);
|
||||||
|
|
||||||
makeUndo(GUI_UNDO_PATTERN_DRAG);
|
makeUndo(GUI_UNDO_PATTERN_DRAG);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue