[aseprite] 52/134: Add KeyAction::Left/RightMouseButton (it's quite experimental at the moment)
Tobias Hansen
thansen at moszumanska.debian.org
Sat Mar 14 17:10:03 UTC 2015
This is an automated email from the git hooks/post-receive script.
thansen pushed a commit to branch master
in repository aseprite.
commit b96d615d6c5f0f54f5db1ce44d13ff522c3e8d97
Author: David Capello <davidcapello at gmail.com>
Date: Sat Nov 8 21:09:29 2014 -0300
Add KeyAction::Left/RightMouseButton (it's quite experimental at the moment)
---
src/app/ui/document_view.cpp | 27 +++++++++++++++++++++++++++
src/app/ui/keyboard_shortcuts.cpp | 2 ++
src/app/ui/keyboard_shortcuts.h | 2 ++
3 files changed, 31 insertions(+)
diff --git a/src/app/ui/document_view.cpp b/src/app/ui/document_view.cpp
index 2d72bf2..03998ed 100644
--- a/src/app/ui/document_view.cpp
+++ b/src/app/ui/document_view.cpp
@@ -38,6 +38,7 @@
#include "raster/sprite.h"
#include "ui/accelerator.h"
#include "ui/message.h"
+#include "ui/system.h"
#include "ui/view.h"
namespace app {
@@ -109,6 +110,32 @@ public:
return isKeyActionPressed(KeyAction::SubtractSelection);
}
+protected:
+ bool onProcessMessage(Message* msg) override {
+ switch (msg->type()) {
+
+ case kKeyDownMessage:
+ case kKeyUpMessage:
+ if (static_cast<KeyMessage*>(msg)->repeat() == 0) {
+ Key* lmb = KeyboardShortcuts::instance()->action(KeyAction::LeftMouseButton);
+ Key* rmb = KeyboardShortcuts::instance()->action(KeyAction::RightMouseButton);
+
+ // Convert action keys into mouse messages.
+ if (lmb->isPressed(msg) || rmb->isPressed(msg)) {
+ MouseMessage mouseMsg(
+ (msg->type() == kKeyDownMessage ? kMouseDownMessage: kMouseUpMessage),
+ (lmb->isPressed(msg) ? kButtonLeft: kButtonRight),
+ gfx::Point(jmouse_x(0), jmouse_y(0)));
+
+ sendMessage(&mouseMsg);
+ return true;
+ }
+ }
+ break;
+ }
+ return Editor::onProcessMessage(msg);
+ }
+
private:
bool isKeyActionPressed(KeyAction action) {
if (Key* key = KeyboardShortcuts::instance()->action(action))
diff --git a/src/app/ui/keyboard_shortcuts.cpp b/src/app/ui/keyboard_shortcuts.cpp
index 723365c..cb597a5 100644
--- a/src/app/ui/keyboard_shortcuts.cpp
+++ b/src/app/ui/keyboard_shortcuts.cpp
@@ -57,6 +57,8 @@ namespace {
{ "LockAxis" , "Lock Axis" , app::KeyAction::LockAxis },
{ "AddSelection" , "Add Selection" , app::KeyAction::AddSelection },
{ "SubtractSelection" , "Subtract Selection" , app::KeyAction::SubtractSelection },
+ { "LeftMouseButton" , "Trigger Left Mouse Button" , app::KeyAction::LeftMouseButton },
+ { "RightMouseButton" , "Trigger Right Mouse Button" , app::KeyAction::RightMouseButton },
{ NULL , NULL , app::KeyAction::None }
};
diff --git a/src/app/ui/keyboard_shortcuts.h b/src/app/ui/keyboard_shortcuts.h
index 3859def..4c70986 100644
--- a/src/app/ui/keyboard_shortcuts.h
+++ b/src/app/ui/keyboard_shortcuts.h
@@ -67,6 +67,8 @@ namespace app {
LockAxis,
AddSelection,
SubtractSelection,
+ LeftMouseButton,
+ RightMouseButton
};
class Key {
--
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