| 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 | #ifndef APP_UI_EDITOR_SCROLLING_STATE_H_INCLUDED |
| 8 | #define APP_UI_EDITOR_SCROLLING_STATE_H_INCLUDED |
| 9 | #pragma once |
| 10 | |
| 11 | #include "app/ui/editor/editor_state.h" |
| 12 | #include "gfx/point.h" |
| 13 | |
| 14 | namespace app { |
| 15 | |
| 16 | class ScrollingState : public EditorState { |
| 17 | public: |
| 18 | ScrollingState(); |
| 19 | virtual bool isTemporalState() const override { return true; } |
| 20 | virtual bool onMouseDown(Editor* editor, ui::MouseMessage* msg) override; |
| 21 | virtual bool onMouseUp(Editor* editor, ui::MouseMessage* msg) override; |
| 22 | virtual bool onMouseMove(Editor* editor, ui::MouseMessage* msg) override; |
| 23 | virtual bool onSetCursor(Editor* editor, const gfx::Point& mouseScreenPos) override; |
| 24 | virtual bool onKeyDown(Editor* editor, ui::KeyMessage* msg) override; |
| 25 | virtual bool onKeyUp(Editor* editor, ui::KeyMessage* msg) override; |
| 26 | virtual bool onUpdateStatusBar(Editor* editor) override; |
| 27 | virtual bool allowLayerEdges() override { return true; } |
| 28 | |
| 29 | virtual LeaveAction onLeaveState(Editor* editor, EditorState* newState) override { |
| 30 | // Just discard this state if we want to enter to another state |
| 31 | // e.g. if we want to enter to MovingPixelsState when the user |
| 32 | // press Ctrl+V when we are scrolling, we have to just discard |
| 33 | // this state (stop the scrolling action). |
| 34 | return DiscardState; |
| 35 | } |
| 36 | |
| 37 | private: |
| 38 | gfx::Point m_oldPos; |
| 39 | }; |
| 40 | |
| 41 | } // namespace app |
| 42 | |
| 43 | #endif // APP_UI_EDITOR_SCROLLING_STATE_H_INCLUDED |
| 44 | |