#ifndef COLORPICKER_H
#define COLORPICKER_H
+#include "bcbutton.h"
#include "bcdialog.h"
+#include "bctextbox.h"
+#include "bcsubwindow.h"
#include "clip.h"
#include "condition.inc"
#include "guicast.h"
#include "thread.h"
#include "vframe.inc"
+#define PALLETTE_HISTORY_SIZE 16
+
class ColorWindow;
class PaletteWheel;
class PaletteWheelValue;
class PaletteCr;
class PaletteCb;
class PaletteAlpha;
-class PalletteHSV;
-class PalletteRGB;
-class PalletteYUV;
-class PalletteAPH;
-
-class ColorThread : public BC_DialogThread
+class PaletteHSV;
+class PaletteRGB;
+class PaletteYUV;
+class PaletteAPH;
+class PaletteHexButton;
+class PaletteHex;
+class PaletteGrabButton;
+class PaletteHistory;
+
+class ColorPicker : public BC_DialogThread
{
public:
- ColorThread(int do_alpha = 0, const char *title = 0);
- ~ColorThread();
+ ColorPicker(int do_alpha = 0, const char *title = 0);
+ ~ColorPicker();
void start_window(int output, int alpha, int do_okcancel=0);
virtual int handle_new_color(int output, int alpha);
class ColorWindow : public BC_Window
{
public:
- ColorWindow(ColorThread *thread, int x, int y, int w, int h, const char *title);
+ ColorWindow(ColorPicker *thread, int x, int y, int w, int h, const char *title);
~ColorWindow();
void create_objects();
void update_hsv();
void update_yuv();
int handle_event();
+ void get_screen_sample();
+ int cursor_motion_event();
+ int button_press_event();
+ int button_release_event();
struct { float r, g, b; } rgb;
struct { float y, u, v; } yuv;
void update_rgb(float r, float g, float b);
void update_hsv(float h, float s, float v);
void update_yuv(float y, float u, float v);
+ void update_rgb_hex(const char *hex);
+ int rgb888();
- ColorThread *thread;
-
+ ColorPicker *thread;
PaletteWheel *wheel;
PaletteWheelValue *wheel_value;
PaletteOutput *output;
PaletteCb *c_b;
PaletteAlpha *alpha;
- PalletteHSV *hsv_h, *hsv_s, *hsv_v;
- PalletteRGB *rgb_r, *rgb_g, *rgb_b;
- PalletteYUV *yuv_y, *yuv_u, *yuv_v;
- PalletteAPH *aph_a;
+ PaletteHSV *hsv_h, *hsv_s, *hsv_v;
+ PaletteRGB *rgb_r, *rgb_g, *rgb_b;
+ PaletteYUV *yuv_y, *yuv_u, *yuv_v;
+ PaletteAPH *aph_a;
+
+ PaletteHexButton *hex_btn;
+ PaletteHex *hex_box;
+ PaletteGrabButton *grab_btn;
+ PaletteHistory *history;
VFrame *value_bitmap;
+ int button_grabbed;
+
+ int palette_history[PALLETTE_HISTORY_SIZE];
+ void load_history();
+ void save_history();
+ void update_history(int color);
+ void update_history();
};
ColorWindow *window;
};
-class PalletteNum : public BC_TumbleTextBox
+class PaletteNum : public BC_TumbleTextBox
{
public:
ColorWindow *window;
float *output;
- PalletteNum(ColorWindow *window, int x, int y,
+ PaletteNum(ColorWindow *window, int x, int y,
float &output, float min, float max);
- ~PalletteNum();
+ ~PaletteNum();
void update_output() { *output = atof(get_text()); }
static int calculate_h() { return BC_Tumbler::calculate_h(); }
};
-class PalletteRGB : public PalletteNum
+class PaletteRGB : public PaletteNum
{
public:
- PalletteRGB(ColorWindow *window, int x, int y,
+ PaletteRGB(ColorWindow *window, int x, int y,
float &output, float min, float max)
- : PalletteNum(window, x, y, output, min, max) {}
+ : PaletteNum(window, x, y, output, min, max) {}
int handle_event();
};
-class PalletteYUV : public PalletteNum
+class PaletteYUV : public PaletteNum
{
public:
- PalletteYUV(ColorWindow *window, int x, int y,
+ PaletteYUV(ColorWindow *window, int x, int y,
float &output, float min, float max)
- : PalletteNum(window, x, y, output, min, max) {}
+ : PaletteNum(window, x, y, output, min, max) {}
int handle_event();
};
-class PalletteHSV : public PalletteNum
+class PaletteHSV : public PaletteNum
{
public:
- PalletteHSV(ColorWindow *window, int x, int y,
+ PaletteHSV(ColorWindow *window, int x, int y,
float &output, float min, float max)
- : PalletteNum(window, x, y, output, min, max) {}
+ : PaletteNum(window, x, y, output, min, max) {}
int handle_event();
};
-class PalletteAPH : public PalletteNum
+class PaletteAPH : public PaletteNum
{
public:
- PalletteAPH(ColorWindow *window, int x, int y,
+ PaletteAPH(ColorWindow *window, int x, int y,
float &output, float min, float max)
- : PalletteNum(window, x, y, output, min, max) {}
+ : PaletteNum(window, x, y, output, min, max) {}
+ int handle_event();
+};
+
+class PaletteHexButton : public BC_GenericButton
+{
+public:
+ PaletteHexButton(ColorWindow *window, int x, int y);
+ ~PaletteHexButton();
+ int handle_event();
+ ColorWindow *window;
+};
+
+class PaletteHex : public BC_TextBox
+{
+public:
+ PaletteHex(ColorWindow *window, int x, int y, const char *hex);
+ ~PaletteHex();
+ int keypress_event();
+ void update();
+ ColorWindow *window;
+};
+
+class PaletteGrabButton : public BC_Button
+{
+public:
+ PaletteGrabButton(ColorWindow *window, int x, int y);
+ ~PaletteGrabButton();
int handle_event();
+
+ ColorWindow *window;
+ VFrame *vframes[3];
+};
+
+class PaletteHistory : public BC_SubWindow
+{
+public:
+ PaletteHistory(ColorWindow *window, int x, int y);
+ ~PaletteHistory();
+ void update(int flush=1);
+ int button_press_event();
+ int button_release_event();
+ int cursor_motion_event();
+ int cursor_leave_event();
+ int repeat_event(int64_t duration);
+
+ ColorWindow *window;
+ int button_down;
};
#endif