#define CP_INDICATOR_SIZE (3)
// Start of David H's conversion code
-typedef struct
-{
- double r; // a fraction between 0 and 1
- double g; // a fraction between 0 and 1
- double b; // a fraction between 0 and 1
-} RGBColor;
-
-typedef struct
-{
- double h; // angle in degrees
- double s; // a fraction between 0 and 1
- double v; // a fraction between 0 and 1
-} HSVColor;
-
static HSVColor get_hsv_from_rgb(RGBColor in)
{
HSVColor out;
}
// End of David H's conversion code
-static HSVColor cp_color_hsv = { 180.0, 1.0, 1.0 }; // use some sane default values
-
enum
{
CP_STATE_NONE,
int ysize_main = CP_MAIN_GRADIENT_HEIGHT;
int xsize_hue = CP_HUE_GRADIENT_WIDTH;
int ysize_hue = CP_HUE_GRADIENT_HEIGHT;
- int x_main = x + (xsize_main - 1) * cp_color_hsv.s;
- int y_main = y + (ysize_main - 1) * (1.0 - cp_color_hsv.v);
- int x_hue = x + ((cp_color_hsv.h / 360.0) * xsize_hue);
+ int x_main = x + (xsize_main - 1) * gi->colorpicker.color_hsv.s;
+ int y_main = y + (ysize_main - 1) * (1.0 - gi->colorpicker.color_hsv.v);
+ int x_hue = x + ((gi->colorpicker.color_hsv.h / 360.0) * xsize_hue);
int y_hue = y + ysize_main;
// draw color position indicator
if (gi->colorpicker.count == 0) // RGB colors
{
- color_rgb = get_rgb_from_hsv(cp_color_hsv);
+ color_rgb = get_rgb_from_hsv(gi->colorpicker.color_hsv);
}
else // indexed colors
{
if (gi->colorpicker.count == 0)
{
- RGBColor rgb_color = get_rgb_from_hsv(cp_color_hsv);
+ RGBColor rgb_color = get_rgb_from_hsv(gi->colorpicker.color_hsv);
char text[128];
sprintf(text, "#%02x%02x%02x",
if (gi->colorpicker.count == 0)
{
- DrawColorPicker_Gradient(surface, cp_color_hsv.h);
+ DrawColorPicker_Gradient(surface, gi->colorpicker.color_hsv.h);
DrawColorPicker_HueGradient(surface);
}
else
{
if (gi->colorpicker.count == 0) // RGB colors
{
- gi->colorpicker.value = get_int_from_hsv(cp_color_hsv);
+ gi->colorpicker.value = get_int_from_hsv(gi->colorpicker.color_hsv);
gi->event.type = GD_EVENT_COLOR_PICKER_LEAVING;
}
}
gi->height = CP_GADGET_HEIGHT + 2 * gi->border.ysize;
if (gi->colorpicker.count == 0) // RGB colors
- cp_color_hsv = get_hsv_from_int(gi->colorpicker.value);
+ gi->colorpicker.color_hsv = get_hsv_from_int(gi->colorpicker.value);
// always start with closed color picker
gi->colorpicker.open = FALSE;
{
if (gi->colorpicker.count == 0) // RGB colors
{
- cp_color_hsv.s = (double)x_main / xsize_main;
- cp_color_hsv.v = 1.0 - (double)y_main / ysize_main;
+ gi->colorpicker.color_hsv.s = (double)x_main / xsize_main;
+ gi->colorpicker.color_hsv.v = 1.0 - (double)y_main / ysize_main;
}
else // indexed colors
{
{
if (gi->colorpicker.count == 0) // RGB colors
{
- cp_color_hsv.h = (double)x_hue / xsize_hue * 360.0;
+ gi->colorpicker.color_hsv.h = (double)x_hue / xsize_hue * 360.0;
DrawColorPicker(gi);
}
#define GDI_ACTIVE_POS(a) ((a) < 0 ? POS_OFFSCREEN : (a))
+typedef struct
+{
+ double r; // a fraction between 0 and 1
+ double g; // a fraction between 0 and 1
+ double b; // a fraction between 0 and 1
+} RGBColor;
+
+typedef struct
+{
+ double h; // angle in degrees
+ double s; // a fraction between 0 and 1
+ double v; // a fraction between 0 and 1
+} HSVColor;
+
typedef void (*gadget_function)(void *);
struct GadgetBorder
// runtime values
boolean open; // opening state of color picker
+ HSVColor color_hsv; // current color value in HSV format
};
struct GadgetInfo