GUI: FM operator swapping

This commit is contained in:
tildearrow 2022-09-10 23:20:22 -05:00
parent 2952baaa54
commit 2f0e97f6d9
3 changed files with 40 additions and 2 deletions

View file

@ -5217,6 +5217,7 @@ FurnaceGUI::FurnaceGUI():
chanToMove(-1), chanToMove(-1),
sysToMove(-1), sysToMove(-1),
sysToDelete(-1), sysToDelete(-1),
opToMove(-1),
transposeAmount(0), transposeAmount(0),
randomizeMin(0), randomizeMin(0),
randomizeMax(255), randomizeMax(255),

View file

@ -1471,7 +1471,7 @@ class FurnaceGUI {
int renderTimeBegin, renderTimeEnd, renderTimeDelta; int renderTimeBegin, renderTimeEnd, renderTimeDelta;
int eventTimeBegin, eventTimeEnd, eventTimeDelta; int eventTimeBegin, eventTimeEnd, eventTimeDelta;
int chanToMove, sysToMove, sysToDelete; int chanToMove, sysToMove, sysToDelete, opToMove;
ImVec2 patWindowPos, patWindowSize; ImVec2 patWindowPos, patWindowSize;

View file

@ -1557,6 +1557,35 @@ void FurnaceGUI::drawMacros(std::vector<FurnaceGUIMacroDesc>& macros) {
#define CENTER_TEXT_20(text) \ #define CENTER_TEXT_20(text) \
ImGui::SetCursorPosX(ImGui::GetCursorPosX()+0.5*(20.0f*dpiScale-ImGui::CalcTextSize(text).x)); ImGui::SetCursorPosX(ImGui::GetCursorPosX()+0.5*(20.0f*dpiScale-ImGui::CalcTextSize(text).x));
#define OP_DRAG_POINT \
if (ImGui::Button(ICON_FA_ARROWS)) { \
} \
if (ImGui::BeginDragDropSource()) { \
opToMove=i; \
ImGui::SetDragDropPayload("FUR_OP",NULL,0,ImGuiCond_Once); \
ImGui::Button(ICON_FA_ARROWS "##SysDrag"); \
ImGui::EndDragDropSource(); \
} else if (ImGui::IsItemHovered()) { \
ImGui::SetTooltip("(drag to swap operators)"); \
} \
if (ImGui::BeginDragDropTarget()) { \
const ImGuiPayload* dragItem=ImGui::AcceptDragDropPayload("FUR_OP"); \
if (dragItem!=NULL) { \
if (dragItem->IsDataType("FUR_OP")) { \
if (opToMove!=i && opToMove>=0) { \
e->lockEngine([this,ins,i]() { \
DivInstrumentFM::Operator origOp=ins->fm.op[orderedOps[opToMove]]; \
ins->fm.op[orderedOps[opToMove]]=ins->fm.op[orderedOps[i]]; \
ins->fm.op[orderedOps[i]]=origOp; \
}); \
PARAMETER; \
} \
opToMove=-1; \
} \
} \
ImGui::EndDragDropTarget(); \
}
void FurnaceGUI::drawInsEdit() { void FurnaceGUI::drawInsEdit() {
if (nextWindow==GUI_WINDOW_INS_EDIT) { if (nextWindow==GUI_WINDOW_INS_EDIT) {
insEditOpen=true; insEditOpen=true;
@ -2074,6 +2103,9 @@ void FurnaceGUI::drawInsEdit() {
ImGui::Text("OP%d",i+1); ImGui::Text("OP%d",i+1);
} }
// drag point
OP_DRAG_POINT;
int maxTl=127; int maxTl=127;
if (ins->type==DIV_INS_OPLL) { if (ins->type==DIV_INS_OPLL) {
if (i==1) { if (i==1) {
@ -2356,7 +2388,10 @@ void FurnaceGUI::drawInsEdit() {
} else { } else {
snprintf(tempID,1024,"Operator %d",i+1); snprintf(tempID,1024,"Operator %d",i+1);
} }
CENTER_TEXT(tempID); float nextCursorPosX=ImGui::GetCursorPosX()+0.5*(ImGui::GetContentRegionAvail().x-ImGui::CalcTextSize(tempID).x);
OP_DRAG_POINT;
ImGui::SameLine();
ImGui::SetCursorPosX(nextCursorPosX);
ImGui::TextUnformatted(tempID); ImGui::TextUnformatted(tempID);
float sliderHeight=200.0f*dpiScale; float sliderHeight=200.0f*dpiScale;
@ -2789,6 +2824,8 @@ void FurnaceGUI::drawInsEdit() {
} }
ImGui::Dummy(ImVec2(dpiScale,dpiScale)); ImGui::Dummy(ImVec2(dpiScale,dpiScale));
OP_DRAG_POINT;
ImGui::SameLine();
if (ins->type==DIV_INS_OPL_DRUMS) { if (ins->type==DIV_INS_OPL_DRUMS) {
ImGui::Text("%s",oplDrumNames[i]); ImGui::Text("%s",oplDrumNames[i]);
} else if (ins->type==DIV_INS_OPL && ins->fm.opllPreset==16) { } else if (ins->type==DIV_INS_OPL && ins->fm.opllPreset==16) {