strcpy(window_title, _(PROGRAM_NAME ": "));
strcat(window_title, title ? title : _("Color Picker"));
BC_DisplayInfo display_info;
- int x = display_info.get_abs_cursor_x() + 25;
- int y = display_info.get_abs_cursor_y() - 100;
- int w = 540, h = 330;
+ int x = display_info.get_abs_cursor_x() + xS(25);
+ int y = display_info.get_abs_cursor_y() - yS(100);
+ int w = xS(540), h = yS(330);
if( ok_cancel )
h += bmax(BC_OKButton::calculate_h(),BC_CancelButton::calculate_h());
int root_w = display_info.get_root_w(), root_h = display_info.get_root_h();
{
ColorWindow *gui = (ColorWindow *)get_gui();
if( !gui ) return;
- gui->lock_window();
+ gui->lock_window("ColorPicker::update_gui");
this->output = output;
this->alpha = alpha;
gui->change_values();
void ColorWindow::create_objects()
{
- int x0 = 10, y0 = 10;
+ int xs5 = xS(5), xs10 = xS(10), xs15 = xS(15);
+ int ys10 = yS(10), ys15 = yS(15), ys25 = yS(25), ys40 = yS(40);
+ int x0 = xs10, y0 = ys10;
lock_window("ColorWindow::create_objects");
change_values();
add_tool(wheel = new PaletteWheel(this, x, y));
wheel->create_objects();
- x += 180; add_tool(wheel_value = new PaletteWheelValue(this, x, y));
+ x += xS(180); add_tool(wheel_value = new PaletteWheelValue(this, x, y));
wheel_value->create_objects();
x = x0;
- y += 180; add_tool(output = new PaletteOutput(this, x, y));
+ y += yS(180); add_tool(output = new PaletteOutput(this, x, y));
output->create_objects();
- y += output->get_h() + 20;
+ y += output->get_h() + yS(20);
load_history(); int x1 = x;
add_tool(hex_btn = new PaletteHexButton(this, x1, y));
char hex[BCSTRLEN]; sprintf(hex,"%06x",thread->output);
- x1 += hex_btn->get_w() + 5;
+ x1 += hex_btn->get_w() + xs5;
add_tool(hex_box = new PaletteHex(this, x1, y, hex));
- x1 += hex_box->get_w() + 15;
+ x1 += hex_box->get_w() + xs15;
add_tool(grab_btn = new PaletteGrabButton(this, x1, y));
- y += hex_box->get_h() + 15;
- add_tool(history = new PaletteHistory(this, 10, y));
+ y += hex_box->get_h() + ys15;
+ add_tool(history = new PaletteHistory(this, xs10, y));
- x += 240;
+ x += xS(240);
add_tool(new BC_Title(x, y =y0, C_("H:"), SMALLFONT));
- add_tool(new BC_Title(x, y+=25, C_("S:"), SMALLFONT));
- add_tool(new BC_Title(x, y+=25, D_("colorpicker_value#V:"), SMALLFONT));
- add_tool(new BC_Title(x, y+=40, C_("R:"), SMALLFONT));
- add_tool(new BC_Title(x, y+=25, C_("G:"), SMALLFONT));
- add_tool(new BC_Title(x, y+=25, C_("B:"), SMALLFONT));
- add_tool(new BC_Title(x, y+=40, C_("Y:"), SMALLFONT));
- add_tool(new BC_Title(x, y+=25, C_("U:"), SMALLFONT));
- add_tool(new BC_Title(x, y+=25, D_("colorpicker_Cr#V:"), SMALLFONT));
+ add_tool(new BC_Title(x, y+=ys25, C_("S:"), SMALLFONT));
+ add_tool(new BC_Title(x, y+=ys25, D_("colorpicker_value#V:"), SMALLFONT));
+ add_tool(new BC_Title(x, y+=ys40, C_("R:"), SMALLFONT));
+ add_tool(new BC_Title(x, y+=ys25, C_("G:"), SMALLFONT));
+ add_tool(new BC_Title(x, y+=ys25, C_("B:"), SMALLFONT));
+ add_tool(new BC_Title(x, y+=ys40, C_("Y:"), SMALLFONT));
+ add_tool(new BC_Title(x, y+=ys25, C_("U:"), SMALLFONT));
+ add_tool(new BC_Title(x, y+=ys25, D_("colorpicker_Cr#V:"), SMALLFONT));
if( thread->do_alpha )
- add_tool(new BC_Title(x, y+=40, C_("A:"), SMALLFONT));
- x += 24;
+ add_tool(new BC_Title(x, y+=ys40, C_("A:"), SMALLFONT));
+ x += xS(24);
add_tool(hue = new PaletteHue(this, x, y= y0));
- add_tool(sat = new PaletteSat(this, x, y+=25));
- add_tool(val = new PaletteVal(this, x, y+=25));
- add_tool(red = new PaletteRed(this, x, y+=40));
- add_tool(grn = new PaletteGrn(this, x, y+=25));
- add_tool(blu = new PaletteBlu(this, x, y+=25));
- add_tool(lum = new PaletteLum(this, x, y+=40));
- add_tool(c_r = new PaletteCr (this, x, y+=25));
- add_tool(c_b = new PaletteCb (this, x, y+=25));
+ add_tool(sat = new PaletteSat(this, x, y+=ys25));
+ add_tool(val = new PaletteVal(this, x, y+=ys25));
+ add_tool(red = new PaletteRed(this, x, y+=ys40));
+ add_tool(grn = new PaletteGrn(this, x, y+=ys25));
+ add_tool(blu = new PaletteBlu(this, x, y+=ys25));
+ add_tool(lum = new PaletteLum(this, x, y+=ys40));
+ add_tool(c_r = new PaletteCr (this, x, y+=ys25));
+ add_tool(c_b = new PaletteCb (this, x, y+=ys25));
if( thread->do_alpha )
- add_tool(alpha = new PaletteAlpha(this, x, y+=40));
+ add_tool(alpha = new PaletteAlpha(this, x, y+=ys40));
- x += hue->get_w() + 10;
+ x += hue->get_w() + xs10;
hsv_h = new PaletteHSV(this, x,y= y0, hsv.h, 0, 360);
hsv_h->create_objects(); hsv_h->set_tooltip(_("Hue"));
- hsv_s = new PaletteHSV(this, x,y+=25, hsv.s, 0, 1);
+ hsv_s = new PaletteHSV(this, x,y+=ys25, hsv.s, 0, 1);
hsv_s->create_objects(); hsv_s->set_tooltip(_("Saturation"));
- hsv_v = new PaletteHSV(this, x,y+=25, hsv.v, 0, 1);
+ hsv_v = new PaletteHSV(this, x,y+=ys25, hsv.v, 0, 1);
hsv_v->create_objects(); hsv_v->set_tooltip(_("Value"));
- rgb_r = new PaletteRGB(this, x,y+=40, rgb.r, 0, 1);
+ rgb_r = new PaletteRGB(this, x,y+=ys40, rgb.r, 0, 1);
rgb_r->create_objects(); rgb_r->set_tooltip(_("Red"));
- rgb_g = new PaletteRGB(this, x,y+=25, rgb.g, 0, 1);
+ rgb_g = new PaletteRGB(this, x,y+=ys25, rgb.g, 0, 1);
rgb_g->create_objects(); rgb_g->set_tooltip(_("Green"));
- rgb_b = new PaletteRGB(this, x,y+=25, rgb.b, 0, 1);
+ rgb_b = new PaletteRGB(this, x,y+=ys25, rgb.b, 0, 1);
rgb_b->create_objects(); rgb_b->set_tooltip(_("Blue"));
- yuv_y = new PaletteYUV(this, x,y+=40, yuv.y, 0, 1);
+ yuv_y = new PaletteYUV(this, x,y+=ys40, yuv.y, 0, 1);
yuv_y->create_objects(); yuv_y->set_tooltip(_("Luminance"));
- yuv_u = new PaletteYUV(this, x,y+=25, yuv.u, 0, 1);
+ yuv_u = new PaletteYUV(this, x,y+=ys25, yuv.u, 0, 1);
yuv_u->create_objects(); yuv_u->set_tooltip(_("Blue Luminance Difference"));
- yuv_v = new PaletteYUV(this, x,y+=25, yuv.v, 0, 1);
+ yuv_v = new PaletteYUV(this, x,y+=ys25, yuv.v, 0, 1);
yuv_v->create_objects(); yuv_v->set_tooltip(_("Red Luminance Difference"));
if( thread->do_alpha ) {
- aph_a = new PaletteAPH(this, x,y+=40, aph, 0, 1);
+ aph_a = new PaletteAPH(this, x,y+=ys40, aph, 0, 1);
aph_a->create_objects(); aph_a->set_tooltip(_("Alpha"));
}
if( thread->ok_cancel ) {
int ColorWindow::handle_event()
{
+ unlock_window();
thread->handle_new_color(rgb888(), alpha8());
+ lock_window("ColorWindow::handle_event");
return 1;
}
PaletteWheel::PaletteWheel(ColorWindow *window, int x, int y)
- : BC_SubWindow(x, y, 170, 170)
+ : BC_SubWindow(x, y, xS(170), yS(170))
{
this->window = window;
oldhue = 0;
}
}
}
-//printf("PaletteWheel::create_objects 1\n");
draw_vframe(&frame,
- 0,
- 0,
- get_w(),
- get_h(),
- 0,
- 0,
- get_w(),
- get_h(),
- 0);
-//printf("PaletteWheel::create_objects 1\n");
+ 0, 0, get_w(), get_h(),
+ 0, 0, get_w(), get_h(), 0);
oldhue = window->hsv.h;
oldsaturation = window->hsv.s;
-//printf("PaletteWheel::create_objects 1\n");
draw(oldhue, oldsaturation);
-//printf("PaletteWheel::create_objects 1\n");
flash();
-//printf("PaletteWheel::create_objects 2\n");
}
float PaletteWheel::torads(float angle)
set_inverse();
set_color(WHITE);
- draw_circle(x - 5, y - 5, 10, 10);
+ draw_circle(x - xS(5), y - yS(5), xS(10), yS(10));
set_opaque();
return 0;
}
}
PaletteWheelValue::PaletteWheelValue(ColorWindow *window, int x, int y)
- : BC_SubWindow(x, y, 40, 170, BLACK)
+ : BC_SubWindow(x, y, xS(40), yS(170), BLACK)
{
this->window = window;
button_down = 0;
row[j * 3 + 2] = b;
}
}
-
draw_3d_border(0, 0, get_w(), get_h(), 1);
draw_vframe(frame, 2, 2, get_w() - 4, get_h() - 4,
2, 2, get_w() - 4, get_h() - 4, 0);
}
PaletteOutput::PaletteOutput(ColorWindow *window, int x, int y)
- : BC_SubWindow(x, y, 180, 30, BLACK)
+ : BC_SubWindow(x, y, xS(180), yS(30), BLACK)
{
this->window = window;
}
}
PaletteHue::PaletteHue(ColorWindow *window, int x, int y)
- : BC_ISlider(x, y, 0, 150, 200, 0, 359, (int)(window->hsv.h), 0)
+ : BC_ISlider(x, y, 0, xS(150), xS(200), 0, 359, (int)(window->hsv.h), 0)
{
this->window = window;
}
}
PaletteSat::PaletteSat(ColorWindow *window, int x, int y)
- : BC_FSlider(x, y, 0, 150, 200, 0, 1.0, window->hsv.s, 0)
+ : BC_FSlider(x, y, 0, xS(150), xS(200), 0, 1.0, window->hsv.s, 0)
{
this->window = window;
set_precision(0.01);
PaletteVal::PaletteVal(ColorWindow *window, int x, int y)
- : BC_FSlider(x, y, 0, 150, 200, 0, 1.0, window->hsv.v, 0)
+ : BC_FSlider(x, y, 0, xS(150), xS(200), 0, 1.0, window->hsv.v, 0)
{
this->window = window;
set_precision(0.01);
PaletteRed::PaletteRed(ColorWindow *window, int x, int y)
- : BC_FSlider(x, y, 0, 150, 200, 0, 1, window->rgb.r, 0)
+ : BC_FSlider(x, y, 0, xS(150), xS(200), 0, 1, window->rgb.r, 0)
{
this->window = window;
set_precision(0.01);
}
PaletteGrn::PaletteGrn(ColorWindow *window, int x, int y)
- : BC_FSlider(x, y, 0, 150, 200, 0, 1, window->rgb.g, 0)
+ : BC_FSlider(x, y, 0, xS(150), xS(200), 0, 1, window->rgb.g, 0)
{
this->window = window;
set_precision(0.01);
}
PaletteBlu::PaletteBlu(ColorWindow *window, int x, int y)
- : BC_FSlider(x, y, 0, 150, 200, 0, 1, window->rgb.b, 0)
+ : BC_FSlider(x, y, 0, xS(150), xS(200), 0, 1, window->rgb.b, 0)
{
this->window = window;
set_precision(0.01);
}
PaletteAlpha::PaletteAlpha(ColorWindow *window, int x, int y)
- : BC_FSlider(x, y, 0, 150, 200, 0, 1, window->aph, 0)
+ : BC_FSlider(x, y, 0, xS(150), xS(200), 0, 1, window->aph, 0)
{
this->window = window;
set_precision(0.01);
}
PaletteLum::PaletteLum(ColorWindow *window, int x, int y)
- : BC_FSlider(x, y, 0, 150, 200, 0, 1, window->yuv.y, 0)
+ : BC_FSlider(x, y, 0, xS(150), xS(200), 0, 1, window->yuv.y, 0)
{
this->window = window;
set_precision(0.01);
}
PaletteCr::PaletteCr(ColorWindow *window, int x, int y)
- : BC_FSlider(x, y, 0, 150, 200, 0, 1, window->yuv.u, 0)
+ : BC_FSlider(x, y, 0, xS(150), xS(200), 0, 1, window->yuv.u, 0)
{
this->window = window;
set_precision(0.01);
}
PaletteCb::PaletteCb(ColorWindow *window, int x, int y)
- : BC_FSlider(x, y, 0, 150, 200, 0, 1, window->yuv.v, 0)
+ : BC_FSlider(x, y, 0, xS(150), xS(200), 0, 1, window->yuv.v, 0)
{
this->window = window;
set_precision(0.01);
PaletteNum::PaletteNum(ColorWindow *window, int x, int y,
float &output, float min, float max)
- : BC_TumbleTextBox(window, output, min, max, x, y, 64)
+ : BC_TumbleTextBox(window, output, min, max, x, y, xS(64))
{
this->window = window;
this->output = &output;
}
PaletteHexButton::PaletteHexButton(ColorWindow *window, int x, int y)
- : BC_GenericButton(x, y, 50, "#")
+ : BC_GenericButton(x, y, xS(50), "#")
{
this->window = window;
set_tooltip(_("hex rgb color"));
}
PaletteHex::PaletteHex(ColorWindow *window, int x, int y, const char *hex)
- : BC_TextBox(x, y, 100, 1, hex)
+ : BC_TextBox(x, y, xS(100), 1, hex)
{
this->window = window;
}
}
PaletteHistory::PaletteHistory(ColorWindow *window, int x, int y)
- : BC_SubWindow(x,y, 200, 24)
+ : BC_SubWindow(x,y, xS(200), yS(24))
{
this->window = window;
button_down = 0;
delete color_picker; color_picker = 0;
}
+void ColorButton::update_gui(int color, int alpha)
+{
+ if( color_picker )
+ color_picker->update_gui(color, alpha);
+ update_gui(color | (~alpha<<24));
+}
+
void ColorButton::update_gui(int color)
{
set_color(color);
color_button->handle_done_event(result);
}
-int ColorButtonPicker::handle_new_color(int color, int alpha)
+void ColorButtonPicker::update(int color, int alpha)
{
color_button->color = color;
+ color_button->alpha = alpha;
color_button->color_thread->update_lock->unlock();
- color_button->handle_new_color(color, alpha);
- return 1;
+}
+
+int ColorButtonPicker::handle_new_color(int color, int alpha)
+{
+ color_button->lock_window("ColorButtonPicker::handle_new_color");
+ color_button->update_gui(color, alpha);
+ color_button->unlock_window();
+ return color_button->handle_new_color(color, alpha);
}
void ColorButtonPicker::update_gui()
{
color_button->lock_window("ColorButtonPicker::update_gui");
- color_button->update_gui(color_button->color);
+ color_button->update_gui(color_button->color, color_button->alpha);
color_button->unlock_window();
}
+void ColorButtonPicker::update_gui(int color, int alpha)
+{
+ ColorPicker::update_gui(color, alpha);
+ color_button->handle_new_color(color, alpha);
+}
+
ColorButtonThread::ColorButtonThread(ColorButton *color_button)
: Thread(1, 0, 0)
{
}
void ColorBoxButton::create_objects()
{
- update_gui(color);
+ update_gui(color, alpha);
}
void ColorBoxButton::set_color(int color)
{
- this->color = color;
+ this->color = (color & 0xffffff);
+ this->alpha = (~color>>24) & 0xff;
int r = (color>>16) & 0xff;
int g = (color>> 8) & 0xff;
int b = (color>> 0) & 0xff;
}
void ColorCircleButton::create_objects()
{
- update_gui(color);
+ update_gui(color, alpha);
}
void ColorCircleButton::set_color(int color)
{
- this->color = color;
+ this->color = (color & 0xffffff);
+ this->alpha = (~color>>24) & 0xff;
int r = (color>>16) & 0xff;
int g = (color>>8) & 0xff;
int b = (color>>0) & 0xff;