From 49c7d3272727cdb532e3f5911aac456704482b5c Mon Sep 17 00:00:00 2001 From: falkTX Date: Fri, 4 Feb 2022 00:11:49 +0000 Subject: [PATCH] extend expanders in carla and ildaeil to show active state --- plugins/Cardinal/src/Carla.cpp | 30 ++++++++++++++++++++++ plugins/Cardinal/src/Expanders.cpp | 8 +++--- plugins/Cardinal/src/Ildaeil.cpp | 40 ++++++++++++++++++++++++------ 3 files changed, 68 insertions(+), 10 deletions(-) diff --git a/plugins/Cardinal/src/Carla.cpp b/plugins/Cardinal/src/Carla.cpp index 121390b..fd39362 100644 --- a/plugins/Cardinal/src/Carla.cpp +++ b/plugins/Cardinal/src/Carla.cpp @@ -463,6 +463,7 @@ static intptr_t host_dispatcher(const NativeHostHandle handle, const NativeHostD #ifndef HEADLESS struct CarlaModuleWidget : ModuleWidgetWith9HP, IdleCallback { CarlaModule* const module; + bool hasLeftSideExpander = false; bool idleCallbackActive = false; bool visible = false; @@ -578,6 +579,26 @@ struct CarlaModuleWidget : ModuleWidgetWith9HP, IdleCallback { { drawBackground(args.vg); drawOutputJacksArea(args.vg, CarlaModule::NUM_INPUTS); + + if (hasLeftSideExpander) + { + nvgBeginPath(args.vg); + nvgRect(args.vg, 1, 90 - 19, 18, 49 * 6 - 4); + nvgFillPaint(args.vg, nvgLinearGradient(args.vg, 0, 0, 18, 0, nvgRGB(0xd0, 0xd0, 0xd0), nvgRGBA(0xd0, 0xd0, 0xd0, 0))); + nvgFill(args.vg); + + for (int i=1; i<6; ++i) + { + const float y = 90 + 49 * i - 23; + const int col1 = 0x18 + static_cast((y / box.size.y) * (0x21 - 0x18) + 0.5f); + const int col2 = 0x19 + static_cast((y / box.size.y) * (0x22 - 0x19) + 0.5f); + nvgBeginPath(args.vg); + nvgRect(args.vg, 1, y, 18, 4); + nvgFillColor(args.vg, nvgRGB(col1, col2, col2)); + nvgFill(args.vg); + } + } + setupTextLines(args.vg); drawTextLine(args.vg, 0, "Audio 1"); @@ -594,6 +615,15 @@ struct CarlaModuleWidget : ModuleWidgetWith9HP, IdleCallback { ModuleWidgetWith9HP::draw(args); } + void step() override + { + hasLeftSideExpander = module != nullptr + && module->leftExpander.module != nullptr + && module->leftExpander.module->model == modelExpanderInputMIDI; + + ModuleWidgetWith9HP::step(); + } + void showUI() { visible = true; diff --git a/plugins/Cardinal/src/Expanders.cpp b/plugins/Cardinal/src/Expanders.cpp index 1d75f09..34e3097 100644 --- a/plugins/Cardinal/src/Expanders.cpp +++ b/plugins/Cardinal/src/Expanders.cpp @@ -227,19 +227,21 @@ struct CardinalExpanderForInputMIDIWidget : ModuleWidgetWithSideScrews<> { { drawBackground(args.vg); - nvgScissor(args.vg, startX, 0.0f, box.size.x - startX, box.size.y); nvgFillColor(args.vg, nvgRGB(0xd0, 0xd0, 0xd0)); + nvgSave(args.vg); + nvgIntersectScissor(args.vg, startX, 0.0f, box.size.x - startX - 1.0f, box.size.y); + for (int i=0; i { + bool hasLeftSideExpander = false; IldaeilWidget* ildaeilWidget = nullptr; IldaeilModuleWidget(IldaeilModule* const module) @@ -1548,13 +1550,37 @@ struct IldaeilModuleWidget : ModuleWidget { void draw(const DrawArgs& args) override { - nvgBeginPath(args.vg); - nvgRect(args.vg, 0, 0, box.size.x, box.size.y); - nvgFillPaint(args.vg, nvgLinearGradient(args.vg, 0, 0, 0, box.size.y, - nvgRGB(0x18, 0x19, 0x19), nvgRGB(0x21, 0x22, 0x22))); - nvgFill(args.vg); + drawBackground(args.vg); + + if (hasLeftSideExpander) + { + nvgBeginPath(args.vg); + nvgRect(args.vg, 1, 90 - 19, 18, 49 * 6 - 4); + nvgFillPaint(args.vg, nvgLinearGradient(args.vg, 0, 0, 18, 0, nvgRGB(0xd0, 0xd0, 0xd0), nvgRGBA(0xd0, 0xd0, 0xd0, 0))); + nvgFill(args.vg); + + for (int i=1; i<6; ++i) + { + const float y = 90 + 49 * i - 23; + const int col1 = 0x18 + static_cast((y / box.size.y) * (0x21 - 0x18) + 0.5f); + const int col2 = 0x19 + static_cast((y / box.size.y) * (0x22 - 0x19) + 0.5f); + nvgBeginPath(args.vg); + nvgRect(args.vg, 1, y, 18, 4); + nvgFillColor(args.vg, nvgRGB(col1, col2, col2)); + nvgFill(args.vg); + } + } + + ModuleWidgetWithSideScrews::draw(args); + } + + void step() override + { + hasLeftSideExpander = module != nullptr + && module->leftExpander.module != nullptr + && module->leftExpander.module->model == modelExpanderInputMIDI; - ModuleWidget::draw(args); + ModuleWidgetWithSideScrews::step(); } DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(IldaeilModuleWidget)