diff --git a/Makefile b/Makefile index cb822e9..b2394d8 100755 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ SLUG = SubmarineUtility # Must follow the format in the Versioning section of https://vcvrack.com/manual/PluginDevelopmentTutorial.html -VERSION = 0.6.0Test +VERSION = 0.6.0Beta # FLAGS will be passed to both the C and C++ compiler FLAGS += @@ -26,16 +26,3 @@ RACK_DIR ?= ../.. # Include the VCV Rack plugin Makefile framework include $(RACK_DIR)/plugin.mk -# Make resources - -RESOURCES += $(subst src/res/,res/,$(wildcard src/res/*.svg)) - -res: $(RESOURCES) - -%.svg: ../src/res/%.svg -ifeq (${SVG_TOOL},inkscape) - inkscape -z -T -l=$@ $< -else - touch $@ -endif - diff --git a/src/ModBrowser.cpp b/src/ModBrowser.cpp index b046be4..0120a7c 100755 --- a/src/ModBrowser.cpp +++ b/src/ModBrowser.cpp @@ -35,11 +35,11 @@ struct SubLogo : SVGWidget{}; } // SubControls -struct ModuleResizeHandle : Widget { +struct ModuleDragHandle : Widget { ModBrowserWidget *mbw; float dragX; Rect originalBox; - ModuleResizeHandle() { + ModuleDragHandle() { box.size = Vec(10, 30); } void onMouseDown(EventMouseDown &e) override { @@ -243,7 +243,7 @@ struct TagBackElement : ListElement { struct ModBrowserWidget : ModuleWidget { SubControls::BackPanel *backPanel; - ModuleResizeHandle *handle; + ModuleDragHandle *handle; Widget *scrollContainer; ScrollWidget *scrollWidget; PluginIcon *pluginIcon; @@ -280,9 +280,9 @@ struct ModBrowserWidget : ModuleWidget { maximizeLogo->visible = false; addChild(maximizeLogo); - //handle = Widget::create(Vec(box.size.x - 10, 175)); - //handle->mbw = this; - //addChild(handle); + handle = Widget::create(Vec(box.size.x - 10, 175)); + handle->mbw = this; + addChild(handle); maximizeButton = Widget::create(Vec(0, 175)); maximizeButton->mbw = this; @@ -368,9 +368,11 @@ struct ModBrowserWidget : ModuleWidget { favIcon->selected = 0; } void Resize() { - debug("Resize %d", box.size.x); + debug("Resize %f", box.size.x); + backPanel->box.size.x = box.size.x - 20; scrollWidget->box.size.x = box.size.x - 20; - scrollContainer->box.size.x = box.size.x - 20; + handle->box.pos.x = box.size.x - 10; + maximizeLogo->box.pos.x = box.size.x - 20; SetListWidth(); } @@ -696,7 +698,7 @@ struct ModBrowserWidget : ModuleWidget { maximizeButton->visible = true; maximizeLogo->visible = false; minimizeLogo->visible = true; - //handle->visible = false; + handle->visible = false; ShiftOthers(box.size.x - oldSize); } else { @@ -708,7 +710,8 @@ struct ModBrowserWidget : ModuleWidget { maximizeButton->visible = false; maximizeLogo->visible = true; minimizeLogo->visible = false; - //handle->visible = true; + handle->visible = true; + Resize(); } } @@ -869,4 +872,36 @@ void TagBackElement::onAction(EventAction &e) { mbw->AddTags(); } +void ModuleDragHandle::onDragStart(EventDragStart &e) { + dragX = gRackWidget->lastMousePos.x; + originalBox = mbw->box; +} + +void ModuleDragHandle::onDragMove(EventDragMove &e) { + + float newDragX = gRackWidget->lastMousePos.x; + float deltaX = newDragX - dragX; + + Rect newBox = originalBox; + const float minWidth = 13 * RACK_GRID_WIDTH; + newBox.size.x += deltaX; + newBox.size.x = fmaxf(newBox.size.x, minWidth); + newBox.size.x = roundf(newBox.size.x / RACK_GRID_WIDTH) * RACK_GRID_WIDTH; + gRackWidget->requestModuleBox(mbw, newBox); + mbw->moduleWidth = mbw->box.size.x; + mbw->Resize(); +} + +void ModuleDragHandle::draw(NVGcontext *vg) { + for (float x = 2.0; x <= 8.0; x += 2.0) { + nvgBeginPath(vg); + const float margin = 5.0; + nvgMoveTo(vg, x + 0.5, margin + 0.5); + nvgLineTo(vg, x + 0.5, box.size.y - margin + 0.5); + nvgStrokeWidth(vg, 1.0); + nvgStrokeColor(vg, nvgRGBAf(0.5, 0.5, 0.5, 0.5)); + nvgStroke(vg); + } +} + Model *modelModBrowser = Model::create("Submarine (Utilities)", "ModBrowser", "ModuleBrowser", UTILITY_TAG); diff --git a/src/res/ModBrowser.svg b/src/res/ModBrowser.svg deleted file mode 100755 index 7ce69d1..0000000 --- a/src/res/ModBrowser.svg +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - diff --git a/src/res/ModBrowserMin.svg b/src/res/ModBrowserMin.svg deleted file mode 100755 index 0aaf359..0000000 --- a/src/res/ModBrowserMin.svg +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - -