1 | // Aseprite |
---|---|
2 | // Copyright (C) 2001-2016 David Capello |
3 | // |
4 | // This program is distributed under the terms of |
5 | // the End-User License Agreement for Aseprite. |
6 | |
7 | #ifdef HAVE_CONFIG_H |
8 | #include "config.h" |
9 | #endif |
10 | |
11 | #include "app/ui/editor/scrolling_state.h" |
12 | |
13 | #include "app/app.h" |
14 | #include "app/ui/editor/editor.h" |
15 | #include "app/ui/status_bar.h" |
16 | #include "gfx/rect.h" |
17 | #include "doc/sprite.h" |
18 | #include "ui/message.h" |
19 | #include "ui/system.h" |
20 | #include "ui/view.h" |
21 | |
22 | namespace app { |
23 | |
24 | using namespace ui; |
25 | |
26 | ScrollingState::ScrollingState() |
27 | { |
28 | } |
29 | |
30 | bool ScrollingState::onMouseDown(Editor* editor, MouseMessage* msg) |
31 | { |
32 | m_oldPos = msg->position(); |
33 | |
34 | editor->captureMouse(); |
35 | return true; |
36 | } |
37 | |
38 | bool ScrollingState::onMouseUp(Editor* editor, MouseMessage* msg) |
39 | { |
40 | editor->backToPreviousState(); |
41 | editor->releaseMouse(); |
42 | return true; |
43 | } |
44 | |
45 | bool ScrollingState::onMouseMove(Editor* editor, MouseMessage* msg) |
46 | { |
47 | View* view = View::getView(editor); |
48 | gfx::Point scroll = view->viewScroll(); |
49 | gfx::Point newPos = msg->position(); |
50 | |
51 | #ifdef _WIN32 |
52 | if (newPos != editor->autoScroll(msg, AutoScroll::ScrollDir)) { |
53 | m_oldPos = newPos; |
54 | return true; |
55 | } |
56 | #endif |
57 | |
58 | scroll -= newPos - m_oldPos; |
59 | m_oldPos = newPos; |
60 | |
61 | editor->setEditorScroll(scroll); |
62 | return true; |
63 | } |
64 | |
65 | bool ScrollingState::onSetCursor(Editor* editor, const gfx::Point& mouseScreenPos) |
66 | { |
67 | editor->showMouseCursor(kScrollCursor); |
68 | return true; |
69 | } |
70 | |
71 | bool ScrollingState::onKeyDown(Editor* editor, KeyMessage* msg) |
72 | { |
73 | return false; |
74 | } |
75 | |
76 | bool ScrollingState::onKeyUp(Editor* editor, KeyMessage* msg) |
77 | { |
78 | return false; |
79 | } |
80 | |
81 | bool ScrollingState::onUpdateStatusBar(Editor* editor) |
82 | { |
83 | return false; |
84 | } |
85 | |
86 | } // namespace app |
87 |