Skip to content

Commit

Permalink
Tidy up project
Browse files Browse the repository at this point in the history
  • Loading branch information
david-c14 committed Aug 29, 2018
1 parent 48ddb2d commit f391691
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 126 deletions.
15 changes: 1 addition & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 +=
Expand All @@ -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

55 changes: 45 additions & 10 deletions src/ModBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -243,7 +243,7 @@ struct TagBackElement : ListElement {

struct ModBrowserWidget : ModuleWidget {
SubControls::BackPanel *backPanel;
ModuleResizeHandle *handle;
ModuleDragHandle *handle;
Widget *scrollContainer;
ScrollWidget *scrollWidget;
PluginIcon *pluginIcon;
Expand Down Expand Up @@ -280,9 +280,9 @@ struct ModBrowserWidget : ModuleWidget {
maximizeLogo->visible = false;
addChild(maximizeLogo);

//handle = Widget::create<ModuleResizeHandle>(Vec(box.size.x - 10, 175));
//handle->mbw = this;
//addChild(handle);
handle = Widget::create<ModuleDragHandle>(Vec(box.size.x - 10, 175));
handle->mbw = this;
addChild(handle);

maximizeButton = Widget::create<MaximizeButton>(Vec(0, 175));
maximizeButton->mbw = this;
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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 {
Expand All @@ -708,7 +710,8 @@ struct ModBrowserWidget : ModuleWidget {
maximizeButton->visible = false;
maximizeLogo->visible = true;
minimizeLogo->visible = false;
//handle->visible = true;
handle->visible = true;
Resize();
}
}

Expand Down Expand Up @@ -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<Module, ModBrowserWidget>("Submarine (Utilities)", "ModBrowser", "ModuleBrowser", UTILITY_TAG);
50 changes: 0 additions & 50 deletions src/res/ModBrowser.svg

This file was deleted.

52 changes: 0 additions & 52 deletions src/res/ModBrowserMin.svg

This file was deleted.

0 comments on commit f391691

Please sign in to comment.