X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fcolorpicker.C;h=57601d7e7bbb7e5dab408d2829c005af9623d2ee;hb=3f801b05e0de577b00e98019b099ed38d66b9550;hp=76692f0d99dcb9630c40aa77085384f5b5c53817;hpb=258d9cb69d560f40961acdd20866e12e940c2f93;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/cinelerra/colorpicker.C b/cinelerra-5.1/cinelerra/colorpicker.C index 76692f0d..57601d7e 100644 --- a/cinelerra-5.1/cinelerra/colorpicker.C +++ b/cinelerra-5.1/cinelerra/colorpicker.C @@ -96,7 +96,7 @@ void ColorPicker::update_gui(int output, int alpha) { 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(); @@ -311,7 +311,9 @@ void ColorWindow::update_display() int ColorWindow::handle_event() { - thread->handle_new_color(rgb888(), (int)(255*aph + 0.5)); + unlock_window(); + thread->handle_new_color(rgb888(), alpha8()); + lock_window("ColorWindow::handle_event"); return 1; } @@ -360,8 +362,12 @@ int ColorWindow::button_release_event() void ColorWindow::update_rgb_hex(const char *hex) { - int color; + unsigned color; if( sscanf(hex,"%x",&color) == 1 ) { + if( thread->do_alpha ) { + aph = ((color>>24) & 0xff) / 255.; + aph_a->update(aph); + } float r = ((color>>16) & 0xff) / 255.; float g = ((color>>8) & 0xff) / 255.; float b = ((color>>0) & 0xff) / 255.; @@ -807,6 +813,7 @@ int PaletteAlpha::handle_event() { window->aph = get_value(); window->aph_a->update(window->aph); + window->hex_box->update(); window->handle_event(); return 1; } @@ -973,6 +980,12 @@ int ColorWindow::rgb888() bclamp(r, 0, 255); bclamp(g, 0, 255); bclamp(b, 0, 255); return (r<<16) | (g<<8) | (b<<0); } +int ColorWindow::alpha8() +{ + int a = 255*aph + 0.5; + bclamp(a, 0, 255); + return a; +} PaletteNum::PaletteNum(ColorWindow *window, int x, int y, float &output, float min, float max) @@ -1047,7 +1060,10 @@ PaletteHex::~PaletteHex() } void PaletteHex::update() { - char hex[BCSTRLEN]; sprintf(hex,"%06x",window->rgb888()); + char hex[BCSTRLEN], *cp = hex; + if( window->thread->do_alpha ) + cp += sprintf(cp,"%02x", window->alpha8()); + sprintf(cp,"%06x",window->rgb888()); BC_TextBox::update(hex); } @@ -1223,6 +1239,13 @@ void ColorButton::close_picker() 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); @@ -1245,21 +1268,34 @@ void ColorButtonPicker::handle_done_event(int result) 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) { @@ -1323,12 +1359,13 @@ void ColorBoxButton::handle_done_event(int result) } 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; @@ -1384,12 +1421,13 @@ void ColorCircleButton::handle_done_event(int result) } 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;