rework keyframe hide popup, keyframe auto render, textbox set_selection wide text
[goodguy/history.git] / cinelerra-5.1 / cinelerra / colorpicker.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  * 
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * 
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  * 
20  */
21
22 #ifndef COLORPICKER_H
23 #define COLORPICKER_H
24
25 #include "condition.inc"
26 #include "guicast.h"
27 #include "mutex.inc"
28 #include "thread.h"
29 #include "vframe.inc"
30
31 class ColorWindow;
32 class PaletteWheel;
33 class PaletteWheelValue;
34 class PaletteOutput;
35 class PaletteHue;
36 class PaletteSaturation;
37 class PaletteValue;
38 class PaletteRed;
39 class PaletteGreen;
40 class PaletteBlue;
41 class PaletteAlpha;
42
43 class ColorThread : public Thread
44 {
45 public:
46         ColorThread(int do_alpha = 0, char *title = 0);
47         ~ColorThread();
48
49
50         void run();
51         void start_window(int output, int alpha);
52         virtual int handle_new_color(int output, int alpha);
53         void update_gui(int output, int alpha);
54         ColorWindow* get_gui();
55
56 private:
57         friend class ColorWindow;
58
59         ColorWindow *window;
60         Condition *completion;
61 // protects window, output, alpha
62         Mutex *mutex;   
63 // Starting color
64         int output;
65         int alpha;
66         int do_alpha;
67         char *title;
68 };
69
70 class ColorWindow : public BC_Window
71 {
72 public:
73         ColorWindow(ColorThread *thread, int x, int y, char *title);
74
75         void create_objects();
76         void change_values();
77         int close_event();
78         void update_display();
79         void update_rgb();
80         int handle_event();
81
82         ColorThread *thread;
83
84         PaletteWheel *wheel;
85         PaletteWheelValue *wheel_value;
86         PaletteOutput *output;
87         PaletteHue *hue;
88         PaletteSaturation *saturation;
89         PaletteValue *value;
90         PaletteRed *red;
91         PaletteGreen *green;
92         PaletteBlue *blue;
93         PaletteAlpha *alpha;
94         VFrame *value_bitmap;
95         float h, s, v, r, g, b, a;
96 };
97
98
99 class PaletteWheel : public BC_SubWindow
100 {
101 public:
102         PaletteWheel(ColorWindow *window, int x, int y);
103         ~PaletteWheel();
104         int button_press_event();
105         int cursor_motion_event();
106         int button_release_event();
107
108         void create_objects();
109         int draw(float hue, float saturation);
110         int get_angle(float x1, float y1, float x2, float y2);
111         float torads(float angle);
112         ColorWindow *window;
113         float oldhue;
114         float oldsaturation;
115         int button_down;
116 };
117
118 class PaletteWheelValue : public BC_SubWindow
119 {
120 public:
121         PaletteWheelValue(ColorWindow *window, int x, int y);
122         ~PaletteWheelValue();
123         void create_objects();
124         int button_press_event();
125         int cursor_motion_event();
126         int button_release_event();
127         int draw(float hue, float saturation, float value);
128         ColorWindow *window;
129         int button_down;
130 // Gradient
131         VFrame *frame;
132 };
133
134 class PaletteOutput : public BC_SubWindow
135 {
136 public:
137         PaletteOutput(ColorWindow *window, int x, int y);
138         ~PaletteOutput();
139         void create_objects();
140         int handle_event();
141         int draw();
142         ColorWindow *window;
143 };
144
145 class PaletteHue : public BC_ISlider
146 {
147 public:
148         PaletteHue(ColorWindow *window, int x, int y);
149         ~PaletteHue();
150         int handle_event();
151         ColorWindow *window;
152 };
153
154 class PaletteSaturation : public BC_FSlider
155 {
156 public:
157         PaletteSaturation(ColorWindow *window, int x, int y);
158         ~PaletteSaturation();
159         int handle_event();
160         ColorWindow *window;
161 };
162
163 class PaletteValue : public BC_FSlider
164 {
165 public:
166         PaletteValue(ColorWindow *window, int x, int y);
167         ~PaletteValue();
168         int handle_event();
169         ColorWindow *window;
170 };
171
172 class PaletteRed : public BC_FSlider
173 {
174 public:
175         PaletteRed(ColorWindow *window, int x, int y);
176         ~PaletteRed();
177         int handle_event();
178         ColorWindow *window;
179 };
180
181 class PaletteGreen : public BC_FSlider
182 {
183 public:
184         PaletteGreen(ColorWindow *window, int x, int y);
185         ~PaletteGreen();
186         int handle_event();
187         ColorWindow *window;
188 };
189
190 class PaletteBlue : public BC_FSlider
191 {
192 public:
193         PaletteBlue(ColorWindow *window, int x, int y);
194         ~PaletteBlue();
195         int handle_event();
196         ColorWindow *window;
197 };
198
199 class PaletteAlpha : public BC_FSlider
200 {
201 public:
202         PaletteAlpha(ColorWindow *window, int x, int y);
203         ~PaletteAlpha();
204         int handle_event();
205         ColorWindow *window;
206 };
207
208 #endif