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 "condition.inc"
35 class PaletteWheelValue;
52 class ColorThread : public BC_DialogThread
55 ColorThread(int do_alpha = 0, const char *title = 0);
58 void start_window(int output, int alpha, int do_okcancel=0);
59 virtual int handle_new_color(int output, int alpha);
60 void update_gui(int output, int alpha);
64 int do_alpha, do_okcancel;
68 class ColorWindow : public BC_Window
71 ColorWindow(ColorThread *thread, int x, int y, int w, int h, const char *title);
74 void create_objects();
77 void update_display();
83 struct { float r, g, b; } rgb;
84 struct { float y, u, v; } yuv;
85 struct { float h, s, v; } hsv;
87 void update_rgb(float r, float g, float b);
88 void update_hsv(float h, float s, float v);
89 void update_yuv(float y, float u, float v);
94 PaletteWheelValue *wheel_value;
95 PaletteOutput *output;
107 PalletteHSV *hsv_h, *hsv_s, *hsv_v;
108 PalletteRGB *rgb_r, *rgb_g, *rgb_b;
109 PalletteYUV *yuv_y, *yuv_u, *yuv_v;
112 VFrame *value_bitmap;
116 class PaletteWheel : public BC_SubWindow
119 PaletteWheel(ColorWindow *window, int x, int y);
121 int button_press_event();
122 int cursor_motion_event();
123 int button_release_event();
125 void create_objects();
126 int draw(float hue, float saturation);
127 int get_angle(float x1, float y1, float x2, float y2);
128 float torads(float angle);
135 class PaletteWheelValue : public BC_SubWindow
138 PaletteWheelValue(ColorWindow *window, int x, int y);
139 ~PaletteWheelValue();
140 void create_objects();
141 int button_press_event();
142 int cursor_motion_event();
143 int button_release_event();
144 int draw(float hue, float saturation, float value);
151 class PaletteOutput : public BC_SubWindow
154 PaletteOutput(ColorWindow *window, int x, int y);
156 void create_objects();
162 class PaletteHue : public BC_ISlider
165 PaletteHue(ColorWindow *window, int x, int y);
171 class PaletteSat : public BC_FSlider
174 PaletteSat(ColorWindow *window, int x, int y);
180 class PaletteVal : public BC_FSlider
183 PaletteVal(ColorWindow *window, int x, int y);
189 class PaletteRed : public BC_FSlider
192 PaletteRed(ColorWindow *window, int x, int y);
198 class PaletteGrn : public BC_FSlider
201 PaletteGrn(ColorWindow *window, int x, int y);
207 class PaletteBlu : public BC_FSlider
210 PaletteBlu(ColorWindow *window, int x, int y);
216 class PaletteAlpha : public BC_FSlider
219 PaletteAlpha(ColorWindow *window, int x, int y);
225 class PaletteLum : public BC_FSlider
228 PaletteLum(ColorWindow *window, int x, int y);
234 class PaletteCr : public BC_FSlider
237 PaletteCr(ColorWindow *window, int x, int y);
243 class PaletteCb : public BC_FSlider
246 PaletteCb(ColorWindow *window, int x, int y);
252 class PalletteNum : public BC_TumbleTextBox
258 PalletteNum(ColorWindow *window, int x, int y,
259 float &output, float min, float max);
261 void update_output() { *output = atof(get_text()); }
262 static int calculate_h() { return BC_Tumbler::calculate_h(); }
265 class PalletteRGB : public PalletteNum
268 PalletteRGB(ColorWindow *window, int x, int y,
269 float &output, float min, float max)
270 : PalletteNum(window, x, y, output, min, max) {}
274 class PalletteYUV : public PalletteNum
277 PalletteYUV(ColorWindow *window, int x, int y,
278 float &output, float min, float max)
279 : PalletteNum(window, x, y, output, min, max) {}
283 class PalletteHSV : public PalletteNum
286 PalletteHSV(ColorWindow *window, int x, int y,
287 float &output, float min, float max)
288 : PalletteNum(window, x, y, output, min, max) {}
292 class PalletteAPH : public PalletteNum
295 PalletteAPH(ColorWindow *window, int x, int y,
296 float &output, float min, float max)
297 : PalletteNum(window, x, y, output, min, max) {}