mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-16 05:42:32 +00:00
Minor refactor from ui::MouseMessage -> tools::Pointer
This commit is contained in:
parent
b1c0d80356
commit
291ebc6a38
@ -144,7 +144,7 @@ bool DrawingState::onMouseDown(Editor* editor, MouseMessage* msg)
|
|||||||
// checkStartDrawingStraightLine() with the right-button.
|
// checkStartDrawingStraightLine() with the right-button.
|
||||||
if (recreateLoop && isCanceled) {
|
if (recreateLoop && isCanceled) {
|
||||||
ASSERT(!m_toolLoopManager);
|
ASSERT(!m_toolLoopManager);
|
||||||
checkStartDrawingStraightLine(editor, msg);
|
checkStartDrawingStraightLine(editor, &pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -154,6 +154,8 @@ bool DrawingState::onMouseUp(Editor* editor, MouseMessage* msg)
|
|||||||
{
|
{
|
||||||
ASSERT(m_toolLoopManager != NULL);
|
ASSERT(m_toolLoopManager != NULL);
|
||||||
|
|
||||||
|
tools::Pointer pointer = pointer_from_msg(editor, msg, m_velocity.velocity());
|
||||||
|
|
||||||
// Selection tools with Replace mode are cancelled with a simple click.
|
// Selection tools with Replace mode are cancelled with a simple click.
|
||||||
// ("one point" controller selection tool i.e. the magic wand, and
|
// ("one point" controller selection tool i.e. the magic wand, and
|
||||||
// selection tools with Add or Subtract mode aren't cancelled with
|
// selection tools with Add or Subtract mode aren't cancelled with
|
||||||
@ -167,8 +169,7 @@ bool DrawingState::onMouseUp(Editor* editor, MouseMessage* msg)
|
|||||||
m_type == DrawingType::SelectTiles ||
|
m_type == DrawingType::SelectTiles ||
|
||||||
(editor->getToolLoopModifiers() != tools::ToolLoopModifiers::kReplaceSelection &&
|
(editor->getToolLoopModifiers() != tools::ToolLoopModifiers::kReplaceSelection &&
|
||||||
editor->getToolLoopModifiers() != tools::ToolLoopModifiers::kIntersectSelection)) {
|
editor->getToolLoopModifiers() != tools::ToolLoopModifiers::kIntersectSelection)) {
|
||||||
m_lastPointer = pointer_from_msg(editor, msg,
|
m_lastPointer = pointer;
|
||||||
m_velocity.velocity());
|
|
||||||
|
|
||||||
// Notify the release of the mouse button to the tool loop
|
// Notify the release of the mouse button to the tool loop
|
||||||
// manager. This is the correct way to say "the user finishes the
|
// manager. This is the correct way to say "the user finishes the
|
||||||
@ -191,7 +192,7 @@ bool DrawingState::onMouseUp(Editor* editor, MouseMessage* msg)
|
|||||||
// button, if the Shift key is pressed, the whole ToolLoop starts
|
// button, if the Shift key is pressed, the whole ToolLoop starts
|
||||||
// again.
|
// again.
|
||||||
if (Preferences::instance().editor.straightLinePreview())
|
if (Preferences::instance().editor.straightLinePreview())
|
||||||
checkStartDrawingStraightLine(editor, msg);
|
checkStartDrawingStraightLine(editor, &pointer);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1689,11 +1689,11 @@ doc::tile_t Editor::getTileByPosition(const gfx::Point& mousePos)
|
|||||||
return doc::tile_i_notile;
|
return doc::tile_i_notile;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Editor::startStraightLineWithFreehandTool(const ui::MouseMessage* msg)
|
bool Editor::startStraightLineWithFreehandTool(const tools::Pointer* pointer)
|
||||||
{
|
{
|
||||||
tools::Tool* tool = App::instance()->activeToolManager()->selectedTool();
|
tools::Tool* tool = App::instance()->activeToolManager()->selectedTool();
|
||||||
// TODO add support for more buttons (X1, X2, etc.)
|
// TODO add support for more buttons (X1, X2, etc.)
|
||||||
int i = (msg && msg->right() ? 1: 0);
|
int i = (pointer && pointer->button() == tools::Pointer::Button::Right ? 1: 0);
|
||||||
return
|
return
|
||||||
(isActive() &&
|
(isActive() &&
|
||||||
(hasMouse() || hasCapture()) &&
|
(hasMouse() || hasCapture()) &&
|
||||||
|
@ -63,6 +63,7 @@ namespace app {
|
|||||||
|
|
||||||
namespace tools {
|
namespace tools {
|
||||||
class Ink;
|
class Ink;
|
||||||
|
class Pointer;
|
||||||
class Tool;
|
class Tool;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,7 +293,7 @@ namespace app {
|
|||||||
|
|
||||||
// Returns true if the Shift key to draw straight lines with a
|
// Returns true if the Shift key to draw straight lines with a
|
||||||
// freehand tool is pressed.
|
// freehand tool is pressed.
|
||||||
bool startStraightLineWithFreehandTool(const ui::MouseMessage* msg);
|
bool startStraightLineWithFreehandTool(const tools::Pointer* pointer);
|
||||||
|
|
||||||
// Functions to handle the set of selected slices.
|
// Functions to handle the set of selected slices.
|
||||||
bool isSliceSelected(const doc::Slice* slice) const;
|
bool isSliceSelected(const doc::Slice* slice) const;
|
||||||
|
@ -324,10 +324,12 @@ bool StandbyState::onMouseDown(Editor* editor, MouseMessage* msg)
|
|||||||
|
|
||||||
// Start the Tool-Loop
|
// Start the Tool-Loop
|
||||||
if (layer && (layer->isImage() || clickedInk->isSelection())) {
|
if (layer && (layer->isImage() || clickedInk->isSelection())) {
|
||||||
|
tools::Pointer pointer = pointer_from_msg(editor, msg);
|
||||||
|
|
||||||
// Shift+click on Pencil tool starts a line onMouseDown() when the
|
// Shift+click on Pencil tool starts a line onMouseDown() when the
|
||||||
// preview (onKeyDown) is disabled.
|
// preview (onKeyDown) is disabled.
|
||||||
if (!Preferences::instance().editor.straightLinePreview() &&
|
if (!Preferences::instance().editor.straightLinePreview() &&
|
||||||
checkStartDrawingStraightLine(editor, msg)) {
|
checkStartDrawingStraightLine(editor, &pointer)) {
|
||||||
// Send first mouse down to draw the straight line and start the
|
// Send first mouse down to draw the straight line and start the
|
||||||
// freehand mode.
|
// freehand mode.
|
||||||
editor->getState()->onMouseDown(editor, msg);
|
editor->getState()->onMouseDown(editor, msg);
|
||||||
@ -344,7 +346,7 @@ bool StandbyState::onMouseDown(Editor* editor, MouseMessage* msg)
|
|||||||
|
|
||||||
startDrawingState(editor,
|
startDrawingState(editor,
|
||||||
DrawingType::Regular,
|
DrawingType::Regular,
|
||||||
pointer_from_msg(editor, msg));
|
pointer);
|
||||||
|
|
||||||
// Restore layer edges
|
// Restore layer edges
|
||||||
if (layerEdges)
|
if (layerEdges)
|
||||||
@ -667,13 +669,13 @@ DrawingState* StandbyState::startDrawingState(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool StandbyState::checkStartDrawingStraightLine(Editor* editor,
|
bool StandbyState::checkStartDrawingStraightLine(Editor* editor,
|
||||||
const ui::MouseMessage* msg)
|
const tools::Pointer* pointer)
|
||||||
{
|
{
|
||||||
// Start line preview with shift key
|
// Start line preview with shift key
|
||||||
if (canCheckStartDrawingStraightLine() &&
|
if (canCheckStartDrawingStraightLine() &&
|
||||||
editor->startStraightLineWithFreehandTool(msg)) {
|
editor->startStraightLineWithFreehandTool(pointer)) {
|
||||||
tools::Pointer::Button pointerButton =
|
tools::Pointer::Button pointerButton =
|
||||||
(msg ? button_from_msg(msg): tools::Pointer::Left);
|
(pointer ? pointer->button(): tools::Pointer::Left);
|
||||||
|
|
||||||
DrawingState* drawingState =
|
DrawingState* drawingState =
|
||||||
startDrawingState(editor,
|
startDrawingState(editor,
|
||||||
@ -682,17 +684,16 @@ bool StandbyState::checkStartDrawingStraightLine(Editor* editor,
|
|||||||
editor->document()->lastDrawingPoint(),
|
editor->document()->lastDrawingPoint(),
|
||||||
tools::Vec2(0.0f, 0.0f),
|
tools::Vec2(0.0f, 0.0f),
|
||||||
pointerButton,
|
pointerButton,
|
||||||
msg ? msg->pointerType(): PointerType::Unknown,
|
pointer ? pointer->type(): PointerType::Unknown,
|
||||||
msg ? msg->pressure(): 0.0f));
|
pointer ? pointer->pressure(): 0.0f));
|
||||||
if (drawingState) {
|
if (drawingState) {
|
||||||
drawingState->sendMovementToToolLoop(
|
drawingState->sendMovementToToolLoop(
|
||||||
tools::Pointer(
|
tools::Pointer(
|
||||||
editor->screenToEditor(msg ? msg->position():
|
pointer ? pointer->point(): editor->screenToEditor(ui::get_mouse_position()),
|
||||||
ui::get_mouse_position()),
|
|
||||||
tools::Vec2(0.0f, 0.0f),
|
tools::Vec2(0.0f, 0.0f),
|
||||||
pointerButton,
|
pointerButton,
|
||||||
msg ? msg->pointerType(): tools::Pointer::Type::Unknown,
|
pointer ? pointer->type(): tools::Pointer::Type::Unknown,
|
||||||
msg ? msg->pressure(): 0.0f));
|
pointer ? pointer->pressure(): 0.0f));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2019 Igara Studio S.A.
|
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2018 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
@ -20,7 +20,6 @@ namespace app {
|
|||||||
namespace tools {
|
namespace tools {
|
||||||
class Ink;
|
class Ink;
|
||||||
class Pointer;
|
class Pointer;
|
||||||
class Command;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class DrawingState;
|
class DrawingState;
|
||||||
@ -55,7 +54,8 @@ namespace app {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void callEyedropper(Editor* editor, const ui::MouseMessage* msg);
|
void callEyedropper(Editor* editor, const ui::MouseMessage* msg);
|
||||||
bool checkStartDrawingStraightLine(Editor* editor, const ui::MouseMessage* msg);
|
bool checkStartDrawingStraightLine(Editor* editor,
|
||||||
|
const tools::Pointer* pointer);
|
||||||
virtual bool canCheckStartDrawingStraightLine() { return true; }
|
virtual bool canCheckStartDrawingStraightLine() { return true; }
|
||||||
|
|
||||||
class Decorator : public EditorDecorator {
|
class Decorator : public EditorDecorator {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user