@@ -225,7 +225,7 @@ class ObjectsResizer : public Component, NVGComponent, Value::Listener {
225225 std::function<void (Point<int >)> onMove;
226226};
227227
228- Canvas::Canvas (PluginEditor* parent, pd::Patch::Ptr p, Component* parentGraph)
228+ Canvas::Canvas (PluginEditor* parent, pd::Patch::Ptr p, Component* parentGraph, bool isQuickCanvas )
229229 : NVGComponent(this )
230230 , editor(parent)
231231 , pd(parent->pd)
@@ -235,6 +235,7 @@ Canvas::Canvas(PluginEditor* parent, pd::Patch::Ptr p, Component* parentGraph)
235235 , graphArea(nullptr )
236236 , pathUpdater(new ConnectionPathUpdater(this ))
237237 , globalMouseListener(this )
238+ , isQuickCanvas(isQuickCanvas)
238239{
239240 selectedComponents.addChangeListener (this );
240241
@@ -293,7 +294,7 @@ Canvas::Canvas(PluginEditor* parent, pd::Patch::Ptr p, Component* parentGraph)
293294 } else {
294295 isGraph = false ;
295296 }
296- if (!isGraph) {
297+ if (!isGraph && !isQuickCanvas ) {
297298 auto * canvasViewport = new CanvasViewport (editor, this );
298299
299300 canvasViewport->setViewedComponent (this , false );
@@ -397,7 +398,17 @@ Canvas::~Canvas()
397398 }
398399
399400 saveViewportState ();
401+
400402 zoomScale.removeListener (this );
403+ commandLocked.referTo (Value ());
404+ commandLocked.removeListener (this );
405+ patchWidth.removeListener (this );
406+ patchHeight.removeListener (this );
407+ xRange.removeListener (this );
408+ yRange.removeListener (this );
409+ isGraphChild.removeListener (this );
410+ hideNameAndArgs.removeListener (this );
411+
401412 editor->removeModifierKeyListener (this );
402413 pd->unregisterMessageListener (this );
403414 patch.setVisible (false );
@@ -592,8 +603,7 @@ bool Canvas::updateFramebuffers(NVGcontext* nvg, Rectangle<int> invalidRegion)
592603}
593604
594605// Callback from canvasViewport to perform actual rendering
595- void Canvas::performRender (NVGcontext* nvg, Rectangle<int > invalidRegion, bool isQuickCanvas)
596- {
606+ void Canvas::performRender (NVGcontext* nvg, Rectangle<int > invalidRegion, bool isQuickCanvas) {
597607 auto const halfSize = infiniteCanvasSize / 2 ;
598608 auto const zoom = getValue<float >(zoomScale);
599609 bool isLocked = getValue<bool >(locked);
@@ -818,15 +828,11 @@ void Canvas::performRender(NVGcontext* nvg, Rectangle<int> invalidRegion, bool i
818828
819829 nvgRestore (nvg);
820830
821- // if (quickCanvas) {
822- // std::cout << "rendering quick canvas region: " << invalidRegion.toString() << std::endl;
823- // quickCanvas->performRender(nvg, quickCanvas->getBounds(), true);
824- // }
825-
826-
827831 // Draw scrollbars
828- if (viewport && isQuickCanvas ) {
832+ if (viewport && !quickCanvas ) {
829833 reinterpret_cast <CanvasViewport*>(viewport.get ())->render (nvg);
834+ } else if (isQuickCanvas) {
835+ reinterpret_cast <CanvasViewport*>(findParentComponentOfClass<Canvas>()->viewport .get ())->render (nvg);
830836 }
831837}
832838
0 commit comments