Browse Source

Set handle widget pos in SvgSlider::setHandlePos(). Step ModuleWidget before rendering in Browser so it can set its default appearance.

tags/v2.4.0
Andrew Belt 1 year ago
parent
commit
16db3fb2e1
3 changed files with 11 additions and 7 deletions
  1. +4
    -6
      include/componentlibrary.hpp
  2. +3
    -0
      src/app/Browser.cpp
  3. +4
    -1
      src/app/SvgSlider.cpp

+ 4
- 6
include/componentlibrary.hpp View File

@@ -680,11 +680,10 @@ struct BefacoTinyKnob : app::SvgKnob {


struct BefacoSlidePot : app::SvgSlider { struct BefacoSlidePot : app::SvgSlider {
BefacoSlidePot() { BefacoSlidePot() {
math::Vec margin = math::Vec(3.5, 3.5);
maxHandlePos = math::Vec(-1, -2).plus(margin);
minHandlePos = math::Vec(-1, 87).plus(margin);
setBackgroundSvg(Svg::load(asset::system("res/ComponentLibrary/BefacoSlidePot.svg"))); setBackgroundSvg(Svg::load(asset::system("res/ComponentLibrary/BefacoSlidePot.svg")));
setHandleSvg(Svg::load(asset::system("res/ComponentLibrary/BefacoSlidePotHandle.svg"))); setHandleSvg(Svg::load(asset::system("res/ComponentLibrary/BefacoSlidePotHandle.svg")));
math::Vec margin = math::Vec(3.5, 3.5);
setHandlePos(math::Vec(-1, 87).plus(margin), math::Vec(-1, -2).plus(margin));
background->box.pos = margin; background->box.pos = margin;
box.size = background->box.size.plus(margin.mult(2)); box.size = background->box.size.plus(margin.mult(2));
} }
@@ -705,11 +704,10 @@ using LEDSlider = VCVSlider;
struct VCVSliderHorizontal : app::SvgSlider { struct VCVSliderHorizontal : app::SvgSlider {
VCVSliderHorizontal() { VCVSliderHorizontal() {
horizontal = true; horizontal = true;
// TODO Fix positions
maxHandlePos = mm2px(math::Vec(22.078, 0.738).plus(math::Vec(0, 2)));
minHandlePos = mm2px(math::Vec(0.738, 0.738).plus(math::Vec(0, 2)));
// TODO Fix SVG // TODO Fix SVG
setBackgroundSvg(Svg::load(asset::system("res/ComponentLibrary/VCVSliderHorizontal.svg"))); setBackgroundSvg(Svg::load(asset::system("res/ComponentLibrary/VCVSliderHorizontal.svg")));
// TODO Fix positions
setHandlePos(mm2px(math::Vec(0.738, 0.738).plus(math::Vec(0, 2))), mm2px(math::Vec(22.078, 0.738).plus(math::Vec(0, 2))));
} }
}; };
using LEDSliderHorizontal = VCVSliderHorizontal; using LEDSliderHorizontal = VCVSliderHorizontal;


+ 3
- 0
src/app/Browser.cpp View File

@@ -202,6 +202,9 @@ struct ModelBox : widget::OpaqueWidget {
mwc->addChild(moduleWidget); mwc->addChild(moduleWidget);
mwc->box.size = moduleWidget->box.size; mwc->box.size = moduleWidget->box.size;


// Step ModuleWidget so it can set its default appearance.
moduleWidget->step();

updateZoom(); updateZoom();
} }




+ 4
- 1
src/app/SvgSlider.cpp View File

@@ -35,7 +35,7 @@ void SvgSlider::setHandleSvg(std::shared_ptr<window::Svg> svg) {
return; return;


handle->setSvg(svg); handle->setSvg(svg);
handle->box.pos = minHandlePos;
handle->box.pos = maxHandlePos;
fb->setDirty(); fb->setDirty();
} }


@@ -43,6 +43,9 @@ void SvgSlider::setHandleSvg(std::shared_ptr<window::Svg> svg) {
void SvgSlider::setHandlePos(math::Vec minHandlePos, math::Vec maxHandlePos) { void SvgSlider::setHandlePos(math::Vec minHandlePos, math::Vec maxHandlePos) {
this->minHandlePos = minHandlePos; this->minHandlePos = minHandlePos;
this->maxHandlePos = maxHandlePos; this->maxHandlePos = maxHandlePos;

// Set handle pos to maximum by default
handle->box.pos = maxHandlePos;
} }






Loading…
Cancel
Save