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;
}
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;
+}
+
const char *PluginClient::get_source_path()
{
+ if( server->plugin ) 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;
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;
}
}
-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();
}
+