mask tweaks, focus follows centroid, gradient/colorpicker rework, no hard edges in...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / mwindow.C
index 979d7e87e88a823b5f212e059772df3fbc71e475..0661591a4c82374f6e985e6b5f004058109220af 100644 (file)
@@ -80,6 +80,7 @@
 #include "mainsession.h"
 #include "mainundo.h"
 #include "mbuttons.h"
+#include "mixersalign.h"
 #include "mutex.h"
 #include "mwindowgui.h"
 #include "mwindow.h"
@@ -240,6 +241,7 @@ MWindow::MWindow()
        speed_edl = 0;
        proxy_beep = 0;
        shuttle = 0;
+       mixers_align = 0;
 }
 
 
@@ -264,6 +266,7 @@ MWindow::~MWindow()
        delete shuttle;         shuttle = 0;
        delete batch_render;    batch_render = 0;
        delete render;          render = 0;
+       delete mixers_align;    mixers_align = 0;
        commit_commercial();
        if( commercials && !commercials->remove_user() ) commercials = 0;
        close_mixers();
@@ -358,7 +361,6 @@ MWindow::~MWindow()
        colormodels.remove_all_objects();
        interlace_project_modes.remove_all_objects();
        interlace_asset_modes.remove_all_objects();
-       interlace_asset_fixmethods.remove_all_objects();
        sighandler->terminate();
        delete sighandler;
        delete run_lock;
@@ -936,14 +938,7 @@ void MWindow::init_preferences()
 {
        preferences = new Preferences;
        preferences->load_defaults(defaults);
-       const char *lv2_path = getenv("LV2_PATH");
-       if( lv2_path && strcmp(lv2_path, preferences->lv2_path) ) {
-               strncpy(preferences->lv2_path, lv2_path, sizeof(preferences->lv2_path));
-               remove_plugin_index();
-       }
-       else if( !lv2_path && preferences->lv2_path[0] ) {
-               File::setenv_path("LV2_PATH",preferences->lv2_path, 0);
-       }
+       File::setenv_path("LV2_PATH",preferences->lv2_path, 1);
        session = new MainSession(this);
        session->load_defaults(defaults);
        // set x11_host, screens, window_config
@@ -1186,8 +1181,12 @@ ZWindow *MWindow::get_mixer(Mixer *&mixer)
        zwindows_lock->lock("MWindow::get_mixer");
        if( !mixer ) mixer = edl->mixers.new_mixer();
        ZWindow *zwindow = 0;
-       for( int i=0; !zwindow && i<zwindows.size(); ++i )
-               if( zwindows[i]->idx < 0 ) zwindow = zwindows[i];
+       for( int i=0; !zwindow && i<zwindows.size(); ++i ) {
+               ZWindow *zwdw = zwindows[i];
+               if( zwdw->running() ) continue;
+               if( zwdw->idx >= 0 ) continue;
+               zwindow = zwindows[i];
+       }
        if( !zwindow )
                zwindows.append(zwindow = new ZWindow(this));
        zwindow->idx = mixer->idx;
@@ -1317,6 +1316,7 @@ void MWindow::close_mixers(int destroy)
        for( int i=zwindows.size(); --i>=0; ) {
                ZWindow *zwindow = zwindows[i];
                if( zwindow->idx < 0 ) continue;
+               zwindow->idx = -1;
                zwindow->destroy = destroy;
                ZWindowGUI *zgui = zwindow->zgui;
                zgui->lock_window("MWindow::select_zwindow 0");
@@ -1331,12 +1331,12 @@ void MWindow::close_mixers(int destroy)
        }
 }
 
-ZWindow *MWindow::create_mixer(Indexable *indexable)
+ZWindow *MWindow::create_mixer(Indexable *indexable, double position)
 {
        ArrayList<Indexable*> new_assets;
        new_assets.append(indexable);
        Track *track = edl->tracks->last;
-       load_assets(&new_assets, 0, LOADMODE_NEW_TRACKS, 0, 0, 0, 0, 0, 0);
+       load_assets(&new_assets, position, LOADMODE_NEW_TRACKS, 0, 0, 0, 0, 0, 1);
        track = !track ? edl->tracks->first : track->next;
        Mixer *mixer = 0;
        ZWindow *zwindow = get_mixer(mixer);
@@ -1361,7 +1361,7 @@ ZWindow *MWindow::create_mixer(Indexable *indexable)
        return zwindow;
 }
 
-void MWindow::create_mixers()
+void MWindow::create_mixers(double position)
 {
        if( !session->drag_assets->size() &&
            !session->drag_clips->size() ) return;
@@ -1373,13 +1373,13 @@ void MWindow::create_mixers()
        for( int i=0; i<session->drag_assets->size(); ++i ) {
                Indexable *indexable = session->drag_assets->get(i);
                if( !indexable->have_video() ) continue;
-               ZWindow *zwindow = create_mixer(indexable);
+               ZWindow *zwindow = create_mixer(indexable, position);
                new_mixers.append(zwindow);
        }
        for( int i=0; i<session->drag_clips->size(); ++i ) {
                Indexable *indexable = (Indexable*)session->drag_clips->get(i);
                if( !indexable->have_video() ) continue;
-               ZWindow *zwindow = create_mixer(indexable);
+               ZWindow *zwindow = create_mixer(indexable, position);
                new_mixers.append(zwindow);
        }
 
@@ -1530,9 +1530,6 @@ void MWindow::init_menus()
 #define ILACEASSETMODELISTADD(x) ilacemode_to_text(string, x); \
                            interlace_asset_modes.append(new InterlacemodeItem(string, x));
 
-#define ILACEFIXMETHODLISTADD(x) ilacefixmethod_to_text(string, x); \
-                           interlace_asset_fixmethods.append(new InterlacefixmethodItem(string, x));
-
        // Interlacing Modes
        ILACEASSETMODELISTADD(ILACE_MODE_UNDETECTED); // Not included in the list for the project options.
 
@@ -1545,10 +1542,7 @@ void MWindow::init_menus()
        ILACEASSETMODELISTADD(ILACE_MODE_NOTINTERLACED);
        ILACEPROJECTMODELISTADD(ILACE_MODE_NOTINTERLACED);
 
-       // Interlacing Fixing Methods
-       ILACEFIXMETHODLISTADD(ILACE_FIXMETHOD_NONE);
-       ILACEFIXMETHODLISTADD(ILACE_FIXMETHOD_UPONE);
-       ILACEFIXMETHODLISTADD(ILACE_FIXMETHOD_DOWNONE);
+       mixers_align = new MixersAlign(this);
 }
 
 void MWindow::init_indexes()
@@ -2196,6 +2190,8 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
                edl->local_session->loop_playback = 0;
                edl->local_session->set_selectionstart(0);
                edl->local_session->set_selectionend(0);
+               edl->local_session->unset_inpoint();
+               edl->local_session-> unset_outpoint();
                set_brender_active(0, 0);
                fit_selection();
                goto_start();
@@ -2713,7 +2709,9 @@ void MWindow::create_objects(int want_gui,
        gui->show_window();
        gui->raise_window();
        gui->unlock_window();
-
+       cwindow->gui->lock_window("MWindow::create_objects 1");
+       cwindow->gui->tool_panel->raise_tool();
+       cwindow->gui->unlock_window();
        if(debug) PRINT_TRACE
 
        if(preferences->use_tipwindow)
@@ -2732,6 +2730,12 @@ void MWindow::create_objects(int want_gui,
        BC_WindowBase::get_resources()->vframe_shm = 1;
 }
 
+int MWindow::uses_opengl()
+{
+       if( !playback_3d || !playback_3d->running() ) return 0;
+       PlaybackConfig *playback_config = edl->session->playback_config;
+       return playback_config->vconfig->driver == PLAYBACK_X11_GL ? 1 : 0;
+}
 
 void MWindow::show_splash()
 {
@@ -2920,25 +2924,30 @@ void MWindow::restore_windows()
        gui->focus();
 }
 
-void MWindow::save_layout(int no)
-{
-       char layout_path[BCTEXTLEN];
-       snprintf(layout_path, sizeof(layout_path), "%s/" LAYOUT_FILE,
-               File::get_config_path(), no);
-       session->save_file(layout_path);
-}
-
-void MWindow::load_layout(int no)
+void MWindow::load_layout(const char *layout)
 {
-       char layout_path[BCTEXTLEN];
-       snprintf(layout_path, sizeof(layout_path), "%s/" LAYOUT_FILE,
-               File::get_config_path(), no);
-       session->load_file(layout_path);
+       char path[BCTEXTLEN];
+       snprintf(path, sizeof(path), "%s/%s", File::get_config_path(), layout);
+       session->load_file(path);
        restore_windows();
        gui->default_positions();
        save_defaults();
 }
 
+void MWindow::save_layout(const char *layout)
+{
+       char path[BCTEXTLEN];
+       snprintf(path, sizeof(path), "%s/%s", File::get_config_path(), layout);
+       session->save_file(path);
+}
+
+void MWindow::delete_layout(const char *layout)
+{
+       char path[BCTEXTLEN];
+       snprintf(path, sizeof(path), "%s/%s", File::get_config_path(), layout);
+       unlink(path);
+}
+
 int MWindow::tile_windows(int window_config)
 {
        int need_reload = 0;
@@ -3586,6 +3595,7 @@ if(debug) printf("MWindow::asset_to_edl %d\n", __LINE__);
 //printf("MWindow::asset_to_edl 4 %s\n", string);
 if(debug) printf("MWindow::asset_to_edl %d\n", __LINE__);
 
+       new_edl->local_session->asset2edl = 1;
        return 0;
 }
 
@@ -3613,9 +3623,7 @@ void MWindow::update_project(int load_mode)
        gui->unlock_window();
        init_brender();
 
-       cwindow->gui->lock_window("MWindow::update_project 1");
        cwindow->update(0, 0, 1, 1, 1);
-       cwindow->gui->unlock_window();
 
        if(debug) PRINT_TRACE
 
@@ -3658,6 +3666,9 @@ void MWindow::update_project(int load_mode)
        if(debug) PRINT_TRACE
        cwindow->gui->lock_window("MWindow::update_project 2");
        cwindow->gui->timebar->update(0);
+       Track *track = cwindow->calculate_affected_track();
+       cwindow->mask_track_id = track ? track->get_id() : -1;
+       cwindow->gui->tool_panel->raise_tool();
        cwindow->gui->unlock_window();
 
        if(debug) PRINT_TRACE