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:
David Capello 2014-11-15 19:57:03 -03:00
parent 0b13e53c67
commit d0f97260fc
4 changed files with 41 additions and 4 deletions

View File

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

View File

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

View File

@ -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)
{

View File

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