Browse Source

Don't redraw FramebufferWidget on subpixel change when dragging ModuleWidgets.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
6ffe9ff900
4 changed files with 15 additions and 1 deletions
  1. +2
    -0
      include/window.hpp
  2. +5
    -0
      src/app/ModuleWidget.cpp
  3. +1
    -1
      src/widget/FramebufferWidget.cpp
  4. +7
    -0
      src/window.cpp

+ 2
- 0
include/window.hpp View File

@@ -92,6 +92,8 @@ struct Window {
DEPRECATED std::shared_ptr<Svg> loadSvg(const std::string& filename) {
return Svg::load(filename);
}

INTERNAL bool& fbDirtyOnSubpixelChange();
};




+ 5
- 0
src/app/ModuleWidget.cpp View File

@@ -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;



+ 1
- 1
src/widget/FramebufferWidget.cpp View File

@@ -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();
}


+ 7
- 0
src/window.cpp View File

@@ -88,6 +88,8 @@ struct Window::Internal {

std::map<std::string, std::shared_ptr<Font>> fontCache;
std::map<std::string, std::shared_ptr<Image>> imageCache;

bool fbDirtyOnSubpixelChange = true;
};


@@ -679,6 +681,11 @@ std::shared_ptr<Image> Window::loadImage(const std::string& filename) {
}


bool& Window::fbDirtyOnSubpixelChange() {
return internal->fbDirtyOnSubpixelChange;
}


void windowInit() {
int err;



Loading…
Cancel
Save