GUI: more patchbay work

This commit is contained in:
tildearrow 2023-01-10 19:09:26 -05:00
parent a36322ff82
commit 51802720a6
7 changed files with 83 additions and 18 deletions

View file

@ -15,8 +15,8 @@ android {
}
minSdkVersion 21
targetSdkVersion 26
versionCode 113
versionName "dev113"
versionCode 136
versionName "dev136"
externalNativeBuild {
cmake {
arguments "-DANDROID_APP_PLATFORM=android-21", "-DANDROID_STL=c++_static"

View file

@ -421,6 +421,9 @@ reserved input portsets:
reserved output portsets:
- `000` through `01F`: chip outputs
- `FFD`: wave/sample preview
- `FFE`: metronome
- `FFF`: "null" portset
# subsong

View file

@ -1466,7 +1466,6 @@ void DivEngine::createNew(const char* description, String sysName, bool inBase64
BUSY_END;
initDispatch();
BUSY_BEGIN;
autoPatchbay();
renderSamples();
reset();
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() {
@ -4181,6 +4190,11 @@ void DivEngine::initDispatch() {
disCont[i].setRates(got.rate);
disCont[i].setQuality(lowQuality);
}
if (song.patchbayAuto) {
saveLock.lock();
autoPatchbay();
saveLock.unlock();
}
recalcChans();
BUSY_END;
}
@ -4438,7 +4452,6 @@ bool DivEngine::init() {
}
initDispatch();
if (!hasLoadedSomething || song.version<135) autoPatchbay();
renderSamples();
reset();
active=true;

View file

@ -987,7 +987,6 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
if (active) {
initDispatch();
BUSY_BEGIN;
autoPatchbay();
renderSamples();
reset();
BUSY_END;
@ -2587,7 +2586,6 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
if (active) {
initDispatch();
BUSY_BEGIN;
if (song.version<135) autoPatchbay();
renderSamples();
reset();
BUSY_END;
@ -3010,7 +3008,6 @@ bool DivEngine::loadMod(unsigned char* file, size_t len) {
if (active) {
initDispatch();
BUSY_BEGIN;
autoPatchbay();
renderSamples();
reset();
BUSY_END;
@ -3694,7 +3691,6 @@ bool DivEngine::loadFC(unsigned char* file, size_t len) {
if (active) {
initDispatch();
BUSY_BEGIN;
autoPatchbay();
renderSamples();
reset();
BUSY_END;

View file

@ -6027,6 +6027,7 @@ FurnaceGUI::FurnaceGUI():
hoveredSubPort(-1),
portDragActive(false),
displayHiddenPorts(false),
displayInternalPorts(false),
subPortPos(0.0f,0.0f),
oscTotal(0),
oscZoom(0.5f),

View file

@ -1664,7 +1664,7 @@ class FurnaceGUI {
int selectedSubPort;
unsigned int hoveredPortSet;
int hoveredSubPort;
bool portDragActive, displayHiddenPorts;
bool portDragActive, displayHiddenPorts, displayInternalPorts;
ImVec2 subPortPos;
// oscilloscope
@ -1776,6 +1776,7 @@ class FurnaceGUI {
bool InvCheckbox(const char* label, bool* value);
// 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);
void updateWindowTitle();

View file

@ -28,14 +28,10 @@ const char* portNamesStereo[2]={
"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) {
String portID=fmt::sprintf("portSet%.4x",portSetID);
ImDrawList* dl=ImGui::GetWindowDrawList();
ImGuiWindow* window=ImGui::GetCurrentWindow();
ImVec2 FurnaceGUI::calcPortSetSize(String label, int ins, int outs) {
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;
@ -46,6 +42,27 @@ bool FurnaceGUI::portSet(String label, unsigned int portSetID, int ins, int outs
// space for ports
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 portSetColor=ImVec4(
portSetBorderColor.x*0.75f,
@ -86,7 +103,7 @@ bool FurnaceGUI::portSet(String label, unsigned int portSetID, int ins, int outs
// label
dl->AddRectFilled(minArea,maxArea,ImGui::GetColorU32(portSetColor),0.0f);
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
for (int i=0; i<ins; i++) {
@ -254,7 +271,8 @@ void FurnaceGUI::drawMixer() {
MARK_MODIFIED;
}
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;
@ -263,7 +281,9 @@ void FurnaceGUI::drawMixer() {
if (ImGui::BeginChild("Patchbay",ImVec2(0,0),true)) {
ImDrawList* dl=ImGui::GetWindowDrawList();
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;
@ -279,6 +299,7 @@ void FurnaceGUI::drawMixer() {
selectedPortSet=i;
if (selectedSubPort>=0) {
portDragActive=true;
ImGui::InhibitInertialScroll();
try {
subPortPos=portPos.at((selectedPortSet<<4)|selectedSubPort);
} 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);
if (portSet("System",0x1000,displayHiddenPorts?DIV_MAX_OUTPUTS:e->getAudioDescGot().outChans,0,e->getAudioDescGot().outChans,0,selectedSubPort,portPos)) {
selectedPortSet=0x1000;
if (selectedSubPort>=0) {
portDragActive=true;
ImGui::InhibitInertialScroll();
try {
subPortPos=portPos.at((selectedPortSet<<4)|selectedSubPort);
} catch (std::out_of_range& e) {