From 6ffe9ff900038fa0b1df1725ab9214295872a3e8 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Tue, 22 Jun 2021 16:50:09 -0400 Subject: [PATCH] Don't redraw FramebufferWidget on subpixel change when dragging ModuleWidgets. --- include/window.hpp | 2 ++ src/app/ModuleWidget.cpp | 5 +++++ src/widget/FramebufferWidget.cpp | 2 +- src/window.cpp | 7 +++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/window.hpp b/include/window.hpp index 04e5194d..2f5b1cee 100644 --- a/include/window.hpp +++ b/include/window.hpp @@ -92,6 +92,8 @@ struct Window { DEPRECATED std::shared_ptr loadSvg(const std::string& filename) { return Svg::load(filename); } + + INTERNAL bool& fbDirtyOnSubpixelChange(); }; diff --git a/src/app/ModuleWidget.cpp b/src/app/ModuleWidget.cpp index feb8eeaa..9c0d471f 100644 --- a/src/app/ModuleWidget.cpp +++ b/src/app/ModuleWidget.cpp @@ -681,6 +681,9 @@ void ModuleWidget::onHoverKey(const HoverKeyEvent& e) { void ModuleWidget::onDragStart(const DragStartEvent& e) { if (e.button == GLFW_MOUSE_BUTTON_LEFT) { + // HACK Disable FramebufferWidget redrawing subpixels while dragging + APP->window->fbDirtyOnSubpixelChange() = false; + // Clear dragRack so dragging in not enabled until mouse is moved a bit. internal->dragRackPos = math::Vec(NAN, NAN); @@ -691,6 +694,8 @@ void ModuleWidget::onDragStart(const DragStartEvent& e) { void ModuleWidget::onDragEnd(const DragEndEvent& e) { if (e.button == GLFW_MOUSE_BUTTON_LEFT) { + APP->window->fbDirtyOnSubpixelChange() = true; + // The next time the module is dragged, it should always move immediately internal->dragEnabled = true; diff --git a/src/widget/FramebufferWidget.cpp b/src/widget/FramebufferWidget.cpp index 4b836cc2..b057bcbf 100644 --- a/src/widget/FramebufferWidget.cpp +++ b/src/widget/FramebufferWidget.cpp @@ -188,7 +188,7 @@ void FramebufferWidget::draw(const DrawArgs& args) { // If drawing to a new subpixel location, rerender in the next frame. // Anything less than 0.1 pixels isn't noticeable. math::Vec offsetFDelta = internal->offsetF.minus(internal->fbOffsetF); - if (dirtyOnSubpixelChange && offsetFDelta.square() >= std::pow(0.1f, 2)) { + if (offsetFDelta.square() >= std::pow(0.1f, 2) && dirtyOnSubpixelChange && APP->window->fbDirtyOnSubpixelChange()) { // DEBUG("%p dirty subpixel (%f, %f) (%f, %f)", this, VEC_ARGS(internal->offsetF), VEC_ARGS(internal->fbOffsetF)); setDirty(); } diff --git a/src/window.cpp b/src/window.cpp index cb6c5555..65f1b075 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -88,6 +88,8 @@ struct Window::Internal { std::map> fontCache; std::map> imageCache; + + bool fbDirtyOnSubpixelChange = true; }; @@ -679,6 +681,11 @@ std::shared_ptr Window::loadImage(const std::string& filename) { } +bool& Window::fbDirtyOnSubpixelChange() { + return internal->fbDirtyOnSubpixelChange; +} + + void windowInit() { int err;