add BC_SCALE env var for hi def monitors, cleanup theme data
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / mwindowgui.C
index d121f29eb222ffba4ad67532455e2aa12bf1fa9b..477d256c927b458d021ca7441a5f87abab2d49d8 100644 (file)
@@ -36,6 +36,7 @@
 #include "edl.h"
 #include "edlsession.h"
 #include "filesystem.h"
+#include "filexml.h"
 #include "keyframepopup.h"
 #include "keys.h"
 #include "language.h"
@@ -65,6 +66,7 @@
 #include "swindow.h"
 #include "theme.h"
 #include "trackcanvas.h"
+#include "trackpopup.h"
 #include "trackscroll.h"
 #include "tracks.h"
 #include "transitionpopup.h"
 // 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;
@@ -116,12 +112,13 @@ MWindowGUI::MWindowGUI(MWindow *mwindow)
        statusbar = 0;
        zoombar = 0;
        mainclock = 0;
+       track_menu = 0;
        edit_menu = 0;
        plugin_menu = 0;
        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;
@@ -267,7 +264,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));
@@ -278,9 +275,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,
@@ -336,6 +333,9 @@ void MWindowGUI::create_objects()
 //     cursor->create_objects();
 
 
+       if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
+       add_subwindow(track_menu = new TrackPopup(mwindow, this));
+       track_menu->create_objects();
        if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
        add_subwindow(edit_menu = new EditPopup(mwindow, this));
        edit_menu->create_objects();
@@ -405,15 +405,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();
@@ -926,9 +926,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()
@@ -1002,11 +1002,11 @@ int MWindowGUI::drag_motion()
 
        if( mwindow->session->current_operation == DRAG_ASSET ||
            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",
@@ -1165,9 +1165,17 @@ int MWindowGUI::keypress_event()
        int result = mbuttons->keypress_event();
        if( result ) return result;
 
-       Track *this_track = 0;
+       Track *this_track = 0, *first_track = 0;
+       int collapse = 0, packed = 0, overwrite = 0, plugins = 0;
+       double position = 0;
 
-       switch(get_keypress()) {
+       switch( get_keypress() ) {
+       case 'A':
+               if( !ctrl_down() || !shift_down() || alt_down() ) break;
+               mwindow->edl->tracks->clear_selected_edits();
+               draw_overlays(1);
+               result = 1;
+               break;
        case 'e':
                mwindow->toggle_editing_mode();
                result = 1;
@@ -1181,8 +1189,59 @@ int MWindowGUI::keypress_event()
                result = 1;
                break;
 
-       case '1': case '2': case '3': case '4':
-       case '5': case '6': case '7': case '8':
+       case 'C':
+               packed = 1;
+       case 'c':
+               if( !ctrl_down() || alt_down() ) break;
+               mwindow->selected_edits_to_clipboard(packed);
+               result = 1;
+               break;
+       case 'P':
+               plugins = 1;
+       case 'b':
+               overwrite = -1; // fall thru
+       case 'v':
+               if( !ctrl_down() || alt_down() ) break;
+               if( mwindow->session->current_operation == DROP_TARGETING ) {
+                       mwindow->session->current_operation = NO_OPERATION;
+                       mwindow->gui->set_editing_mode(1);
+                       int pane_no = 0;
+                       for( ; pane_no<TOTAL_PANES; ++pane_no  ) {
+                               if( !pane[pane_no] ) continue;
+                               first_track = pane[pane_no]->over_track();
+                               if( first_track ) break;
+                       }
+                       if( first_track ) {
+                               int cursor_x = pane[pane_no]->canvas->get_relative_cursor_x();
+                               position = mwindow->edl->get_cursor_position(cursor_x, pane_no);
+                       }
+               }
+               else
+                       position = mwindow->edl->local_session->get_selectionstart();
+               if( !plugins )
+                       mwindow->paste(position, first_track, 0, overwrite);
+               else
+                       mwindow->paste_clipboard(first_track, position, 1, 0, 1, 1, 1);
+               mwindow->edl->tracks->clear_selected_edits();
+               draw_overlays(1);
+               result = 1;
+               break;
+       case 'M':
+               collapse = 1;
+       case BACKSPACE:
+       case 'm':
+               mwindow->cut_selected_edits(0, collapse);
+               result = 1;
+               break;
+       case 'z':
+               collapse = 1;
+       case 'x':
+               if( !ctrl_down() || alt_down() ) break;
+               mwindow->cut_selected_edits(1, collapse);
+               result = 1;
+               break;
+
+       case '1' ... '8':
                if( !alt_down() || shift_down() ) break;
                if( !mwindow->select_asset(get_keypress()-'1',1) )
                        result = 1;
@@ -1296,18 +1355,7 @@ int MWindowGUI::keypress_event()
                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:
+       case KEY_F1 ... KEY_F12:
                resend_event(mwindow->cwindow->gui);
                return 1;
        }
@@ -2294,7 +2342,7 @@ 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);
+               mbuttons->transport->handle_transport(STOP, 1);
                if( lock_msg ) lock_window(lock_msg);
        }
 }