1 #include "bcdisplayinfo.h"
4 #include "mainprogress.h"
12 REGISTER_PLUGIN(ReFrame)
23 ReFrame::ReFrame(PluginServer *server)
24 : PluginVClient(server)
36 char* ReFrame::plugin_title() { return N_("Reframe"); }
38 NEW_PICON_MACRO(ReFrame)
41 int ReFrame::load_defaults()
45 // set the default directory
46 sprintf(directory, "%sreframe.rc", BCASTDIR);
50 defaults = new BC_Hash(directory);
54 scale = defaults->get("SCALE", (double)1);
58 int ReFrame::save_defaults()
60 defaults->update("SCALE", scale);
65 int ReFrame::get_parameters()
68 ReFrameWindow window(this, info.get_abs_cursor_x(), info.get_abs_cursor_y());
69 window.create_objects();
70 int result = window.run_window();
76 int ReFrame::start_loop()
78 if(PluginClient::interactive)
80 char string[BCTEXTLEN];
81 sprintf(string, "%s...", plugin_title());
82 progress = start_progress(string,
83 (PluginClient::end - PluginClient::start));
90 int ReFrame::stop_loop()
92 if(PluginClient::interactive)
94 progress->stop_progress();
101 int ReFrame::process_loop(VFrame *buffer)
105 int64_t input_offset = Units::to_int64((double)current_position *
107 PluginClient::start);
109 read_frame(buffer, input_offset);
112 input_offset = Units::to_int64((double)current_position *
114 PluginClient::start);
116 if(PluginClient::interactive)
117 result = progress->update(input_offset - PluginClient::start);
119 if(input_offset >= PluginClient::end) result = 1;
135 ReFrameOutput::ReFrameOutput(ReFrame *plugin, int x, int y)
136 : BC_TextBox(x, y, 150, 1, (float)plugin->scale)
138 this->plugin = plugin;
141 int ReFrameOutput::handle_event()
143 plugin->scale = atof(get_text());
149 ReFrameWindow::ReFrameWindow(ReFrame *plugin, int x, int y)
150 : BC_Window(plugin->plugin_title(),
161 this->plugin = plugin;
164 ReFrameWindow::~ReFrameWindow()
169 void ReFrameWindow::create_objects()
172 add_subwindow(new BC_Title(x, y, _("Scale factor:")));
174 add_subwindow(new ReFrameOutput(plugin, x, y));
175 add_subwindow(new BC_OKButton(this));
176 add_subwindow(new BC_CancelButton(this));
182 WINDOW_CLOSE_EVENT(ReFrameWindow)