GUI: patchbay right click menu

This commit is contained in:
tildearrow 2023-01-12 03:56:18 -05:00
parent 01f6e8f963
commit 93aa84bb27
3 changed files with 45 additions and 1 deletions

View File

@ -3879,6 +3879,34 @@ bool DivEngine::patchDisconnect(unsigned int src, unsigned int dest) {
return false;
}
void DivEngine::patchDisconnectAll(unsigned int portSet) {
BUSY_BEGIN;
saveLock.lock();
if (portSet&0x1000) {
portSet&=0xfff;
for (size_t i=0; i<song.patchbay.size(); i++) {
if ((song.patchbay[i]&0xfff0)==(portSet<<4)) {
song.patchbay.erase(song.patchbay.begin()+i);
i--;
}
}
} else {
portSet&=0xfff;
for (size_t i=0; i<song.patchbay.size(); i++) {
if ((song.patchbay[i]&0xfff00000)==(portSet<<20)) {
song.patchbay.erase(song.patchbay.begin()+i);
i--;
}
}
}
saveLock.unlock();
BUSY_END;
}
void DivEngine::noteOn(int chan, int ins, int note, int vol) {
if (chan<0 || chan>=chans) return;
BUSY_BEGIN;

View File

@ -849,6 +849,9 @@ class DivEngine {
// returns false if connection doesn't exist
bool patchDisconnect(unsigned int src, unsigned int dest);
// disconnect all in patchbay
void patchDisconnectAll(unsigned int portSet);
// play note
void noteOn(int chan, int ins, int note, int vol=-1);

View File

@ -107,13 +107,18 @@ bool FurnaceGUI::portSet(String label, unsigned int portSetID, int ins, int outs
hovered=ImGui::ItemHoverable(rect,ImGui::GetID(portID.c_str()));
active=(hovered && ImGui::IsMouseClicked(ImGuiMouseButton_Left));
if (hovered && ImGui::IsMouseClicked(ImGuiMouseButton_Right)) {
ImGui::OpenPopup("SubPortOptions");
selectedPortSet=portSetID;
clickedPort=-1;
}
if (hovered) hoveredPortSet=portSetID;
if (active) clickedPort=-1;
// label
dl->AddRectFilled(minArea,maxArea,ImGui::GetColorU32(portSetColor),0.0f);
dl->AddRect(minArea,maxArea,ImGui::GetColorU32(portSetBorderColor),0.0f,dpiScale);
dl->AddRect(minArea,maxArea,ImGui::GetColorU32((selectedPortSet==portSetID)?uiColors[GUI_COLOR_TEXT]:portSetBorderColor),0.0f,0,dpiScale);
dl->AddText(ImGui::GetFont(),ImGui::GetFontSize(),textPos,ImGui::GetColorU32(uiColors[GUI_COLOR_TEXT]),label.c_str(),NULL,ImGui::GetWindowSize().x*0.6f);
}
@ -385,6 +390,7 @@ void FurnaceGUI::drawMixer() {
if (!e->patchConnect(src,dest)) {
e->patchDisconnect(src,dest);
}
MARK_MODIFIED;
}
}
}
@ -411,6 +417,13 @@ void FurnaceGUI::drawMixer() {
}
}
}
if (ImGui::BeginPopup("SubPortOptions",ImGuiWindowFlags_NoMove|ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings)) {
if (ImGui::MenuItem("disconnect all")) {
e->patchDisconnectAll(selectedPortSet);
MARK_MODIFIED;
}
ImGui::EndPopup();
}
ImGui::EndChild();
}
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_MIXER;