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 int button_press_event();
92 int button_release_event();
94 struct { float r, g, b; } rgb;
95 struct { float y, u, v; } yuv;
96 struct { float h, s, v; } hsv;
98 void update_rgb(float r, float g, float b);
99 void update_hsv(float h, float s, float v);
100 void update_yuv(float y, float u, float v);
101 void update_rgb_hex(const char *hex);
106 PaletteWheelValue *wheel_value;
107 PaletteOutput *output;
119 PaletteHSV *hsv_h, *hsv_s, *hsv_v;
120 PaletteRGB *rgb_r, *rgb_g, *rgb_b;
121 PaletteYUV *yuv_y, *yuv_u, *yuv_v;
124 PaletteHexButton *hex_btn;
126 PaletteGrabButton *grab_btn;
127 PaletteHistory *history;
129 VFrame *value_bitmap;
132 int palette_history[PALLETTE_HISTORY_SIZE];
135 void update_history(int color);
136 void update_history();
140 class PaletteWheel : public BC_SubWindow
143 PaletteWheel(ColorWindow *window, int x, int y);
145 int button_press_event();
146 int cursor_motion_event();
147 int button_release_event();
149 void create_objects();
150 int draw(float hue, float saturation);
151 int get_angle(float x1, float y1, float x2, float y2);
152 float torads(float angle);
159 class PaletteWheelValue : public BC_SubWindow
162 PaletteWheelValue(ColorWindow *window, int x, int y);
163 ~PaletteWheelValue();
164 void create_objects();
165 int button_press_event();
166 int cursor_motion_event();
167 int button_release_event();
168 int draw(float hue, float saturation, float value);
175 class PaletteOutput : public BC_SubWindow
178 PaletteOutput(ColorWindow *window, int x, int y);
180 void create_objects();
186 class PaletteHue : public BC_ISlider
189 PaletteHue(ColorWindow *window, int x, int y);
195 class PaletteSat : public BC_FSlider
198 PaletteSat(ColorWindow *window, int x, int y);
204 class PaletteVal : public BC_FSlider
207 PaletteVal(ColorWindow *window, int x, int y);
213 class PaletteRed : public BC_FSlider
216 PaletteRed(ColorWindow *window, int x, int y);
222 class PaletteGrn : public BC_FSlider
225 PaletteGrn(ColorWindow *window, int x, int y);
231 class PaletteBlu : public BC_FSlider
234 PaletteBlu(ColorWindow *window, int x, int y);
240 class PaletteAlpha : public BC_FSlider
243 PaletteAlpha(ColorWindow *window, int x, int y);
249 class PaletteLum : public BC_FSlider
252 PaletteLum(ColorWindow *window, int x, int y);
258 class PaletteCr : public BC_FSlider
261 PaletteCr(ColorWindow *window, int x, int y);
267 class PaletteCb : public BC_FSlider
270 PaletteCb(ColorWindow *window, int x, int y);
276 class PaletteNum : public BC_TumbleTextBox
282 PaletteNum(ColorWindow *window, int x, int y,
283 float &output, float min, float max);
285 void update_output() { *output = atof(get_text()); }
286 static int calculate_h() { return BC_Tumbler::calculate_h(); }
289 class PaletteRGB : public PaletteNum
292 PaletteRGB(ColorWindow *window, int x, int y,
293 float &output, float min, float max)
294 : PaletteNum(window, x, y, output, min, max) {}
298 class PaletteYUV : public PaletteNum
301 PaletteYUV(ColorWindow *window, int x, int y,
302 float &output, float min, float max)
303 : PaletteNum(window, x, y, output, min, max) {}
307 class PaletteHSV : public PaletteNum
310 PaletteHSV(ColorWindow *window, int x, int y,
311 float &output, float min, float max)
312 : PaletteNum(window, x, y, output, min, max) {}
316 class PaletteAPH : public PaletteNum
319 PaletteAPH(ColorWindow *window, int x, int y,
320 float &output, float min, float max)
321 : PaletteNum(window, x, y, output, min, max) {}
325 class PaletteHexButton : public BC_GenericButton
328 PaletteHexButton(ColorWindow *window, int x, int y);
334 class PaletteHex : public BC_TextBox
337 PaletteHex(ColorWindow *window, int x, int y, const char *hex);
339 int keypress_event();
344 class PaletteGrabButton : public BC_Button
347 PaletteGrabButton(ColorWindow *window, int x, int y);
348 ~PaletteGrabButton();
355 class PaletteHistory : public BC_SubWindow
358 PaletteHistory(ColorWindow *window, int x, int y);
360 void update(int flush=1);
361 int button_press_event();
362 int button_release_event();
363 int cursor_motion_event();
364 int cursor_leave_event();
365 int repeat_event(int64_t duration);