1 #include "bcdisplayinfo.h"
5 #include "overlayframe.h"
15 #define _(String) gettext(String)
16 #define gettext_noop(String) String
17 #define N_(String) gettext_noop (String)
19 REGISTER_PLUGIN(SlideMain)
25 SlideLeft::SlideLeft(SlideMain *plugin,
31 plugin->motion_direction == 0,
34 this->plugin = plugin;
35 this->window = window;
38 int SlideLeft::handle_event()
41 plugin->motion_direction = 0;
42 window->right->update(0);
43 plugin->send_configure_change();
47 SlideRight::SlideRight(SlideMain *plugin,
53 plugin->motion_direction == 1,
56 this->plugin = plugin;
57 this->window = window;
60 int SlideRight::handle_event()
63 plugin->motion_direction = 1;
64 window->left->update(0);
65 plugin->send_configure_change();
69 SlideIn::SlideIn(SlideMain *plugin,
75 plugin->direction == 0,
78 this->plugin = plugin;
79 this->window = window;
82 int SlideIn::handle_event()
85 plugin->direction = 0;
86 window->out->update(0);
87 plugin->send_configure_change();
91 SlideOut::SlideOut(SlideMain *plugin,
97 plugin->direction == 1,
100 this->plugin = plugin;
101 this->window = window;
104 int SlideOut::handle_event()
107 plugin->direction = 1;
108 window->in->update(0);
109 plugin->send_configure_change();
120 SlideWindow::SlideWindow(SlideMain *plugin, int x, int y)
121 : BC_Window(plugin->gui_string,
132 this->plugin = plugin;
136 int SlideWindow::close_event()
142 void SlideWindow::create_objects()
145 add_subwindow(new BC_Title(x, y, _("Direction:")));
147 add_subwindow(left = new SlideLeft(plugin,
152 add_subwindow(right = new SlideRight(plugin,
159 add_subwindow(new BC_Title(x, y, _("Direction:")));
161 add_subwindow(in = new SlideIn(plugin,
166 add_subwindow(out = new SlideOut(plugin,
178 PLUGIN_THREAD_OBJECT(SlideMain, SlideThread, SlideWindow)
185 SlideMain::SlideMain(PluginServer *server)
186 : PluginVClient(server)
188 motion_direction = 0;
190 PLUGIN_CONSTRUCTOR_MACRO
193 SlideMain::~SlideMain()
195 PLUGIN_DESTRUCTOR_MACRO
198 char* SlideMain::plugin_title() { return _("Slide"); }
199 int SlideMain::is_video() { return 1; }
200 int SlideMain::is_transition() { return 1; }
201 int SlideMain::uses_gui() { return 1; }
202 SHOW_GUI_MACRO(SlideMain, SlideThread);
203 SET_STRING_MACRO(SlideMain)
204 RAISE_WINDOW_MACRO(SlideMain)
207 VFrame* SlideMain::new_picon()
209 return new VFrame(picon_png);
212 int SlideMain::load_defaults()
214 char directory[BCTEXTLEN];
215 // set the default directory
216 sprintf(directory, "%sslide.rc", BCASTDIR);
219 defaults = new Defaults(directory);
222 motion_direction = defaults->get("MOTION_DIRECTION", motion_direction);
223 direction = defaults->get("DIRECTION", direction);
227 int SlideMain::save_defaults()
229 defaults->update("MOTION_DIRECTION", motion_direction);
230 defaults->update("DIRECTION", direction);
235 void SlideMain::save_data(KeyFrame *keyframe)
238 output.set_shared_string(keyframe->data, MESSAGESIZE);
239 output.tag.set_title("SLIDE");
240 output.tag.set_property("MOTION_DIRECTION", motion_direction);
241 output.tag.set_property("DIRECTION", direction);
243 output.terminate_string();
246 void SlideMain::read_data(KeyFrame *keyframe)
250 input.set_shared_string(keyframe->data, strlen(keyframe->data));
252 while(!input.read_tag())
254 if(input.tag.title_is("SLIDE"))
256 motion_direction = input.tag.get_property("MOTION_DIRECTION", motion_direction);
257 direction = input.tag.get_property("DIRECTION", direction);
262 void SlideMain::load_configuration()
264 read_data(get_prev_keyframe(get_source_position()));
272 #define SLIDE(type, components) \
276 if(motion_direction == 0) \
278 for(int j = 0; j < h; j++) \
280 type *in_row = (type*)incoming->get_rows()[j]; \
281 type *out_row = (type*)outgoing->get_rows()[j]; \
283 PluginClient::get_source_position() / \
284 PluginClient::get_total_len(); \
286 for(int k = 0, l = w - x; k < x; k++, l++) \
288 out_row[k * components + 0] = in_row[l * components + 0]; \
289 out_row[k * components + 1] = in_row[l * components + 1]; \
290 out_row[k * components + 2] = in_row[l * components + 2]; \
291 if(components == 4) out_row[k * components + 3] = in_row[l * components + 3]; \
297 for(int j = 0; j < h; j++) \
299 type *in_row = (type*)incoming->get_rows()[j]; \
300 type *out_row = (type*)outgoing->get_rows()[j]; \
302 PluginClient::get_source_position() / \
303 PluginClient::get_total_len(); \
305 for(int k = x, l = 0; k < w; k++, l++) \
307 out_row[k * components + 0] = in_row[l * components + 0]; \
308 out_row[k * components + 1] = in_row[l * components + 1]; \
309 out_row[k * components + 2] = in_row[l * components + 2]; \
310 if(components == 4) out_row[k * components + 3] = in_row[l * components + 3]; \
317 if(motion_direction == 0) \
319 for(int j = 0; j < h; j++) \
321 type *in_row = (type*)incoming->get_rows()[j]; \
322 type *out_row = (type*)outgoing->get_rows()[j]; \
324 PluginClient::get_source_position() / \
325 PluginClient::get_total_len(); \
328 for(k = 0, l = w - x; k < x; k++, l++) \
330 out_row[k * components + 0] = out_row[l * components + 0]; \
331 out_row[k * components + 1] = out_row[l * components + 1]; \
332 out_row[k * components + 2] = out_row[l * components + 2]; \
333 if(components == 4) out_row[k * components + 3] = out_row[l * components + 3]; \
337 out_row[k * components + 0] = in_row[k * components + 0]; \
338 out_row[k * components + 1] = in_row[k * components + 1]; \
339 out_row[k * components + 2] = in_row[k * components + 2]; \
340 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
346 for(int j = 0; j < h; j++) \
348 type *in_row = (type*)incoming->get_rows()[j]; \
349 type *out_row = (type*)outgoing->get_rows()[j]; \
351 PluginClient::get_source_position() / \
352 PluginClient::get_total_len(); \
354 for(int k = w - 1, l = w - x - 1; k >= x; k--, l--) \
356 out_row[k * components + 0] = out_row[l * components + 0]; \
357 out_row[k * components + 1] = out_row[l * components + 1]; \
358 out_row[k * components + 2] = out_row[l * components + 2]; \
359 if(components == 4) out_row[k * components + 3] = out_row[l * components + 3]; \
361 for(int k = 0; k < x; k++) \
363 out_row[k * components + 0] = in_row[k * components + 0]; \
364 out_row[k * components + 1] = in_row[k * components + 1]; \
365 out_row[k * components + 2] = in_row[k * components + 2]; \
366 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
377 int SlideMain::process_realtime(VFrame *incoming, VFrame *outgoing)
379 load_configuration();
381 int w = incoming->get_w();
382 int h = incoming->get_h();
385 switch(incoming->get_color_model())
389 SLIDE(unsigned char, 3)
393 SLIDE(unsigned char, 4)
399 case BC_RGBA16161616:
400 case BC_YUVA16161616: