Pencil: support multiple lines with Shift+click (#1387)

This commit is contained in:
David Capello 2017-06-16 16:42:37 -03:00
parent 265d18635c
commit a370a6e719
3 changed files with 30 additions and 16 deletions

View File

@ -128,6 +128,12 @@ bool DrawingState::onMouseUp(Editor* editor, MouseMessage* msg)
// Update the timeline. TODO make this state observable by the timeline.
App::instance()->timeline()->updateUsingEditor(editor);
// Restart again? Here we handle the case to draw multiple lines
// using Shift+click with the Pencil tool. When we release the mouse
// button, if the Shift key is pressed, the whole ToolLoop starts
// again.
checkStartDrawingStraightLine(editor);
return true;
}

View File

@ -487,22 +487,8 @@ bool StandbyState::onSetCursor(Editor* editor, const gfx::Point& mouseScreenPos)
bool StandbyState::onKeyDown(Editor* editor, KeyMessage* msg)
{
// Start line preview with shift key
if (editor->startStraightLineWithFreehandTool()) {
DrawingState* drawingState =
startDrawingState(editor,
DrawingType::LineFreehand,
tools::Pointer(
editor->document()->lastDrawingPoint(),
tools::Pointer::Left));
if (drawingState) {
drawingState->sendMovementToToolLoop(
tools::Pointer(
editor->screenToEditor(ui::get_mouse_position()),
tools::Pointer::Left));
if (checkStartDrawingStraightLine(editor))
return true;
}
}
return false;
}
@ -621,6 +607,27 @@ DrawingState* StandbyState::startDrawingState(Editor* editor,
return static_cast<DrawingState*>(newState.get());
}
bool StandbyState::checkStartDrawingStraightLine(Editor* editor)
{
// Start line preview with shift key
if (editor->startStraightLineWithFreehandTool()) {
DrawingState* drawingState =
startDrawingState(editor,
DrawingType::LineFreehand,
tools::Pointer(
editor->document()->lastDrawingPoint(),
tools::Pointer::Left));
if (drawingState) {
drawingState->sendMovementToToolLoop(
tools::Pointer(
editor->screenToEditor(ui::get_mouse_position()),
tools::Pointer::Left));
return true;
}
}
return false;
}
Transformation StandbyState::getTransformation(Editor* editor)
{
Transformation t = editor->document()->getTransformation();

View File

@ -50,6 +50,7 @@ namespace app {
protected:
void callEyedropper(Editor* editor);
bool checkStartDrawingStraightLine(Editor* editor);
class Decorator : public EditorDecorator {
public: