4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "bcdisplayinfo.h"
26 #include "mainprogress.h"
33 REGISTER_PLUGIN(ReFrame)
44 ReFrame::ReFrame(PluginServer *server)
45 : PluginVClient(server)
54 const char* ReFrame::plugin_title() { return N_("Reframe"); }
58 int ReFrame::load_defaults()
62 // set the default directory
63 sprintf(directory, "%s/reframe.rc", File::get_config_path());
67 defaults = new BC_Hash(directory);
71 scale = defaults->get("SCALE", (double)1);
75 int ReFrame::save_defaults()
77 defaults->update("SCALE", scale);
82 int ReFrame::get_parameters()
85 ReFrameWindow window(this, info.get_abs_cursor_x(), info.get_abs_cursor_y());
86 window.create_objects();
87 int result = window.run_window();
93 int ReFrame::start_loop()
95 if(PluginClient::interactive)
97 char string[BCTEXTLEN];
98 sprintf(string, "%s...", plugin_title());
99 progress = start_progress(string,
100 (PluginClient::end - PluginClient::start));
103 current_position = 0;
107 int ReFrame::stop_loop()
109 if(PluginClient::interactive)
111 progress->stop_progress();
118 int ReFrame::process_loop(VFrame *buffer)
122 int64_t input_offset = Units::to_int64((double)current_position *
124 PluginClient::start);
126 read_frame(buffer, input_offset);
129 input_offset = Units::to_int64((double)current_position *
131 PluginClient::start);
133 if(PluginClient::interactive)
134 result = progress->update(input_offset - PluginClient::start);
136 if(input_offset >= PluginClient::end) result = 1;
152 ReFrameOutput::ReFrameOutput(ReFrame *plugin, int x, int y)
153 : BC_TextBox(x, y, xS(150), 1, (float)plugin->scale)
155 this->plugin = plugin;
158 int ReFrameOutput::handle_event()
160 plugin->scale = atof(get_text());
166 ReFrameWindow::ReFrameWindow(ReFrame *plugin, int x, int y)
167 : BC_Window(plugin->plugin_title(),
178 this->plugin = plugin;
181 ReFrameWindow::~ReFrameWindow()
186 void ReFrameWindow::create_objects()
188 int x = xS(10), y = yS(10);
189 lock_window("ReFrameWindow::create_objects");
190 add_subwindow(new BC_Title(x, y, _("Scale factor:")));
192 add_subwindow(new ReFrameOutput(plugin, x, y));
193 add_subwindow(new BC_OKButton(this));
194 add_subwindow(new BC_CancelButton(this));
199 int ReFrameWindow::close_event()