1 | // Aseprite |
2 | // Copyright (C) 2001-2018 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_TOOLBAR_H_INCLUDED |
8 | #define APP_UI_TOOLBAR_H_INCLUDED |
9 | #pragma once |
10 | |
11 | #include "app/tools/active_tool_observer.h" |
12 | #include "gfx/point.h" |
13 | #include "obs/connection.h" |
14 | #include "ui/timer.h" |
15 | #include "ui/widget.h" |
16 | |
17 | #include <map> |
18 | |
19 | namespace ui { |
20 | class CloseEvent; |
21 | class ; |
22 | class TipWindow; |
23 | } |
24 | |
25 | namespace app { |
26 | namespace tools { |
27 | class Tool; |
28 | class ToolGroup; |
29 | } |
30 | |
31 | // Class to show selected tools for each tool (vertically) |
32 | class ToolBar : public ui::Widget |
33 | , public tools::ActiveToolObserver { |
34 | static ToolBar* m_instance; |
35 | public: |
36 | static ToolBar* instance() { return m_instance; } |
37 | |
38 | static const int NoneIndex = -1; |
39 | static const int PreviewVisibilityIndex = -2; |
40 | |
41 | ToolBar(); |
42 | ~ToolBar(); |
43 | |
44 | bool isToolVisible(tools::Tool* tool); |
45 | void selectTool(tools::Tool* tool); |
46 | void selectToolGroup(tools::ToolGroup* toolGroup); |
47 | |
48 | void openTipWindow(tools::ToolGroup* toolGroup, tools::Tool* tool); |
49 | void closeTipWindow(); |
50 | |
51 | protected: |
52 | bool onProcessMessage(ui::Message* msg) override; |
53 | void onSizeHint(ui::SizeHintEvent& ev) override; |
54 | void onPaint(ui::PaintEvent& ev) override; |
55 | void onVisible(bool visible) override; |
56 | |
57 | private: |
58 | int getToolGroupIndex(tools::ToolGroup* group); |
59 | void (int group_index, tools::ToolGroup* group); |
60 | void (); |
61 | gfx::Rect getToolGroupBounds(int group_index); |
62 | gfx::Point getToolPositionInGroup(int group_index, tools::Tool* tool); |
63 | void openTipWindow(int group_index, tools::Tool* tool); |
64 | void (); |
65 | |
66 | // ActiveToolObserver impl |
67 | void onActiveToolChange(tools::Tool* tool) override; |
68 | void onSelectedToolChange(tools::Tool* tool) override; |
69 | |
70 | // What tool is selected for each tool-group |
71 | std::map<const tools::ToolGroup*, tools::Tool*> m_selectedInGroup; |
72 | |
73 | // Index of the tool group or special button highlighted. |
74 | int m_hotIndex; |
75 | |
76 | // What tool has the mouse above |
77 | tools::Tool* m_hotTool; |
78 | |
79 | // True if the popup-window must be opened when a tool-button is hot |
80 | bool m_openOnHot; |
81 | |
82 | // True if the last MouseDown opened the popup. This is used to |
83 | // close the popup with a second MouseUp event. |
84 | bool m_openedRecently; |
85 | |
86 | // Window displayed to show a tool-group |
87 | ui::PopupWindow* ; |
88 | class ToolStrip; |
89 | ToolStrip* m_currentStrip; |
90 | |
91 | // Tool-tip window |
92 | ui::TipWindow* m_tipWindow; |
93 | |
94 | ui::Timer m_tipTimer; |
95 | bool m_tipOpened; |
96 | |
97 | obs::connection m_closeConn; |
98 | }; |
99 | |
100 | } // namespace app |
101 | |
102 | #endif |
103 | |