rework histogram_bezier, init wm icon set_icon(gg), update de.po+msg/txt
[goodguy/history.git] / cinelerra-5.1 / cinelerra / gwindowgui.C
index b1b8300c2ee9c72d42b67193ad8f7e6f737fec7d..70bfca1e96bf87736beaf39bda4e17c320222d34 100644 (file)
@@ -27,6 +27,7 @@
 #include "edl.h"
 #include "edlsession.h"
 #include "gwindowgui.h"
+#include "keys.h"
 #include "language.h"
 #include "localsession.h"
 #include "mainmenu.h"
@@ -49,6 +50,8 @@ GWindowGUI::GWindowGUI(MWindow *mwindow, int w, int h)
 {
        this->mwindow = mwindow;
        color_thread = 0;
+       camera_xyz = 0;
+       projector_xyz = 0;
 }
 
 GWindowGUI::~GWindowGUI()
@@ -60,34 +63,34 @@ void GWindowGUI::start_color_thread(GWindowColorButton *color_button)
 {
        unlock_window();
        delete color_thread;
-       color_thread = new GWindowColorThread(color_button);
+       color_thread = new GWindowColorThread(this, color_button);
        int color = auto_colors[color_button->auto_toggle->info->ref];
        color_thread->start(color);
        lock_window("GWindowGUI::start_color_thread");
 }
 
-const char *GWindowGUI::other_text[NON_AUTOMATION_TOTAL] =
+const char *GWindowGUI::non_auto_text[NON_AUTOMATION_TOTAL] =
 {
-       "Assets",
-       "Titles",
-       "Transitions",
-       "Plugin Autos"
+       N_("Assets"),
+       N_("Titles"),
+       N_("Transitions"),
+       N_("Plugin Keyframes"),
 };
 
 const char *GWindowGUI::auto_text[AUTOMATION_TOTAL] =
 {
-       "Mute",
-       "Camera X",
-       "Camera Y",
-       "Camera Z",
-       "Projector X",
-       "Projector Y",
-       "Projector Z",
-       "Fade",
-       "Pan",
-       "Mode",
-       "Mask",
-       "Speed"
+       N_("Mute"),
+       N_("Camera X"),
+       N_("Camera Y"),
+       N_("Camera Z"),
+       N_("Projector X"),
+       N_("Projector Y"),
+       N_("Projector Z"),
+       N_("Fade"),
+       N_("Pan"),
+       N_("Mode"),
+       N_("Mask"),
+       N_("Speed")
 };
 
 int GWindowGUI::auto_colors[AUTOMATION_TOTAL] =
@@ -144,18 +147,28 @@ static toggleinfo toggle_order[] =
        {1, AUTOMATION_FADE},
        {1, AUTOMATION_MUTE},
        {1, AUTOMATION_SPEED},
+       {1, AUTOMATION_MODE},
+       {1, AUTOMATION_PAN},
+       {1, AUTOMATION_MASK},
+       {0, -1}, // bar
        {1, AUTOMATION_CAMERA_X},
        {1, AUTOMATION_CAMERA_Y},
        {1, AUTOMATION_CAMERA_Z},
+       {-1, NONAUTOTOGGLES_CAMERA_XYZ},
+       {0, -1}, // bar
        {1, AUTOMATION_PROJECTOR_X},
        {1, AUTOMATION_PROJECTOR_Y},
        {1, AUTOMATION_PROJECTOR_Z},
-       {0, -1}, // bar
-       {1, AUTOMATION_MODE},
-       {1, AUTOMATION_PAN},
-       {1, AUTOMATION_MASK},
+       {-1, NONAUTOTOGGLES_PROJECTOR_XYZ},
 };
 
+const char *GWindowGUI::toggle_text(toggleinfo *tp)
+{
+       if( tp->isauto > 0 ) return _(auto_text[tp->ref]);
+       if( !tp->isauto ) return _(non_auto_text[tp->ref]);
+       return _("XYZ");
+}
+
 void GWindowGUI::calculate_extents(BC_WindowBase *gui, int *w, int *h)
 {
        int temp1, temp2, temp3, temp4, temp5, temp6, temp7;
@@ -165,7 +178,7 @@ void GWindowGUI::calculate_extents(BC_WindowBase *gui, int *w, int *h)
 
        for( int i=0; i<(int)(sizeof(toggle_order)/sizeof(toggle_order[0])); ++i ) {
                toggleinfo *tp = &toggle_order[i];
-               int isauto = tp->isauto, ref = tp->ref;
+               int ref = tp->ref;
                if( ref < 0 ) {
                        *h += get_resources()->bar_data->get_h() + 5;
                        continue;
@@ -174,8 +187,7 @@ void GWindowGUI::calculate_extents(BC_WindowBase *gui, int *w, int *h)
                        BC_WindowBase::get_resources()->checkbox_images,
                        0, &temp1, &current_w, &current_h,
                        &temp2, &temp3, &temp4, &temp5, &temp6, &temp7,
-                       _(isauto ?  auto_text[ref] : other_text[ref]),
-                       MEDIUMFONT);
+                       toggle_text(tp), MEDIUMFONT);
                current_w += current_h;
                *w = MAX(current_w, *w);
                *h += current_h + 5;
@@ -190,8 +202,10 @@ GWindowColorButton::GWindowColorButton(GWindowToggle *auto_toggle, int x, int y,
 {
        this->auto_toggle = auto_toggle;
        this->color = 0;
-       for( int i=0; i<3; ++i )
-               vframes[i] = new VFrame(w, w, BC_RGBA8888, -1);
+       for( int i=0; i<3; ++i ) {
+               vframes[i] = new VFrame(w, w, BC_RGBA8888);
+               vframes[i]->clear_frame();
+       }
 }
 
 GWindowColorButton::~GWindowColorButton()
@@ -247,11 +261,12 @@ void GWindowColorButton::update_gui(int color)
        draw_face();
 }
 
-GWindowColorThread::GWindowColorThread(GWindowColorButton *color_button)
- : ColorThread(0, color_button->auto_toggle->caption)
+GWindowColorThread::GWindowColorThread(GWindowGUI *gui, GWindowColorButton *color_button)
+ : ColorPicker(0, color_button->auto_toggle->caption)
 {
-       this->color = 0;
+       this->gui = gui;
        this->color_button = color_button;
+       this->color = 0;
        color_update = new GWindowColorUpdate(this);
 }
 
@@ -269,7 +284,6 @@ void GWindowColorThread::start(int color)
 void GWindowColorThread::handle_done_event(int result)
 {
        color_update->stop();
-       GWindowGUI *gui = color_button->auto_toggle->gui;
        int ref = color_button->auto_toggle->info->ref;
        gui->lock_window("GWindowColorThread::handle_done_event");
        if( !result ) {
@@ -282,7 +296,7 @@ void GWindowColorThread::handle_done_event(int result)
                color_button->update_gui(color);
        }
        gui->unlock_window();
-       MWindowGUI *mwindow_gui = color_button->auto_toggle->gui->mwindow->gui;
+       MWindowGUI *mwindow_gui = gui->mwindow->gui;
        mwindow_gui->lock_window("GWindowColorUpdate::run");
        mwindow_gui->draw_overlays(1);
        mwindow_gui->unlock_window();
@@ -297,7 +311,9 @@ int GWindowColorThread::handle_new_color(int color, int alpha)
 
 void GWindowColorThread::update_gui()
 {
+       gui->lock_window("GWindowColorThread::update_gui");
        color_button->update_gui(color);
+       gui->unlock_window();
 }
 
 GWindowColorUpdate::GWindowColorUpdate(GWindowColorThread *color_thread)
@@ -351,7 +367,7 @@ int GWindowColorButton::handle_event()
 void GWindowGUI::create_objects()
 {
        int x = 10, y = 10;
-       lock_window("GWindowGUI::create_objects 1");
+       lock_window("GWindowGUI::create_objects");
 
        for( int i=0; i<(int)(sizeof(toggle_order)/sizeof(toggle_order[0])); ++i ) {
                toggleinfo *tp = &toggle_order[i];
@@ -363,49 +379,98 @@ void GWindowGUI::create_objects()
                        y += bar->get_h() + 5;
                        continue;
                }
-               VFrame *vframe = 0;
-               switch( ref ) {
-               case AUTOMATION_MODE: vframe = mwindow->theme->modekeyframe_data;  break;
-               case AUTOMATION_PAN:  vframe = mwindow->theme->pankeyframe_data;   break;
-               case AUTOMATION_MASK: vframe = mwindow->theme->maskkeyframe_data;  break;
-               }
-               const char *label = tp->isauto ? auto_text[tp->ref] : other_text[tp->ref] ;
-               int color = !tp->isauto ? -1 : auto_colors[tp->ref];
-               GWindowToggle *toggle = new GWindowToggle(mwindow, this, x, y, label, color, tp);
+               const char *label = toggle_text(tp);
+               int color = tp->isauto > 0 ? auto_colors[tp->ref] : WHITE;
+               GWindowToggle *toggle = new GWindowToggle(this, x, y, label, color, tp);
                add_tool(toggles[i] = toggle);
-               if( vframe )
-                       draw_vframe(vframe, get_w()-vframe->get_w()-10, y);
-               else if( tp->isauto ) {
-                       int wh = toggle->get_h() - 4;
-                       GWindowColorButton *color_button =
-                               new GWindowColorButton(toggle, get_w()-wh-10, y+2, wh);
-                       add_tool(color_button);
-                       color_button->set_color(color);
-                       color_button->draw_face();
+               if( tp->isauto > 0 ) {
+                       VFrame *vframe = 0;
+                       switch( ref ) {
+                       case AUTOMATION_MODE: vframe = mwindow->theme->modekeyframe_data;  break;
+                       case AUTOMATION_PAN:  vframe = mwindow->theme->pankeyframe_data;   break;
+                       case AUTOMATION_MASK: vframe = mwindow->theme->maskkeyframe_data;  break;
+                       }
+                       if( !vframe ) {
+                               int wh = toggle->get_h() - 4;
+                               GWindowColorButton *color_button =
+                                       new GWindowColorButton(toggle, get_w()-wh-10, y+2, wh);
+                               add_tool(color_button);
+                               color_button->set_color(color);
+                               color_button->draw_face();
+                       }
+                       else
+                               draw_vframe(vframe, get_w()-vframe->get_w()-10, y);
+               }
+               else if( tp->isauto < 0 ) {
+                       const char *accel = 0;
+                       switch( ref ) {
+                       case NONAUTOTOGGLES_CAMERA_XYZ:
+                               camera_xyz = toggle;
+                               accel = _("Shift-F1");
+                               break;
+                       case NONAUTOTOGGLES_PROJECTOR_XYZ:
+                               projector_xyz = toggle;
+                               accel = _("Shift-F2");
+                               break;
+                       }
+                        if( accel ) {
+                               int x1 = get_w() - BC_Title::calculate_w(this, accel) - 10;
+                               add_subwindow(new BC_Title(x1, y, accel));
+                       }
                }
                y += toggles[i]->get_h() + 5;
        }
+       update_toggles(0);
        unlock_window();
 }
 
-void GWindowGUI::update_mwindow()
+void GWindowGUI::update_mwindow(int toggles, int overlays)
 {
        unlock_window();
-       mwindow->gui->mainmenu->update_toggles(1);
+       mwindow->gui->lock_window("GWindowGUI::update_mwindow");
+       if( toggles )
+               mwindow->gui->mainmenu->update_toggles(0);
+       if( overlays )
+               mwindow->gui->draw_overlays(1);
+       mwindow->gui->unlock_window();
        lock_window("GWindowGUI::update_mwindow");
 }
 
 void GWindowGUI::update_toggles(int use_lock)
 {
-       if(use_lock) lock_window("GWindowGUI::update_toggles");
+       if(use_lock) {
+               lock_window("GWindowGUI::update_toggles");
+               set_cool(0);
+       }
 
        for( int i=0; i<(int)(sizeof(toggle_order)/sizeof(toggle_order[0])); ++i ) {
                if( toggles[i] ) toggles[i]->update();
        }
 
+       camera_xyz->set_value(check_xyz(AUTOMATION_CAMERA_X) > 0 ? 1 : 0);
+       projector_xyz->set_value(check_xyz(AUTOMATION_PROJECTOR_X) > 0 ? 1 : 0);
+
        if(use_lock) unlock_window();
 }
 
+void GWindowGUI::toggle_camera_xyz()
+{
+       int v = camera_xyz->get_value() ? 0 : 1;
+       camera_xyz->set_value(v);
+       xyz_check(AUTOMATION_CAMERA_X, v);
+       update_toggles(0);
+       update_mwindow(1, 1);
+}
+
+void GWindowGUI::toggle_projector_xyz()
+{
+       int v = projector_xyz->get_value() ? 0 : 1;
+       projector_xyz->set_value(v);
+       xyz_check(AUTOMATION_PROJECTOR_X, v);
+       update_toggles(0);
+       update_mwindow(1, 1);
+}
+
 int GWindowGUI::translation_event()
 {
        mwindow->session->gwindow_x = get_x();
@@ -415,6 +480,7 @@ int GWindowGUI::translation_event()
 
 int GWindowGUI::close_event()
 {
+       delete color_thread;  color_thread = 0;
        hide_window();
        mwindow->session->show_gwindow = 0;
        unlock_window();
@@ -431,6 +497,14 @@ int GWindowGUI::close_event()
 int GWindowGUI::keypress_event()
 {
        switch(get_keypress()) {
+       case KEY_F1:
+               if( shift_down() )
+                       toggle_camera_xyz();
+               break;
+       case KEY_F2:
+               if( shift_down() )
+                       toggle_projector_xyz();
+               break;
        case 'w':
        case 'W':
        case '0':
@@ -443,16 +517,47 @@ int GWindowGUI::keypress_event()
        return 0;
 }
 
+int GWindowGUI::check_xyz(int group)
+{
+// returns 1=all set, -1=all clear, 0=mixed
+       int *autos = mwindow->edl->session->auto_conf->autos;
+       int v = autos[group], ret = v ? 1 : -1;
+       if( autos[group+1] != v || autos[group+2] != v ) ret = 0;
+       return ret;
+}
+void GWindowGUI::xyz_check(int group, int v)
+{
+       int *autos = mwindow->edl->session->auto_conf->autos;
+       autos[group+0] = v;
+       autos[group+1] = v;
+       autos[group+2] = v;
+}
+
+int* GWindowGUI::get_main_value(toggleinfo *info)
+{
+       if( info->isauto > 0 )
+               return &mwindow->edl->session->auto_conf->autos[info->ref];
+       if( !info->isauto ) {
+               switch( info->ref ) {
+               case NON_AUTOMATION_ASSETS: return &mwindow->edl->session->show_assets;
+               case NON_AUTOMATION_TITLES: return &mwindow->edl->session->show_titles;
+               case NON_AUTOMATION_TRANSITIONS: return &mwindow->edl->session->auto_conf->transitions;
+               case NON_AUTOMATION_PLUGIN_AUTOS: return &mwindow->edl->session->auto_conf->plugins;
+               }
+       }
+       return 0;
+}
+
 
-GWindowToggle::GWindowToggle(MWindow *mwindow, GWindowGUI *gui, int x, int y,
+GWindowToggle::GWindowToggle(GWindowGUI *gui, int x, int y,
        const char *text, int color, toggleinfo *info)
- : BC_CheckBox(x, y, *get_main_value(mwindow, info), text, MEDIUMFONT, color)
+ : BC_CheckBox(x, y, 0, text, MEDIUMFONT, color)
 {
-       this->mwindow = mwindow;
        this->gui = gui;
        this->info = info;
        this->color = color;
        this->color_button = 0;
+       hot = hot_value = 0;
 }
 
 GWindowToggle::~GWindowToggle()
@@ -463,14 +568,57 @@ GWindowToggle::~GWindowToggle()
 int GWindowToggle::handle_event()
 {
        int value = get_value();
-       *get_main_value(mwindow, info) = value;
-       gui->update_mwindow();
-
+       if( shift_down() ) {
+               if( !hot ) {
+                       gui->set_hot(this);
+                       value = 1;
+               }
+               else {
+                       gui->set_cool(1);
+                       value = hot_value;
+               }
+       }
+       else
+               gui->set_cool(0);
+       if( info->isauto >= 0 ) {
+               *gui->get_main_value(info) = value;
+               switch( info->ref ) {
+               case AUTOMATION_CAMERA_X:
+               case AUTOMATION_CAMERA_Y:
+               case AUTOMATION_CAMERA_Z: {
+                       int v = gui->check_xyz(AUTOMATION_CAMERA_X);
+                       gui->camera_xyz->set_value(v > 0 ? 1 : 0);
+                       break; }
+               case AUTOMATION_PROJECTOR_X:
+               case AUTOMATION_PROJECTOR_Y:
+               case AUTOMATION_PROJECTOR_Z: {
+                       int v = gui->check_xyz(AUTOMATION_PROJECTOR_X);
+                       gui->projector_xyz->set_value(v > 0 ? 1 : 0);
+                       break; }
+               }
+       }
+       else {
+               int group = -1;
+               switch( info->ref ) {
+               case NONAUTOTOGGLES_CAMERA_XYZ:     group = AUTOMATION_CAMERA_X;     break;
+               case NONAUTOTOGGLES_PROJECTOR_XYZ:  group = AUTOMATION_PROJECTOR_X;  break;
+               }
+               if( group >= 0 ) {
+                       gui->xyz_check(group, value);
+                       gui->update_toggles(0);
+               }
+       }
+       gui->update_mwindow(1, 0);
 
 // Update stuff in MWindow
        unlock_window();
+       MWindow *mwindow = gui->mwindow;
        mwindow->gui->lock_window("GWindowToggle::handle_event");
-       if( info->isauto ) {
+
+       mwindow->gui->update(1, 1, 0, 0, 1, 0, 0);
+       mwindow->gui->draw_overlays(1);
+
+       if( value && info->isauto > 0 ) {
                int autogroup_type = -1;
                switch( info->ref ) {
                case AUTOMATION_FADE:
@@ -493,24 +641,10 @@ int GWindowToggle::handle_event()
                        autogroup_type = AUTOGROUPTYPE_ZOOM;
                        break;
                }
-               if( value && autogroup_type >= 0 ) {
+               if( autogroup_type >= 0 ) {
                        mwindow->edl->local_session->zoombar_showautotype = autogroup_type;
                        mwindow->gui->zoombar->update_autozoom();
                }
-               mwindow->gui->draw_overlays(1);
-       }
-       else {
-               switch( info->ref ) {
-               case NON_AUTOMATION_ASSETS:
-               case NON_AUTOMATION_TITLES:
-                       mwindow->gui->update(1, 1, 0, 0, 1, 0, 0);
-                       break;
-
-               case NON_AUTOMATION_TRANSITIONS:
-               case NON_AUTOMATION_PLUGIN_AUTOS:
-                       mwindow->gui->draw_overlays(1);
-                       break;
-               }
        }
 
        mwindow->gui->unlock_window();
@@ -519,30 +653,62 @@ int GWindowToggle::handle_event()
        return 1;
 }
 
-int* GWindowToggle::get_main_value(MWindow *mwindow, toggleinfo *info)
+void GWindowToggle::update()
 {
-       if( info->isauto )
-               return &mwindow->edl->session->auto_conf->autos[info->ref];
+       int *vp = gui->get_main_value(info);
+       if( vp ) set_value(*vp);
+}
+
+void GWindowToggle::update_gui(int color)
+{
+       BC_Toggle::color = color;
+       draw_face(1,0);
+}
 
-       switch( info->ref ) {
-       case NON_AUTOMATION_ASSETS: return &mwindow->edl->session->show_assets;
-       case NON_AUTOMATION_TITLES: return &mwindow->edl->session->show_titles;
-       case NON_AUTOMATION_TRANSITIONS: return &mwindow->edl->session->auto_conf->transitions;
-       case NON_AUTOMATION_PLUGIN_AUTOS: return &mwindow->edl->session->auto_conf->plugins;
+int GWindowToggle::draw_face(int flash, int flush)
+{
+       int ret = BC_Toggle::draw_face(flash, flush);
+       if( hot ) {
+               set_color(color);
+               set_opaque();
+               draw_rectangle(text_x-1, text_y-1, text_w+1, text_h+1);
+               if( flash ) this->flash(0);
+               if( flush ) this->flush();
        }
-       return 0;
+       return ret;
 }
 
-void GWindowToggle::update()
+void GWindowGUI::set_cool(int reset, int all)
 {
-       int *vp = get_main_value(mwindow, info);
-       if( !vp ) return;
-       set_value(*vp);
+       for( int i=0; i<(int)(sizeof(toggles)/sizeof(toggles[0])); ++i ) {
+               GWindowToggle* toggle = toggles[i];
+               if( !toggle ) continue;
+               int *vp = get_main_value(toggle->info);
+               if( !vp ) continue;
+               if( toggle->hot ) {
+                       toggle->hot = 0;
+                       toggle->draw_face(1, 0);
+               }
+               if( reset > 0 )
+                       *vp = toggle->hot_value;
+               else {
+                       toggle->hot_value = *vp;
+                       if( reset < 0 ) {
+                               if ( all || toggle->info->isauto > 0 )
+                                       *vp = 0;
+                       }
+               }
+       }
+       if( reset )
+               update_toggles(0);
 }
 
-void GWindowToggle::update_gui(int color)
+void GWindowGUI::set_hot(GWindowToggle *toggle)
 {
-       BC_Toggle::color = color;
-       draw_face(1,0);
+       int *vp = get_main_value(toggle->info);
+       if( !vp ) return;
+       set_cool(-1, !toggle->info->isauto ? 1 : 0);
+       toggle->hot = 1;
+       toggle->set_value(*vp = 1);
 }