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=726bd00f57b254b40cb964a393395ea0bb7a25c3;hb=0e16112661802284c0d2c9eb8d1df84141125e91;hpb=9fed7535470aa37781733db836068da3b4c17a0d diff --git a/cinelerra-5.1/cinelerra/pluginclient.C b/cinelerra-5.1/cinelerra/pluginclient.C index 726bd00f..da9a6977 100644 --- a/cinelerra-5.1/cinelerra/pluginclient.C +++ b/cinelerra-5.1/cinelerra/pluginclient.C @@ -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; +} +