From 4a15d69a19542a75d4dffb2abe073702109e7e27 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Mon, 18 Oct 2021 15:29:02 -0400 Subject: [PATCH] Transform drawLayer() in ZoomWidget and TransformWidget. --- include/widget/TransformWidget.hpp | 6 ++++++ include/widget/ZoomWidget.hpp | 1 + src/widget/ZoomWidget.cpp | 10 ++++++++++ 3 files changed, 17 insertions(+) diff --git a/include/widget/TransformWidget.hpp b/include/widget/TransformWidget.hpp index f83cba08..538abe03 100644 --- a/include/widget/TransformWidget.hpp +++ b/include/widget/TransformWidget.hpp @@ -48,6 +48,12 @@ struct TransformWidget : Widget { nvgTransform(args.vg, transform[0], transform[1], transform[2], transform[3], transform[4], transform[5]); 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); + } }; diff --git a/include/widget/ZoomWidget.hpp b/include/widget/ZoomWidget.hpp index be923b26..2719b408 100644 --- a/include/widget/ZoomWidget.hpp +++ b/include/widget/ZoomWidget.hpp @@ -18,6 +18,7 @@ struct ZoomWidget : Widget { return zoom; } void draw(const DrawArgs& args) override; + void drawLayer(const DrawArgs& args, int layer) override; void onHover(const HoverEvent& e) override { HoverEvent e2 = e; diff --git a/src/widget/ZoomWidget.cpp b/src/widget/ZoomWidget.cpp index ed791096..5049d58e 100644 --- a/src/widget/ZoomWidget.cpp +++ b/src/widget/ZoomWidget.cpp @@ -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 rack