Browse Source

Transform drawLayer() in ZoomWidget and TransformWidget.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
4a15d69a19
3 changed files with 17 additions and 0 deletions
  1. +6
    -0
      include/widget/TransformWidget.hpp
  2. +1
    -0
      include/widget/ZoomWidget.hpp
  3. +10
    -0
      src/widget/ZoomWidget.cpp

+ 6
- 0
include/widget/TransformWidget.hpp View File

@@ -48,6 +48,12 @@ struct TransformWidget : Widget {
nvgTransform(args.vg, transform[0], transform[1], transform[2], transform[3], transform[4], transform[5]); nvgTransform(args.vg, transform[0], transform[1], transform[2], transform[3], transform[4], transform[5]);
Widget::draw(args); Widget::draw(args);
} }

void drawLayer(const DrawArgs& args, int layer) override {
// No need to save the state because that is done in the parent
nvgTransform(args.vg, transform[0], transform[1], transform[2], transform[3], transform[4], transform[5]);
Widget::drawLayer(args, layer);
}
}; };






+ 1
- 0
include/widget/ZoomWidget.hpp View File

@@ -18,6 +18,7 @@ struct ZoomWidget : Widget {
return zoom; return zoom;
} }
void draw(const DrawArgs& args) override; void draw(const DrawArgs& args) override;
void drawLayer(const DrawArgs& args, int layer) override;


void onHover(const HoverEvent& e) override { void onHover(const HoverEvent& e) override {
HoverEvent e2 = e; HoverEvent e2 = e;


+ 10
- 0
src/widget/ZoomWidget.cpp View File

@@ -50,5 +50,15 @@ void ZoomWidget::draw(const DrawArgs& args) {
} }




void ZoomWidget::drawLayer(const DrawArgs& args, int layer) {
DrawArgs zoomCtx = args;
zoomCtx.clipBox.pos = zoomCtx.clipBox.pos.div(zoom);
zoomCtx.clipBox.size = zoomCtx.clipBox.size.div(zoom);
// No need to save the state because that is done in the parent
nvgScale(args.vg, zoom, zoom);
Widget::drawLayer(zoomCtx, layer);
}


} // namespace widget } // namespace widget
} // namespace rack } // namespace rack

Loading…
Cancel
Save