1 | // Aseprite |
2 | // Copyright (C) 2022 Igara Studio S.A. |
3 | // Copyright (C) 2001-2016 David Capello |
4 | // |
5 | // This program is distributed under the terms of |
6 | // the End-User License Agreement for Aseprite. |
7 | |
8 | #ifndef APP_UI_STATE_WITH_WHEEL_BEHAVIOR_H_INCLUDED |
9 | #define APP_UI_STATE_WITH_WHEEL_BEHAVIOR_H_INCLUDED |
10 | #pragma once |
11 | |
12 | #include "app/color.h" |
13 | #include "app/tools/ink_type.h" |
14 | #include "app/ui/editor/editor_state.h" |
15 | #include "app/ui/key.h" |
16 | #include "doc/frame.h" |
17 | #include "doc/layer.h" |
18 | #include "doc/layer_list.h" |
19 | |
20 | namespace render { |
21 | class Zoom; |
22 | } |
23 | |
24 | namespace app { |
25 | |
26 | namespace tools { |
27 | class Tool; |
28 | class ToolGroup; |
29 | } |
30 | |
31 | class StateWithWheelBehavior : public EditorState { |
32 | public: |
33 | enum class ScrollBigSteps { Off, On }; |
34 | enum class PreciseWheel { Off, On }; |
35 | |
36 | // Indicates that the message comes from a real mouse wheel (which |
37 | // might have special handling inverting the direction of the |
38 | // wheel action depending on the operating system, etc.) |
39 | enum class FromMouseWheel { Off, On }; |
40 | |
41 | StateWithWheelBehavior(); |
42 | |
43 | bool onMouseWheel(Editor* editor, ui::MouseMessage* msg) override; |
44 | bool onTouchMagnify(Editor* editor, ui::TouchMessage* msg) override; |
45 | bool onSetCursor(Editor* editor, const gfx::Point& mouseScreenPos) override; |
46 | |
47 | protected: |
48 | void processWheelAction(Editor* editor, |
49 | WheelAction wheelAction, |
50 | const gfx::Point& position, |
51 | gfx::Point delta, |
52 | double dz, |
53 | const ScrollBigSteps scrollBigSteps, |
54 | const PreciseWheel preciseWheel, |
55 | const FromMouseWheel fromMouseWheel); |
56 | const doc::LayerList& browsableLayers(Editor* editor) const; |
57 | |
58 | virtual Color initialFgColor() const; |
59 | virtual Color initialBgColor() const; |
60 | virtual int initialFgTileIndex() const; |
61 | virtual int initialBgTileIndex() const; |
62 | virtual int initialBrushSize(); |
63 | virtual int initialBrushAngle(); |
64 | virtual gfx::Point initialScroll(Editor* editor) const; |
65 | virtual render::Zoom initialZoom(Editor* editor) const; |
66 | virtual doc::frame_t initialFrame(Editor* editor) const; |
67 | virtual doc::layer_t initialLayer(Editor* editor) const; |
68 | virtual tools::InkType initialInkType(Editor* editor) const; |
69 | virtual int initialInkOpacity(Editor* editor) const; |
70 | virtual int initialCelOpacity(Editor* editor) const; |
71 | virtual int initialLayerOpacity(Editor* editor) const; |
72 | virtual tools::Tool* initialTool() const; |
73 | virtual void changeFgColor(Color c); |
74 | virtual void disableQuickTool() const; |
75 | |
76 | virtual tools::Tool* getInitialToolInActiveGroup(); |
77 | virtual void onToolChange(tools::Tool* tool); |
78 | virtual void onToolGroupChange(Editor* editor, |
79 | tools::ToolGroup* group); |
80 | |
81 | tools::Tool* getActiveTool() const; |
82 | |
83 | private: |
84 | void setZoom(Editor* editor, const render::Zoom& zoom, const gfx::Point& mousePos); |
85 | |
86 | mutable doc::LayerList m_browsableLayers; |
87 | tools::Tool* m_tool = nullptr; |
88 | }; |
89 | |
90 | } // namespace app |
91 | |
92 | #endif |
93 | |