Browse Source

Remove old panel if ModuleWidget::setPanel is called multiple times,

move in2px and mm2px to widgets.hpp
tags/v0.5.0
Andrew Belt 7 years ago
parent
commit
661e93bb24
4 changed files with 18 additions and 10 deletions
  1. +2
    -0
      include/app.hpp
  2. +0
    -9
      include/rack.hpp
  3. +9
    -0
      include/widgets.hpp
  4. +7
    -1
      src/app/ModuleWidget.cpp

+ 2
- 0
include/app.hpp View File

@@ -14,6 +14,7 @@ struct Wire;
struct RackWidget; struct RackWidget;
struct ParamWidget; struct ParamWidget;
struct Port; struct Port;
struct SVGPanel;


//////////////////// ////////////////////
// module // module
@@ -31,6 +32,7 @@ struct ModuleWidget : OpaqueWidget {
/** Owns the module pointer */ /** Owns the module pointer */
Module *module = NULL; Module *module = NULL;


SVGPanel *panel = NULL;
std::vector<Port*> inputs; std::vector<Port*> inputs;
std::vector<Port*> outputs; std::vector<Port*> outputs;
std::vector<ParamWidget*> params; std::vector<ParamWidget*> params;


+ 0
- 9
include/rack.hpp View File

@@ -18,15 +18,6 @@ namespace rack {
//////////////////// ////////////////////




inline Vec in2px(Vec inches) {
return inches.mult(SVG_DPI);
}

inline Vec mm2px(Vec millimeters) {
return millimeters.mult(SVG_DPI / 25.4);
}


template <class TModuleWidget> template <class TModuleWidget>
Model *createModel(std::string manufacturerSlug, std::string manufacturerName, std::string slug, std::string name) { Model *createModel(std::string manufacturerSlug, std::string manufacturerName, std::string slug, std::string name) {
struct TModel : Model { struct TModel : Model {


+ 9
- 0
include/widgets.hpp View File

@@ -16,6 +16,15 @@
namespace rack { namespace rack {




inline Vec in2px(Vec inches) {
return inches.mult(SVG_DPI);
}

inline Vec mm2px(Vec millimeters) {
return millimeters.mult(SVG_DPI / 25.4);
}


//////////////////// ////////////////////
// resources // resources
//////////////////// ////////////////////


+ 7
- 1
src/app/ModuleWidget.cpp View File

@@ -43,7 +43,13 @@ void ModuleWidget::addParam(ParamWidget *param) {
} }


void ModuleWidget::setPanel(std::shared_ptr<SVG> svg) { void ModuleWidget::setPanel(std::shared_ptr<SVG> svg) {
SVGPanel *panel = new SVGPanel();
// Remove old panel
if (panel) {
removeChild(panel);
panel = NULL;
}

panel = new SVGPanel();
panel->setBackground(svg); panel->setBackground(svg);
addChild(panel); addChild(panel);




Loading…
Cancel
Save