diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index dc72ccadd..576470bf0 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -2495,6 +2495,7 @@ void FurnaceGUI::moveCursorPrevChannel(bool overflow) { selStart=cursor; selEnd=cursor; + demandScrollX=true; } void FurnaceGUI::moveCursorNextChannel(bool overflow) { @@ -2517,6 +2518,7 @@ void FurnaceGUI::moveCursorNextChannel(bool overflow) { selStart=cursor; selEnd=cursor; + demandScrollX=true; } void FurnaceGUI::moveCursorTop(bool select) { @@ -2526,6 +2528,7 @@ void FurnaceGUI::moveCursorTop(bool select) { DETERMINE_FIRST; cursor.xCoarse=firstChannel; cursor.xFine=0; + demandScrollX=true; } else { cursor.y=0; } @@ -2543,6 +2546,7 @@ void FurnaceGUI::moveCursorBottom(bool select) { DETERMINE_LAST; cursor.xCoarse=lastChannel-1; cursor.xFine=2+e->song.pat[cursor.xCoarse].effectRows*2; + demandScrollX=true; } else { cursor.y=e->song.patLen-1; } @@ -2873,7 +2877,7 @@ void FurnaceGUI::doCopy(bool cut) { } } -void FurnaceGUI::doPaste() { +void FurnaceGUI::doPaste(PasteMode mode) { finishSelection(); prepareUndo(GUI_UNDO_PATTERN_PASTE); char* clipText=SDL_GetClipboardText(); @@ -4406,6 +4410,99 @@ void FurnaceGUI::processDrags(int dragX, int dragY) { #define BIND_FOR(x) getKeyName(actionKeys[x],true).c_str() +void FurnaceGUI::editOptions(bool topMenu) { + char id[4096]; + if (ImGui::MenuItem("cut",BIND_FOR(GUI_ACTION_PAT_CUT))) doCopy(true); + if (ImGui::MenuItem("copy",BIND_FOR(GUI_ACTION_PAT_COPY))) doCopy(false); + if (ImGui::MenuItem("paste",BIND_FOR(GUI_ACTION_PAT_PASTE))) doPaste(); + if (ImGui::BeginMenu("paste special...")) { + ImGui::MenuItem("paste mix",BIND_FOR(GUI_ACTION_PAT_PASTE_MIX)); + ImGui::MenuItem("paste mix (background)",BIND_FOR(GUI_ACTION_PAT_PASTE_MIX_BG)); + ImGui::MenuItem("paste flood",BIND_FOR(GUI_ACTION_PAT_PASTE_FLOOD)); + ImGui::MenuItem("paste overflow",BIND_FOR(GUI_ACTION_PAT_PASTE_OVERFLOW)); + ImGui::EndMenu(); + } + if (ImGui::MenuItem("delete",BIND_FOR(GUI_ACTION_PAT_DELETE))) doDelete(); + if (topMenu) { + if (ImGui::MenuItem("select all",BIND_FOR(GUI_ACTION_PAT_SELECT_ALL))) doSelectAll(); + } + ImGui::Separator(); + + if (ImGui::MenuItem("set latch",BIND_FOR(GUI_ACTION_PAT_LATCH))) { + // TODO + } + ImGui::Separator(); + + if (ImGui::MenuItem("note up",BIND_FOR(GUI_ACTION_PAT_NOTE_UP))) doTranspose(1); + if (ImGui::MenuItem("note down",BIND_FOR(GUI_ACTION_PAT_NOTE_DOWN))) doTranspose(-1); + if (ImGui::MenuItem("octave up",BIND_FOR(GUI_ACTION_PAT_OCTAVE_UP))) doTranspose(12); + if (ImGui::MenuItem("octave down",BIND_FOR(GUI_ACTION_PAT_OCTAVE_DOWN))) doTranspose(-12); + if (ImGui::InputInt("##TransposeAmount",&transposeAmount,1,1)) { + if (transposeAmount<-96) transposeAmount=-96; + if (transposeAmount>96) transposeAmount=96; + } + ImGui::SameLine(); + if (ImGui::Button("Transpose")) { + doTranspose(transposeAmount); + ImGui::CloseCurrentPopup(); + } + + ImGui::Separator(); + ImGui::MenuItem("interpolate",BIND_FOR(GUI_ACTION_PAT_INTERPOLATE)); + ImGui::MenuItem("fade in",BIND_FOR(GUI_ACTION_PAT_FADE_IN)); + ImGui::MenuItem("fade out",BIND_FOR(GUI_ACTION_PAT_FADE_OUT)); + if (ImGui::BeginMenu("change instrument...")) { + if (e->song.ins.empty()) { + ImGui::Text("no instruments available"); + } + for (size_t i=0; isong.ins.size(); i++) { + snprintf(id,4095,"%.2X: %s",(int)i,e->song.ins[i]->name.c_str()); + if (ImGui::MenuItem(id)) { // TODO + } + } + ImGui::EndMenu(); + } + if (ImGui::BeginMenu("scale...")) { + if (ImGui::InputFloat("Bottom",&scaleMin,1,1,"%.1f%%")) { + if (scaleMin<0.0f) scaleMin=0.0f; + if (scaleMin>100.0f) scaleMin=100.0f; + } + if (ImGui::InputFloat("Top",&scaleMax,1,1,"%.1f%%")) { + if (scaleMax<0.0f) scaleMax=0.0f; + if (scaleMax>100.0f) scaleMax=100.0f; + } + if (ImGui::Button("Scale")) { + ImGui::CloseCurrentPopup(); + } + ImGui::EndMenu(); + } + if (ImGui::BeginMenu("randomize...")) { + ImGui::InputInt("Minimum",&randomizeMin,1,1); + ImGui::InputInt("Maximum",&randomizeMax,1,1); + if (ImGui::Button("Randomize")) { + ImGui::CloseCurrentPopup(); + } + ImGui::EndMenu(); + } + ImGui::MenuItem("invert values",BIND_FOR(GUI_ACTION_PAT_INVERT_VALUES)); + + ImGui::Separator(); + + ImGui::MenuItem("flip selection",BIND_FOR(GUI_ACTION_PAT_FLIP_SELECTION)); + ImGui::MenuItem("collapse",BIND_FOR(GUI_ACTION_PAT_COLLAPSE_ROWS)); + ImGui::MenuItem("expand",BIND_FOR(GUI_ACTION_PAT_EXPAND_ROWS)); + + if (topMenu) { + ImGui::Separator(); + ImGui::MenuItem("collapse pattern",BIND_FOR(GUI_ACTION_PAT_COLLAPSE_PAT)); + ImGui::MenuItem("expand pattern",BIND_FOR(GUI_ACTION_PAT_EXPAND_PAT)); + + ImGui::Separator(); + ImGui::MenuItem("collapse song",BIND_FOR(GUI_ACTION_PAT_COLLAPSE_SONG)); + ImGui::MenuItem("expand song",BIND_FOR(GUI_ACTION_PAT_EXPAND_SONG)); + } +} + bool FurnaceGUI::loop() { while (!quit) { SDL_Event ev; @@ -5059,16 +5156,7 @@ bool FurnaceGUI::loop() { if (ImGui::MenuItem("undo",BIND_FOR(GUI_ACTION_UNDO))) doUndo(); if (ImGui::MenuItem("redo",BIND_FOR(GUI_ACTION_REDO))) doRedo(); ImGui::Separator(); - if (ImGui::MenuItem("cut",BIND_FOR(GUI_ACTION_PAT_CUT))) doCopy(true); - if (ImGui::MenuItem("copy",BIND_FOR(GUI_ACTION_PAT_COPY))) doCopy(false); - if (ImGui::MenuItem("paste",BIND_FOR(GUI_ACTION_PAT_PASTE))) doPaste(); - if (ImGui::MenuItem("delete",BIND_FOR(GUI_ACTION_PAT_DELETE))) doDelete(); - if (ImGui::MenuItem("select all",BIND_FOR(GUI_ACTION_PAT_SELECT_ALL))) doSelectAll(); - ImGui::Separator(); - if (ImGui::MenuItem("note up",BIND_FOR(GUI_ACTION_PAT_NOTE_UP))) doTranspose(1); - if (ImGui::MenuItem("note down",BIND_FOR(GUI_ACTION_PAT_NOTE_DOWN))) doTranspose(-1); - if (ImGui::MenuItem("octave up",BIND_FOR(GUI_ACTION_PAT_OCTAVE_UP))) doTranspose(12); - if (ImGui::MenuItem("octave down",BIND_FOR(GUI_ACTION_PAT_OCTAVE_DOWN))) doTranspose(-12); + editOptions(true); /*ImGui::Separator(); ImGui::MenuItem("clear...");*/ ImGui::EndMenu(); @@ -6171,6 +6259,11 @@ FurnaceGUI::FurnaceGUI(): bindSetPending(false), nextScroll(-1.0f), nextAddScroll(0.0f), + transposeAmount(0), + randomizeMin(0), + randomizeMax(255), + scaleMin(0.0f), + scaleMax(100.0f), oldOrdersLen(0) { // octave 1 diff --git a/src/gui/gui.h b/src/gui/gui.h index 7f200e381..99285d086 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -234,6 +234,10 @@ enum FurnaceGUIActions { GUI_ACTION_PAT_CUT, GUI_ACTION_PAT_COPY, GUI_ACTION_PAT_PASTE, + GUI_ACTION_PAT_PASTE_MIX, + GUI_ACTION_PAT_PASTE_MIX_BG, + GUI_ACTION_PAT_PASTE_FLOOD, + GUI_ACTION_PAT_PASTE_OVERFLOW, GUI_ACTION_PAT_CURSOR_UP, GUI_ACTION_PAT_CURSOR_DOWN, GUI_ACTION_PAT_CURSOR_LEFT, @@ -269,6 +273,18 @@ enum FurnaceGUIActions { GUI_ACTION_PAT_COLLAPSE, GUI_ACTION_PAT_INCREASE_COLUMNS, GUI_ACTION_PAT_DECREASE_COLUMNS, + GUI_ACTION_PAT_INTERPOLATE, + GUI_ACTION_PAT_FADE_IN, + GUI_ACTION_PAT_FADE_OUT, + GUI_ACTION_PAT_INVERT_VALUES, + GUI_ACTION_PAT_FLIP_SELECTION, + GUI_ACTION_PAT_COLLAPSE_ROWS, + GUI_ACTION_PAT_EXPAND_ROWS, + GUI_ACTION_PAT_COLLAPSE_PAT, + GUI_ACTION_PAT_EXPAND_PAT, + GUI_ACTION_PAT_COLLAPSE_SONG, + GUI_ACTION_PAT_EXPAND_SONG, + GUI_ACTION_PAT_LATCH, GUI_ACTION_PAT_MAX, GUI_ACTION_INS_LIST_MIN, @@ -335,6 +351,14 @@ enum FurnaceGUIActions { GUI_ACTION_MAX }; +enum PasteMode { + GUI_PASTE_MODE_NORMAL=0, + GUI_PASTE_MODE_MIX_FG, + GUI_PASTE_MODE_MIX_BG, + GUI_PASTE_MODE_FLOOD, + GUI_PASTE_MODE_OVERFLOW +}; + #define FURKMOD_CTRL (1<<31) #define FURKMOD_SHIFT (1<<29) #define FURKMOD_META (1<<28) @@ -651,6 +675,8 @@ class FurnaceGUI { ImVec2 threeChars, twoChars; SelectionPoint sel1, sel2; int dummyRows, demandX; + int transposeAmount, randomizeMin, randomizeMax; + float scaleMin, scaleMax; int oldOrdersLen; DivOrders oldOrders; @@ -719,9 +745,10 @@ class FurnaceGUI { void doInsert(); void doTranspose(int amount); void doCopy(bool cut); - void doPaste(); + void doPaste(PasteMode mode=GUI_PASTE_MODE_NORMAL); void doUndo(); void doRedo(); + void editOptions(bool topMenu); void play(int row=0); void stop(); diff --git a/src/gui/pattern.cpp b/src/gui/pattern.cpp index 9bf6eee59..b2ff56cec 100644 --- a/src/gui/pattern.cpp +++ b/src/gui/pattern.cpp @@ -813,21 +813,7 @@ void FurnaceGUI::drawPattern() { if (patternOpen) { if (!inhibitMenu && ImGui::IsItemClicked(ImGuiMouseButton_Right)) ImGui::OpenPopup("patternActionMenu"); if (ImGui::BeginPopup("patternActionMenu",ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings)) { - char id[4096]; - ImGui::Selectable("cut"); - ImGui::Selectable("copy"); - ImGui::Selectable("paste"); - if (ImGui::BeginMenu("change instrument...")) { - if (e->song.ins.empty()) { - ImGui::Text("no instruments available"); - } - for (size_t i=0; isong.ins.size(); i++) { - snprintf(id,4095,"%.2X: %s",(int)i,e->song.ins[i]->name.c_str()); - if (ImGui::Selectable(id)) { // TODO - } - } - ImGui::EndMenu(); - } + editOptions(false); ImGui::EndPopup(); } }