From 51802720a6db15f936756314963346cfc170592b Mon Sep 17 00:00:00 2001 From: tildearrow Date: Tue, 10 Jan 2023 19:09:26 -0500 Subject: [PATCH] GUI: more patchbay work --- android/app/build.gradle | 4 +-- papers/format.md | 3 ++ src/engine/engine.cpp | 17 ++++++++-- src/engine/fileOps.cpp | 4 --- src/gui/gui.cpp | 1 + src/gui/gui.h | 3 +- src/gui/mixer.cpp | 69 ++++++++++++++++++++++++++++++++++------ 7 files changed, 83 insertions(+), 18 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 92a79e4d6..9f0cb2594 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -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" diff --git a/papers/format.md b/papers/format.md index d8ec4bbf0..6522760e8 100644 --- a/papers/format.md +++ b/papers/format.md @@ -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 diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 8b8849aa8..4791bd2df 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -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& portPos); void updateWindowTitle(); diff --git a/src/gui/mixer.cpp b/src/gui/mixer.cpp index 6c6085a50..5ff0093e5 100644 --- a/src/gui/mixer.cpp +++ b/src/gui/mixer.cpp @@ -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& 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& 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