X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fpluginclient.C;h=da9a697716a8be5b23c520055305ebdc83d2bfe4;hp=606f83d95af6ce007aa7d685d5a6fbb730761af3;hb=0e16112661802284c0d2c9eb8d1df84141125e91;hpb=7fd85fb66168f6b518c5f2d73e04036e87faa0e1 diff --git a/cinelerra-5.1/cinelerra/pluginclient.C b/cinelerra-5.1/cinelerra/pluginclient.C index 606f83d9..da9a6977 100644 --- a/cinelerra-5.1/cinelerra/pluginclient.C +++ b/cinelerra-5.1/cinelerra/pluginclient.C @@ -43,13 +43,13 @@ #include "track.h" #include "transportque.inc" - +#include +#include +#include +#include +#include #include #include -#include - - - PluginClientThread::PluginClientThread(PluginClient *client) @@ -146,21 +146,15 @@ PluginClientFrame::~PluginClientFrame() PluginClientWindow::PluginClientWindow(PluginClient *client, 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 */, - (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) + client->window_x /* - w / 2 */, client->window_y /* - h / 2 */, + w, h, min_w, min_h, 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, - (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) + : BC_Window(title, x, y, w, h, min_w, min_h, allow_resize, 0, 1) { this->client = 0; } @@ -188,6 +182,244 @@ int PluginClientWindow::close_event() return 1; } +void PluginClientWindow::param_updated() +{ + printf("PluginClientWindow::param_updated %d undefined\n", __LINE__); +} + +//phyllis +PluginParam::PluginParam(PluginClient *plugin, PluginClientWindow *gui, + int x1, int x2, int x3, int y, int text_w, + int *output_i, float *output_f, int *output_q, + const char *title, float min, float max) +{ + this->output_i = output_i; + this->output_f = output_f; + this->output_q = output_q; + this->title = cstrdup(title); + this->plugin = plugin; + this->gui = gui; + this->x1 = x1; + this->x2 = x2; + this->x3 = x3; + this->text_w = text_w; + this->y = y; + this->min = min; + this->max = max; + fpot = 0; + ipot = 0; + qpot = 0; + text = 0; + precision = 2; +} +PluginParam::~PluginParam() +{ + delete fpot; + delete ipot; + delete qpot; + delete text; + delete title; +} + + +void PluginParam::initialize() +{ + BC_Title *title_; + int y2 = y + + (BC_Pot::calculate_h() - + BC_Title::calculate_h(gui, _(title), MEDIUMFONT)) / 2; + gui->add_tool(title_ = new BC_Title(x1, y2, _(title))); + + if(output_f) + { + gui->add_tool(fpot = new PluginFPot(this, x2, y)); + } + + if(output_i) + { + gui->add_tool(ipot = new PluginIPot(this, x2, y)); + } + + if(output_q) + { + gui->add_tool(qpot = new PluginQPot(this, x2, y)); + } + + int y3 = y + + (BC_Pot::calculate_h() - + BC_TextBox::calculate_h(gui, MEDIUMFONT, 1, 1)) / 2; + if(output_i) + { + gui->add_tool(text = new PluginText(this, x3, y3, *output_i)); + } + if(output_f) + { + gui->add_tool(text = new PluginText(this, x3, y3, *output_f)); + } + if(output_q) + { + gui->add_tool(text = new PluginText(this, x3, y3, *output_q)); + } + + set_precision(precision); +} + +void PluginParam::update(int skip_text, int skip_pot) +{ + if(!skip_text) + { + if(output_i) + { + text->update((int64_t)*output_i); + } + if(output_q) + { + text->update((int64_t)*output_q); + } + if(output_f) + { + text->update((float)*output_f); + } + } + + if(!skip_pot) + { + if(ipot) + { + ipot->update((int64_t)*output_i); + } + if(qpot) + { + qpot->update((int64_t)*output_q); + } + if(fpot) + { + fpot->update((float)*output_f); + } + } +} + +void PluginParam::set_precision(int digits) +{ + this->precision = digits; + if(fpot) + { + if(text) + { + text->set_precision(digits); + } + + fpot->set_precision(1.0f / pow(10, digits)); + } +} + + +PluginFPot::PluginFPot(PluginParam *param, int x, int y) + : BC_FPot(x, + y, + *param->output_f, + param->min, + param->max) +{ + this->param = param; + set_use_caption(0); +} + +int PluginFPot::handle_event() +{ + *param->output_f = get_value(); + param->update(0, 1); + param->plugin->send_configure_change(); + param->gui->param_updated(); + return 1; +} + +PluginIPot::PluginIPot(PluginParam *param, int x, int y) + : BC_IPot(x, + y, + *param->output_i, + (int)param->min, + (int)param->max) +{ + this->param = param; + set_use_caption(0); +} + +int PluginIPot::handle_event() +{ + *param->output_i = get_value(); + param->update(0, 1); + param->plugin->send_configure_change(); + param->gui->param_updated(); + return 1; +} + + +PluginQPot::PluginQPot(PluginParam *param, int x, int y) + : BC_QPot(x, + y, + *param->output_q) +{ + this->param = param; + set_use_caption(0); +} + +int PluginQPot::handle_event() +{ + *param->output_q = get_value(); + param->update(0, 1); + param->plugin->send_configure_change(); + param->gui->param_updated(); + return 1; +} + +PluginText::PluginText(PluginParam *param, int x, int y, int value) + : BC_TextBox(x, + y, + param->text_w, + 1, + (int64_t)value, + 1, + MEDIUMFONT) +{ + this->param = param; +} + +PluginText::PluginText(PluginParam *param, int x, int y, float value) + : BC_TextBox(x, + y, + param->text_w, + 1, + (float)value, + 1, + MEDIUMFONT, + param->precision) +{ + this->param = param; +} + +int PluginText::handle_event() +{ + if(param->output_i) + { + *param->output_i = atoi(get_text()); + } + + if(param->output_f) + { + *param->output_f = atof(get_text()); + } + + if(param->output_q) + { + *param->output_q = atoi(get_text()); + } + param->update(1, 0); + param->plugin->send_configure_change(); + param->gui->param_updated(); + return 1; +} + @@ -551,38 +783,38 @@ void PluginClient::load_defaults_xml() using_defaults = 1; //printf("PluginClient::load_defaults_xml %d %s\n", __LINE__, path); - KeyFrame temp_keyframe; - FILE *fp = fopen(path, "r"); - if( fp ) { - struct stat st; int fd = fileno(fp); - int64_t sz = !fstat(fd, &st) ? st.st_size : BCTEXTLEN; - char *data = temp_keyframe.get_data(sz+1); - int data_size = fread(data, 1, sz, fp); - if( data_size < 0 ) data_size = 0; - if( data_size > 0 ) { - data[data_size] = 0; - temp_keyframe.xbuf->oseek(data_size); + char *data = 0; + int64_t len = -1; + struct stat st; + int fd = open(path, O_RDONLY); + if( fd >= 0 && !fstat(fd, &st) ) { + int64_t sz = st.st_size; + data = new char[sz+1]; + len = read(fd, data, sz); + close(fd); + } + if( data && len >= 0 ) { + data[len] = 0; // Get window extents - int i = 0; - for( int state=0; i<(data_size-8) && state>=0; ++i ) { - if( !data[i] || data[i] == '<' ) break; - if( !isdigit(data[i]) ) continue; - if( !state ) { - window_x = atoi(data + i); - state = 1; - } - else { - window_y = atoi(data + i); - state = -1; - } - while( i=0; ++i ) { + if( !data[i] || data[i] == '<' ) break; + if( !isdigit(data[i]) ) continue; + if( !state ) { + window_x = atoi(data+i); + state = 1; } - temp_keyframe.xbuf->iseek(i); - read_data(&temp_keyframe); + else { + window_y = atoi(data+i); + state = -1; + } + while( iplugin ) return 0; 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; @@ -733,24 +966,24 @@ int PluginClient::get_interpolation_type() float PluginClient::get_red() { - EDL *edl = server->mwindow ? server->mwindow->edl : server->edl; - return !edl ? 0 : edl->local_session->use_max ? + EDL *edl = get_edl(); + return edl->local_session->use_max ? edl->local_session->red_max : edl->local_session->red; } float PluginClient::get_green() { - EDL *edl = server->mwindow ? server->mwindow->edl : server->edl; - return !edl ? 0 : edl->local_session->use_max ? + EDL *edl = get_edl(); + return edl->local_session->use_max ? edl->local_session->green_max : edl->local_session->green; } float PluginClient::get_blue() { - EDL *edl = server->mwindow ? server->mwindow->edl : server->edl; - return !edl ? 0 : edl->local_session->use_max ? + EDL *edl = get_edl(); + return edl->local_session->use_max ? edl->local_session->blue_max : edl->local_session->blue; } @@ -864,14 +1097,44 @@ void PluginClient::get_projector(float *x, float *y, float *z, int64_t position) } -EDLSession* PluginClient::get_edlsession() +void PluginClient::output_to_track(float ox, float oy, float &tx, float &ty) { - if(server->edl) - return server->edl->session; - return 0; + float projector_x, projector_y, projector_z; + int64_t position = get_source_position(); + get_projector(&projector_x, &projector_y, &projector_z, position); + EDL *edl = get_edl(); + projector_x += edl->session->output_w / 2; + projector_y += edl->session->output_h / 2; + Track *track = server->plugin ? server->plugin->track : 0; + int track_w = track ? track->track_w : edl->session->output_w; + int track_h = track ? track->track_h : edl->session->output_h; + tx = (ox - projector_x) / projector_z + track_w / 2; + ty = (oy - projector_y) / projector_z + track_h / 2; +} + +void PluginClient::track_to_output(float tx, float ty, float &ox, float &oy) +{ + float projector_x, projector_y, projector_z; + int64_t position = get_source_position(); + get_projector(&projector_x, &projector_y, &projector_z, position); + EDL *edl = get_edl(); + projector_x += edl->session->output_w / 2; + projector_y += edl->session->output_h / 2; + Track *track = server->plugin ? server->plugin->track : 0; + int track_w = track ? track->track_w : edl->session->output_w; + int track_h = track ? track->track_h : edl->session->output_h; + ox = (tx - track_w / 2) * projector_z + projector_x; + oy = (ty - track_h / 2) * projector_z + projector_y; +} + + +EDL *PluginClient::get_edl() +{ + return server->mwindow ? server->mwindow->edl : server->edl; } int PluginClient::gui_open() { return server->gui_open(); } +