1 | // Aseprite |
2 | // Copyright (C) 2019-2020 Igara Studio S.A. |
3 | // Copyright (C) 2018 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_COLOR_SHADES_H_INCLUDED |
9 | #define APP_UI_COLOR_SHADES_H_INCLUDED |
10 | #pragma once |
11 | |
12 | #include "app/shade.h" |
13 | #include "obs/signal.h" |
14 | #include "ui/mouse_button.h" |
15 | #include "ui/widget.h" |
16 | |
17 | namespace doc { |
18 | class Remap; |
19 | } |
20 | |
21 | namespace app { |
22 | |
23 | class ColorShades : public ui::Widget { |
24 | public: |
25 | enum ClickType { |
26 | ClickEntries, |
27 | DragAndDropEntries, |
28 | ClickWholeShade |
29 | }; |
30 | |
31 | ColorShades(const Shade& colors, ClickType click); |
32 | |
33 | ClickType clickType() const { return m_click; } |
34 | |
35 | void setMinColors(int minColors); |
36 | void reverseShadeColors(); |
37 | doc::Remap* createShadeRemap(bool left); |
38 | int size() const { return int(m_shade.size()); } |
39 | |
40 | const Shade& getShade() const { return m_shade; } |
41 | void setShade(const Shade& shade); |
42 | |
43 | int getHotEntry() const { return m_hotIndex; } |
44 | |
45 | class ClickEvent { |
46 | public: |
47 | ClickEvent(ui::MouseButton button) : m_button(button) { } |
48 | ui::MouseButton button() const { return m_button; } |
49 | private: |
50 | ui::MouseButton m_button; |
51 | }; |
52 | |
53 | obs::signal<void(ClickEvent&)> Click; |
54 | |
55 | private: |
56 | void onInitTheme(ui::InitThemeEvent& ev) override; |
57 | bool onProcessMessage(ui::Message* msg) override; |
58 | void onSizeHint(ui::SizeHintEvent& ev) override; |
59 | void onPaint(ui::PaintEvent& ev) override; |
60 | bool isHotEntryVisible() const { |
61 | return m_click != ClickWholeShade; |
62 | } |
63 | |
64 | ClickType m_click; |
65 | Shade m_shade; |
66 | int m_minColors; |
67 | int m_hotIndex; |
68 | int m_dragIndex; |
69 | bool m_dropBefore; |
70 | int m_boxSize; |
71 | }; |
72 | |
73 | } // namespace app |
74 | |
75 | #endif |
76 | |