Merge branch 'dev' of git@github.com:aseprite/aseprite.git into dev

This commit is contained in:
David Capello 2014-04-29 01:21:43 -03:00
commit be13633d44
22 changed files with 129 additions and 62 deletions

View File

@ -268,14 +268,6 @@ bool MovingPixelsState::onMouseMove(Editor* editor, MouseMessage* msg)
return StandbyState::onMouseMove(editor, msg); return StandbyState::onMouseMove(editor, msg);
} }
bool MovingPixelsState::onMouseWheel(Editor* editor, MouseMessage* msg)
{
ASSERT(m_pixelsMovement != NULL);
// Use StandbyState implementation
return StandbyState::onMouseWheel(editor, msg);
}
bool MovingPixelsState::onSetCursor(Editor* editor) bool MovingPixelsState::onSetCursor(Editor* editor)
{ {
ASSERT(m_pixelsMovement != NULL); ASSERT(m_pixelsMovement != NULL);

View File

@ -50,7 +50,6 @@ namespace app {
virtual bool onMouseDown(Editor* editor, ui::MouseMessage* msg) OVERRIDE; virtual bool onMouseDown(Editor* editor, ui::MouseMessage* msg) OVERRIDE;
virtual bool onMouseUp(Editor* editor, ui::MouseMessage* msg) OVERRIDE; virtual bool onMouseUp(Editor* editor, ui::MouseMessage* msg) OVERRIDE;
virtual bool onMouseMove(Editor* editor, ui::MouseMessage* msg) OVERRIDE; virtual bool onMouseMove(Editor* editor, ui::MouseMessage* msg) OVERRIDE;
virtual bool onMouseWheel(Editor* editor, ui::MouseMessage* msg) OVERRIDE;
virtual bool onSetCursor(Editor* editor) OVERRIDE; virtual bool onSetCursor(Editor* editor) OVERRIDE;
virtual bool onKeyDown(Editor* editor, ui::KeyMessage* msg) OVERRIDE; virtual bool onKeyDown(Editor* editor, ui::KeyMessage* msg) OVERRIDE;
virtual bool onKeyUp(Editor* editor, ui::KeyMessage* msg) OVERRIDE; virtual bool onKeyUp(Editor* editor, ui::KeyMessage* msg) OVERRIDE;

View File

@ -74,11 +74,6 @@ bool ScrollingState::onMouseMove(Editor* editor, MouseMessage* msg)
return true; return true;
} }
bool ScrollingState::onMouseWheel(Editor* editor, MouseMessage* msg)
{
return false;
}
bool ScrollingState::onSetCursor(Editor* editor) bool ScrollingState::onSetCursor(Editor* editor)
{ {
editor->hideDrawingCursor(); editor->hideDrawingCursor();

View File

@ -34,7 +34,6 @@ namespace app {
virtual bool onMouseDown(Editor* editor, ui::MouseMessage* msg) OVERRIDE; virtual bool onMouseDown(Editor* editor, ui::MouseMessage* msg) OVERRIDE;
virtual bool onMouseUp(Editor* editor, ui::MouseMessage* msg) OVERRIDE; virtual bool onMouseUp(Editor* editor, ui::MouseMessage* msg) OVERRIDE;
virtual bool onMouseMove(Editor* editor, ui::MouseMessage* msg) OVERRIDE; virtual bool onMouseMove(Editor* editor, ui::MouseMessage* msg) OVERRIDE;
virtual bool onMouseWheel(Editor* editor, ui::MouseMessage* msg) OVERRIDE;
virtual bool onSetCursor(Editor* editor) OVERRIDE; virtual bool onSetCursor(Editor* editor) OVERRIDE;
virtual bool onKeyDown(Editor* editor, ui::KeyMessage* msg) OVERRIDE; virtual bool onKeyDown(Editor* editor, ui::KeyMessage* msg) OVERRIDE;
virtual bool onKeyUp(Editor* editor, ui::KeyMessage* msg) OVERRIDE; virtual bool onKeyUp(Editor* editor, ui::KeyMessage* msg) OVERRIDE;

View File

@ -281,12 +281,15 @@ bool StandbyState::onMouseMove(Editor* editor, MouseMessage* msg)
bool StandbyState::onMouseWheel(Editor* editor, MouseMessage* msg) bool StandbyState::onMouseWheel(Editor* editor, MouseMessage* msg)
{ {
int dz = -msg->wheelDelta(); int dz = msg->wheelDelta().x + msg->wheelDelta().y;
WHEEL_ACTION wheelAction = WHEEL_NONE; WHEEL_ACTION wheelAction = WHEEL_NONE;
bool scrollBigSteps = false; bool scrollBigSteps = false;
// Without modifiers // Without modifiers
if (msg->keyModifiers() == kKeyNoneModifier) { if (msg->keyModifiers() == kKeyNoneModifier) {
if (msg->wheelDelta().x != 0)
wheelAction = WHEEL_HSCROLL;
else
wheelAction = WHEEL_ZOOM; wheelAction = WHEEL_ZOOM;
} }
else { else {
@ -318,7 +321,6 @@ bool StandbyState::onMouseWheel(Editor* editor, MouseMessage* msg)
break; break;
case WHEEL_FG: case WHEEL_FG:
// if (m_state == EDITOR_STATE_STANDBY)
{ {
int newIndex = 0; int newIndex = 0;
if (ColorBar::instance()->getFgColor().getType() == app::Color::IndexType) { if (ColorBar::instance()->getFgColor().getType() == app::Color::IndexType) {
@ -330,7 +332,6 @@ bool StandbyState::onMouseWheel(Editor* editor, MouseMessage* msg)
break; break;
case WHEEL_BG: case WHEEL_BG:
// if (m_state == EDITOR_STATE_STANDBY)
{ {
int newIndex = 0; int newIndex = 0;
if (ColorBar::instance()->getBgColor().getType() == app::Color::IndexType) { if (ColorBar::instance()->getBgColor().getType() == app::Color::IndexType) {
@ -342,7 +343,6 @@ bool StandbyState::onMouseWheel(Editor* editor, MouseMessage* msg)
break; break;
case WHEEL_FRAME: case WHEEL_FRAME:
// if (m_state == EDITOR_STATE_STANDBY)
{ {
Command* command = CommandsModule::instance()->getCommandByName Command* command = CommandsModule::instance()->getCommandByName
((dz < 0) ? CommandId::GotoNextFrame: ((dz < 0) ? CommandId::GotoNextFrame:

View File

@ -73,11 +73,6 @@ bool ZoomingState::onMouseMove(Editor* editor, MouseMessage* msg)
return true; return true;
} }
bool ZoomingState::onMouseWheel(Editor* editor, MouseMessage* msg)
{
return false;
}
bool ZoomingState::onSetCursor(Editor* editor) bool ZoomingState::onSetCursor(Editor* editor)
{ {
editor->hideDrawingCursor(); editor->hideDrawingCursor();

View File

@ -34,7 +34,6 @@ namespace app {
virtual bool onMouseDown(Editor* editor, ui::MouseMessage* msg) OVERRIDE; virtual bool onMouseDown(Editor* editor, ui::MouseMessage* msg) OVERRIDE;
virtual bool onMouseUp(Editor* editor, ui::MouseMessage* msg) OVERRIDE; virtual bool onMouseUp(Editor* editor, ui::MouseMessage* msg) OVERRIDE;
virtual bool onMouseMove(Editor* editor, ui::MouseMessage* msg) OVERRIDE; virtual bool onMouseMove(Editor* editor, ui::MouseMessage* msg) OVERRIDE;
virtual bool onMouseWheel(Editor* editor, ui::MouseMessage* msg) OVERRIDE;
virtual bool onSetCursor(Editor* editor) OVERRIDE; virtual bool onSetCursor(Editor* editor) OVERRIDE;
virtual bool onKeyDown(Editor* editor, ui::KeyMessage* msg) OVERRIDE; virtual bool onKeyDown(Editor* editor, ui::KeyMessage* msg) OVERRIDE;
virtual bool onKeyUp(Editor* editor, ui::KeyMessage* msg) OVERRIDE; virtual bool onKeyUp(Editor* editor, ui::KeyMessage* msg) OVERRIDE;

View File

@ -274,7 +274,7 @@ bool FileList::onProcessMessage(Message* msg)
View* view = View::getView(this); View* view = View::getView(this);
if (view) { if (view) {
gfx::Point scroll = view->getViewScroll(); gfx::Point scroll = view->getViewScroll();
scroll.y += -static_cast<MouseMessage*>(msg)->wheelDelta() * 3*(2+getTextHeight()+2); scroll += static_cast<MouseMessage*>(msg)->wheelDelta() * 3*(2+getTextHeight()+2);
view->setViewScroll(scroll); view->setViewScroll(scroll);
} }
break; break;

View File

@ -255,7 +255,7 @@ bool PaletteView::onProcessMessage(Message* msg)
View* view = View::getView(this); View* view = View::getView(this);
if (view) { if (view) {
gfx::Point scroll = view->getViewScroll(); gfx::Point scroll = view->getViewScroll();
scroll.y += -static_cast<MouseMessage*>(msg)->wheelDelta() * 3 * m_boxsize; scroll += static_cast<MouseMessage*>(msg)->wheelDelta() * 3 * m_boxsize;
view->setViewScroll(scroll); view->setViewScroll(scroll);
} }
break; break;

View File

@ -286,14 +286,15 @@ bool Tabs::onProcessMessage(Message* msg)
return true; return true;
case kMouseWheelMessage: { case kMouseWheelMessage: {
int dx = -static_cast<MouseMessage*>(msg)->wheelDelta() * getBounds().w/6; int dz =
// setScrollX(m_scrollX+dx); (static_cast<MouseMessage*>(msg)->wheelDelta().x -
static_cast<MouseMessage*>(msg)->wheelDelta().y) * getBounds().w/6;
m_begScrollX = m_scrollX; m_begScrollX = m_scrollX;
if (m_ani != ANI_SMOOTH_SCROLL) if (m_ani != ANI_SMOOTH_SCROLL)
m_endScrollX = m_scrollX + dx; m_endScrollX = m_scrollX + dz;
else else
m_endScrollX += dx; m_endScrollX += dz;
// Limit endScrollX position (to improve animation ending to the correct position) // Limit endScrollX position (to improve animation ending to the correct position)
{ {

View File

@ -740,10 +740,12 @@ bool Timeline::onProcessMessage(Message* msg)
case kMouseWheelMessage: case kMouseWheelMessage:
if (m_document) { if (m_document) {
int dz = -static_cast<MouseMessage*>(msg)->wheelDelta(); int dz = static_cast<MouseMessage*>(msg)->wheelDelta().y;
int dx = 0; int dx = 0;
int dy = 0; int dy = 0;
dx += static_cast<MouseMessage*>(msg)->wheelDelta().x;
if (msg->ctrlPressed()) if (msg->ctrlPressed())
dx = dz * FRMSIZE; dx = dz * FRMSIZE;
else else

View File

@ -252,7 +252,7 @@ bool ToolBar::onProcessMessage(Message* msg)
MouseMessage* mouseMsg2 = new MouseMessage( MouseMessage* mouseMsg2 = new MouseMessage(
kMouseDownMessage, kMouseDownMessage,
mouseMsg->buttons(), mouseMsg->buttons(),
mouseMsg->position(), 0); mouseMsg->position());
mouseMsg2->addRecipient(strip); mouseMsg2->addRecipient(strip);
getManager()->enqueueMessage(mouseMsg2); getManager()->enqueueMessage(mouseMsg2);
} }
@ -694,7 +694,7 @@ bool ToolBar::ToolStrip::onProcessMessage(Message* msg)
MouseMessage* mouseMsg2 = new MouseMessage( MouseMessage* mouseMsg2 = new MouseMessage(
kMouseDownMessage, kMouseDownMessage,
mouseMsg->buttons(), mouseMsg->buttons(),
mouseMsg->position(), 0); mouseMsg->position());
mouseMsg2->addRecipient(bar); mouseMsg2->addRecipient(bar);
getManager()->enqueueMessage(mouseMsg2); getManager()->enqueueMessage(mouseMsg2);
} }

View File

@ -43,21 +43,21 @@ namespace she {
int type() const { return m_type; } int type() const { return m_type; }
const Files& files() const { return m_files; } const Files& files() const { return m_files; }
gfx::Point position() const { return m_position; } gfx::Point position() const { return m_position; }
gfx::Point wheelDelta() const { return m_wheelDelta; }
MouseButton button() const { return m_button; } MouseButton button() const { return m_button; }
int delta() const { return m_delta; }
void setType(Type type) { m_type = type; } void setType(Type type) { m_type = type; }
void setFiles(const Files& files) { m_files = files; } void setFiles(const Files& files) { m_files = files; }
void setPosition(const gfx::Point& pos) { m_position = pos; } void setPosition(const gfx::Point& pos) { m_position = pos; }
void setWheelDelta(const gfx::Point& delta) { m_wheelDelta = delta; }
void setButton(MouseButton button) { m_button = button; } void setButton(MouseButton button) { m_button = button; }
void setDelta(int delta) { m_delta = delta; }
private: private:
Type m_type; Type m_type;
Files m_files; Files m_files;
gfx::Point m_position; gfx::Point m_position;
gfx::Point m_wheelDelta;
MouseButton m_button; MouseButton m_button;
int m_delta;
}; };
} // namespace she } // namespace she

View File

@ -28,6 +28,10 @@
#else #else
typedef FARPROC wndproc_t; typedef FARPROC wndproc_t;
#endif #endif
#ifndef WM_MOUSEHWHEEL
#define WM_MOUSEHWHEEL 0x020E
#endif
#endif #endif
#ifdef WIN32 #ifdef WIN32
@ -297,7 +301,8 @@ static LRESULT CALLBACK wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpara
break; break;
} }
case WM_MOUSEWHEEL: { case WM_MOUSEWHEEL:
case WM_MOUSEHWHEEL: {
RECT rc; RECT rc;
::GetWindowRect(hwnd, &rc); ::GetWindowRect(hwnd, &rc);
@ -307,7 +312,66 @@ static LRESULT CALLBACK wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpara
GET_X_LPARAM(lparam), GET_X_LPARAM(lparam),
GET_Y_LPARAM(lparam)) - gfx::Point(rc.left, rc.top)) GET_Y_LPARAM(lparam)) - gfx::Point(rc.left, rc.top))
/ display_scale); / display_scale);
ev.setDelta(((short)HIWORD(wparam)) / WHEEL_DELTA);
int z = ((short)HIWORD(wparam)) / WHEEL_DELTA;
gfx::Point delta(
(msg == WM_MOUSEHWHEEL ? z: 0),
(msg == WM_MOUSEWHEEL ? -z: 0));
ev.setWheelDelta(delta);
//PRINTF("WHEEL: %d %d\n", delta.x, delta.y);
queue_event(ev);
break;
}
case WM_HSCROLL:
case WM_VSCROLL: {
RECT rc;
::GetWindowRect(hwnd, &rc);
POINT pos;
::GetCursorPos(&pos);
Event ev;
ev.setType(Event::MouseWheel);
ev.setPosition((gfx::Point(pos.x, pos.y) - gfx::Point(rc.left, rc.top))
/ display_scale);
int bar = (msg == WM_HSCROLL ? SB_HORZ: SB_VERT);
int z = GetScrollPos(hwnd, bar);
switch (LOWORD(wparam)) {
case SB_LEFT:
case SB_LINELEFT:
--z;
break;
case SB_PAGELEFT:
z -= 2;
break;
case SB_RIGHT:
case SB_LINERIGHT:
++z;
break;
case SB_PAGERIGHT:
z += 2;
break;
case SB_THUMBPOSITION:
case SB_THUMBTRACK:
case SB_ENDSCROLL:
// Do nothing
break;
}
gfx::Point delta(
(msg == WM_HSCROLL ? (z-50): 0),
(msg == WM_VSCROLL ? (z-50): 0));
ev.setWheelDelta(delta);
//PRINTF("SCROLL: %d %d\n", delta.x, delta.y);
SetScrollPos(hwnd, bar, 50, FALSE);
queue_event(ev); queue_event(ev);
break; break;
} }
@ -318,9 +382,17 @@ static LRESULT CALLBACK wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpara
void subclass_hwnd(HWND hwnd) void subclass_hwnd(HWND hwnd)
{ {
// Add the WS_EX_ACCEPTFILES SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) | WS_HSCROLL | WS_VSCROLL);
SetWindowLong(hwnd, GWL_EXSTYLE, SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_ACCEPTFILES);
GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_ACCEPTFILES);
SCROLLINFO si;
si.cbSize = sizeof(SCROLLINFO);
si.fMask = SIF_POS | SIF_RANGE;
si.nMin = 0;
si.nPos = 50;
si.nMax = 100;
SetScrollInfo(hwnd, SB_HORZ, &si, FALSE);
SetScrollInfo(hwnd, SB_VERT, &si, FALSE);
base_wndproc = (wndproc_t)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)wndproc); base_wndproc = (wndproc_t)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)wndproc);
} }

View File

@ -436,7 +436,7 @@ bool ComboBoxEntry::onProcessMessage(Message* msg)
releaseMouse(); releaseMouse();
MouseMessage mouseMsg2(kMouseDownMessage, MouseMessage mouseMsg2(kMouseDownMessage,
mouseMsg->buttons(), mouseMsg->position(), 0); mouseMsg->buttons(), mouseMsg->position());
pick->sendMessage(&mouseMsg2); pick->sendMessage(&mouseMsg2);
return true; return true;
} }

View File

@ -84,7 +84,7 @@ bool IntEntry::onProcessMessage(Message* msg)
MouseMessage mouseMsg2(kMouseDownMessage, MouseMessage mouseMsg2(kMouseDownMessage,
mouseMsg->buttons(), mouseMsg->buttons(),
mouseMsg->position(), 0); mouseMsg->position());
m_slider->sendMessage(&mouseMsg2); m_slider->sendMessage(&mouseMsg2);
} }
} }
@ -93,7 +93,9 @@ bool IntEntry::onProcessMessage(Message* msg)
case kMouseWheelMessage: case kMouseWheelMessage:
if (isEnabled()) { if (isEnabled()) {
int oldValue = getValue(); int oldValue = getValue();
int newValue = oldValue + static_cast<MouseMessage*>(msg)->wheelDelta(); int newValue = oldValue
+ static_cast<MouseMessage*>(msg)->wheelDelta().x
- static_cast<MouseMessage*>(msg)->wheelDelta().y;
newValue = MID(m_min, newValue, m_max); newValue = MID(m_min, newValue, m_max);
if (newValue != oldValue) { if (newValue != oldValue) {
setValue(newValue); setValue(newValue);

View File

@ -186,7 +186,7 @@ bool ListBox::onProcessMessage(Message* msg)
View* view = View::getView(this); View* view = View::getView(this);
if (view) { if (view) {
gfx::Point scroll = view->getViewScroll(); gfx::Point scroll = view->getViewScroll();
scroll.y += -static_cast<MouseMessage*>(msg)->wheelDelta() * getTextHeight()*3; scroll += static_cast<MouseMessage*>(msg)->wheelDelta() * getTextHeight()*3;
view->setViewScroll(scroll); view->setViewScroll(scroll);
} }
break; break;

View File

@ -290,7 +290,8 @@ void Manager::generateMouseMessages()
// Mouse wheel // Mouse wheel
if (jmouse_z(0) != jmouse_z(1)) if (jmouse_z(0) != jmouse_z(1))
handleMouseWheel(mousePos, currentMouseButtons(0), jmouse_z(0) - jmouse_z(1)); handleMouseWheel(mousePos, currentMouseButtons(0),
gfx::Point(0, jmouse_z(1) - jmouse_z(0)));
// Mouse clicks // Mouse clicks
if (jmouse_b(0) != jmouse_b(1)) { if (jmouse_b(0) != jmouse_b(1)) {
@ -521,7 +522,7 @@ void Manager::generateMessagesFromSheEvents()
if (!mouse_events_from_she) if (!mouse_events_from_she)
continue; continue;
handleMouseWheel(sheEvent.position(), m_mouseButtons, sheEvent.delta()); handleMouseWheel(sheEvent.position(), m_mouseButtons, sheEvent.wheelDelta());
break; break;
} }
} }
@ -588,11 +589,12 @@ void Manager::handleMouseDoubleClick(const gfx::Point& mousePos, MouseButtons mo
} }
} }
void Manager::handleMouseWheel(const gfx::Point& mousePos, MouseButtons mouseButtons, int delta) void Manager::handleMouseWheel(const gfx::Point& mousePos, MouseButtons mouseButtons, const gfx::Point& wheelDelta)
{ {
enqueueMessage(newMouseMessage(kMouseWheelMessage, enqueueMessage(newMouseMessage(
kMouseWheelMessage,
(capture_widget ? capture_widget: mouse_widget), (capture_widget ? capture_widget: mouse_widget),
mousePos, mouseButtons, delta)); mousePos, mouseButtons, wheelDelta));
} }
// Handles Z order: Send the window to top (only when you click in a // Handles Z order: Send the window to top (only when you click in a
@ -1425,9 +1427,10 @@ Widget* Manager::findMagneticWidget(Widget* widget)
// static // static
Message* Manager::newMouseMessage(MessageType type, Message* Manager::newMouseMessage(MessageType type,
Widget* widget, gfx::Point mousePos, MouseButtons buttons, int delta) Widget* widget, const gfx::Point& mousePos,
MouseButtons buttons, const gfx::Point& wheelDelta)
{ {
Message* msg = new MouseMessage(type, buttons, mousePos, delta); Message* msg = new MouseMessage(type, buttons, mousePos, wheelDelta);
if (widget != NULL) if (widget != NULL)
msg->addRecipient(widget); msg->addRecipient(widget);

View File

@ -100,7 +100,7 @@ namespace ui {
void handleMouseDown(const gfx::Point& mousePos, MouseButtons mouseButtons); void handleMouseDown(const gfx::Point& mousePos, MouseButtons mouseButtons);
void handleMouseUp(const gfx::Point& mousePos, MouseButtons mouseButtons); void handleMouseUp(const gfx::Point& mousePos, MouseButtons mouseButtons);
void handleMouseDoubleClick(const gfx::Point& mousePos, MouseButtons mouseButtons); void handleMouseDoubleClick(const gfx::Point& mousePos, MouseButtons mouseButtons);
void handleMouseWheel(const gfx::Point& mousePos, MouseButtons mouseButtons, int delta); void handleMouseWheel(const gfx::Point& mousePos, MouseButtons mouseButtons, const gfx::Point& wheelDelta);
void handleWindowZOrder(); void handleWindowZOrder();
void pumpQueue(); void pumpQueue();
@ -108,7 +108,8 @@ namespace ui {
static bool someParentIsFocusStop(Widget* widget); static bool someParentIsFocusStop(Widget* widget);
static Widget* findMagneticWidget(Widget* widget); static Widget* findMagneticWidget(Widget* widget);
static Message* newMouseMessage(MessageType type, static Message* newMouseMessage(MessageType type,
Widget* widget, gfx::Point mousePos, MouseButtons buttons, int delta = 0); Widget* widget, const gfx::Point& mousePos,
MouseButtons buttons, const gfx::Point& wheelDelta = gfx::Point(0, 0));
static MouseButtons currentMouseButtons(int antique); static MouseButtons currentMouseButtons(int antique);
void broadcastKeyMsg(Message* msg); void broadcastKeyMsg(Message* msg);

View File

@ -101,22 +101,27 @@ namespace ui {
class MouseMessage : public Message class MouseMessage : public Message
{ {
public: public:
MouseMessage(MessageType type, MouseButtons buttons, const gfx::Point& pos, int delta) MouseMessage(MessageType type, MouseButtons buttons,
: Message(type), m_buttons(buttons), m_pos(pos), m_delta(delta) { const gfx::Point& pos,
const gfx::Point& wheelDelta = gfx::Point(0, 0))
: Message(type),
m_buttons(buttons),
m_pos(pos),
m_wheelDelta(wheelDelta) {
} }
MouseButtons buttons() const { return m_buttons; } MouseButtons buttons() const { return m_buttons; }
bool left() const { return (m_buttons & kButtonLeft) == kButtonLeft; } bool left() const { return (m_buttons & kButtonLeft) == kButtonLeft; }
bool right() const { return (m_buttons & kButtonRight) == kButtonRight; } bool right() const { return (m_buttons & kButtonRight) == kButtonRight; }
bool middle() const { return (m_buttons & kButtonMiddle) == kButtonMiddle; } bool middle() const { return (m_buttons & kButtonMiddle) == kButtonMiddle; }
int wheelDelta() const { return m_delta; } gfx::Point wheelDelta() const { return m_wheelDelta; }
const gfx::Point& position() const { return m_pos; } const gfx::Point& position() const { return m_pos; }
private: private:
MouseButtons m_buttons; // Pressed buttons MouseButtons m_buttons; // Pressed buttons
gfx::Point m_pos; // Mouse position gfx::Point m_pos; // Mouse position
int m_delta; // Wheel axis variation gfx::Point m_wheelDelta; // Wheel axis variation
}; };
class TimerMessage : public Message class TimerMessage : public Message

View File

@ -191,7 +191,9 @@ bool Slider::onProcessMessage(Message* msg)
case kMouseWheelMessage: case kMouseWheelMessage:
if (isEnabled()) { if (isEnabled()) {
int value = m_value + static_cast<MouseMessage*>(msg)->wheelDelta(); int value = m_value
+ static_cast<MouseMessage*>(msg)->wheelDelta().x
- static_cast<MouseMessage*>(msg)->wheelDelta().y;
value = MID(m_min, value, m_max); value = MID(m_min, value, m_max);

View File

@ -134,7 +134,7 @@ bool TextBox::onProcessMessage(Message* msg)
if (view) { if (view) {
gfx::Point scroll = view->getViewScroll(); gfx::Point scroll = view->getViewScroll();
scroll.y += -static_cast<MouseMessage*>(msg)->wheelDelta() * getTextHeight()*3; scroll += static_cast<MouseMessage*>(msg)->wheelDelta() * getTextHeight()*3;
view->setViewScroll(scroll); view->setViewScroll(scroll);
} }