3 * Copyright (C) 1997-2011 Adam Williams <broadcast at earthling dot net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "interpolatevideo.h"
24 #include "interpolatewindow.h"
35 InterpolateVideoWindow::InterpolateVideoWindow(InterpolateVideo *plugin)
36 : PluginClientWindow(plugin,
43 this->plugin = plugin;
46 InterpolateVideoWindow::~InterpolateVideoWindow()
50 void InterpolateVideoWindow::create_objects()
52 int xs5 = xS(5), xs10 = xS(10);
54 int x = xs10, y = ys10;
59 add_subwindow(title = new BC_Title(x, y, _("Input frames per second:")));
60 y += title->get_h() + plugin->get_theme()->widget_border;
61 add_subwindow(rate = new InterpolateVideoRate(plugin,
65 add_subwindow(rate_menu = new InterpolateVideoRateMenu(plugin,
67 x + rate->get_w() + xs5,
69 y += rate->get_h() + plugin->get_theme()->widget_border;
70 add_subwindow(keyframes = new InterpolateVideoKeyframes(plugin,
74 y += keyframes->get_h() + plugin->get_theme()->widget_border;
75 add_subwindow(flow = new InterpolateVideoFlow(plugin,
80 y += flow->get_h() + plugin->get_theme()->widget_border;
81 add_subwindow(vectors = new InterpolateVideoVectors(plugin,
86 y += vectors->get_h() + plugin->get_theme()->widget_border;
87 add_subwindow(radius_title = new BC_Title(x, y, _("Search radius:")));
88 add_subwindow(radius = new InterpolateVideoRadius(plugin,
90 x + radius_title->get_w() + plugin->get_theme()->widget_border,
93 y += radius->get_h() + plugin->get_theme()->widget_border;
94 add_subwindow(size_title = new BC_Title(x, y, _("Macroblock size:")));
95 add_subwindow(size = new InterpolateVideoSize(plugin,
97 x + size_title->get_w() + plugin->get_theme()->widget_border,
105 void InterpolateVideoWindow::update_enabled()
107 if(plugin->config.use_keyframes)
116 if(plugin->config.optic_flow)
121 radius_title->set_color(get_resources()->default_text_color);
122 size_title->set_color(get_resources()->default_text_color);
129 radius_title->set_color(get_resources()->disabled_text_color);
130 size_title->set_color(get_resources()->disabled_text_color);
146 InterpolateVideoRate::InterpolateVideoRate(InterpolateVideo *plugin,
147 InterpolateVideoWindow *gui,
154 (float)plugin->config.input_rate)
156 this->plugin = plugin;
160 int InterpolateVideoRate::handle_event()
162 plugin->config.input_rate = Units::atoframerate(get_text());
163 plugin->send_configure_change();
170 InterpolateVideoRateMenu::InterpolateVideoRateMenu(InterpolateVideo *plugin,
171 InterpolateVideoWindow *gui,
179 &plugin->get_theme()->frame_rates,
186 this->plugin = plugin;
190 int InterpolateVideoRateMenu::handle_event()
192 char *text = get_selection(0, 0)->get_text();
193 plugin->config.input_rate = atof(text);
194 gui->rate->update(text);
195 plugin->send_configure_change();
202 InterpolateVideoKeyframes::InterpolateVideoKeyframes(InterpolateVideo *plugin,
203 InterpolateVideoWindow *gui,
208 plugin->config.use_keyframes,
209 _("Use keyframes as input"))
211 this->plugin = plugin;
214 int InterpolateVideoKeyframes::handle_event()
216 plugin->config.use_keyframes = get_value();
217 gui->update_enabled();
218 plugin->send_configure_change();
225 InterpolateVideoFlow::InterpolateVideoFlow(InterpolateVideo *plugin,
226 InterpolateVideoWindow *gui,
231 plugin->config.optic_flow,
234 this->plugin = plugin;
237 int InterpolateVideoFlow::handle_event()
239 plugin->config.optic_flow = get_value();
240 gui->update_enabled();
241 plugin->send_configure_change();
247 InterpolateVideoVectors::InterpolateVideoVectors(InterpolateVideo *plugin,
248 InterpolateVideoWindow *gui,
253 plugin->config.draw_vectors,
254 _("Draw motion vectors"))
256 this->plugin = plugin;
259 int InterpolateVideoVectors::handle_event()
261 plugin->config.draw_vectors = get_value();
262 plugin->send_configure_change();
271 InterpolateVideoRadius::InterpolateVideoRadius(InterpolateVideo *plugin,
272 InterpolateVideoWindow *gui,
277 plugin->config.search_radius,
281 this->plugin = plugin;
284 int InterpolateVideoRadius::handle_event()
286 plugin->config.search_radius = get_value();
287 plugin->send_configure_change();
299 InterpolateVideoSize::InterpolateVideoSize(InterpolateVideo *plugin,
300 InterpolateVideoWindow *gui,
305 plugin->config.macroblock_size,
309 this->plugin = plugin;
312 int InterpolateVideoSize::handle_event()
314 plugin->config.macroblock_size = get_value();
315 plugin->send_configure_change();