X-Git-Url: http://git.cinelerra-gg.org/git/?p=goodguy%2Fhistory.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fcolorpicker.C;h=c82e728a644618e0c0a54a4019b2e4f4a70a424e;hp=60fcfad9fd779c6bc37aff2fb2ca5d3614d026f8;hb=a4de4732339bf38b5b225c533be1bdf60748f04a;hpb=4f7f413cbc1c6ea5da27cb75ca27a3ab317243ec diff --git a/cinelerra-5.1/cinelerra/colorpicker.C b/cinelerra-5.1/cinelerra/colorpicker.C index 60fcfad9..c82e728a 100644 --- a/cinelerra-5.1/cinelerra/colorpicker.C +++ b/cinelerra-5.1/cinelerra/colorpicker.C @@ -34,6 +34,9 @@ #include #include +#undef MSGQUAL +#define MSGQUAL "colorpicker" + #define PALETTE_DATA "palette.dat" ColorThread::ColorThread(int do_alpha, const char *title) @@ -171,17 +174,17 @@ void ColorWindow::create_objects() add_tool(history = new PaletteHistory(this, 10, y)); x += 240; - add_tool(new BC_Title(x, y =y0, _("H:"), SMALLFONT)); - add_tool(new BC_Title(x, y+=25, _("S:"), SMALLFONT)); - add_tool(new BC_Title(x, y+=25, _("V:"), SMALLFONT)); - add_tool(new BC_Title(x, y+=40, _("R:"), SMALLFONT)); - add_tool(new BC_Title(x, y+=25, _("G:"), SMALLFONT)); - add_tool(new BC_Title(x, y+=25, _("B:"), SMALLFONT)); - add_tool(new BC_Title(x, y+=40, _("Y:"), SMALLFONT)); - add_tool(new BC_Title(x, y+=25, _("U:"), SMALLFONT)); - add_tool(new BC_Title(x, y+=25, _("V:"), SMALLFONT)); + 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)); if( thread->do_alpha ) - add_tool(new BC_Title(x, y+=40, _("A:"), SMALLFONT)); + add_tool(new BC_Title(x, y+=40, C_("A:"), SMALLFONT)); x += 24; add_tool(hue = new PaletteHue(this, x, y= y0)); add_tool(sat = new PaletteSat(this, x, y+=25)); @@ -211,9 +214,9 @@ void ColorWindow::create_objects() yuv_y = new PaletteYUV(this, x,y+=40, 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->create_objects(); yuv_u->set_tooltip(_("Complement Blue")); + 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->create_objects(); yuv_v->set_tooltip(_("Complement Red")); + 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->create_objects(); aph_a->set_tooltip(_("Alpha")); @@ -309,35 +312,47 @@ int ColorWindow::handle_event() return 1; } +void ColorWindow::get_screen_sample() +{ + int cx, cy; + get_abs_cursor_xy(cx, cy); + BC_Capture capture_bitmap(1, 1, 0); + VFrame vframe(1,1,BC_RGB888); + capture_bitmap.capture_frame(&vframe, cx,cy); + unsigned char *data = vframe.get_data(); + rgb.r = data[0]/255.; rgb.g = data[1]/255.; rgb.b = data[2]/255.; + update_rgb(); +} + +int ColorWindow::cursor_motion_event() +{ + if( button_grabbed && get_button_down() ) { + get_screen_sample(); + return 1; + } + return 0; +} + int ColorWindow::button_press_event() { if( button_grabbed ) { - grab_cursor(); + get_screen_sample(); + return 1; } return 0; } + int ColorWindow::button_release_event() { if( button_grabbed ) { - grab_btn->disable(); - grab_btn->enable(); ungrab_buttons(); ungrab_cursor(); + grab_btn->enable(); button_grabbed = 0; - int cx, cy; - get_abs_cursor_xy(cx, cy); -//printf("grabbed button %d,%d\n",cx,cy); - BC_Capture capture_bitmap(1, 1, 0); - VFrame vframe(1,1,BC_RGB888); - capture_bitmap.capture_frame(&vframe, cx,cy); - unsigned char *data = vframe.get_data(); - rgb.r = data[0]/255.; rgb.g = data[1]/255.; rgb.b = data[2]/255.; - update_rgb(); - update_display(); update_history(); return handle_event(); } - return 0; + return 1; } void ColorWindow::update_rgb_hex(const char *hex) @@ -349,7 +364,6 @@ void ColorWindow::update_rgb_hex(const char *hex) float b = ((color>>0) & 0xff) / 255.; rgb.r = r; rgb.g = g; rgb.b = b; update_rgb(); - update_display(); update_history(); handle_event(); } @@ -392,8 +406,8 @@ int PaletteWheel::cursor_motion_event() distance = (int)sqrt(x1 * x1 + y1 * y1); float s = (float)distance / (get_w() / 2); bclamp(s, 0, 1); window->hsv.s = s; + window->hsv.v = 1; window->update_hsv(); - window->update_display(); window->handle_event(); return 1; } @@ -592,7 +606,6 @@ int PaletteWheelValue::cursor_motion_event() float v = 1.0 - (float)(get_cursor_y() - 2) / (get_h() - 4); bclamp(v, 0, 1); window->hsv.v = v; window->update_hsv(); - window->update_display(); window->handle_event(); return 1; } @@ -976,7 +989,6 @@ int PaletteHSV::handle_event() { update_output(); window->update_hsv(); - window->update_display(); window->handle_event(); return 1; } @@ -985,7 +997,6 @@ int PaletteRGB::handle_event() { update_output(); window->update_rgb(); - window->update_display(); window->handle_event(); return 1; } @@ -994,7 +1005,6 @@ int PaletteYUV::handle_event() { update_output(); window->update_yuv(); - window->update_display(); window->handle_event(); return 1; } @@ -1066,6 +1076,7 @@ PaletteGrabButton::~PaletteGrabButton() int PaletteGrabButton::handle_event() { if( window->grab_buttons() ) { + grab_cursor(); window->button_grabbed = 1; button_press_event(); // redraw face HI } @@ -1125,7 +1136,6 @@ int PaletteHistory::cursor_motion_event() if( window->rgb.r != r || window->rgb.g != g || window->rgb.b != b ) { window->rgb.r = r; window->rgb.g = g; window->rgb.b = b; window->update_rgb(); - window->update_display(); } return 1; }