Skip to content

Commit

Permalink
Add messages for X1/X2 mouse buttons
Browse files Browse the repository at this point in the history
Related to aseprite#598
  • Loading branch information
dacap committed Apr 13, 2017
1 parent b9d4776 commit 2aeae2a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
4 changes: 3 additions & 1 deletion src/she/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ namespace she {
NoneButton,
LeftButton,
RightButton,
MiddleButton
MiddleButton,
X1Button,
X2Button,
};

typedef std::vector<std::string> Files;
Expand Down
26 changes: 19 additions & 7 deletions src/she/win/window.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SHE library
// Copyright (C) 2012-2016 David Capello
// Copyright (C) 2012-2017 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
Expand Down Expand Up @@ -458,7 +458,8 @@ namespace she {

case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_MBUTTONDOWN: {
case WM_MBUTTONDOWN:
case WM_XBUTTONDOWN: {
Event ev;
ev.setType(Event::MouseDown);
ev.setModifiers(get_modifiers_from_last_win32_message());
Expand All @@ -468,7 +469,10 @@ namespace she {
ev.setButton(
msg == WM_LBUTTONDOWN ? Event::LeftButton:
msg == WM_RBUTTONDOWN ? Event::RightButton:
msg == WM_MBUTTONDOWN ? Event::MiddleButton: Event::NoneButton);
msg == WM_MBUTTONDOWN ? Event::MiddleButton:
msg == WM_XBUTTONDOWN && GET_XBUTTON_WPARAM(wparam) == 1 ? Event::X1Button:
msg == WM_XBUTTONDOWN && GET_XBUTTON_WPARAM(wparam) == 2 ? Event::X2Button:
Event::NoneButton);

if (m_pointerType != PointerType::Unknown) {
ev.setPointerType(m_pointerType);
Expand All @@ -481,7 +485,8 @@ namespace she {

case WM_LBUTTONUP:
case WM_RBUTTONUP:
case WM_MBUTTONUP: {
case WM_MBUTTONUP:
case WM_XBUTTONUP: {
Event ev;
ev.setType(Event::MouseUp);
ev.setModifiers(get_modifiers_from_last_win32_message());
Expand All @@ -491,7 +496,10 @@ namespace she {
ev.setButton(
msg == WM_LBUTTONUP ? Event::LeftButton:
msg == WM_RBUTTONUP ? Event::RightButton:
msg == WM_MBUTTONUP ? Event::MiddleButton: Event::NoneButton);
msg == WM_MBUTTONUP ? Event::MiddleButton:
msg == WM_XBUTTONUP && GET_XBUTTON_WPARAM(wparam) == 1 ? Event::X1Button:
msg == WM_XBUTTONUP && GET_XBUTTON_WPARAM(wparam) == 2 ? Event::X2Button:
Event::NoneButton);

if (m_pointerType != PointerType::Unknown) {
ev.setPointerType(m_pointerType);
Expand All @@ -509,7 +517,8 @@ namespace she {

case WM_LBUTTONDBLCLK:
case WM_MBUTTONDBLCLK:
case WM_RBUTTONDBLCLK: {
case WM_RBUTTONDBLCLK:
case WM_XBUTTONDBLCLK: {
Event ev;
ev.setType(Event::MouseDoubleClick);
ev.setModifiers(get_modifiers_from_last_win32_message());
Expand All @@ -519,7 +528,10 @@ namespace she {
ev.setButton(
msg == WM_LBUTTONDBLCLK ? Event::LeftButton:
msg == WM_RBUTTONDBLCLK ? Event::RightButton:
msg == WM_MBUTTONDBLCLK ? Event::MiddleButton: Event::NoneButton);
msg == WM_MBUTTONDBLCLK ? Event::MiddleButton:
msg == WM_XBUTTONDBLCLK && GET_XBUTTON_WPARAM(wparam) == 1 ? Event::X1Button:
msg == WM_XBUTTONDBLCLK && GET_XBUTTON_WPARAM(wparam) == 2 ? Event::X2Button:
Event::NoneButton);

if (m_pointerType != PointerType::Unknown) {
ev.setPointerType(m_pointerType);
Expand Down
2 changes: 2 additions & 0 deletions src/ui/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ static MouseButtons mouse_buttons_from_she_to_ui(const she::Event& sheEvent)
case she::Event::LeftButton: return kButtonLeft; break;
case she::Event::RightButton: return kButtonRight; break;
case she::Event::MiddleButton: return kButtonMiddle; break;
case she::Event::X1Button: return kButtonX1; break;
case she::Event::X2Button: return kButtonX2; break;
default: return kButtonNone;
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/ui/mouse_buttons.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Aseprite UI Library
// Copyright (C) 2001-2013 David Capello
// Copyright (C) 2001-2017 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
Expand All @@ -14,7 +14,9 @@ namespace ui {
kButtonNone = 0,
kButtonLeft = 1,
kButtonRight = 2,
kButtonMiddle = 4
kButtonMiddle = 4,
kButtonX1 = 8,
kButtonX2 = 16,
};

} // namespace ui
Expand Down

0 comments on commit 2aeae2a

Please sign in to comment.