rework histogram_bezier, init wm icon set_icon(gg), update de.po+msg/txt
[goodguy/history.git] / cinelerra-5.1 / cinelerra / mwindowgui.C
index 74f3e1f3b9a0200bd57afa70de2453e3d9c296c6..70c4808a959ea8b8c25a72b13fc6abb471ef0227 100644 (file)
@@ -251,6 +251,7 @@ void MWindowGUI::get_scrollbars(int flush)
 
 void MWindowGUI::create_objects()
 {
+       lock_window("MWindowGUI::create_objects");
        const int debug = 0;
 
        resource_thread = new ResourceThread(mwindow, this);
@@ -277,7 +278,10 @@ void MWindowGUI::create_objects()
 
        add_subwindow(mbuttons = new MButtons(mwindow, this));
        mbuttons->create_objects();
-       add_subwindow(ffmpeg_toggle = new FFMpegToggle(mwindow, mbuttons, menu_w(), menu_h()+2));
+       int x1 = mbuttons->get_x() + mbuttons->get_w(), y1 = mbuttons->get_y()+2;
+       add_subwindow(proxy_toggle = new ProxyToggle(mwindow, mbuttons, x1, y1));
+       x1 += proxy_toggle->get_w() + 3;
+       add_subwindow(ffmpeg_toggle = new FFMpegToggle(mwindow, mbuttons, x1, y1));
 
        pane[TOP_LEFT_PANE] = new TimelinePane(mwindow,
                TOP_LEFT_PANE,
@@ -320,12 +324,8 @@ void MWindowGUI::create_objects()
 
        if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
        add_subwindow(mainclock = new MainClock(mwindow,
-               mwindow->theme->mclock_x,
-               mwindow->theme->mclock_y,
+               mwindow->theme->mclock_x, mwindow->theme->mclock_y,
                mwindow->theme->mclock_w));
-       mainclock->set_position_offset( (double)
-               (mwindow->edl->session->get_frame_offset() /
-                       mwindow->edl->session->frame_rate));
        if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
        mainclock->update(0);
 
@@ -360,7 +360,9 @@ void MWindowGUI::create_objects()
 #ifdef HAVE_DVB
        channel_info = new ChannelInfo(mwindow);
 #endif
+#ifdef HAVE_COMMERCIAL
        db_window = new DbWindow(mwindow);
+#endif
        swindow = new SWindow(mwindow);
 
        if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
@@ -372,6 +374,7 @@ void MWindowGUI::create_objects()
        pane[TOP_LEFT_PANE]->canvas->activate();
 
        if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
+       unlock_window();
 }
 
 void MWindowGUI::redraw_time_dependancies()
@@ -408,7 +411,10 @@ int MWindowGUI::resize_event(int w, int h)
        mwindow->theme->get_mwindow_sizes(this, w, h);
        mwindow->theme->draw_mwindow_bg(this);
        mbuttons->resize_event();
-       ffmpeg_toggle->reposition_window(menu_w(), menu_h()+2);
+       int x1 = mbuttons->get_x() + mbuttons->get_w(), y1 = mbuttons->get_y()+2;
+       proxy_toggle->reposition_window(x1, y1);
+       x1 += proxy_toggle->get_w() + 3;
+       ffmpeg_toggle->reposition_window(x1, y1);
        statusbar->resize_event();
        zoombar->resize_event();
 
@@ -535,6 +541,7 @@ int MWindowGUI::resize_event(int w, int h)
                mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h());
        resource_thread->start_draw();
 
+       flash(1);
        return 0;
 }
 
@@ -657,6 +664,29 @@ void MWindowGUI::update_patchbay()
        }
 }
 
+void MWindowGUI::update_proxy_toggle()
+{
+       int value = mwindow->edl->session->proxy_scale == 1 ? 1 : 0;
+       proxy_toggle->set_value(value);
+       if( mwindow->edl->session->proxy_scale == 1 &&
+           mwindow->edl->session->proxy_disabled_scale == 1 )
+               proxy_toggle->hide();
+       else
+               proxy_toggle->show();
+}
+
+void MWindowGUI::update_plugintoggles()
+{
+       for(int i = 0; i < TOTAL_PANES; i++)
+       {
+               if(pane[i])
+               {
+                       pane[i]->canvas->refresh_plugintoggles();
+               }
+       }
+
+}
+
 void MWindowGUI::draw_indexes(Indexable *indexable)
 {
        for(int i = 0; i < TOTAL_PANES; i++)
@@ -703,6 +733,13 @@ void MWindowGUI::flash_canvas(int flush)
        }
 }
 
+int MWindowGUI::show_window(int flush)
+{
+       int ret = BC_WindowBase::show_window(flush);
+       update_proxy_toggle();
+       return ret;
+}
+
 void MWindowGUI::draw_cursor(int do_plugintoggles)
 {
        for(int i = 0; i < TOTAL_PANES; i++)
@@ -758,18 +795,6 @@ void MWindowGUI::set_playing_back(int value)
        }
 }
 
-void MWindowGUI::update_plugintoggles()
-{
-       for(int i = 0; i < TOTAL_PANES; i++)
-       {
-               if(pane[i])
-               {
-                       pane[i]->canvas->refresh_plugintoggles();
-               }
-       }
-
-}
-
 void MWindowGUI::update_scrollbars(int flush)
 {
        for(int i = 0; i < TOTAL_PANES; i++)
@@ -917,16 +942,25 @@ int MWindowGUI::visible(int64_t x1, int64_t x2, int64_t view_x1, int64_t view_x2
 }
 
 
-int MWindowGUI::show_message(char *message, int color)
+void MWindowGUI::show_message(const char *message, int color)
 {
-// printf("MWindowGUI::show_message %d: %s 0x%08x 0x%08x\n",
-// __LINE__, message, color, mwindow->theme->message_normal);
-       if(color < 0) color = mwindow->theme->message_normal;
-       statusbar->status_text->set_color(color);
-       statusbar->status_text->update(message);
-       return 0;
+       statusbar->show_message(message, color);
+}
+
+void MWindowGUI::update_default_message()
+{
+       statusbar->update_default_message();
 }
 
+void MWindowGUI::reset_default_message()
+{
+       statusbar->reset_default_message();
+}
+
+void MWindowGUI::default_message()
+{
+       statusbar->default_message();
+}
 
 // Drag motion called from other window
 int MWindowGUI::drag_motion()
@@ -1033,7 +1067,7 @@ int MWindowGUI::drag_stop()
        }
 
 
-//printf("TrackCanvas::drag_stop %d %d\n", redraw, mwindow->session->current_operation);
+//printf("MWindowGUI::drag_stop %d %d\n", redraw, mwindow->session->current_operation);
        if(redraw)
        {
                mwindow->edl->tracks->update_y_pixels(mwindow->theme);
@@ -1110,15 +1144,6 @@ void MWindowGUI::default_positions()
 }
 
 
-int MWindowGUI::button_release_event()
-{
-       if( keyvalue_popup ) {
-               delete keyvalue_popup;  keyvalue_popup = 0;
-       }
-       return 0;
-}
-
-
 int MWindowGUI::repeat_event(int64_t duration)
 {
 // if(duration == 100)
@@ -1156,12 +1181,22 @@ int MWindowGUI::keypress_event()
        int result = mbuttons->keypress_event();
        if( result ) return result;
 
+       Track *this_track = 0;
+
        switch(get_keypress()) {
        case 'e':
                mwindow->toggle_editing_mode();
                result = 1;
                break;
 
+       case 'k': case 'K':
+               if( alt_down() ) break;
+               stop_transport("MWindowGUI::keypress_event 1");
+               mwindow->nearest_plugin_keyframe(shift_down(),
+                       !ctrl_down() ? PLAY_FORWARD : PLAY_REVERSE);
+               result = 1;
+               break;
+
        case '1': case '2': case '3': case '4':
        case '5': case '6': case '7': case '8':
                if( !alt_down() || shift_down() ) break;
@@ -1172,9 +1207,7 @@ int MWindowGUI::keypress_event()
        case LEFT:
                if( !ctrl_down() ) {
                        if( alt_down() ) {
-                               unlock_window();
-                               mbuttons->transport->handle_transport(STOP, 1, 0, 0);
-                               lock_window("MWindowGUI::keypress_event 1");
+                               stop_transport("MWindowGUI::keypress_event 1");
                                mwindow->prev_edit_handle(shift_down());
                        }
                        else
@@ -1183,12 +1216,17 @@ int MWindowGUI::keypress_event()
                }
                break;
 
+       case ',':
+               if( !ctrl_down() && !alt_down() ) {
+                       mwindow->move_left();
+                       result = 1;
+               }
+               break;
+
        case RIGHT:
                if( !ctrl_down() ) {
                        if( alt_down() ) {
-                               unlock_window();
-                               mbuttons->transport->handle_transport(STOP, 1, 0, 0);
-                               lock_window("MWindowGUI::keypress_event 2");
+                               stop_transport("MWindowGUI::keypress_event 2");
                                mwindow->next_edit_handle(shift_down());
                        }
                        else
@@ -1197,6 +1235,13 @@ int MWindowGUI::keypress_event()
                }
                break;
 
+       case '.':
+               if( !ctrl_down() && !alt_down() ) {
+                       mwindow->move_right();
+                       result = 1;
+               }
+               break;
+
        case UP:
                if( ctrl_down() && !alt_down() )
                        mwindow->expand_y();
@@ -1239,7 +1284,6 @@ int MWindowGUI::keypress_event()
 
        case TAB:
        case LEFTTAB:
-               Track *this_track = 0;
                for( int i=0; i<TOTAL_PANES; ++i ) {
                        if( !pane[i] ) continue;
                        if( (this_track = pane[i]->over_track()) != 0 ) break;
@@ -1263,10 +1307,25 @@ int MWindowGUI::keypress_event()
                update(0, 1, 0, 0, 1, 0, 1);
                unlock_window();
                mwindow->cwindow->update(0, 1, 1);
-               lock_window("TrackCanvas::keypress_event 3");
+               lock_window("MWindowGUI::keypress_event 3");
 
                result = 1;
                break;
+
+       case KEY_F1:
+       case KEY_F2:
+       case KEY_F3:
+       case KEY_F4:
+       case KEY_F5:
+       case KEY_F6:
+       case KEY_F7:
+       case KEY_F8:
+       case KEY_F9:
+       case KEY_F10:
+       case KEY_F11:
+       case KEY_F12:
+               resend_event(mwindow->cwindow->gui);
+               return 1;
        }
 
 // since things under cursor have changed...
@@ -1292,7 +1351,7 @@ int MWindowGUI::key_listener(int key)
                        record->record_gui->interrupt_thread->start(0);
                break;
        case KPHAND:
-               mwindow->quit(0);
+               mwindow->quit();
                break;
 #ifdef HAVE_DVB
        case KPBOOK:
@@ -2230,6 +2289,32 @@ void MWindowGUI::draw_trackmovement()
 }
 
 
+void MWindowGUI::update_mixers(Track *track, int v)
+{
+       for( int i=0; i<TOTAL_PANES;  ++i ) {
+               if( !pane[i] ) continue;
+               PatchBay *patchbay = pane[i]->patchbay;
+               if( !patchbay ) continue;
+               for( int j=0; j<patchbay->patches.total; ++j ) {
+                       PatchGUI *patchgui = patchbay->patches.values[j];
+                       if( !patchgui->mix ) continue;
+                       if( !track || patchgui->track == track ) {
+                               patchgui->mix->update(v>=0 ? v :
+                                       mwindow->mixer_track_active(patchgui->track));
+                       }
+               }
+       }
+}
+
+void MWindowGUI::stop_transport(const char *lock_msg)
+{
+       if( !mbuttons->transport->is_stopped() ) {
+               if( lock_msg ) unlock_window();
+               mbuttons->transport->handle_transport(STOP, 1, 0, 0);
+               if( lock_msg ) lock_window(lock_msg);
+       }
+}
+
 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
  : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
 {
@@ -2264,19 +2349,20 @@ int PaneButton::cursor_motion_event()
 
 int PaneButton::button_release_event()
 {
-       mwindow->gui->stop_pane_drag();
+       if( get_buttonpress() != WHEEL_DOWN && get_buttonpress() != WHEEL_UP )
+               mwindow->gui->stop_pane_drag();
        int result = BC_Button::button_release_event();
        return result;
 }
 
 
 FFMpegToggle::FFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
- : BC_Toggle(x, y, mwindow->theme->ffmpeg_toggle, mwindow->preferences->ffmpeg_early_probe)
+ : BC_Toggle(x, y, mwindow->theme->ffmpeg_toggle,
+        mwindow->preferences->get_file_probe_armed("FFMPEG_Early") > 0 ? 1 : 0)
 {
        this->mwindow = mwindow;
        this->mbuttons = mbuttons;
-       set_tooltip( mwindow->preferences->ffmpeg_early_probe ?
-               _("Try FFMpeg first") : _("Try FFMpeg last"));
+       set_tooltip(get_value() ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
 }
 
 FFMpegToggle::~FFMpegToggle()
@@ -2285,12 +2371,73 @@ FFMpegToggle::~FFMpegToggle()
 
 int FFMpegToggle::handle_event()
 {
-       mwindow->preferences->ffmpeg_early_probe = get_value();
-       set_tooltip( mwindow->preferences->ffmpeg_early_probe ?
-               _("Try FFMpeg first") : _("Try FFMpeg last"));
+       int ffmpeg_early_probe = get_value();
+       set_tooltip(ffmpeg_early_probe ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
+       mwindow->preferences->set_file_probe_armed("FFMPEG_Early", ffmpeg_early_probe);
+       mwindow->preferences->set_file_probe_armed("FFMPEG_Late", !ffmpeg_early_probe);
+
        mwindow->show_warning(&mwindow->preferences->warn_indexes,
                _("Changing the base codecs may require rebuilding indexes."));
        return 1;
 }
 
 
+ProxyToggle::ProxyToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
+ : BC_Toggle(x, y, ( !mwindow->edl->session->proxy_use_scaler ?
+                       mwindow->theme->proxy_p_toggle :
+                       mwindow->theme->proxy_s_toggle ),
+               mwindow->edl->session->proxy_disabled_scale != 1)
+{
+       this->mwindow = mwindow;
+       this->mbuttons = mbuttons;
+       scaler_images = mwindow->edl->session->proxy_use_scaler;
+       set_tooltip(mwindow->edl->session->proxy_disabled_scale==1 ?
+               _("Disable proxy") : _("Enable proxy"));
+}
+
+void ProxyToggle::show()
+{
+       int use_scaler = mwindow->edl->session->proxy_use_scaler;
+       if( scaler_images != use_scaler )
+               set_images(!(scaler_images=use_scaler) ?
+                       mwindow->theme->proxy_p_toggle :
+                       mwindow->theme->proxy_s_toggle );
+       draw_face(1, 0);
+       if( is_hidden() )
+               show_window();
+}
+
+void ProxyToggle::hide()
+{
+       if( !is_hidden() )
+               hide_window();
+}
+
+ProxyToggle::~ProxyToggle()
+{
+}
+
+int ProxyToggle::handle_event()
+{
+       int disabled = get_value();
+       if( disabled )
+               mwindow->disable_proxy();
+       else
+               mwindow->enable_proxy();
+       set_tooltip(!disabled ? _("Disable proxy") : _("Enable proxy"));
+       return 1;
+}
+
+int ProxyToggle::keypress_event()
+{
+       if( ctrl_down() && !shift_down() && !alt_down() ) {
+               int key = get_keypress();
+               if( key == 'r' ) {
+                       int value = get_value() ? 0 : 1;
+                       set_value(value);
+                       return handle_event();
+               }
+       }
+       return 0;
+}
+