add 1:1 convert, add es.po: thx sergio, cwdw zoom tweak, add done beep pots, bd forma...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / mwindow.C
index 35bd21e4d44d534c857972aced98adc3399bca38..89d188debcece611b4a3d8a4a017e665aa97d324 100644 (file)
@@ -27,6 +27,7 @@
 #include "awindowgui.h"
 #include "awindow.h"
 #include "batchrender.h"
+#include "bccmodels.h"
 #include "bcdisplayinfo.h"
 #include "bcprogressbox.h"
 #include "bcsignals.h"
@@ -40,9 +41,9 @@
 #include "channelinfo.h"
 #include "clip.h"
 #include "clipedls.h"
-#include "bccmodels.h"
 #include "commercials.h"
 #include "confirmsave.h"
+#include "convert.h"
 #include "cplayback.h"
 #include "ctimebar.h"
 #include "cwindowgui.h"
@@ -225,6 +226,7 @@ MWindow::MWindow()
        create_bd = 0;
        create_dvd = 0;
        batch_render = 0;
+       convert_render = 0;
        render = 0;
        edl = 0;
        gui = 0;
@@ -265,6 +267,7 @@ MWindow::~MWindow()
        delete create_dvd;      create_dvd = 0;
        delete shuttle;         shuttle = 0;
        delete batch_render;    batch_render = 0;
+       delete convert_render;  convert_render = 0;
        delete render;          render = 0;
        delete mixers_align;    mixers_align = 0;
        commit_commercial();
@@ -1453,7 +1456,7 @@ void MWindow::tile_mixers()
        int bw = lt + BC_DisplayInfo::get_right_border();  // borders
        int bh = top + BC_DisplayInfo::get_bottom_border();
        int zx = 0, zy = 0;  // window origins
-       int mw = 10+10, mh = 10+10; // canvas margins
+       int mw = xS(10+10), mh = yS(10+10); // canvas margins
        int rsz = 0, n = 0, dz = 0;
        int ow = edl->session->output_w, oh = edl->session->output_h;
        for( int i=0; i<zwindows.size(); ++i ) {
@@ -1465,7 +1468,7 @@ void MWindow::tile_mixers()
                int mx = x2 - zw, my = y2 - zh;
                if( xx > mx ) xx = mx;
                if( yy > my ) yy = my;
-               xx += lt + dz;  yy += top + dz;
+               xx += lt + xS(dz);  yy += top + yS(dz);
                zwindow->reposition(xx,yy, ww,hh);
                if( zwindow->running() ) {
                        ZWindowGUI *gui = (ZWindowGUI *)zwindow->get_gui();
@@ -2275,9 +2278,8 @@ int MWindow::render_proxy(ArrayList<Indexable *> &new_idxbls)
        Asset *format_asset = new Asset;
        format_asset->format = FILE_FFMPEG;
        format_asset->load_defaults(defaults, "PROXY_", 1, 1, 0, 0, 0);
-       ProxyRender proxy_render(this, format_asset);
        int new_scale = edl->session->proxy_scale;
-       int use_scaler = edl->session->proxy_use_scaler;
+       ProxyRender proxy_render(this, format_asset, new_scale);
 
        for( int i=0; i<new_idxbls.size(); ++i ) {
                Indexable *orig = new_idxbls.get(i);
@@ -2294,8 +2296,7 @@ int MWindow::render_proxy(ArrayList<Indexable *> &new_idxbls)
 // render needed proxies
        int result = proxy_render.create_needed_proxies(new_scale);
        if( !result ) {
-               add_proxy(use_scaler,
-                       &proxy_render.orig_idxbls, &proxy_render.orig_proxies);
+               add_proxy(&proxy_render.orig_idxbls, &proxy_render.orig_proxies);
        }
        format_asset->remove_user();
        return !result ? proxy_render.needed_proxies.size() : -1;
@@ -2344,7 +2345,9 @@ int MWindow::to_proxy(Asset *asset, int new_scale, int new_use_scaler)
        edl->Garbage::add_user();
        save_backup();
        undo_before(_("proxy"), this);
-       ProxyRender proxy_render(this, asset);
+       int asset_scale = new_scale == 1 ? 0 :
+                       !new_use_scaler ? 1 : new_scale;
+       ProxyRender proxy_render(this, asset, asset_scale);
 
 // revert project to original size from current size
 // remove all session proxy assets at the at the current proxy_scale
@@ -2635,7 +2638,7 @@ void MWindow::create_objects(int want_gui,
 
        if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
 
-       plugin_guis = new ArrayList<PluginServer*>;
+       plugin_guis = new PluginGUIs(this);
        dead_plugins = new ArrayList<PluginServer*>;
        keyframe_threads = new ArrayList<KeyFrameThread*>;
 
@@ -3171,9 +3174,6 @@ void MWindow::show_keyframe_gui(Plugin *plugin)
 }
 
 
-
-
-
 void MWindow::show_plugin(Plugin *plugin)
 {
        int done = 0;
@@ -3223,6 +3223,8 @@ SET_TRACE
                }
        }
        plugin_gui_lock->unlock();
+// update show/gui_id
+       sync_parameters(CHANGE_PARAMS);
 //printf("MWindow::show_plugin %d\n", __LINE__);
 SET_TRACE
 //sleep(1);
@@ -3254,6 +3256,8 @@ void MWindow::hide_plugin(Plugin *plugin, int lock)
                }
        }
        if(lock) plugin_gui_lock->unlock();
+// update show/gui_id
+       sync_parameters(CHANGE_PARAMS);
 }
 
 void MWindow::delete_plugin(PluginServer *plugin)
@@ -3429,7 +3433,6 @@ void MWindow::update_plugin_guis(int do_keyframe_guis)
                                }
 
                                if(!got_it) plugin->show = 0;
-
                                plugin = (Plugin*)plugin->next;
                        }
                }
@@ -3445,45 +3448,34 @@ void MWindow::update_plugin_guis(int do_keyframe_guis)
 
 int MWindow::plugin_gui_open(Plugin *plugin)
 {
-       int result = 0;
+       int gui_id = plugin->gui_id;
+       if( gui_id < 0 ) return 0;
        plugin_gui_lock->lock("MWindow::plugin_gui_open");
-       for(int i = 0; i < plugin_guis->total; i++)
-       {
-               if(plugin_guis->get(i)->plugin->identical_location(plugin))
-               {
-                       result = 1;
-                       break;
-               }
-       }
+       PluginServer *plugin_server = plugin_guis->gui_server(gui_id);
+       int result = plugin_server ? 1 : 0;
        plugin_gui_lock->unlock();
        return result;
 }
 
 void MWindow::render_plugin_gui(void *data, Plugin *plugin)
 {
+       int gui_id = plugin->gui_id;
+       if( gui_id < 0 ) return;
        plugin_gui_lock->lock("MWindow::render_plugin_gui");
-       for(int i = 0; i < plugin_guis->total; i++)
-       {
-               if(plugin_guis->get(i)->plugin->identical_location(plugin))
-               {
-                       plugin_guis->get(i)->render_gui(data);
-                       break;
-               }
-       }
+       PluginServer *plugin_server = plugin_guis->gui_server(gui_id);
+       if( plugin_server )
+               plugin_server->render_gui(data);
        plugin_gui_lock->unlock();
 }
 
 void MWindow::render_plugin_gui(void *data, int size, Plugin *plugin)
 {
+       int gui_id = plugin->gui_id;
+       if( gui_id < 0 ) return;
        plugin_gui_lock->lock("MWindow::render_plugin_gui");
-       for(int i = 0; i < plugin_guis->total; i++)
-       {
-               if(plugin_guis->get(i)->plugin->identical_location(plugin))
-               {
-                       plugin_guis->get(i)->render_gui(data, size);
-                       break;
-               }
-       }
+       PluginServer *plugin_server = plugin_guis->gui_server(gui_id);
+       if( plugin_server )
+               plugin_server->render_gui(data, size);
        plugin_gui_lock->unlock();
 }
 
@@ -3671,6 +3663,7 @@ void MWindow::update_project(int load_mode)
                        zwindow->set_title(mixer->title);
                        zwindow->start();
                }
+               cwindow->gui->canvas->set_zoom(edl, 0);
        }
        update_vwindow();
 
@@ -3680,6 +3673,7 @@ void MWindow::update_project(int load_mode)
        Track *track = cwindow->calculate_affected_track();
        cwindow->mask_track_id = track ? track->get_id() : -1;
        cwindow->gui->tool_panel->raise_tool();
+       cwindow->gui->update_canvas(0);
        cwindow->gui->unlock_window();
 
        if(debug) PRINT_TRACE
@@ -4087,44 +4081,50 @@ void MWindow::remove_asset_from_caches(Asset *asset)
 }
 
 
-void MWindow::remove_assets_from_project(int push_undo, int redraw,
+void MWindow::remove_assets_from_project(int push_undo, int redraw, int delete_indexes,
                ArrayList<Indexable*> *drag_assets, ArrayList<EDL*> *drag_clips)
 {
        awindow->gui->close_view_popup();
 
-       for(int i = 0; i < drag_assets->total; i++) {
-               Indexable *indexable = drag_assets->get(i);
-               if(indexable->is_asset) remove_asset_from_caches((Asset*)indexable);
-       }
-
 // Remove from VWindow.
-       for(int i = 0; i < session->drag_clips->total; i++) {
-               for(int j = 0; j < vwindows.size(); j++) {
-                       VWindow *vwindow = vwindows[j];
-                       if( !vwindow->is_running() ) continue;
-                       if(session->drag_clips->get(i) == vwindow->get_edl()) {
-                               vwindow->gui->lock_window("MWindow::remove_assets_from_project 1");
-                               vwindow->delete_source(1, 1);
-                               vwindow->gui->unlock_window();
+       if( drag_clips ) {
+               for(int i = 0; i < drag_clips->total; i++) {
+                       for(int j = 0; j < vwindows.size(); j++) {
+                               VWindow *vwindow = vwindows[j];
+                               if( !vwindow->is_running() ) continue;
+                               if(drag_clips->get(i) == vwindow->get_edl()) {
+                                       vwindow->gui->lock_window("MWindow::remove_assets_from_project 1");
+                                       vwindow->delete_source(1, 1);
+                                       vwindow->gui->unlock_window();
+                               }
                        }
                }
        }
 
-       for(int i = 0; i < drag_assets->size(); i++) {
-               for(int j = 0; j < vwindows.size(); j++) {
-                       VWindow *vwindow = vwindows[j];
-                       if( !vwindow->is_running() ) continue;
-                       if(drag_assets->get(i) == vwindow->get_source()) {
-                               vwindow->gui->lock_window("MWindow::remove_assets_from_project 2");
-                               vwindow->delete_source(1, 1);
-                               vwindow->gui->unlock_window();
+       if( drag_assets ) {
+               for(int i = 0; i < drag_assets->size(); i++) {
+                       for(int j = 0; j < vwindows.size(); j++) {
+                               VWindow *vwindow = vwindows[j];
+                               if( !vwindow->is_running() ) continue;
+                               if(drag_assets->get(i) == vwindow->get_source()) {
+                                       vwindow->gui->lock_window("MWindow::remove_assets_from_project 2");
+                                       vwindow->delete_source(1, 1);
+                                       vwindow->gui->unlock_window();
+                               }
                        }
                }
-       }
 
-       for(int i = 0; i < drag_assets->size(); i++) {
-               Indexable *indexable = drag_assets->get(i);
-               remove_indexfile(indexable);
+               for(int i = 0; i < drag_assets->total; i++) {
+                       Indexable *indexable = drag_assets->get(i);
+                       if(indexable->is_asset) remove_asset_from_caches((Asset*)indexable);
+               }
+
+               if( delete_indexes ) {
+                       for(int i = 0; i < drag_assets->size(); i++) {
+                               Indexable *indexable = drag_assets->get(i);
+                               remove_indexfile(indexable);
+                       }
+               }
        }
 
 //printf("MWindow::rebuild_indices 1 %s\n", indexable->path);
@@ -4149,10 +4149,8 @@ void MWindow::remove_assets_from_project(int push_undo, int redraw,
 
 void MWindow::remove_assets_from_disk()
 {
-       remove_assets_from_project(1,
-               1,
-               session->drag_assets,
-               session->drag_clips);
+       remove_assets_from_project(1, 1, 1,
+               session->drag_assets, session->drag_clips);
 
 // Remove from disk
        for(int i = 0; i < session->drag_assets->total; i++)