Credit Andrew - fix vorbis audio which was scratchy and ensure aging plugin does...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / colorpicker.C
index 78f1f957fd2ef72b20b6c70859d9b3fde2a47491..b1e2a94969a5cb745170c9b29b532e51ca6b7a44 100644 (file)
@@ -79,13 +79,14 @@ BC_Window* ColorPicker::new_gui()
        int w = ColorWindow::calculate_w();
        int h = ColorWindow::calculate_h();
        if( ok_cancel )
-               h += bmax(BC_OKButton::calculate_h(),BC_CancelButton::calculate_h());
+               h += bmax(ColorOK::calculate_h(),ColorCancel::calculate_h());
        int root_w = display_info.get_root_w(), root_h = display_info.get_root_h();
        if( x+w > root_w ) x = root_w - w;
        if( y+h > root_h ) y = root_h - h;
        if( x < 0 ) x = 0;
        if( y < 0 ) y = 0;
        ColorWindow *window = new ColorWindow(this, x, y, w, h, window_title);
+       window->create_objects();
        window->start_selection(color, !do_alpha ? -1 : alpha, ok_cancel);
        return window;
 }
@@ -108,12 +109,21 @@ ColorWindow::ColorWindow(ColorPicker *thread, int x, int y, int w, int h, const
    ColorGUI(this)
 {
        this->thread = thread;
+// *** CONTEXT_HELP ***
+       context_help_set_keyword("Title");
 }
 
 ColorWindow::~ColorWindow()
 {
 }
 
+void ColorWindow::create_objects()
+{
+       BC_WindowBase::create_objects();
+       ColorGUI::create_objects();
+       thread->create_objects(this);
+}
+
 void ColorWindow::update_gui(int color, int alpha)
 {
        lock_window("ColorWindow::update_gui");
@@ -148,7 +158,6 @@ ColorGUI::ColorGUI(BC_WindowBase *window)
        hue = 0; sat = 0; val = 0;
        red = 0; grn = 0; blu = 0;
        lum = 0; c_r = 0; c_b = 0;
-       alpha = 0;
 
        hsv_h = 0;  hsv_s = 0;  hsv_v = 0;
        rgb_r = 0;  rgb_g = 0;  rgb_b = 0;
@@ -244,6 +253,8 @@ void ColorGUI::create_objects()
 
        x += hue->get_w() + xs10;
        hsv_h = new PaletteHSV(this, x,y= y0, hsv.h, 0, 360);
+       hsv_h->set_increment(1);
+       hsv_h->set_precision(1);
        hsv_h->create_objects();  hsv_h->set_tooltip(_("Hue"));
        hsv_s = new PaletteHSV(this, x,y+=ys25, hsv.s, 0, 1);
        hsv_s->create_objects();  hsv_s->set_tooltip(_("Saturation"));
@@ -266,8 +277,8 @@ void ColorGUI::create_objects()
                aph_a->create_objects();  aph_a->set_tooltip(_("Alpha"));
        }
        if( ok_cancel ) {
-               add_tool(new BC_OKButton(window));
-               add_tool(new BC_CancelButton(window));
+               add_tool(new ColorOK(this, window));
+               add_tool(new ColorCancel(this, window));
        }
        create_objects(this);
 
@@ -289,8 +300,41 @@ void ColorGUI::change_values()
 }
 
 
+ColorOK::ColorOK(ColorGUI *gui, BC_WindowBase *window)
+ : BC_OKButton(window)
+{
+       this->gui = gui;
+       this->window = window;
+}
+int ColorOK::handle_event()
+{
+       gui->ok_cancel = 0;
+       gui->close_gui();
+       window->sync_display();
+       return 1;
+}
+
+ColorCancel::ColorCancel(ColorGUI *gui, BC_WindowBase *window)
+ : BC_CancelButton(window)
+{
+       this->gui = gui;
+       this->window = window;
+}
+int ColorCancel::handle_event()
+{
+       gui->ok_cancel = 1;
+       gui->close_gui();
+       window->sync_display();
+       return 1;
+}
+
 int ColorGUI::close_gui()
 {
+       if( button_grabbed ) {
+               button_grabbed = 0;
+               window->ungrab_buttons();
+               window->ungrab_cursor();
+       }
        window->set_done(ok_cancel ? 1 : 0);
        return 1;
 }
@@ -1141,7 +1185,7 @@ int PaletteGrabButton::handle_event()
        if( gui->window->grab_buttons() ) {
                gui->window->grab_cursor();
                gui->button_grabbed = 1;
-               gui->button_press_gui(); // redraw face HI
+               return BC_Button::button_press_event(); // redraw face HI
        }
        return 1;
 }
@@ -1321,7 +1365,7 @@ void ColorButtonPicker::update(int color, int alpha)
 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->update_gui(color);
        color_button->unlock_window();
        return color_button->handle_new_color(color, alpha);
 }
@@ -1408,7 +1452,8 @@ void ColorBoxButton::create_objects()
 void ColorBoxButton::set_color(int color)
 {
        this->color = (color & 0xffffff);
-       this->alpha = (~color>>24) & 0xff;
+       if( this->alpha >= 0 )
+               this->alpha = (~color>>24) & 0xff;
        int r = (color>>16) & 0xff;
        int g = (color>> 8) & 0xff;
        int b = (color>> 0) & 0xff;
@@ -1470,7 +1515,8 @@ void ColorCircleButton::create_objects()
 void ColorCircleButton::set_color(int color)
 {
        this->color = (color & 0xffffff);
-       this->alpha = (~color>>24) & 0xff;
+       if( this->alpha >= 0 )
+               this->alpha = (~color>>24) & 0xff;
        int r = (color>>16) & 0xff;
        int g = (color>>8) & 0xff;
        int b = (color>>0) & 0xff;