From 30252ae668da299ae605faa1a401c9e5586ff280 Mon Sep 17 00:00:00 2001 From: Evan King Date: Fri, 9 Mar 2018 15:09:20 +0900 Subject: [PATCH] Modify source to reflect change from PNG to SVG addChild for setting faceplate graphics is changed to ModuleWidget's setPanel method to reflect the usual approach to setting SVG graphics for the faceplate. In Tides, addChild is still used so that the faceplate can be switched between Tides and Sheep as needed. --- src/Blinds.cpp | 24 +++++++++--------------- src/Braids.cpp | 8 +------- src/Branches.cpp | 8 +------- src/Clouds.cpp | 8 +------- src/Elements.cpp | 8 +------- src/Frames.cpp | 8 +------- src/Kinks.cpp | 8 +------- src/Links.cpp | 8 +------- src/Rings.cpp | 8 +------- src/Shades.cpp | 8 +------- src/Tides.cpp | 12 ++++++------ src/Veils.cpp | 16 +++++----------- src/Warps.cpp | 10 ++-------- 13 files changed, 31 insertions(+), 103 deletions(-) diff --git a/src/Blinds.cpp b/src/Blinds.cpp index f43e857..44e4796 100644 --- a/src/Blinds.cpp +++ b/src/Blinds.cpp @@ -71,13 +71,7 @@ void Blinds::step() { struct BlindsWidget : ModuleWidget { BlindsWidget(Blinds *module) : ModuleWidget(module) { - box.size = Vec(15*12, 380); - { - Panel *panel = new LightPanel(); - panel->backgroundImage = Image::load(assetPlugin(plugin, "res/Blinds.png")); - panel->box.size = box.size; - addChild(panel); - } + setPanel(SVG::load(assetPlugin(plugin, "res/Blinds.svg"))); addChild(Widget::create(Vec(15, 0))); addChild(Widget::create(Vec(150, 0))); @@ -109,15 +103,15 @@ struct BlindsWidget : ModuleWidget { addOutput(Port::create(Vec(144, 198), Port::OUTPUT, module, Blinds::OUT3_OUTPUT)); addOutput(Port::create(Vec(144, 277), Port::OUTPUT, module, Blinds::OUT4_OUTPUT)); - addChild(ModuleLightWidget::create>(Vec(77, 96), module, Blinds::CV1_POS_LIGHT)); - addChild(ModuleLightWidget::create>(Vec(77, 175), module, Blinds::CV2_POS_LIGHT)); - addChild(ModuleLightWidget::create>(Vec(77, 254), module, Blinds::CV3_POS_LIGHT)); - addChild(ModuleLightWidget::create>(Vec(77, 333), module, Blinds::CV4_POS_LIGHT)); + addChild(ModuleLightWidget::create>(Vec(78, 96), module, Blinds::CV1_POS_LIGHT)); + addChild(ModuleLightWidget::create>(Vec(78, 175), module, Blinds::CV2_POS_LIGHT)); + addChild(ModuleLightWidget::create>(Vec(78, 254), module, Blinds::CV3_POS_LIGHT)); + addChild(ModuleLightWidget::create>(Vec(78, 333), module, Blinds::CV4_POS_LIGHT)); - addChild(ModuleLightWidget::create>(Vec(150, 87), module, Blinds::OUT1_POS_LIGHT)); - addChild(ModuleLightWidget::create>(Vec(150, 166), module, Blinds::OUT2_POS_LIGHT)); - addChild(ModuleLightWidget::create>(Vec(150, 245), module, Blinds::OUT3_POS_LIGHT)); - addChild(ModuleLightWidget::create>(Vec(150, 324), module, Blinds::OUT4_POS_LIGHT)); + addChild(ModuleLightWidget::create>(Vec(152, 87), module, Blinds::OUT1_POS_LIGHT)); + addChild(ModuleLightWidget::create>(Vec(152, 166), module, Blinds::OUT2_POS_LIGHT)); + addChild(ModuleLightWidget::create>(Vec(152, 245), module, Blinds::OUT3_POS_LIGHT)); + addChild(ModuleLightWidget::create>(Vec(152, 324), module, Blinds::OUT4_POS_LIGHT)); } }; diff --git a/src/Braids.cpp b/src/Braids.cpp index f608b0b..ab79e24 100644 --- a/src/Braids.cpp +++ b/src/Braids.cpp @@ -295,13 +295,7 @@ struct BraidsLowCpuItem : MenuItem { struct BraidsWidget : ModuleWidget { BraidsWidget(Braids *module) : ModuleWidget(module) { - box.size = Vec(15*16, 380); - { - Panel *panel = new LightPanel(); - panel->backgroundImage = Image::load(assetPlugin(plugin, "res/Braids.png")); - panel->box.size = box.size; - addChild(panel); - } + setPanel(SVG::load(assetPlugin(plugin, "res/Braids.svg"))); { BraidsDisplay *display = new BraidsDisplay(); diff --git a/src/Branches.cpp b/src/Branches.cpp index 9115a32..7b630a3 100644 --- a/src/Branches.cpp +++ b/src/Branches.cpp @@ -91,13 +91,7 @@ void Branches::step() { struct BranchesWidget : ModuleWidget { BranchesWidget(Branches *module) : ModuleWidget(module) { - box.size = Vec(15*6, 380); - { - Panel *panel = new LightPanel(); - panel->backgroundImage = Image::load(assetPlugin(plugin, "res/Branches.png")); - panel->box.size = box.size; - addChild(panel); - } + setPanel(SVG::load(assetPlugin(plugin, "res/Branches.svg"))); addChild(Widget::create(Vec(15, 0))); addChild(Widget::create(Vec(15, 365))); diff --git a/src/Clouds.cpp b/src/Clouds.cpp index a63a69f..bf7578c 100644 --- a/src/Clouds.cpp +++ b/src/Clouds.cpp @@ -310,13 +310,7 @@ struct CloudsWidget : ModuleWidget { ParamWidget *reverbParam; CloudsWidget(Clouds *module) : ModuleWidget(module) { - box.size = Vec(15*18, 380); - { - Panel *panel = new LightPanel(); - panel->backgroundImage = Image::load(assetPlugin(plugin, "res/Clouds.png")); - panel->box.size = box.size; - addChild(panel); - } + setPanel(SVG::load(assetPlugin(plugin, "res/Clouds.svg"))); addChild(Widget::create(Vec(15, 0))); addChild(Widget::create(Vec(240, 0))); diff --git a/src/Elements.cpp b/src/Elements.cpp index 73f97a8..1a0b599 100644 --- a/src/Elements.cpp +++ b/src/Elements.cpp @@ -229,13 +229,7 @@ struct ElementsModalItem : MenuItem { struct ElementsWidget : ModuleWidget { ElementsWidget(Elements *module) : ModuleWidget(module) { - box.size = Vec(15*34, 380); - { - Panel *panel = new LightPanel(); - panel->backgroundImage = Image::load(assetPlugin(plugin, "res/Elements.png")); - panel->box.size = box.size; - addChild(panel); - } + setPanel(SVG::load(assetPlugin(plugin, "res/Elements.svg"))); addChild(Widget::create(Vec(15, 0))); addChild(Widget::create(Vec(480, 0))); diff --git a/src/Frames.cpp b/src/Frames.cpp index 98d0dd2..4450c9a 100644 --- a/src/Frames.cpp +++ b/src/Frames.cpp @@ -287,13 +287,7 @@ struct CKSSRot : SVGSwitch, ToggleSwitch { struct FramesWidget : ModuleWidget { FramesWidget(Frames *module) : ModuleWidget(module) { - box.size = Vec(15*18, 380); - { - Panel *panel = new LightPanel(); - panel->backgroundImage = Image::load(assetPlugin(plugin, "res/Frames.png")); - panel->box.size = box.size; - addChild(panel); - } + setPanel(SVG::load(assetPlugin(plugin, "res/Frames.svg"))); addChild(Widget::create(Vec(15, 0))); addChild(Widget::create(Vec(box.size.x-30, 0))); diff --git a/src/Kinks.cpp b/src/Kinks.cpp index 79e2ea5..491751d 100644 --- a/src/Kinks.cpp +++ b/src/Kinks.cpp @@ -70,13 +70,7 @@ void Kinks::step() { struct KinksWidget : ModuleWidget { KinksWidget(Kinks *module) : ModuleWidget(module) { - box.size = Vec(15*4, 380); - { - Panel *panel = new LightPanel(); - panel->backgroundImage = Image::load(assetPlugin(plugin, "res/Kinks.png")); - panel->box.size = box.size; - addChild(panel); - } + setPanel(SVG::load(assetPlugin(plugin, "res/Kinks.svg"))); addChild(Widget::create(Vec(15, 0))); addChild(Widget::create(Vec(15, 365))); diff --git a/src/Links.cpp b/src/Links.cpp index 124a26e..7f24fb3 100644 --- a/src/Links.cpp +++ b/src/Links.cpp @@ -58,13 +58,7 @@ void Links::step() { struct LinksWidget : ModuleWidget { LinksWidget(Links *module) : ModuleWidget(module) { - box.size = Vec(15*4, 380); - { - Panel *panel = new LightPanel(); - panel->backgroundImage = Image::load(assetPlugin(plugin, "res/Links.png")); - panel->box.size = box.size; - addChild(panel); - } + setPanel(SVG::load(assetPlugin(plugin, "res/Links.svg"))); addChild(Widget::create(Vec(15, 0))); addChild(Widget::create(Vec(15, 365))); diff --git a/src/Rings.cpp b/src/Rings.cpp index 3d47388..fed78da 100644 --- a/src/Rings.cpp +++ b/src/Rings.cpp @@ -248,13 +248,7 @@ void Rings::step() { struct RingsWidget : ModuleWidget { RingsWidget(Rings *module) : ModuleWidget(module) { - box.size = Vec(15*14, 380); - { - Panel *panel = new LightPanel(); - panel->backgroundImage = Image::load(assetPlugin(plugin, "res/Rings.png")); - panel->box.size = box.size; - addChild(panel); - } + setPanel(SVG::load(assetPlugin(plugin, "res/Rings.svg"))); addChild(Widget::create(Vec(15, 0))); addChild(Widget::create(Vec(180, 0))); diff --git a/src/Shades.cpp b/src/Shades.cpp index 94b68e1..357a6fa 100644 --- a/src/Shades.cpp +++ b/src/Shades.cpp @@ -62,13 +62,7 @@ void Shades::step() { struct ShadesWidget : ModuleWidget { ShadesWidget(Shades *module) : ModuleWidget(module) { - box.size = Vec(15*6, 380); - { - Panel *panel = new LightPanel(); - panel->backgroundImage = Image::load(assetPlugin(plugin, "res/Shades.png")); - panel->box.size = box.size; - addChild(panel); - } + setPanel(SVG::load(assetPlugin(plugin, "res/Shades.svg"))); addChild(Widget::create(Vec(15, 0))); addChild(Widget::create(Vec(15, 365))); diff --git a/src/Tides.cpp b/src/Tides.cpp index ad2b874..7d0915b 100644 --- a/src/Tides.cpp +++ b/src/Tides.cpp @@ -205,20 +205,20 @@ struct TidesSheepItem : MenuItem { struct TidesWidget : ModuleWidget { - Panel *tidesPanel; - Panel *sheepPanel; + SVGPanel *tidesPanel; + SVGPanel *sheepPanel; TidesWidget(Tides *module) : ModuleWidget(module) { box.size = Vec(15*14, 380); { - tidesPanel = new LightPanel(); - tidesPanel->backgroundImage = Image::load(assetPlugin(plugin, "res/Tides.png")); + tidesPanel = new SVGPanel(); + tidesPanel->setBackground(SVG::load(assetPlugin(plugin, "res/Tides.svg"))); tidesPanel->box.size = box.size; addChild(tidesPanel); } { - sheepPanel = new LightPanel(); - sheepPanel->backgroundImage = Image::load(assetPlugin(plugin, "res/Sheep.png")); + sheepPanel = new SVGPanel(); + sheepPanel->setBackground(SVG::load(assetPlugin(plugin, "res/Sheep.svg"))); sheepPanel->box.size = box.size; addChild(sheepPanel); } diff --git a/src/Veils.cpp b/src/Veils.cpp index d0391f6..d6b1e09 100644 --- a/src/Veils.cpp +++ b/src/Veils.cpp @@ -70,13 +70,7 @@ void Veils::step() { struct VeilsWidget : ModuleWidget { VeilsWidget(Veils *module) : ModuleWidget(module) { - box.size = Vec(15*12, 380); - { - Panel *panel = new LightPanel(); - panel->backgroundImage = Image::load(assetPlugin(plugin, "res/Veils.png")); - panel->box.size = box.size; - addChild(panel); - } + setPanel(SVG::load(assetPlugin(plugin, "res/Veils.svg"))); addChild(Widget::create(Vec(15, 0))); addChild(Widget::create(Vec(150, 0))); @@ -108,10 +102,10 @@ struct VeilsWidget : ModuleWidget { addOutput(Port::create(Vec(144, 198), Port::OUTPUT, module, Veils::OUT3_OUTPUT)); addOutput(Port::create(Vec(144, 277), Port::OUTPUT, module, Veils::OUT4_OUTPUT)); - addChild(ModuleLightWidget::create>(Vec(150, 87), module, Veils::OUT1_POS_LIGHT)); - addChild(ModuleLightWidget::create>(Vec(150, 166), module, Veils::OUT2_POS_LIGHT)); - addChild(ModuleLightWidget::create>(Vec(150, 245), module, Veils::OUT3_POS_LIGHT)); - addChild(ModuleLightWidget::create>(Vec(150, 324), module, Veils::OUT4_POS_LIGHT)); + addChild(ModuleLightWidget::create>(Vec(152, 87), module, Veils::OUT1_POS_LIGHT)); + addChild(ModuleLightWidget::create>(Vec(152, 166), module, Veils::OUT2_POS_LIGHT)); + addChild(ModuleLightWidget::create>(Vec(152, 245), module, Veils::OUT3_POS_LIGHT)); + addChild(ModuleLightWidget::create>(Vec(152, 324), module, Veils::OUT4_POS_LIGHT)); } }; diff --git a/src/Warps.cpp b/src/Warps.cpp index e0dd919..b86b609 100644 --- a/src/Warps.cpp +++ b/src/Warps.cpp @@ -128,13 +128,7 @@ struct AlgorithmLight : RedGreenBlueLight { struct WarpsWidget : ModuleWidget { WarpsWidget(Warps *module) : ModuleWidget(module) { - box.size = Vec(15*10, 380); - { - Panel *panel = new LightPanel(); - panel->backgroundImage = Image::load(assetPlugin(plugin, "res/Warps.png")); - panel->box.size = box.size; - addChild(panel); - } + setPanel(SVG::load(assetPlugin(plugin, "res/Warps.svg"))); addChild(Widget::create(Vec(15, 0))); addChild(Widget::create(Vec(120, 0))); @@ -158,7 +152,7 @@ struct WarpsWidget : ModuleWidget { addOutput(Port::create(Vec(80, 316), Port::OUTPUT, module, Warps::MODULATOR_OUTPUT)); addOutput(Port::create(Vec(116, 316), Port::OUTPUT, module, Warps::AUX_OUTPUT)); - addChild(ModuleLightWidget::create>(Vec(20, 167), module, Warps::CARRIER_GREEN_LIGHT)); + addChild(ModuleLightWidget::create>(Vec(21, 167), module, Warps::CARRIER_GREEN_LIGHT)); addChild(ModuleLightWidget::create(Vec(40, 63), module, Warps::ALGORITHM_LIGHT)); }