mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-17 07:10:36 +00:00
Avoid redrawing transformation on each mouse position change (related to #2149)
This commit is contained in:
parent
b355f34a70
commit
95ce7541e7
@ -52,6 +52,7 @@
|
||||
#include "ui/view.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
|
||||
namespace app {
|
||||
|
||||
@ -63,6 +64,8 @@ MovingPixelsState::MovingPixelsState(Editor* editor, MouseMessage* msg, PixelsMo
|
||||
, m_observingEditor(false)
|
||||
, m_discarded(false)
|
||||
, m_renderTimer(50)
|
||||
, m_oldSpritePos(std::numeric_limits<int>::min(),
|
||||
std::numeric_limits<int>::min())
|
||||
{
|
||||
// MovingPixelsState needs a selection tool to avoid problems
|
||||
// sharing the extra cel between the drawing cursor preview and the
|
||||
@ -367,14 +370,21 @@ bool MovingPixelsState::onMouseMove(Editor* editor, MouseMessage* msg)
|
||||
|
||||
// If there is a button pressed
|
||||
if (m_pixelsMovement->isDragging()) {
|
||||
m_renderTimer.start();
|
||||
m_pixelsMovement->setFastMode(true);
|
||||
|
||||
// Auto-scroll
|
||||
gfx::Point mousePos = editor->autoScroll(msg, AutoScroll::MouseDir);
|
||||
|
||||
// Get the position of the mouse in the sprite
|
||||
gfx::Point spritePos = editor->screenToEditor(mousePos);
|
||||
if (spritePos == m_oldSpritePos) {
|
||||
// Avoid redrawing everything if the position in the canvas didn't change.
|
||||
// TODO remove this if we add support for anti-aliasing in the
|
||||
// transformations
|
||||
return true;
|
||||
}
|
||||
m_oldSpritePos = spritePos;
|
||||
|
||||
m_renderTimer.start();
|
||||
m_pixelsMovement->setFastMode(true);
|
||||
|
||||
// Get the customization for the pixels movement (snap to grid, angle snap, etc.).
|
||||
KeyContext keyContext = KeyContext::Normal;
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -95,6 +95,11 @@ namespace app {
|
||||
|
||||
ui::Timer m_renderTimer;
|
||||
|
||||
// Position of the mouse in the canvas to avoid redrawing when the
|
||||
// mouse position changes (only we redraw when the canvas position
|
||||
// changes).
|
||||
gfx::Point m_oldSpritePos;
|
||||
|
||||
obs::connection m_ctxConn;
|
||||
obs::connection m_opaqueConn;
|
||||
obs::connection m_transparentConn;
|
||||
|
Loading…
Reference in New Issue
Block a user