move in2px and mm2px to widgets.hpptags/v0.5.0
| @@ -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; | ||||
| @@ -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 { | ||||
| @@ -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 | ||||
| //////////////////// | //////////////////// | ||||
| @@ -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); | ||||