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);
105 PaletteWheelValue *wheel_value;
106 PaletteOutput *output;
118 PaletteHSV *hsv_h, *hsv_s, *hsv_v;
119 PaletteRGB *rgb_r, *rgb_g, *rgb_b;
120 PaletteYUV *yuv_y, *yuv_u, *yuv_v;
123 PaletteHexButton *hex_btn;
125 PaletteGrabButton *grab_btn;
126 PaletteHistory *history;
128 VFrame *value_bitmap;
131 int palette_history[PALLETTE_HISTORY_SIZE];
134 void update_history(int color);
135 void update_history();
139 class PaletteWheel : public BC_SubWindow
142 PaletteWheel(ColorWindow *window, int x, int y);
144 int button_press_event();
145 int cursor_motion_event();
146 int button_release_event();
148 void create_objects();
149 int draw(float hue, float saturation);
150 int get_angle(float x1, float y1, float x2, float y2);
151 float torads(float angle);
158 class PaletteWheelValue : public BC_SubWindow
161 PaletteWheelValue(ColorWindow *window, int x, int y);
162 ~PaletteWheelValue();
163 void create_objects();
164 int button_press_event();
165 int cursor_motion_event();
166 int button_release_event();
167 int draw(float hue, float saturation, float value);
174 class PaletteOutput : public BC_SubWindow
177 PaletteOutput(ColorWindow *window, int x, int y);
179 void create_objects();
185 class PaletteHue : public BC_ISlider
188 PaletteHue(ColorWindow *window, int x, int y);
194 class PaletteSat : public BC_FSlider
197 PaletteSat(ColorWindow *window, int x, int y);
203 class PaletteVal : public BC_FSlider
206 PaletteVal(ColorWindow *window, int x, int y);
212 class PaletteRed : public BC_FSlider
215 PaletteRed(ColorWindow *window, int x, int y);
221 class PaletteGrn : public BC_FSlider
224 PaletteGrn(ColorWindow *window, int x, int y);
230 class PaletteBlu : public BC_FSlider
233 PaletteBlu(ColorWindow *window, int x, int y);
239 class PaletteAlpha : public BC_FSlider
242 PaletteAlpha(ColorWindow *window, int x, int y);
248 class PaletteLum : public BC_FSlider
251 PaletteLum(ColorWindow *window, int x, int y);
257 class PaletteCr : public BC_FSlider
260 PaletteCr(ColorWindow *window, int x, int y);
266 class PaletteCb : public BC_FSlider
269 PaletteCb(ColorWindow *window, int x, int y);
275 class PaletteNum : public BC_TumbleTextBox
281 PaletteNum(ColorWindow *window, int x, int y,
282 float &output, float min, float max);
284 void update_output() { *output = atof(get_text()); }
285 static int calculate_h() { return BC_Tumbler::calculate_h(); }
288 class PaletteRGB : public PaletteNum
291 PaletteRGB(ColorWindow *window, int x, int y,
292 float &output, float min, float max)
293 : PaletteNum(window, x, y, output, min, max) {}
297 class PaletteYUV : public PaletteNum
300 PaletteYUV(ColorWindow *window, int x, int y,
301 float &output, float min, float max)
302 : PaletteNum(window, x, y, output, min, max) {}
306 class PaletteHSV : public PaletteNum
309 PaletteHSV(ColorWindow *window, int x, int y,
310 float &output, float min, float max)
311 : PaletteNum(window, x, y, output, min, max) {}
315 class PaletteAPH : public PaletteNum
318 PaletteAPH(ColorWindow *window, int x, int y,
319 float &output, float min, float max)
320 : PaletteNum(window, x, y, output, min, max) {}
324 class PaletteHexButton : public BC_GenericButton
327 PaletteHexButton(ColorWindow *window, int x, int y);
333 class PaletteHex : public BC_TextBox
336 PaletteHex(ColorWindow *window, int x, int y, const char *hex);
343 class PaletteGrabButton : public BC_Button
346 PaletteGrabButton(ColorWindow *window, int x, int y);
347 ~PaletteGrabButton();
354 class PaletteHistory : public BC_SubWindow
357 PaletteHistory(ColorWindow *window, int x, int y);
359 void update(int flush=1);
360 int button_press_event();
361 int button_release_event();
362 int cursor_motion_event();
363 int cursor_enter_event();
364 int cursor_leave_event();
365 int repeat_event(int64_t duration);