4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
27 #include "bctextbox.h"
28 #include "bcsubwindow.h"
30 #include "condition.inc"
36 #define PALLETTE_HISTORY_SIZE 16
40 class PaletteWheelValue;
56 class PaletteHexButton;
58 class PaletteGrabButton;
61 class ColorPicker : public BC_DialogThread
64 ColorPicker(int do_alpha = 0, const char *title = 0);
67 void start_window(int output, int alpha, int do_okcancel=0);
68 virtual int handle_new_color(int output, int alpha);
69 void update_gui(int output, int alpha);
72 int orig_color, orig_alpha;
74 int do_alpha, do_okcancel;
78 class ColorWindow : public BC_Window
81 ColorWindow(ColorPicker *thread, int x, int y, int w, int h, const char *title);
84 void create_objects();
87 void update_display();
92 void get_screen_sample();
93 int cursor_motion_event();
94 int button_press_event();
95 int button_release_event();
97 struct { float r, g, b; } rgb;
98 struct { float y, u, v; } yuv;
99 struct { float h, s, v; } hsv;
101 void update_rgb(float r, float g, float b);
102 void update_hsv(float h, float s, float v);
103 void update_yuv(float y, float u, float v);
104 void update_rgb_hex(const char *hex);
109 PaletteWheelValue *wheel_value;
110 PaletteOutput *output;
122 PaletteHSV *hsv_h, *hsv_s, *hsv_v;
123 PaletteRGB *rgb_r, *rgb_g, *rgb_b;
124 PaletteYUV *yuv_y, *yuv_u, *yuv_v;
127 PaletteHexButton *hex_btn;
129 PaletteGrabButton *grab_btn;
130 PaletteHistory *history;
132 VFrame *value_bitmap;
135 int palette_history[PALLETTE_HISTORY_SIZE];
138 void update_history(int color);
139 void update_history();
143 class PaletteWheel : public BC_SubWindow
146 PaletteWheel(ColorWindow *window, int x, int y);
148 int button_press_event();
149 int cursor_motion_event();
150 int button_release_event();
152 void create_objects();
153 int draw(float hue, float saturation);
154 int get_angle(float x1, float y1, float x2, float y2);
155 float torads(float angle);
162 class PaletteWheelValue : public BC_SubWindow
165 PaletteWheelValue(ColorWindow *window, int x, int y);
166 ~PaletteWheelValue();
167 void create_objects();
168 int button_press_event();
169 int cursor_motion_event();
170 int button_release_event();
171 int draw(float hue, float saturation, float value);
178 class PaletteOutput : public BC_SubWindow
181 PaletteOutput(ColorWindow *window, int x, int y);
183 void create_objects();
189 class PaletteHue : public BC_ISlider
192 PaletteHue(ColorWindow *window, int x, int y);
198 class PaletteSat : public BC_FSlider
201 PaletteSat(ColorWindow *window, int x, int y);
207 class PaletteVal : public BC_FSlider
210 PaletteVal(ColorWindow *window, int x, int y);
216 class PaletteRed : public BC_FSlider
219 PaletteRed(ColorWindow *window, int x, int y);
225 class PaletteGrn : public BC_FSlider
228 PaletteGrn(ColorWindow *window, int x, int y);
234 class PaletteBlu : public BC_FSlider
237 PaletteBlu(ColorWindow *window, int x, int y);
243 class PaletteAlpha : public BC_FSlider
246 PaletteAlpha(ColorWindow *window, int x, int y);
252 class PaletteLum : public BC_FSlider
255 PaletteLum(ColorWindow *window, int x, int y);
261 class PaletteCr : public BC_FSlider
264 PaletteCr(ColorWindow *window, int x, int y);
270 class PaletteCb : public BC_FSlider
273 PaletteCb(ColorWindow *window, int x, int y);
279 class PaletteNum : public BC_TumbleTextBox
285 PaletteNum(ColorWindow *window, int x, int y,
286 float &output, float min, float max);
288 void update_output() { *output = atof(get_text()); }
289 static int calculate_h() { return BC_Tumbler::calculate_h(); }
292 class PaletteRGB : public PaletteNum
295 PaletteRGB(ColorWindow *window, int x, int y,
296 float &output, float min, float max)
297 : PaletteNum(window, x, y, output, min, max) {}
301 class PaletteYUV : public PaletteNum
304 PaletteYUV(ColorWindow *window, int x, int y,
305 float &output, float min, float max)
306 : PaletteNum(window, x, y, output, min, max) {}
310 class PaletteHSV : public PaletteNum
313 PaletteHSV(ColorWindow *window, int x, int y,
314 float &output, float min, float max)
315 : PaletteNum(window, x, y, output, min, max) {}
319 class PaletteAPH : public PaletteNum
322 PaletteAPH(ColorWindow *window, int x, int y,
323 float &output, float min, float max)
324 : PaletteNum(window, x, y, output, min, max) {}
328 class PaletteHexButton : public BC_GenericButton
331 PaletteHexButton(ColorWindow *window, int x, int y);
337 class PaletteHex : public BC_TextBox
340 PaletteHex(ColorWindow *window, int x, int y, const char *hex);
342 int keypress_event();
347 class PaletteGrabButton : public BC_Button
350 PaletteGrabButton(ColorWindow *window, int x, int y);
351 ~PaletteGrabButton();
358 class PaletteHistory : public BC_SubWindow
361 PaletteHistory(ColorWindow *window, int x, int y);
363 void update(int flush=1);
364 int button_press_event();
365 int button_release_event();
366 int cursor_motion_event();
367 int cursor_leave_event();
368 int repeat_event(int64_t duration);