add binfolder path relative filters, fix gbrp color model, vwdw timebar tweaks, title...
[goodguy/history.git] / cinelerra-5.1 / cinelerra / pluginclient.C
index 2f5d0e377f93b3873c7657161a2070ef47942906..4cab34b513f80b208a14d1a95d848fb430a9ab3a 100644 (file)
 #include "bcsignals.h"
 #include "clip.h"
 #include "condition.h"
+#include "edits.h"
+#include "edit.h"
 #include "edl.h"
 #include "edlsession.h"
 #include "file.h"
 #include "filesystem.h"
+#include "indexable.h"
 #include "language.h"
 #include "localsession.h"
 #include "mainundo.h"
 #include "mwindow.h"
+#include "plugin.h"
 #include "pluginclient.h"
 #include "pluginserver.h"
 #include "preferences.h"
+#include "track.h"
 #include "transportque.inc"
 
 
@@ -70,7 +75,7 @@ void PluginClientThread::run()
        if(client->window_x < 0) client->window_x = info.get_abs_cursor_x();
        if(client->window_y < 0) client->window_y = info.get_abs_cursor_y();
        if(!window)
-               window = client->new_window();
+               window = (PluginClientWindow*)client->new_window();
 
        if(window) {
                window->lock_window("PluginClientThread::run");
@@ -86,6 +91,7 @@ void PluginClientThread::run()
 //printf("PluginClientThread::run %p %d\n", this, __LINE__);
                window->hide_window(1);
                window->unlock_window();
+               window->done_event(result);
 // Can't save defaults in the destructor because it's not called immediately
 // after closing.
                /* if(client->defaults) */ client->save_defaults_xml();
@@ -135,22 +141,23 @@ PluginClientFrame::~PluginClientFrame()
 
 
 PluginClientWindow::PluginClientWindow(PluginClient *client,
-       int w,
-       int h,
-       int min_w,
-       int min_h,
-       int allow_resize)
+       int w, int h, int min_w, int min_h, int allow_resize)
  : BC_Window(client->gui_string,
        client->window_x /* - w / 2 */,
        client->window_y /* - h / 2 */,
-       w, h, min_w, min_h, allow_resize, 0, 1)
+       (int)(w*get_resources()->font_scale+0.5), (int)(h*get_resources()->font_scale+0.5),
+       (int)(min_w*get_resources()->font_scale+0.5), (int)(min_h*get_resources()->font_scale+0.5),
+       allow_resize, 0, 1)
 {
        this->client = client;
 }
 
 PluginClientWindow::PluginClientWindow(const char *title,
        int x, int y, int w, int h, int min_w, int min_h, int allow_resize)
- : BC_Window(title, x, y, w, h, min_w, min_h, allow_resize, 0, 1)
+ : BC_Window(title, x, y,
+        (int)(w*get_resources()->font_scale+0.5), (int)(h*get_resources()->font_scale+0.5),
+        (int)(min_w*get_resources()->font_scale+0.5), (int)(min_h*get_resources()->font_scale+0.5),
+       allow_resize, 0, 1)
 {
        this->client = 0;
 }
@@ -331,14 +338,8 @@ int PluginClient::show_gui()
        thread->start();
        thread->init_complete->lock("PluginClient::show_gui");
 // Must wait before sending any hide_gui
-       if(thread->window)
-       {
-               thread->window->init_wait();
-       }
-       else
-       {
-               return 1;
-       }
+       if( !thread->window ) return 1;
+       thread->window->init_wait();
        return 0;
 }
 
@@ -683,6 +684,14 @@ double PluginClient::get_project_framerate()
        return server->get_project_framerate();
 }
 
+const char *PluginClient::get_source_path()
+{
+       int64_t source_position = server->plugin->startproject;
+       Edit *edit = server->plugin->track->edits->editof(source_position,PLAY_FORWARD,0);
+       Indexable *indexable = edit ? edit->get_source() : 0;
+       return indexable ? indexable->path : 0;
+}
+
 
 void PluginClient::update_display_title()
 {
@@ -722,39 +731,29 @@ int PluginClient::get_interpolation_type()
 
 float PluginClient::get_red()
 {
-       if(server->mwindow)
-               return server->mwindow->edl->local_session->red;
-       else
-       if(server->edl)
-               return server->edl->local_session->red;
-       else
-               return 0;
+       EDL *edl = server->mwindow ? server->mwindow->edl : server->edl;
+       return !edl ? 0 : edl->local_session->use_max ?
+               edl->local_session->red_max :
+               edl->local_session->red;
 }
 
 float PluginClient::get_green()
 {
-       if(server->mwindow)
-               return server->mwindow->edl->local_session->green;
-       else
-       if(server->edl)
-               return server->edl->local_session->green;
-       else
-               return 0;
+       EDL *edl = server->mwindow ? server->mwindow->edl : server->edl;
+       return !edl ? 0 : edl->local_session->use_max ?
+               edl->local_session->green_max :
+               edl->local_session->green;
 }
 
 float PluginClient::get_blue()
 {
-       if(server->mwindow)
-               return server->mwindow->edl->local_session->blue;
-       else
-       if(server->edl)
-               return server->edl->local_session->blue;
-       else
-               return 0;
+       EDL *edl = server->mwindow ? server->mwindow->edl : server->edl;
+       return !edl ? 0 : edl->local_session->use_max ?
+               edl->local_session->blue_max :
+               edl->local_session->blue;
 }
 
 
-
 int64_t PluginClient::get_source_position()
 {
        return source_position;