rework audio import_samples + resample + playback speed sampling, fix clear_boarder...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / mwindowgui.C
index 53677b4229bc32eca088241ba9438993a2c8558d..248a56004a9d4b3f0297238583143a8b2ccbe845 100644 (file)
 // the main window uses its own private colormap for video
 MWindowGUI::MWindowGUI(MWindow *mwindow)
  : BC_Window(_(PROGRAM_NAME ": Program"),
-               mwindow->session->mwindow_x,
-               mwindow->session->mwindow_y,
-               mwindow->session->mwindow_w,
-               mwindow->session->mwindow_h,
-               100,
-               100,
-               1,
-               1,
-               1)
+               mwindow->session->mwindow_x, mwindow->session->mwindow_y,
+               mwindow->session->mwindow_w, mwindow->session->mwindow_h,
+               xS(100), yS(100), 1, 1, 1)
 {
        this->mwindow = mwindow;
 //     samplescroll = 0;
@@ -124,7 +118,7 @@ MWindowGUI::MWindowGUI(MWindow *mwindow)
        keyframe_menu = 0;
        keyframe_hide = 0;
        keyvalue_popup = 0;
-       transition_menu = 0;
+       transition_menu = 0;
        remote_control = 0;
        cwindow_remote_handler = 0;
        record_remote_handler = 0;
@@ -156,102 +150,6 @@ MWindowGUI::~MWindowGUI()
        delete y_divider;
 }
 
-#if 0
-void MWindowGUI::get_scrollbars(int flush)
-{
-       //int64_t h_needed = mwindow->edl->get_tracks_height(mwindow->theme);
-       //int64_t w_needed = mwindow->edl->get_tracks_width();
-       int need_xscroll = 0;
-       int need_yscroll = 0;
-       view_w = mwindow->theme->mcanvas_w;
-       view_h = mwindow->theme->mcanvas_h;
-
-// Scrollbars are constitutive
-       need_xscroll = need_yscroll = 1;
-       view_h = mwindow->theme->mcanvas_h;
-       view_w = mwindow->theme->mcanvas_w;
-
-//     for(int i = 0; i < 2; i++)
-//     {
-//             if(w_needed > view_w)
-//             {
-//                     need_xscroll = 1;
-//                     view_h = mwindow->theme->mcanvas_h - SCROLL_SPAN;
-//             }
-//             else
-//                     need_xscroll = 0;
-//
-//             if(h_needed > view_h)
-//             {
-//                     need_yscroll = 1;
-//                     view_w = mwindow->theme->mcanvas_w - SCROLL_SPAN;
-//             }
-//             else
-//                     need_yscroll = 0;
-//     }
-//printf("MWindowGUI::get_scrollbars 1\n");
-
-       if(canvas && (view_w != canvas->get_w() || view_h != canvas->get_h()))
-       {
-               canvas->reposition_window(mwindow->theme->mcanvas_x,
-                       mwindow->theme->mcanvas_y,
-                       view_w,
-                       view_h);
-       }
-
-       if(need_xscroll)
-       {
-               if(!samplescroll)
-                       add_subwindow(samplescroll = new SampleScroll(mwindow,
-                               this,
-                               mwindow->theme->mhscroll_x,
-                               mwindow->theme->mhscroll_y,
-                               mwindow->theme->mhscroll_w));
-               else
-                       samplescroll->resize_event();
-
-               samplescroll->set_position(0);
-       }
-       else
-       {
-               if(samplescroll) delete samplescroll;
-               samplescroll = 0;
-               mwindow->edl->local_session->view_start = 0;
-       }
-
-
-       if(need_yscroll)
-       {
-//printf("MWindowGUI::get_scrollbars 1.1 %p %p\n", this, canvas);
-               if(!trackscroll)
-                       add_subwindow(trackscroll = new TrackScroll(mwindow,
-                               this,
-                               mwindow->theme->mvscroll_x,
-                               mwindow->theme->mvscroll_y,
-                               mwindow->theme->mvscroll_h));
-               else
-                       trackscroll->resize_event();
-
-
-//printf("MWindowGUI::get_scrollbars 1.2\n");
-               trackscroll->update_length(mwindow->edl->get_tracks_height(mwindow->theme),
-                       mwindow->edl->local_session->track_start,
-                       view_h,
-                       0);
-//printf("MWindowGUI::get_scrollbars 1.3\n");
-       }
-       else
-       {
-               if(trackscroll) delete trackscroll;
-               trackscroll = 0;
-               mwindow->edl->local_session->track_start = 0;
-       }
-
-       if(flush) this->flush();
-
-}
-#endif // 0
-
 void MWindowGUI::create_objects()
 {
        lock_window("MWindowGUI::create_objects");
@@ -270,7 +168,7 @@ void MWindowGUI::create_objects()
 
        if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
 
-       int x = get_w() - MainShBtns::calculate_w(0);
+       int x = get_w() - MainShBtns::calculate_w(-1, 0, -1);
        add_subwindow(mainmenu = new MainMenu(mwindow, this, x));
        mainmenu->create_objects();
        add_subwindow(mainshbtns = new MainShBtns(mwindow, x, -1));
@@ -281,9 +179,9 @@ void MWindowGUI::create_objects()
 
        add_subwindow(mbuttons = new MButtons(mwindow, this));
        mbuttons->create_objects();
-       int x1 = mbuttons->get_x() + mbuttons->get_w(), y1 = mbuttons->get_y()+2;
+       int x1 = mbuttons->get_x() + mbuttons->get_w(), y1 = mbuttons->get_y()+yS(2);
        add_subwindow(proxy_toggle = new ProxyToggle(mwindow, mbuttons, x1, y1));
-       x1 += proxy_toggle->get_w() + 3;
+       x1 += proxy_toggle->get_w() + xS(3);
        add_subwindow(ffmpeg_toggle = new FFMpegToggle(mwindow, mbuttons, x1, y1));
 
        pane[TOP_LEFT_PANE] = new TimelinePane(mwindow,
@@ -294,26 +192,6 @@ void MWindowGUI::create_objects()
                mwindow->theme->mcanvas_h);
        pane[TOP_LEFT_PANE]->create_objects();
 
-//     add_subwindow(timebar = new MTimeBar(mwindow,
-//             this,
-//             mwindow->theme->mtimebar_x,
-//             mwindow->theme->mtimebar_y,
-//             mwindow->theme->mtimebar_w,
-//             mwindow->theme->mtimebar_h));
-//     timebar->create_objects();
-
-//     if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
-//     add_subwindow(patchbay = new PatchBay(mwindow, this));
-//     patchbay->create_objects();
-
-//     if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
-//     get_scrollbars(0);
-
-//     if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
-//     mwindow->gui->add_subwindow(canvas = new TrackCanvas(mwindow, this));
-//     canvas->create_objects();
-
-
        if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
        add_subwindow(zoombar = new ZoomBar(mwindow, this));
        zoombar->create_objects();
@@ -411,15 +289,15 @@ int MWindowGUI::resize_event(int w, int h)
 //printf("MWindowGUI::resize_event %d\n", __LINE__);
        mwindow->session->mwindow_w = w;
        mwindow->session->mwindow_h = h;
-       int x = w - MainShBtns::calculate_w(0);
+       int x = w - MainShBtns::calculate_w(-1, 0, -1);
        mainmenu->resize_event(x, mainmenu->get_h());
        mainshbtns->reposition_window(x, -1);
        mwindow->theme->get_mwindow_sizes(this, w, h);
        mwindow->theme->draw_mwindow_bg(this);
        mbuttons->resize_event();
-       int x1 = mbuttons->get_x() + mbuttons->get_w(), y1 = mbuttons->get_y()+2;
+       int x1 = mbuttons->get_x() + mbuttons->get_w(), y1 = mbuttons->get_y()+yS(2);
        proxy_toggle->reposition_window(x1, y1);
-       x1 += proxy_toggle->get_w() + 3;
+       x1 += proxy_toggle->get_w() + xS(3);
        ffmpeg_toggle->reposition_window(x1, y1);
        statusbar->resize_event();
        zoombar->resize_event();
@@ -932,9 +810,9 @@ int MWindowGUI::visible(int64_t x1, int64_t x2, int64_t view_x1, int64_t view_x2
 }
 
 
-void MWindowGUI::show_message(const char *message, int color)
+void MWindowGUI::show_message(const char *message, int msg_color, int bar_color)
 {
-       statusbar->show_message(message, color);
+       statusbar->show_message(message, msg_color, bar_color);
 }
 
 void MWindowGUI::update_default_message()
@@ -1010,10 +888,9 @@ int MWindowGUI::drag_motion()
            mwindow->session->current_operation == DRAG_EDIT ||
            mwindow->session->current_operation == DRAG_GROUP ||
            mwindow->session->current_operation == DRAG_AEFFECT_COPY ||
-           mwindow->session->current_operation == DRAG_VEFFECT_COPY )
-        {
-                redraw = 1;
-        }
+           mwindow->session->current_operation == DRAG_VEFFECT_COPY ) {
+               redraw = 1;
+       }
 
 
 // printf("drag_motion %d %d over_track=%p over_edit=%p\n",
@@ -1235,6 +1112,7 @@ int MWindowGUI::keypress_event()
                break;
        case 'M':
                collapse = 1;
+       case BACKSPACE:
        case 'm':
                mwindow->cut_selected_edits(0, collapse);
                result = 1;
@@ -2413,7 +2291,7 @@ int FFMpegToggle::handle_event()
        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->update_preferences(mwindow->preferences);
        mwindow->show_warning(&mwindow->preferences->warn_indexes,
                _("Changing the base codecs may require rebuilding indexes."));
        return 1;