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"
25 #include "mainprogress.h"
32 REGISTER_PLUGIN(ReFrame)
43 ReFrame::ReFrame(PluginServer *server)
44 : PluginVClient(server)
53 const char* ReFrame::plugin_title() { return _("Reframe"); }
57 int ReFrame::load_defaults()
61 // set the default directory
62 sprintf(directory, "%sreframe.rc", BCASTDIR);
66 defaults = new BC_Hash(directory);
70 scale = defaults->get("SCALE", (double)1);
74 int ReFrame::save_defaults()
76 defaults->update("SCALE", scale);
81 int ReFrame::get_parameters()
84 ReFrameWindow window(this, info.get_abs_cursor_x(), info.get_abs_cursor_y());
85 window.create_objects();
86 int result = window.run_window();
92 int ReFrame::start_loop()
94 if(PluginClient::interactive)
96 char string[BCTEXTLEN];
97 sprintf(string, "%s...", plugin_title());
98 progress = start_progress(string,
99 (PluginClient::end - PluginClient::start));
102 current_position = 0;
106 int ReFrame::stop_loop()
108 if(PluginClient::interactive)
110 progress->stop_progress();
117 int ReFrame::process_loop(VFrame *buffer)
121 int64_t input_offset = Units::to_int64((double)current_position *
123 PluginClient::start);
125 read_frame(buffer, input_offset);
128 input_offset = Units::to_int64((double)current_position *
130 PluginClient::start);
132 if(PluginClient::interactive)
133 result = progress->update(input_offset - PluginClient::start);
135 if(input_offset >= PluginClient::end) result = 1;
151 ReFrameOutput::ReFrameOutput(ReFrame *plugin, int x, int y)
152 : BC_TextBox(x, y, 150, 1, (float)plugin->scale)
154 this->plugin = plugin;
157 int ReFrameOutput::handle_event()
159 plugin->scale = atof(get_text());
165 ReFrameWindow::ReFrameWindow(ReFrame *plugin, int x, int y)
166 : BC_Window(plugin->plugin_title(),
177 this->plugin = plugin;
180 ReFrameWindow::~ReFrameWindow()
185 void ReFrameWindow::create_objects()
188 lock_window("ReFrameWindow::create_objects");
189 add_subwindow(new BC_Title(x, y, _("Scale factor:")));
191 add_subwindow(new ReFrameOutput(plugin, x, y));
192 add_subwindow(new BC_OKButton(this));
193 add_subwindow(new BC_CancelButton(this));
198 int ReFrameWindow::close_event()