-
Notifications
You must be signed in to change notification settings - Fork 6
/
colorwidgets.h
60 lines (47 loc) · 1.48 KB
/
colorwidgets.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#pragma once
#include "widgets.h"
class TextEdit;
class ColorSliders : public Widget
{
public:
ColorSliders(SvgNode* n, bool allowalpha = true);
void setColor(Color c);
void setVisibleGroup(bool hsv);
std::function<void(Color)> onColorChanged;
private:
void updateWidgets(bool rgb, bool hsv);
void setSliderColors(Slider* slider, ColorF start, ColorF stop);
Slider* createGroup(const char* title, const std::function<void(real)>& callback, const std::vector<Color>& colors={0, 0});
ColorF currColor;
//Widget* colorPreview;
Slider* sliderR;
Slider* sliderB;
Slider* sliderG;
Slider* sliderH;
Slider* sliderS;
Slider* sliderV;
Slider* sliderA;
};
class ColorEditBox : public Widget
{
public:
ColorEditBox(SvgNode* n, ColorSliders* _colorPicker, bool allowalpha = true);
Color color() const { return currColor; }
void setColor(Color c);
Button* previewBtn;
bool allowAlpha;
std::function<void(Color)> onColorChanged;
private:
void updateHexEdit(Color c);
void updatePreview(Color c);
enum {HEX_COLOR, RGB_COLOR, NAMED_COLOR} editType;
Color currColor;
TextEdit* hexEdit;
SvgNode* colorPreview;
ColorSliders* colorPicker;
};
std::string colorToHex(Color c);
Button* createColorBtn();
Widget* createTabBar(const std::vector<std::string>& titles, std::function<void(int)> onChanged);
ColorEditBox* createColorEditBox(bool allowAlpha = true, bool withColorPicker = true);
ColorEditBox* createColorEditBox(bool allowAlpha, ColorSliders* colorSliders);