00001 #include "bcdisplayinfo.h"
00002 #include "bchash.h"
00003 #include "language.h"
00004 #include "mainprogress.h"
00005 #include "picon_png.h"
00006 #include "reframe.h"
00007
00008
00009
00010
00011
00012 REGISTER_PLUGIN(ReFrame)
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 ReFrame::ReFrame(PluginServer *server)
00024 : PluginVClient(server)
00025 {
00026 load_defaults();
00027 current_position = 0;
00028 }
00029
00030 ReFrame::~ReFrame()
00031 {
00032 save_defaults();
00033 delete defaults;
00034 }
00035
00036 char* ReFrame::plugin_title() { return N_("Reframe"); }
00037
00038 NEW_PICON_MACRO(ReFrame)
00039
00040
00041 int ReFrame::load_defaults()
00042 {
00043 char directory[1024];
00044
00045
00046 sprintf(directory, "%sreframe.rc", BCASTDIR);
00047
00048
00049
00050 defaults = new BC_Hash(directory);
00051
00052 defaults->load();
00053
00054 scale = defaults->get("SCALE", (double)1);
00055 return 0;
00056 }
00057
00058 int ReFrame::save_defaults()
00059 {
00060 defaults->update("SCALE", scale);
00061 defaults->save();
00062 return 0;
00063 }
00064
00065 int ReFrame::get_parameters()
00066 {
00067 BC_DisplayInfo info;
00068 ReFrameWindow window(this, info.get_abs_cursor_x(), info.get_abs_cursor_y());
00069 window.create_objects();
00070 int result = window.run_window();
00071
00072 return result;
00073 }
00074
00075
00076 int ReFrame::start_loop()
00077 {
00078 if(PluginClient::interactive)
00079 {
00080 char string[BCTEXTLEN];
00081 sprintf(string, "%s...", plugin_title());
00082 progress = start_progress(string,
00083 (PluginClient::end - PluginClient::start));
00084 }
00085
00086 current_position = 0;
00087 return 0;
00088 }
00089
00090 int ReFrame::stop_loop()
00091 {
00092 if(PluginClient::interactive)
00093 {
00094 progress->stop_progress();
00095 delete progress;
00096 }
00097 return 0;
00098 }
00099
00100
00101 int ReFrame::process_loop(VFrame *buffer)
00102 {
00103 int result = 0;
00104
00105 int64_t input_offset = Units::to_int64((double)current_position *
00106 scale +
00107 PluginClient::start);
00108
00109 read_frame(buffer, input_offset);
00110
00111 current_position++;
00112 input_offset = Units::to_int64((double)current_position *
00113 scale +
00114 PluginClient::start);
00115
00116 if(PluginClient::interactive)
00117 result = progress->update(input_offset - PluginClient::start);
00118
00119 if(input_offset >= PluginClient::end) result = 1;
00120
00121 return result;
00122 }
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135 ReFrameOutput::ReFrameOutput(ReFrame *plugin, int x, int y)
00136 : BC_TextBox(x, y, 150, 1, (float)plugin->scale)
00137 {
00138 this->plugin = plugin;
00139 }
00140
00141 int ReFrameOutput::handle_event()
00142 {
00143 plugin->scale = atof(get_text());
00144 return 1;
00145 }
00146
00147
00148
00149 ReFrameWindow::ReFrameWindow(ReFrame *plugin, int x, int y)
00150 : BC_Window(plugin->plugin_title(),
00151 x,
00152 y,
00153 230,
00154 160,
00155 230,
00156 160,
00157 0,
00158 0,
00159 1)
00160 {
00161 this->plugin = plugin;
00162 }
00163
00164 ReFrameWindow::~ReFrameWindow()
00165 {
00166 }
00167
00168
00169 void ReFrameWindow::create_objects()
00170 {
00171 int x = 10, y = 10;
00172 add_subwindow(new BC_Title(x, y, _("Scale factor:")));
00173 y += 20;
00174 add_subwindow(new ReFrameOutput(plugin, x, y));
00175 add_subwindow(new BC_OKButton(this));
00176 add_subwindow(new BC_CancelButton(this));
00177
00178 show_window();
00179 flush();
00180 }
00181
00182 WINDOW_CLOSE_EVENT(ReFrameWindow)
00183
00184