mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-17 08:43:11 +00:00
Avoid regenerating Document's extral cel when we're moving pixels (fix #522)
As PixelsMovement class uses the extra cel to show the pixels that we're moving, we cannot show brush previews of quicktools (as the brush preview uses/destroy/regenerate the same extra cel for its own purpose).
This commit is contained in:
parent
0b13e53c67
commit
d0f97260fc
@ -1012,15 +1012,29 @@ void Editor::updateQuicktool()
|
||||
return;
|
||||
}
|
||||
|
||||
tools::Tool* old_quicktool = m_quicktool;
|
||||
tools::Tool* new_quicktool = m_customizationDelegate->getQuickTool(current_tool);
|
||||
|
||||
// Check if the current state accept the given quicktool.
|
||||
if (new_quicktool && !m_state->acceptQuickTool(new_quicktool))
|
||||
return;
|
||||
|
||||
// Hide the drawing cursor with the current tool brush size before
|
||||
// we change the quicktool. In this way we avoid using the
|
||||
// quicktool brush size to clean the current tool cursor.
|
||||
hideDrawingCursor();
|
||||
//
|
||||
// TODO Remove EditorState::regenerateDrawingCursor() creating a
|
||||
// new Document concept of multiple extra cels: we need an extra
|
||||
// cel for the drawing cursor, other for the moving pixels,
|
||||
// etc. In this way we'll not have conflicts between different
|
||||
// uses of the same extra cel.
|
||||
if (m_state->regenerateDrawingCursor())
|
||||
hideDrawingCursor();
|
||||
|
||||
tools::Tool* old_quicktool = m_quicktool;
|
||||
m_quicktool = m_customizationDelegate->getQuickTool(current_tool);
|
||||
m_quicktool = new_quicktool;
|
||||
|
||||
showDrawingCursor();
|
||||
if (m_state->regenerateDrawingCursor())
|
||||
showDrawingCursor();
|
||||
|
||||
// If the tool has changed, we must to update the status bar because
|
||||
// the new tool can display something different in the status bar (e.g. Eyedropper)
|
||||
|
@ -32,6 +32,10 @@ namespace app {
|
||||
class Editor;
|
||||
class EditorDecorator;
|
||||
|
||||
namespace tools {
|
||||
class Tool;
|
||||
}
|
||||
|
||||
// Represents one state of the sprite's editor (Editor class). This
|
||||
// is a base class, a dummy state that ignores all events from the
|
||||
// Editor. Subclasses overrides these methods to customize the
|
||||
@ -103,6 +107,13 @@ namespace app {
|
||||
// drawing cursor.
|
||||
virtual bool requireBrushPreview() { return false; }
|
||||
|
||||
// Returns true if this state accept the given quicktool.
|
||||
virtual bool acceptQuickTool(tools::Tool* tool) { return true; }
|
||||
|
||||
// Returns true if this state supports changing the drawing cursor
|
||||
// extra cel.
|
||||
virtual bool regenerateDrawingCursor() { return true; }
|
||||
|
||||
private:
|
||||
DISABLE_COPYING(EditorState);
|
||||
};
|
||||
|
@ -413,6 +413,16 @@ bool MovingPixelsState::onUpdateStatusBar(Editor* editor)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MovingPixelsState::acceptQuickTool(tools::Tool* tool)
|
||||
{
|
||||
return
|
||||
(!m_pixelsMovement ||
|
||||
tool->getInk(0)->isSelection() ||
|
||||
tool->getInk(0)->isEyedropper() ||
|
||||
tool->getInk(0)->isScrollMovement() ||
|
||||
tool->getInk(0)->isZoom());
|
||||
}
|
||||
|
||||
// Before executing any command, we drop the pixels (go back to standby).
|
||||
void MovingPixelsState::onBeforeCommandExecution(Command* command)
|
||||
{
|
||||
|
@ -58,6 +58,8 @@ namespace app {
|
||||
virtual bool onKeyDown(Editor* editor, ui::KeyMessage* msg) override;
|
||||
virtual bool onKeyUp(Editor* editor, ui::KeyMessage* msg) override;
|
||||
virtual bool onUpdateStatusBar(Editor* editor) override;
|
||||
virtual bool acceptQuickTool(tools::Tool* tool) override;
|
||||
virtual bool regenerateDrawingCursor() override { return false; }
|
||||
|
||||
// EditorObserver
|
||||
virtual void onBeforeFrameChanged(Editor* editor) override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user