mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-26 22:43:01 +00:00
GUI: prepare for drag selection to move
This commit is contained in:
parent
af8c6313df
commit
ea082b255c
5 changed files with 98 additions and 11 deletions
|
@ -43,6 +43,22 @@ void FurnaceGUI::startSelection(int xCoarse, int xFine, int y, bool fullRow) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (settings.dragMovesSelection && !fullRow) {
|
||||||
|
if (xCoarse>=selStart.xCoarse && (xFine>=selStart.xFine || xCoarse>selStart.xCoarse) && y>=selStart.y &&
|
||||||
|
xCoarse<=selEnd.xCoarse && (xFine<=selEnd.xFine || xCoarse<selEnd.xCoarse) && y<=selEnd.y) {
|
||||||
|
dragging=true;
|
||||||
|
selecting=true;
|
||||||
|
selectingFull=false;
|
||||||
|
dragSourceX=xCoarse;
|
||||||
|
dragSourceY=y;
|
||||||
|
dragDestinationX=xCoarse;
|
||||||
|
dragDestinationY=y;
|
||||||
|
dragStart=selStart;
|
||||||
|
dragEnd=selEnd;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (fullRow) {
|
if (fullRow) {
|
||||||
selStart.xCoarse=firstChannel;
|
selStart.xCoarse=firstChannel;
|
||||||
selStart.xFine=0;
|
selStart.xFine=0;
|
||||||
|
@ -68,6 +84,20 @@ void FurnaceGUI::startSelection(int xCoarse, int xFine, int y, bool fullRow) {
|
||||||
|
|
||||||
void FurnaceGUI::updateSelection(int xCoarse, int xFine, int y, bool fullRow) {
|
void FurnaceGUI::updateSelection(int xCoarse, int xFine, int y, bool fullRow) {
|
||||||
if (!selecting) return;
|
if (!selecting) return;
|
||||||
|
if (dragging) {
|
||||||
|
dragDestinationX=xCoarse;
|
||||||
|
dragDestinationY=y;
|
||||||
|
cursorDrag.xCoarse=xCoarse;
|
||||||
|
cursorDrag.xFine=xFine;
|
||||||
|
cursorDrag.y=y;
|
||||||
|
|
||||||
|
selStart.xCoarse=dragStart.xCoarse+(dragDestinationX-dragSourceX);
|
||||||
|
selStart.xFine=dragStart.xFine;
|
||||||
|
selStart.y=dragStart.y+(dragDestinationY-dragSourceY);
|
||||||
|
selEnd.xCoarse=dragEnd.xCoarse+(dragDestinationX-dragSourceX);
|
||||||
|
selEnd.xFine=dragEnd.xFine;
|
||||||
|
selEnd.y=dragEnd.y+(dragDestinationY-dragSourceY);
|
||||||
|
} else {
|
||||||
if (selectingFull) {
|
if (selectingFull) {
|
||||||
DETERMINE_LAST;
|
DETERMINE_LAST;
|
||||||
selEnd.xCoarse=lastChannel-1;
|
selEnd.xCoarse=lastChannel-1;
|
||||||
|
@ -79,6 +109,7 @@ void FurnaceGUI::updateSelection(int xCoarse, int xFine, int y, bool fullRow) {
|
||||||
selEnd.y=y;
|
selEnd.y=y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FurnaceGUI::finishSelection() {
|
void FurnaceGUI::finishSelection() {
|
||||||
// swap points if needed
|
// swap points if needed
|
||||||
|
@ -103,6 +134,18 @@ void FurnaceGUI::finishSelection() {
|
||||||
selecting=false;
|
selecting=false;
|
||||||
selectingFull=false;
|
selectingFull=false;
|
||||||
|
|
||||||
|
if (dragging) {
|
||||||
|
if (dragSourceX==dragDestinationX && dragSourceY==dragDestinationY) {
|
||||||
|
cursor=cursorDrag;
|
||||||
|
selStart=cursorDrag;
|
||||||
|
selEnd=cursorDrag;
|
||||||
|
} else { // perform drag
|
||||||
|
doDrag();
|
||||||
|
}
|
||||||
|
|
||||||
|
dragging=false;
|
||||||
|
}
|
||||||
|
|
||||||
// boundary check
|
// boundary check
|
||||||
int chanCount=e->getTotalChannelCount();
|
int chanCount=e->getTotalChannelCount();
|
||||||
|
|
||||||
|
|
|
@ -918,6 +918,32 @@ void FurnaceGUI::doExpand(int multiplier) {
|
||||||
makeUndo(GUI_UNDO_PATTERN_EXPAND);
|
makeUndo(GUI_UNDO_PATTERN_EXPAND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 1. COPY
|
||||||
|
// 2. CLEAR
|
||||||
|
// 3. PASTE
|
||||||
|
void FurnaceGUI::doDrag() {
|
||||||
|
int iCoarse=selStart.xCoarse;
|
||||||
|
int iFine=selStart.xFine;
|
||||||
|
for (; iCoarse<=selEnd.xCoarse; iCoarse++) {
|
||||||
|
if (!e->curSubSong->chanShow[iCoarse]) continue;
|
||||||
|
DivPattern* pat=e->curPat[iCoarse].getPattern(e->curOrders->ord[iCoarse][curOrder],true);
|
||||||
|
for (; iFine<3+e->curPat[iCoarse].effectCols*2 && (iCoarse<selEnd.xCoarse || iFine<=selEnd.xFine); iFine++) {
|
||||||
|
for (int j=selStart.y; j<=selEnd.y; j++) {
|
||||||
|
if (iFine==0) {
|
||||||
|
pat->data[j][iFine]=0;
|
||||||
|
if (selStart.y==selEnd.y) pat->data[j][2]=-1;
|
||||||
|
}
|
||||||
|
pat->data[j][iFine+1]=(iFine<1)?0:-1;
|
||||||
|
|
||||||
|
if (selStart.y==selEnd.y && iFine>2 && iFine&1 && settings.effectDeletionAltersValue) {
|
||||||
|
pat->data[j][iFine+2]=-1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
iFine=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FurnaceGUI::doUndo() {
|
void FurnaceGUI::doUndo() {
|
||||||
if (undoHist.empty()) return;
|
if (undoHist.empty()) return;
|
||||||
UndoStep& us=undoHist.back();
|
UndoStep& us=undoHist.back();
|
||||||
|
|
|
@ -4372,6 +4372,10 @@ FurnaceGUI::FurnaceGUI():
|
||||||
latchTarget(0),
|
latchTarget(0),
|
||||||
wheelX(0),
|
wheelX(0),
|
||||||
wheelY(0),
|
wheelY(0),
|
||||||
|
dragSourceX(0),
|
||||||
|
dragSourceY(0),
|
||||||
|
dragDestinationX(0),
|
||||||
|
dragDestinationY(0),
|
||||||
exportFadeOut(5.0),
|
exportFadeOut(5.0),
|
||||||
editControlsOpen(true),
|
editControlsOpen(true),
|
||||||
ordersOpen(true),
|
ordersOpen(true),
|
||||||
|
@ -4403,6 +4407,7 @@ FurnaceGUI::FurnaceGUI():
|
||||||
findOpen(false),
|
findOpen(false),
|
||||||
selecting(false),
|
selecting(false),
|
||||||
selectingFull(false),
|
selectingFull(false),
|
||||||
|
dragging(false),
|
||||||
curNibble(false),
|
curNibble(false),
|
||||||
orderNibble(false),
|
orderNibble(false),
|
||||||
followOrders(true),
|
followOrders(true),
|
||||||
|
|
|
@ -1024,6 +1024,7 @@ class FurnaceGUI {
|
||||||
int effectValCellSpacing;
|
int effectValCellSpacing;
|
||||||
int doubleClickColumn;
|
int doubleClickColumn;
|
||||||
int blankIns;
|
int blankIns;
|
||||||
|
int dragMovesSelection;
|
||||||
unsigned int maxUndoSteps;
|
unsigned int maxUndoSteps;
|
||||||
String mainFontPath;
|
String mainFontPath;
|
||||||
String patFontPath;
|
String patFontPath;
|
||||||
|
@ -1124,6 +1125,7 @@ class FurnaceGUI {
|
||||||
effectValCellSpacing(0),
|
effectValCellSpacing(0),
|
||||||
doubleClickColumn(1),
|
doubleClickColumn(1),
|
||||||
blankIns(0),
|
blankIns(0),
|
||||||
|
dragMovesSelection(1),
|
||||||
maxUndoSteps(100),
|
maxUndoSteps(100),
|
||||||
mainFontPath(""),
|
mainFontPath(""),
|
||||||
patFontPath(""),
|
patFontPath(""),
|
||||||
|
@ -1138,7 +1140,7 @@ class FurnaceGUI {
|
||||||
|
|
||||||
int curIns, curWave, curSample, curOctave, curOrder, prevIns, oldRow, oldOrder, oldOrder1, editStep, exportLoops, soloChan, soloTimeout, orderEditMode, orderCursor;
|
int curIns, curWave, curSample, curOctave, curOrder, prevIns, oldRow, oldOrder, oldOrder1, editStep, exportLoops, soloChan, soloTimeout, orderEditMode, orderCursor;
|
||||||
int loopOrder, loopRow, loopEnd, isClipping, extraChannelButtons, patNameTarget, newSongCategory, latchTarget;
|
int loopOrder, loopRow, loopEnd, isClipping, extraChannelButtons, patNameTarget, newSongCategory, latchTarget;
|
||||||
int wheelX, wheelY;
|
int wheelX, wheelY, dragSourceX, dragSourceY, dragDestinationX, dragDestinationY;
|
||||||
|
|
||||||
double exportFadeOut;
|
double exportFadeOut;
|
||||||
|
|
||||||
|
@ -1148,8 +1150,8 @@ class FurnaceGUI {
|
||||||
bool pianoOpen, notesOpen, channelsOpen, regViewOpen, logOpen, effectListOpen, chanOscOpen;
|
bool pianoOpen, notesOpen, channelsOpen, regViewOpen, logOpen, effectListOpen, chanOscOpen;
|
||||||
bool subSongsOpen, findOpen;
|
bool subSongsOpen, findOpen;
|
||||||
|
|
||||||
SelectionPoint selStart, selEnd, cursor;
|
SelectionPoint selStart, selEnd, cursor, cursorDrag, dragStart, dragEnd;
|
||||||
bool selecting, selectingFull, curNibble, orderNibble, followOrders, followPattern, changeAllOrders, mobileUI;
|
bool selecting, selectingFull, dragging, curNibble, orderNibble, followOrders, followPattern, changeAllOrders, mobileUI;
|
||||||
bool collapseWindow, demandScrollX, fancyPattern, wantPatName, firstFrame, tempoView, waveHex, lockLayout, editOptsVisible, latchNibble, nonLatchNibble;
|
bool collapseWindow, demandScrollX, fancyPattern, wantPatName, firstFrame, tempoView, waveHex, lockLayout, editOptsVisible, latchNibble, nonLatchNibble;
|
||||||
FurnaceGUIWindows curWindow, nextWindow, curWindowLast;
|
FurnaceGUIWindows curWindow, nextWindow, curWindowLast;
|
||||||
float peak[2];
|
float peak[2];
|
||||||
|
@ -1465,6 +1467,7 @@ class FurnaceGUI {
|
||||||
void startSelection(int xCoarse, int xFine, int y, bool fullRow=false);
|
void startSelection(int xCoarse, int xFine, int y, bool fullRow=false);
|
||||||
void updateSelection(int xCoarse, int xFine, int y, bool fullRow=false);
|
void updateSelection(int xCoarse, int xFine, int y, bool fullRow=false);
|
||||||
void finishSelection();
|
void finishSelection();
|
||||||
|
void finishDrag();
|
||||||
|
|
||||||
void moveCursor(int x, int y, bool select);
|
void moveCursor(int x, int y, bool select);
|
||||||
void moveCursorPrevChannel(bool overflow);
|
void moveCursorPrevChannel(bool overflow);
|
||||||
|
@ -1494,6 +1497,7 @@ class FurnaceGUI {
|
||||||
void doRedo();
|
void doRedo();
|
||||||
void doFind();
|
void doFind();
|
||||||
void doReplace();
|
void doReplace();
|
||||||
|
void doDrag();
|
||||||
void editOptions(bool topMenu);
|
void editOptions(bool topMenu);
|
||||||
void noteInput(int num, int key, int vol=-1);
|
void noteInput(int num, int key, int vol=-1);
|
||||||
void valueInput(int num, bool direct=false, int target=-1);
|
void valueInput(int num, bool direct=false, int target=-1);
|
||||||
|
|
|
@ -412,6 +412,11 @@ void FurnaceGUI::drawSettings() {
|
||||||
settings.doubleClickColumn=doubleClickColumnB;
|
settings.doubleClickColumn=doubleClickColumnB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool dragMovesSelectionB=settings.dragMovesSelection;
|
||||||
|
if (ImGui::Checkbox("Allow dragging selection",&dragMovesSelectionB)) {
|
||||||
|
settings.dragMovesSelection=dragMovesSelectionB;
|
||||||
|
}
|
||||||
|
|
||||||
bool allowEditDockingB=settings.allowEditDocking;
|
bool allowEditDockingB=settings.allowEditDocking;
|
||||||
if (ImGui::Checkbox("Allow docking editors",&allowEditDockingB)) {
|
if (ImGui::Checkbox("Allow docking editors",&allowEditDockingB)) {
|
||||||
settings.allowEditDocking=allowEditDockingB;
|
settings.allowEditDocking=allowEditDockingB;
|
||||||
|
@ -2037,6 +2042,8 @@ void FurnaceGUI::syncSettings() {
|
||||||
settings.effectValCellSpacing=e->getConfInt("effectValCellSpacing",0);
|
settings.effectValCellSpacing=e->getConfInt("effectValCellSpacing",0);
|
||||||
settings.doubleClickColumn=e->getConfInt("doubleClickColumn",1);
|
settings.doubleClickColumn=e->getConfInt("doubleClickColumn",1);
|
||||||
settings.blankIns=e->getConfInt("blankIns",0);
|
settings.blankIns=e->getConfInt("blankIns",0);
|
||||||
|
// SET TO 1 AFTER YOU ARE DONE
|
||||||
|
settings.dragMovesSelection=e->getConfInt("dragMovesSelection",0);
|
||||||
|
|
||||||
clampSetting(settings.mainFontSize,2,96);
|
clampSetting(settings.mainFontSize,2,96);
|
||||||
clampSetting(settings.patFontSize,2,96);
|
clampSetting(settings.patFontSize,2,96);
|
||||||
|
@ -2121,6 +2128,7 @@ void FurnaceGUI::syncSettings() {
|
||||||
clampSetting(settings.effectValCellSpacing,0,32);
|
clampSetting(settings.effectValCellSpacing,0,32);
|
||||||
clampSetting(settings.doubleClickColumn,0,1);
|
clampSetting(settings.doubleClickColumn,0,1);
|
||||||
clampSetting(settings.blankIns,0,1);
|
clampSetting(settings.blankIns,0,1);
|
||||||
|
clampSetting(settings.dragMovesSelection,0,1);
|
||||||
|
|
||||||
settings.initialSys=e->decodeSysDesc(e->getConfString("initialSys",""));
|
settings.initialSys=e->decodeSysDesc(e->getConfString("initialSys",""));
|
||||||
if (settings.initialSys.size()<4) {
|
if (settings.initialSys.size()<4) {
|
||||||
|
@ -2254,6 +2262,7 @@ void FurnaceGUI::commitSettings() {
|
||||||
e->setConf("effectValCellSpacing",settings.effectValCellSpacing);
|
e->setConf("effectValCellSpacing",settings.effectValCellSpacing);
|
||||||
e->setConf("doubleClickColumn",settings.doubleClickColumn);
|
e->setConf("doubleClickColumn",settings.doubleClickColumn);
|
||||||
e->setConf("blankIns",settings.blankIns);
|
e->setConf("blankIns",settings.blankIns);
|
||||||
|
e->setConf("dragMovesSelection",settings.dragMovesSelection);
|
||||||
|
|
||||||
// colors
|
// colors
|
||||||
for (int i=0; i<GUI_COLOR_MAX; i++) {
|
for (int i=0; i<GUI_COLOR_MAX; i++) {
|
||||||
|
|
Loading…
Reference in a new issue