GUI: more patchbay work
This commit is contained in:
parent
a36322ff82
commit
51802720a6
|
@ -15,8 +15,8 @@ android {
|
||||||
}
|
}
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 26
|
targetSdkVersion 26
|
||||||
versionCode 113
|
versionCode 136
|
||||||
versionName "dev113"
|
versionName "dev136"
|
||||||
externalNativeBuild {
|
externalNativeBuild {
|
||||||
cmake {
|
cmake {
|
||||||
arguments "-DANDROID_APP_PLATFORM=android-21", "-DANDROID_STL=c++_static"
|
arguments "-DANDROID_APP_PLATFORM=android-21", "-DANDROID_STL=c++_static"
|
||||||
|
|
|
@ -421,6 +421,9 @@ reserved input portsets:
|
||||||
|
|
||||||
reserved output portsets:
|
reserved output portsets:
|
||||||
- `000` through `01F`: chip outputs
|
- `000` through `01F`: chip outputs
|
||||||
|
- `FFD`: wave/sample preview
|
||||||
|
- `FFE`: metronome
|
||||||
|
- `FFF`: "null" portset
|
||||||
|
|
||||||
# subsong
|
# subsong
|
||||||
|
|
||||||
|
|
|
@ -1466,7 +1466,6 @@ void DivEngine::createNew(const char* description, String sysName, bool inBase64
|
||||||
BUSY_END;
|
BUSY_END;
|
||||||
initDispatch();
|
initDispatch();
|
||||||
BUSY_BEGIN;
|
BUSY_BEGIN;
|
||||||
autoPatchbay();
|
|
||||||
renderSamples();
|
renderSamples();
|
||||||
reset();
|
reset();
|
||||||
BUSY_END;
|
BUSY_END;
|
||||||
|
@ -3830,6 +3829,16 @@ void DivEngine::autoPatchbay() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// wave/sample preview
|
||||||
|
for (unsigned int j=0; j<DIV_MAX_OUTPUTS; j++) {
|
||||||
|
song.patchbay.push_back(0xffd00000|j);
|
||||||
|
}
|
||||||
|
|
||||||
|
// metronome
|
||||||
|
for (unsigned int j=0; j<DIV_MAX_OUTPUTS; j++) {
|
||||||
|
song.patchbay.push_back(0xffe00000|j);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivEngine::autoPatchbayP() {
|
void DivEngine::autoPatchbayP() {
|
||||||
|
@ -4181,6 +4190,11 @@ void DivEngine::initDispatch() {
|
||||||
disCont[i].setRates(got.rate);
|
disCont[i].setRates(got.rate);
|
||||||
disCont[i].setQuality(lowQuality);
|
disCont[i].setQuality(lowQuality);
|
||||||
}
|
}
|
||||||
|
if (song.patchbayAuto) {
|
||||||
|
saveLock.lock();
|
||||||
|
autoPatchbay();
|
||||||
|
saveLock.unlock();
|
||||||
|
}
|
||||||
recalcChans();
|
recalcChans();
|
||||||
BUSY_END;
|
BUSY_END;
|
||||||
}
|
}
|
||||||
|
@ -4438,7 +4452,6 @@ bool DivEngine::init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
initDispatch();
|
initDispatch();
|
||||||
if (!hasLoadedSomething || song.version<135) autoPatchbay();
|
|
||||||
renderSamples();
|
renderSamples();
|
||||||
reset();
|
reset();
|
||||||
active=true;
|
active=true;
|
||||||
|
|
|
@ -987,7 +987,6 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
||||||
if (active) {
|
if (active) {
|
||||||
initDispatch();
|
initDispatch();
|
||||||
BUSY_BEGIN;
|
BUSY_BEGIN;
|
||||||
autoPatchbay();
|
|
||||||
renderSamples();
|
renderSamples();
|
||||||
reset();
|
reset();
|
||||||
BUSY_END;
|
BUSY_END;
|
||||||
|
@ -2587,7 +2586,6 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
||||||
if (active) {
|
if (active) {
|
||||||
initDispatch();
|
initDispatch();
|
||||||
BUSY_BEGIN;
|
BUSY_BEGIN;
|
||||||
if (song.version<135) autoPatchbay();
|
|
||||||
renderSamples();
|
renderSamples();
|
||||||
reset();
|
reset();
|
||||||
BUSY_END;
|
BUSY_END;
|
||||||
|
@ -3010,7 +3008,6 @@ bool DivEngine::loadMod(unsigned char* file, size_t len) {
|
||||||
if (active) {
|
if (active) {
|
||||||
initDispatch();
|
initDispatch();
|
||||||
BUSY_BEGIN;
|
BUSY_BEGIN;
|
||||||
autoPatchbay();
|
|
||||||
renderSamples();
|
renderSamples();
|
||||||
reset();
|
reset();
|
||||||
BUSY_END;
|
BUSY_END;
|
||||||
|
@ -3694,7 +3691,6 @@ bool DivEngine::loadFC(unsigned char* file, size_t len) {
|
||||||
if (active) {
|
if (active) {
|
||||||
initDispatch();
|
initDispatch();
|
||||||
BUSY_BEGIN;
|
BUSY_BEGIN;
|
||||||
autoPatchbay();
|
|
||||||
renderSamples();
|
renderSamples();
|
||||||
reset();
|
reset();
|
||||||
BUSY_END;
|
BUSY_END;
|
||||||
|
|
|
@ -6027,6 +6027,7 @@ FurnaceGUI::FurnaceGUI():
|
||||||
hoveredSubPort(-1),
|
hoveredSubPort(-1),
|
||||||
portDragActive(false),
|
portDragActive(false),
|
||||||
displayHiddenPorts(false),
|
displayHiddenPorts(false),
|
||||||
|
displayInternalPorts(false),
|
||||||
subPortPos(0.0f,0.0f),
|
subPortPos(0.0f,0.0f),
|
||||||
oscTotal(0),
|
oscTotal(0),
|
||||||
oscZoom(0.5f),
|
oscZoom(0.5f),
|
||||||
|
|
|
@ -1664,7 +1664,7 @@ class FurnaceGUI {
|
||||||
int selectedSubPort;
|
int selectedSubPort;
|
||||||
unsigned int hoveredPortSet;
|
unsigned int hoveredPortSet;
|
||||||
int hoveredSubPort;
|
int hoveredSubPort;
|
||||||
bool portDragActive, displayHiddenPorts;
|
bool portDragActive, displayHiddenPorts, displayInternalPorts;
|
||||||
ImVec2 subPortPos;
|
ImVec2 subPortPos;
|
||||||
|
|
||||||
// oscilloscope
|
// oscilloscope
|
||||||
|
@ -1776,6 +1776,7 @@ class FurnaceGUI {
|
||||||
bool InvCheckbox(const char* label, bool* value);
|
bool InvCheckbox(const char* label, bool* value);
|
||||||
|
|
||||||
// mixer stuff
|
// mixer stuff
|
||||||
|
ImVec2 calcPortSetSize(String label, int ins, int outs);
|
||||||
bool portSet(String label, unsigned int portSetID, int ins, int outs, int activeIns, int activeOuts, int& clickedPort, std::map<unsigned int,ImVec2>& portPos);
|
bool portSet(String label, unsigned int portSetID, int ins, int outs, int activeIns, int activeOuts, int& clickedPort, std::map<unsigned int,ImVec2>& portPos);
|
||||||
|
|
||||||
void updateWindowTitle();
|
void updateWindowTitle();
|
||||||
|
|
|
@ -28,14 +28,10 @@ const char* portNamesStereo[2]={
|
||||||
"right"
|
"right"
|
||||||
};
|
};
|
||||||
|
|
||||||
bool FurnaceGUI::portSet(String label, unsigned int portSetID, int ins, int outs, int activeIns, int activeOuts, int& clickedPort, std::map<unsigned int,ImVec2>& portPos) {
|
ImVec2 FurnaceGUI::calcPortSetSize(String label, int ins, int outs) {
|
||||||
String portID=fmt::sprintf("portSet%.4x",portSetID);
|
|
||||||
|
|
||||||
ImDrawList* dl=ImGui::GetWindowDrawList();
|
|
||||||
ImGuiWindow* window=ImGui::GetCurrentWindow();
|
|
||||||
ImGuiStyle& style=ImGui::GetStyle();
|
ImGuiStyle& style=ImGui::GetStyle();
|
||||||
|
|
||||||
ImVec2 labelSize=ImGui::CalcTextSize(label.c_str());
|
ImVec2 labelSize=ImGui::CalcTextSize(label.c_str(),NULL,false,ImGui::GetWindowSize().x*0.6f);
|
||||||
|
|
||||||
ImVec2 size=labelSize;
|
ImVec2 size=labelSize;
|
||||||
|
|
||||||
|
@ -46,6 +42,27 @@ bool FurnaceGUI::portSet(String label, unsigned int portSetID, int ins, int outs
|
||||||
// space for ports
|
// space for ports
|
||||||
size.y+=MAX(ins,outs)*(labelSize.y+style.FramePadding.y+style.ItemSpacing.y);
|
size.y+=MAX(ins,outs)*(labelSize.y+style.FramePadding.y+style.ItemSpacing.y);
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FurnaceGUI::portSet(String label, unsigned int portSetID, int ins, int outs, int activeIns, int activeOuts, int& clickedPort, std::map<unsigned int,ImVec2>& portPos) {
|
||||||
|
String portID=fmt::sprintf("portSet%.4x",portSetID);
|
||||||
|
|
||||||
|
ImDrawList* dl=ImGui::GetWindowDrawList();
|
||||||
|
ImGuiWindow* window=ImGui::GetCurrentWindow();
|
||||||
|
ImGuiStyle& style=ImGui::GetStyle();
|
||||||
|
|
||||||
|
ImVec2 labelSize=ImGui::CalcTextSize(label.c_str(),NULL,false,ImGui::GetWindowSize().x*0.6f);
|
||||||
|
|
||||||
|
ImVec2 size=labelSize;
|
||||||
|
|
||||||
|
// pad
|
||||||
|
size.x+=style.FramePadding.x*2.0f;
|
||||||
|
size.y+=style.FramePadding.y*2.0f;
|
||||||
|
|
||||||
|
// space for ports
|
||||||
|
size.y+=MAX(ins,outs)*(ImGui::GetFontSize()+style.FramePadding.y+style.ItemSpacing.y);
|
||||||
|
|
||||||
ImVec4 portSetBorderColor=uiColors[GUI_COLOR_PATCHBAY_PORTSET];
|
ImVec4 portSetBorderColor=uiColors[GUI_COLOR_PATCHBAY_PORTSET];
|
||||||
ImVec4 portSetColor=ImVec4(
|
ImVec4 portSetColor=ImVec4(
|
||||||
portSetBorderColor.x*0.75f,
|
portSetBorderColor.x*0.75f,
|
||||||
|
@ -86,7 +103,7 @@ bool FurnaceGUI::portSet(String label, unsigned int portSetID, int ins, int outs
|
||||||
// label
|
// label
|
||||||
dl->AddRectFilled(minArea,maxArea,ImGui::GetColorU32(portSetColor),0.0f);
|
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(portSetBorderColor),0.0f,dpiScale);
|
||||||
dl->AddText(textPos,ImGui::GetColorU32(uiColors[GUI_COLOR_TEXT]),label.c_str());
|
dl->AddText(ImGui::GetFont(),ImGui::GetFontSize(),textPos,ImGui::GetColorU32(uiColors[GUI_COLOR_TEXT]),label.c_str(),NULL,ImGui::GetWindowSize().x*0.6f);
|
||||||
|
|
||||||
// input ports
|
// input ports
|
||||||
for (int i=0; i<ins; i++) {
|
for (int i=0; i<ins; i++) {
|
||||||
|
@ -254,7 +271,8 @@ void FurnaceGUI::drawMixer() {
|
||||||
MARK_MODIFIED;
|
MARK_MODIFIED;
|
||||||
}
|
}
|
||||||
ImGui::Checkbox("Display hidden ports",&displayHiddenPorts);
|
ImGui::Checkbox("Display hidden ports",&displayHiddenPorts);
|
||||||
ImGui::Dummy(ImVec2(1.0f,ImGui::GetFrameHeightWithSpacing()*2.0f));
|
ImGui::Checkbox("Display internal",&displayInternalPorts);
|
||||||
|
ImGui::Dummy(ImVec2(1.0f,ImGui::GetFrameHeightWithSpacing()));
|
||||||
}
|
}
|
||||||
|
|
||||||
hoveredPortSet=0x1fff;
|
hoveredPortSet=0x1fff;
|
||||||
|
@ -263,7 +281,9 @@ void FurnaceGUI::drawMixer() {
|
||||||
if (ImGui::BeginChild("Patchbay",ImVec2(0,0),true)) {
|
if (ImGui::BeginChild("Patchbay",ImVec2(0,0),true)) {
|
||||||
ImDrawList* dl=ImGui::GetWindowDrawList();
|
ImDrawList* dl=ImGui::GetWindowDrawList();
|
||||||
ImVec2 topPos=ImGui::GetCursorPos();
|
ImVec2 topPos=ImGui::GetCursorPos();
|
||||||
topPos.x+=ImGui::GetContentRegionAvail().x-60.0*dpiScale;
|
ImVec2 sysSize=calcPortSetSize("System",displayHiddenPorts?DIV_MAX_OUTPUTS:e->getAudioDescGot().outChans,0);
|
||||||
|
topPos.x+=ImGui::GetContentRegionAvail().x-sysSize.x;
|
||||||
|
topPos.y+=(ImGui::GetContentRegionAvail().y-sysSize.y)*0.5+ImGui::GetScrollY();
|
||||||
|
|
||||||
if (ImGui::IsWindowHovered() && ImGui::IsMouseClicked(ImGuiMouseButton_Left)) selectedPortSet=0x1fff;
|
if (ImGui::IsWindowHovered() && ImGui::IsMouseClicked(ImGuiMouseButton_Left)) selectedPortSet=0x1fff;
|
||||||
|
|
||||||
|
@ -279,6 +299,7 @@ void FurnaceGUI::drawMixer() {
|
||||||
selectedPortSet=i;
|
selectedPortSet=i;
|
||||||
if (selectedSubPort>=0) {
|
if (selectedSubPort>=0) {
|
||||||
portDragActive=true;
|
portDragActive=true;
|
||||||
|
ImGui::InhibitInertialScroll();
|
||||||
try {
|
try {
|
||||||
subPortPos=portPos.at((selectedPortSet<<4)|selectedSubPort);
|
subPortPos=portPos.at((selectedPortSet<<4)|selectedSubPort);
|
||||||
} catch (std::out_of_range& e) {
|
} catch (std::out_of_range& e) {
|
||||||
|
@ -287,11 +308,41 @@ void FurnaceGUI::drawMixer() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// metronome/sample preview
|
||||||
|
if (displayInternalPorts) {
|
||||||
|
if (portSet("Sample Preview",0xffd,0,1,0,1,selectedSubPort,portPos)) {
|
||||||
|
selectedPortSet=0xffe;
|
||||||
|
if (selectedSubPort>=0) {
|
||||||
|
portDragActive=true;
|
||||||
|
ImGui::InhibitInertialScroll();
|
||||||
|
try {
|
||||||
|
subPortPos=portPos.at((selectedPortSet<<4)|selectedSubPort);
|
||||||
|
} catch (std::out_of_range& e) {
|
||||||
|
portDragActive=false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (portSet("Metronome",0xffe,0,1,0,1,selectedSubPort,portPos)) {
|
||||||
|
selectedPortSet=0xffe;
|
||||||
|
if (selectedSubPort>=0) {
|
||||||
|
portDragActive=true;
|
||||||
|
ImGui::InhibitInertialScroll();
|
||||||
|
try {
|
||||||
|
subPortPos=portPos.at((selectedPortSet<<4)|selectedSubPort);
|
||||||
|
} catch (std::out_of_range& e) {
|
||||||
|
portDragActive=false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::SetCursorPos(topPos);
|
ImGui::SetCursorPos(topPos);
|
||||||
if (portSet("System",0x1000,displayHiddenPorts?DIV_MAX_OUTPUTS:e->getAudioDescGot().outChans,0,e->getAudioDescGot().outChans,0,selectedSubPort,portPos)) {
|
if (portSet("System",0x1000,displayHiddenPorts?DIV_MAX_OUTPUTS:e->getAudioDescGot().outChans,0,e->getAudioDescGot().outChans,0,selectedSubPort,portPos)) {
|
||||||
selectedPortSet=0x1000;
|
selectedPortSet=0x1000;
|
||||||
if (selectedSubPort>=0) {
|
if (selectedSubPort>=0) {
|
||||||
portDragActive=true;
|
portDragActive=true;
|
||||||
|
ImGui::InhibitInertialScroll();
|
||||||
try {
|
try {
|
||||||
subPortPos=portPos.at((selectedPortSet<<4)|selectedSubPort);
|
subPortPos=portPos.at((selectedPortSet<<4)|selectedSubPort);
|
||||||
} catch (std::out_of_range& e) {
|
} catch (std::out_of_range& e) {
|
||||||
|
|
Loading…
Reference in a new issue