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 ColorThread : public BC_DialogThread
64 ColorThread(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);
73 int do_alpha, do_okcancel;
77 class ColorWindow : public BC_Window
80 ColorWindow(ColorThread *thread, int x, int y, int w, int h, const char *title);
83 void create_objects();
86 void update_display();
91 void get_screen_sample();
92 int cursor_motion_event();
93 int button_press_event();
94 int button_release_event();
96 struct { float r, g, b; } rgb;
97 struct { float y, u, v; } yuv;
98 struct { float h, s, v; } hsv;
100 void update_rgb(float r, float g, float b);
101 void update_hsv(float h, float s, float v);
102 void update_yuv(float y, float u, float v);
103 void update_rgb_hex(const char *hex);
108 PaletteWheelValue *wheel_value;
109 PaletteOutput *output;
121 PaletteHSV *hsv_h, *hsv_s, *hsv_v;
122 PaletteRGB *rgb_r, *rgb_g, *rgb_b;
123 PaletteYUV *yuv_y, *yuv_u, *yuv_v;
126 PaletteHexButton *hex_btn;
128 PaletteGrabButton *grab_btn;
129 PaletteHistory *history;
131 VFrame *value_bitmap;
134 int palette_history[PALLETTE_HISTORY_SIZE];
137 void update_history(int color);
138 void update_history();
142 class PaletteWheel : public BC_SubWindow
145 PaletteWheel(ColorWindow *window, int x, int y);
147 int button_press_event();
148 int cursor_motion_event();
149 int button_release_event();
151 void create_objects();
152 int draw(float hue, float saturation);
153 int get_angle(float x1, float y1, float x2, float y2);
154 float torads(float angle);
161 class PaletteWheelValue : public BC_SubWindow
164 PaletteWheelValue(ColorWindow *window, int x, int y);
165 ~PaletteWheelValue();
166 void create_objects();
167 int button_press_event();
168 int cursor_motion_event();
169 int button_release_event();
170 int draw(float hue, float saturation, float value);
177 class PaletteOutput : public BC_SubWindow
180 PaletteOutput(ColorWindow *window, int x, int y);
182 void create_objects();
188 class PaletteHue : public BC_ISlider
191 PaletteHue(ColorWindow *window, int x, int y);
197 class PaletteSat : public BC_FSlider
200 PaletteSat(ColorWindow *window, int x, int y);
206 class PaletteVal : public BC_FSlider
209 PaletteVal(ColorWindow *window, int x, int y);
215 class PaletteRed : public BC_FSlider
218 PaletteRed(ColorWindow *window, int x, int y);
224 class PaletteGrn : public BC_FSlider
227 PaletteGrn(ColorWindow *window, int x, int y);
233 class PaletteBlu : public BC_FSlider
236 PaletteBlu(ColorWindow *window, int x, int y);
242 class PaletteAlpha : public BC_FSlider
245 PaletteAlpha(ColorWindow *window, int x, int y);
251 class PaletteLum : public BC_FSlider
254 PaletteLum(ColorWindow *window, int x, int y);
260 class PaletteCr : public BC_FSlider
263 PaletteCr(ColorWindow *window, int x, int y);
269 class PaletteCb : public BC_FSlider
272 PaletteCb(ColorWindow *window, int x, int y);
278 class PaletteNum : public BC_TumbleTextBox
284 PaletteNum(ColorWindow *window, int x, int y,
285 float &output, float min, float max);
287 void update_output() { *output = atof(get_text()); }
288 static int calculate_h() { return BC_Tumbler::calculate_h(); }
291 class PaletteRGB : public PaletteNum
294 PaletteRGB(ColorWindow *window, int x, int y,
295 float &output, float min, float max)
296 : PaletteNum(window, x, y, output, min, max) {}
300 class PaletteYUV : public PaletteNum
303 PaletteYUV(ColorWindow *window, int x, int y,
304 float &output, float min, float max)
305 : PaletteNum(window, x, y, output, min, max) {}
309 class PaletteHSV : public PaletteNum
312 PaletteHSV(ColorWindow *window, int x, int y,
313 float &output, float min, float max)
314 : PaletteNum(window, x, y, output, min, max) {}
318 class PaletteAPH : public PaletteNum
321 PaletteAPH(ColorWindow *window, int x, int y,
322 float &output, float min, float max)
323 : PaletteNum(window, x, y, output, min, max) {}
327 class PaletteHexButton : public BC_GenericButton
330 PaletteHexButton(ColorWindow *window, int x, int y);
336 class PaletteHex : public BC_TextBox
339 PaletteHex(ColorWindow *window, int x, int y, const char *hex);
341 int keypress_event();
346 class PaletteGrabButton : public BC_Button
349 PaletteGrabButton(ColorWindow *window, int x, int y);
350 ~PaletteGrabButton();
357 class PaletteHistory : public BC_SubWindow
360 PaletteHistory(ColorWindow *window, int x, int y);
362 void update(int flush=1);
363 int button_press_event();
364 int button_release_event();
365 int cursor_motion_event();
366 int cursor_leave_event();
367 int repeat_event(int64_t duration);