[aseprite] 39/128: Enable eraser support for Wacom tablets on Skia/Win back-end
Tobias Hansen
thansen at moszumanska.debian.org
Mon May 9 21:24:21 UTC 2016
This is an automated email from the git hooks/post-receive script.
thansen pushed a commit to branch master
in repository aseprite.
commit a58cbfbc1ca510ed3ad6df199a1864e0634edf09
Author: David Capello <davidcapello at gmail.com>
Date: Wed Apr 20 22:33:10 2016 -0300
Enable eraser support for Wacom tablets on Skia/Win back-end
Related to #610
---
src/app/ui/document_view.cpp | 1 +
src/app/ui/editor/editor.cpp | 17 +++++++
src/app/ui/editor/editor.h | 2 +
src/app/ui/toolbar.cpp | 4 +-
src/ui/combobox.cpp | 3 +-
src/ui/int_entry.cpp | 3 +-
src/ui/manager.cpp | 109 ++++++++++++++++++++++++++++++++-----------
src/ui/manager.h | 37 +++++++++++----
src/ui/message.h | 5 ++
src/ui/pointer_type.h | 23 +++++++++
src/ui/ui.h | 5 +-
src/ui/widget.cpp | 2 +
12 files changed, 170 insertions(+), 41 deletions(-)
diff --git a/src/app/ui/document_view.cpp b/src/app/ui/document_view.cpp
index b8e3a13..8926720 100644
--- a/src/app/ui/document_view.cpp
+++ b/src/app/ui/document_view.cpp
@@ -113,6 +113,7 @@ protected:
if (lmb->isPressed(msg) || rmb->isPressed(msg)) {
MouseMessage mouseMsg(
(msg->type() == kKeyDownMessage ? kMouseDownMessage: kMouseUpMessage),
+ PointerType::Unknown,
(lmb->isPressed(msg) ? kButtonLeft: kButtonRight),
msg->modifiers(),
ui::get_mouse_position());
diff --git a/src/app/ui/editor/editor.cpp b/src/app/ui/editor/editor.cpp
index 13030bf..ca58bfd 100644
--- a/src/app/ui/editor/editor.cpp
+++ b/src/app/ui/editor/editor.cpp
@@ -164,6 +164,7 @@ Editor::Editor(Document* document, EditorFlags flags)
, m_antsOffset(0)
, m_customizationDelegate(NULL)
, m_docView(NULL)
+ , m_lastPointerType(ui::PointerType::Unknown)
, m_flags(flags)
, m_secondaryButton(false)
, m_aniSpeed(1.0)
@@ -919,6 +920,12 @@ tools::Tool* Editor::getCurrentEditorTool()
if (m_quicktool)
return m_quicktool;
+ // Eraser tip
+ if (m_lastPointerType == ui::PointerType::Eraser) {
+ tools::ToolBox* toolbox = App::instance()->getToolBox();
+ return toolbox->getToolById(tools::WellKnownTools::Eraser);
+ }
+
tools::Tool* tool = App::instance()->activeTool();
if (m_secondaryButton &&
@@ -1277,6 +1284,8 @@ bool Editor::onProcessMessage(Message* msg)
MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);
m_oldPos = mouseMsg->position();
+ m_lastPointerType = mouseMsg->pointerType();
+
if (!m_secondaryButton && mouseMsg->right()) {
m_secondaryButton = mouseMsg->right();
@@ -1293,6 +1302,9 @@ bool Editor::onProcessMessage(Message* msg)
case kMouseMoveMessage:
if (m_sprite) {
EditorStatePtr holdState(m_state);
+
+ m_lastPointerType = static_cast<MouseMessage*>(msg)->pointerType();
+
return m_state->onMouseMove(this, static_cast<MouseMessage*>(msg));
}
break;
@@ -1303,6 +1315,8 @@ bool Editor::onProcessMessage(Message* msg)
MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);
bool result = m_state->onMouseUp(this, mouseMsg);
+ m_lastPointerType = mouseMsg->pointerType();
+
if (!hasCapture()) {
m_secondaryButton = false;
@@ -1320,6 +1334,9 @@ bool Editor::onProcessMessage(Message* msg)
if (m_sprite) {
MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);
EditorStatePtr holdState(m_state);
+
+ m_lastPointerType = mouseMsg->pointerType();
+
bool used = m_state->onDoubleClick(this, mouseMsg);
if (used)
return true;
diff --git a/src/app/ui/editor/editor.h b/src/app/ui/editor/editor.h
index ba04e35..5c20232 100644
--- a/src/app/ui/editor/editor.h
+++ b/src/app/ui/editor/editor.h
@@ -28,6 +28,7 @@
#include "render/zoom.h"
#include "ui/base.h"
#include "ui/cursor_type.h"
+#include "ui/pointer_type.h"
#include "ui/timer.h"
#include "ui/widget.h"
@@ -324,6 +325,7 @@ namespace app {
DocumentView* m_docView;
gfx::Point m_oldPos;
+ ui::PointerType m_lastPointerType;
EditorFlags m_flags;
diff --git a/src/app/ui/toolbar.cpp b/src/app/ui/toolbar.cpp
index 68cbd6b..ce06e6a 100644
--- a/src/app/ui/toolbar.cpp
+++ b/src/app/ui/toolbar.cpp
@@ -1,5 +1,5 @@
// Aseprite
-// Copyright (C) 2001-2015 David Capello
+// Copyright (C) 2001-2016 David Capello
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@@ -221,6 +221,7 @@ bool ToolBar::onProcessMessage(Message* msg)
MouseMessage* mouseMsg2 = new MouseMessage(
kMouseDownMessage,
+ mouseMsg->pointerType(),
mouseMsg->buttons(),
mouseMsg->modifiers(),
mouseMsg->position());
@@ -635,6 +636,7 @@ bool ToolBar::ToolStrip::onProcessMessage(Message* msg)
MouseMessage* mouseMsg2 = new MouseMessage(
kMouseDownMessage,
+ mouseMsg->pointerType(),
mouseMsg->buttons(),
mouseMsg->modifiers(),
mouseMsg->position());
diff --git a/src/ui/combobox.cpp b/src/ui/combobox.cpp
index ddf508a..b66d6f9 100644
--- a/src/ui/combobox.cpp
+++ b/src/ui/combobox.cpp
@@ -1,5 +1,5 @@
// Aseprite UI Library
-// Copyright (C) 2001-2013, 2015 David Capello
+// Copyright (C) 2001-2016 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@@ -481,6 +481,7 @@ bool ComboBoxEntry::onProcessMessage(Message* msg)
releaseMouse();
MouseMessage mouseMsg2(kMouseDownMessage,
+ mouseMsg->pointerType(),
mouseMsg->buttons(),
mouseMsg->modifiers(),
mouseMsg->position());
diff --git a/src/ui/int_entry.cpp b/src/ui/int_entry.cpp
index a43b8f7..77ab25d 100644
--- a/src/ui/int_entry.cpp
+++ b/src/ui/int_entry.cpp
@@ -1,5 +1,5 @@
// Aseprite UI Library
-// Copyright (C) 2001-2013, 2015 David Capello
+// Copyright (C) 2001-2016 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@@ -90,6 +90,7 @@ bool IntEntry::onProcessMessage(Message* msg)
releaseMouse();
MouseMessage mouseMsg2(kMouseDownMessage,
+ mouseMsg->pointerType(),
mouseMsg->buttons(),
mouseMsg->modifiers(),
mouseMsg->position());
diff --git a/src/ui/manager.cpp b/src/ui/manager.cpp
index bf4c985..3d0b9bf 100644
--- a/src/ui/manager.cpp
+++ b/src/ui/manager.cpp
@@ -247,7 +247,8 @@ bool Manager::generateMessages()
}
void Manager::generateSetCursorMessage(const gfx::Point& mousePos,
- KeyModifiers modifiers)
+ KeyModifiers modifiers,
+ PointerType pointerType)
{
if (get_mouse_cursor() == kOutsideDisplay)
return;
@@ -257,7 +258,9 @@ void Manager::generateSetCursorMessage(const gfx::Point& mousePos,
enqueueMessage(
newMouseMessage(
kSetCursorMessage, dst,
- mousePos, _internal_get_mouse_buttons(),
+ mousePos,
+ pointerType,
+ _internal_get_mouse_buttons(),
modifiers));
else
set_mouse_cursor(kArrowCursor);
@@ -273,6 +276,18 @@ static MouseButtons mouse_buttons_from_she_to_ui(const she::Event& sheEvent)
}
}
+static PointerType pointer_type_from_she_event(const she::Event& sheEvent)
+{
+ switch (sheEvent.device()) {
+ case she::Event::MouseDevice: return PointerType::Mouse; break;
+ case she::Event::MultitouchDevice: return PointerType::Multitouch; break;
+ case she::Event::StylusDevice: return PointerType::Pen; break;
+ case she::Event::EraserDevice: return PointerType::Eraser; break;
+ default:
+ return PointerType::Unknown;
+ }
+}
+
void Manager::generateMessagesFromSheEvents()
{
she::Event lastMouseMoveEvent;
@@ -346,8 +361,11 @@ void Manager::generateMessagesFromSheEvents()
case she::Event::MouseMove: {
_internal_set_mouse_position(sheEvent.position());
- handleMouseMove(sheEvent.position(), m_mouseButtons,
- sheEvent.modifiers());
+ handleMouseMove(
+ sheEvent.position(),
+ m_mouseButtons,
+ sheEvent.modifiers(),
+ pointer_type_from_she_event(sheEvent));
lastMouseMoveEvent = sheEvent;
break;
}
@@ -357,8 +375,11 @@ void Manager::generateMessagesFromSheEvents()
m_mouseButtons = (MouseButtons)((int)m_mouseButtons | (int)pressedButton);
_internal_set_mouse_buttons(m_mouseButtons);
- handleMouseDown(sheEvent.position(), pressedButton,
- sheEvent.modifiers());
+ handleMouseDown(
+ sheEvent.position(),
+ pressedButton,
+ sheEvent.modifiers(),
+ pointer_type_from_she_event(sheEvent));
break;
}
@@ -367,21 +388,28 @@ void Manager::generateMessagesFromSheEvents()
m_mouseButtons = (MouseButtons)((int)m_mouseButtons & ~(int)releasedButton);
_internal_set_mouse_buttons(m_mouseButtons);
- handleMouseUp(sheEvent.position(), releasedButton,
- sheEvent.modifiers());
+ handleMouseUp(
+ sheEvent.position(),
+ releasedButton,
+ sheEvent.modifiers(),
+ pointer_type_from_she_event(sheEvent));
break;
}
case she::Event::MouseDoubleClick: {
MouseButtons clickedButton = mouse_buttons_from_she_to_ui(sheEvent);
- handleMouseDoubleClick(sheEvent.position(), clickedButton,
- sheEvent.modifiers());
+ handleMouseDoubleClick(
+ sheEvent.position(),
+ clickedButton,
+ sheEvent.modifiers(),
+ pointer_type_from_she_event(sheEvent));
break;
}
case she::Event::MouseWheel: {
handleMouseWheel(sheEvent.position(), m_mouseButtons,
sheEvent.modifiers(),
+ pointer_type_from_she_event(sheEvent),
sheEvent.wheelDelta(),
sheEvent.preciseWheel());
break;
@@ -403,13 +431,15 @@ void Manager::generateMessagesFromSheEvents()
if (lastMouseMoveEvent.type() != she::Event::None) {
sheEvent = lastMouseMoveEvent;
generateSetCursorMessage(sheEvent.position(),
- sheEvent.modifiers());
+ sheEvent.modifiers(),
+ pointer_type_from_she_event(sheEvent));
}
}
void Manager::handleMouseMove(const gfx::Point& mousePos,
MouseButtons mouseButtons,
- KeyModifiers modifiers)
+ KeyModifiers modifiers,
+ PointerType pointerType)
{
// Get the list of widgets to send mouse messages.
mouse_widgets_list.clear();
@@ -436,12 +466,16 @@ void Manager::handleMouseMove(const gfx::Point& mousePos,
enqueueMessage(
newMouseMessage(
kMouseMoveMessage, dst,
- mousePos, mouseButtons, modifiers));
+ mousePos,
+ pointerType,
+ mouseButtons,
+ modifiers));
}
void Manager::handleMouseDown(const gfx::Point& mousePos,
MouseButtons mouseButtons,
- KeyModifiers modifiers)
+ KeyModifiers modifiers,
+ PointerType pointerType)
{
handleWindowZOrder();
@@ -449,41 +483,53 @@ void Manager::handleMouseDown(const gfx::Point& mousePos,
newMouseMessage(
kMouseDownMessage,
(capture_widget ? capture_widget: mouse_widget),
- mousePos, mouseButtons, modifiers));
+ mousePos,
+ pointerType,
+ mouseButtons,
+ modifiers));
}
void Manager::handleMouseUp(const gfx::Point& mousePos,
MouseButtons mouseButtons,
- KeyModifiers modifiers)
+ KeyModifiers modifiers,
+ PointerType pointerType)
{
enqueueMessage(
newMouseMessage(
kMouseUpMessage,
(capture_widget ? capture_widget: mouse_widget),
- mousePos, mouseButtons, modifiers));
+ mousePos,
+ pointerType,
+ mouseButtons,
+ modifiers));
}
void Manager::handleMouseDoubleClick(const gfx::Point& mousePos,
MouseButtons mouseButtons,
- KeyModifiers modifiers)
+ KeyModifiers modifiers,
+ PointerType pointerType)
{
Widget* dst = (capture_widget ? capture_widget: mouse_widget);
if (dst) {
enqueueMessage(
newMouseMessage(
kDoubleClickMessage,
- dst, mousePos, mouseButtons, modifiers));
+ dst, mousePos, pointerType,
+ mouseButtons, modifiers));
}
}
void Manager::handleMouseWheel(const gfx::Point& mousePos,
- MouseButtons mouseButtons, KeyModifiers modifiers,
- const gfx::Point& wheelDelta, bool preciseWheel)
+ MouseButtons mouseButtons,
+ KeyModifiers modifiers,
+ PointerType pointerType,
+ const gfx::Point& wheelDelta,
+ bool preciseWheel)
{
enqueueMessage(newMouseMessage(
kMouseWheelMessage,
(capture_widget ? capture_widget: mouse_widget),
- mousePos, mouseButtons, modifiers,
+ mousePos, pointerType, mouseButtons, modifiers,
wheelDelta, preciseWheel));
}
@@ -776,7 +822,9 @@ void Manager::setMouse(Widget* widget)
Message* msg = newMouseMessage(
kMouseEnterMessage, NULL,
- get_mouse_position(), _internal_get_mouse_buttons(),
+ get_mouse_position(),
+ PointerType::Unknown,
+ _internal_get_mouse_buttons(),
kKeyUninitializedModifier);
for (; it != widget_parents.end(); ++it) {
@@ -786,7 +834,8 @@ void Manager::setMouse(Widget* widget)
enqueueMessage(msg);
generateSetCursorMessage(get_mouse_position(),
- kKeyUninitializedModifier);
+ kKeyUninitializedModifier,
+ PointerType::Unknown);
}
}
}
@@ -1419,12 +1468,16 @@ Widget* Manager::findMagneticWidget(Widget* widget)
// static
Message* Manager::newMouseMessage(
MessageType type,
- Widget* widget, const gfx::Point& mousePos,
- MouseButtons buttons, KeyModifiers modifiers,
- const gfx::Point& wheelDelta, bool preciseWheel)
+ Widget* widget,
+ const gfx::Point& mousePos,
+ PointerType pointerType,
+ MouseButtons buttons,
+ KeyModifiers modifiers,
+ const gfx::Point& wheelDelta,
+ bool preciseWheel)
{
Message* msg = new MouseMessage(
- type, buttons, modifiers, mousePos,
+ type, pointerType, buttons, modifiers, mousePos,
wheelDelta, preciseWheel);
if (widget != NULL)
diff --git a/src/ui/manager.h b/src/ui/manager.h
index 0b83646..cbc938d 100644
--- a/src/ui/manager.h
+++ b/src/ui/manager.h
@@ -12,6 +12,7 @@
#include "ui/keys.h"
#include "ui/message_type.h"
#include "ui/mouse_buttons.h"
+#include "ui/pointer_type.h"
#include "ui/widget.h"
namespace she {
@@ -115,14 +116,32 @@ namespace ui {
virtual void onNewDisplayConfiguration();
private:
- void generateSetCursorMessage(const gfx::Point& mousePos, KeyModifiers modifiers);
+ void generateSetCursorMessage(const gfx::Point& mousePos,
+ KeyModifiers modifiers,
+ PointerType pointerType);
void generateMessagesFromSheEvents();
- void handleMouseMove(const gfx::Point& mousePos, MouseButtons mouseButtons, KeyModifiers modifiers);
- void handleMouseDown(const gfx::Point& mousePos, MouseButtons mouseButtons, KeyModifiers modifiers);
- void handleMouseUp(const gfx::Point& mousePos, MouseButtons mouseButtons, KeyModifiers modifiers);
- void handleMouseDoubleClick(const gfx::Point& mousePos, MouseButtons mouseButtons, KeyModifiers modifiers);
- void handleMouseWheel(const gfx::Point& mousePos, MouseButtons mouseButtons, KeyModifiers modifiers,
- const gfx::Point& wheelDelta, bool preciseWheel);
+ void handleMouseMove(const gfx::Point& mousePos,
+ MouseButtons mouseButtons,
+ KeyModifiers modifiers,
+ PointerType pointerType);
+ void handleMouseDown(const gfx::Point& mousePos,
+ MouseButtons mouseButtons,
+ KeyModifiers modifiers,
+ PointerType pointerType);
+ void handleMouseUp(const gfx::Point& mousePos,
+ MouseButtons mouseButtons,
+ KeyModifiers modifiers,
+ PointerType pointerType);
+ void handleMouseDoubleClick(const gfx::Point& mousePos,
+ MouseButtons mouseButtons,
+ KeyModifiers modifiers,
+ PointerType pointerType);
+ void handleMouseWheel(const gfx::Point& mousePos,
+ MouseButtons mouseButtons,
+ KeyModifiers modifiers,
+ PointerType pointerType,
+ const gfx::Point& wheelDelta,
+ bool preciseWheel);
void handleTouchMagnify(const gfx::Point& mousePos,
const KeyModifiers modifiers,
const double magnification);
@@ -135,7 +154,9 @@ namespace ui {
static Message* newMouseMessage(
MessageType type,
Widget* widget, const gfx::Point& mousePos,
- MouseButtons buttons, KeyModifiers modifiers,
+ PointerType pointerType,
+ MouseButtons buttons,
+ KeyModifiers modifiers,
const gfx::Point& wheelDelta = gfx::Point(0, 0),
bool preciseWheel = false);
void broadcastKeyMsg(Message* msg);
diff --git a/src/ui/message.h b/src/ui/message.h
index 01dca20..01cff48 100644
--- a/src/ui/message.h
+++ b/src/ui/message.h
@@ -14,6 +14,7 @@
#include "ui/keys.h"
#include "ui/message_type.h"
#include "ui/mouse_buttons.h"
+#include "ui/pointer_type.h"
#include "ui/widgets_list.h"
#include <string>
@@ -103,18 +104,21 @@ namespace ui {
class MouseMessage : public Message {
public:
MouseMessage(MessageType type,
+ PointerType pointerType,
MouseButtons buttons,
KeyModifiers modifiers,
const gfx::Point& pos,
const gfx::Point& wheelDelta = gfx::Point(0, 0),
bool preciseWheel = false)
: Message(type, modifiers),
+ m_pointerType(pointerType),
m_buttons(buttons),
m_pos(pos),
m_wheelDelta(wheelDelta),
m_preciseWheel(preciseWheel) {
}
+ PointerType pointerType() const { return m_pointerType; }
MouseButtons buttons() const { return m_buttons; }
bool left() const { return (m_buttons & kButtonLeft) == kButtonLeft; }
bool right() const { return (m_buttons & kButtonRight) == kButtonRight; }
@@ -125,6 +129,7 @@ namespace ui {
const gfx::Point& position() const { return m_pos; }
private:
+ PointerType m_pointerType;
MouseButtons m_buttons; // Pressed buttons
gfx::Point m_pos; // Mouse position
gfx::Point m_wheelDelta; // Wheel axis variation
diff --git a/src/ui/pointer_type.h b/src/ui/pointer_type.h
new file mode 100644
index 0000000..8a17928
--- /dev/null
+++ b/src/ui/pointer_type.h
@@ -0,0 +1,23 @@
+// Aseprite UI Library
+// Copyright (C) 2016 David Capello
+//
+// This file is released under the terms of the MIT license.
+// Read LICENSE.txt for more information.
+
+#ifndef UI_POINTER_TYPE_H_INCLUDED
+#define UI_POINTER_TYPE_H_INCLUDED
+#pragma once
+
+namespace ui {
+
+ enum class PointerType {
+ Unknown,
+ Mouse,
+ Multitouch,
+ Pen,
+ Eraser
+ };
+
+} // namespace ui
+
+#endif
diff --git a/src/ui/ui.h b/src/ui/ui.h
index f9d153b..f5b4f99 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -1,5 +1,5 @@
// Aseprite UI Library
-// Copyright (C) 2001-2013, 2015 David Capello
+// Copyright (C) 2001-2016 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@@ -43,14 +43,15 @@
#include "ui/overlay_manager.h"
#include "ui/paint_event.h"
#include "ui/panel.h"
+#include "ui/pointer_type.h"
#include "ui/popup_window.h"
-#include "ui/size_hint_event.h"
#include "ui/property.h"
#include "ui/register_message.h"
#include "ui/resize_event.h"
#include "ui/save_layout_event.h"
#include "ui/scroll_bar.h"
#include "ui/separator.h"
+#include "ui/size_hint_event.h"
#include "ui/slider.h"
#include "ui/splitter.h"
#include "ui/system.h"
diff --git a/src/ui/widget.cpp b/src/ui/widget.cpp
index a20e4ef..047dc99 100644
--- a/src/ui/widget.cpp
+++ b/src/ui/widget.cpp
@@ -1242,6 +1242,7 @@ bool Widget::offerCapture(ui::MouseMessage* mouseMsg, int widget_type)
MouseMessage* mouseMsg2 = new MouseMessage(
kMouseDownMessage,
+ mouseMsg->pointerType(),
mouseMsg->buttons(),
mouseMsg->modifiers(),
mouseMsg->position());
@@ -1328,6 +1329,7 @@ bool Widget::onProcessMessage(Message* msg)
if (kMouseDownMessage) {
MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);
MouseMessage mouseMsg2(kMouseDownMessage,
+ mouseMsg->pointerType(),
mouseMsg->buttons(),
mouseMsg->modifiers(),
mouseMsg->position(),
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git
More information about the Pkg-games-commits
mailing list