00001 #include "defaults.h"
00002 #include "levelwindow.h"
00003 #include "mainmenu.h"
00004 #include "mwindow.h"
00005 #include "mwindowgui.h"
00006 #include "mainsession.h"
00007 #include "vframe.h"
00008 #include "videowindow.h"
00009 #include "videowindowgui.h"
00010
00011
00012 VideoWindow::VideoWindow(MWindow *mwindow)
00013 : Thread()
00014 {
00015 this->mwindow = mwindow;
00016 vbuffer = 0;
00017 gui = 0;
00018 video_window_w = 320;
00019 video_visible = 0;
00020 video_cropping = 0;
00021 }
00022
00023 VideoWindow::~VideoWindow()
00024 {
00025 if(gui)
00026 {
00027 gui->set_done(0);
00028 Thread::join();
00029 delete gui;
00030 }
00031 }
00032
00033 int VideoWindow::load_defaults(Defaults *defaults)
00034 {
00035 video_visible = defaults->get("VIDEOVISIBLE", 1);
00036 video_window_w = defaults->get("PLAYVIDEOW", video_window_w);
00037 }
00038
00039 int VideoWindow::update_defaults(Defaults *defaults)
00040 {
00041 defaults->update("VIDEOVISIBLE", video_visible);
00042 defaults->update("PLAYVIDEOW", video_window_w);
00043 }
00044
00045 int VideoWindow::create_objects()
00046 {
00047 set_synchronous(1);
00048 if(mwindow->gui)
00049 {
00050 init_window();
00051 }
00052 }
00053
00054 int VideoWindow::init_window()
00055 {
00056
00057
00058
00059
00060
00061
00062 }
00063
00064 int VideoWindow::show_window()
00065 {
00066 if(gui)
00067 {
00068 video_visible = 1;
00069 gui->show_window();
00070 mwindow->gui->mainmenu->set_show_video(1);
00071 }
00072 }
00073
00074 int VideoWindow::hide_window()
00075 {
00076 if(gui)
00077 {
00078 video_visible = 0;
00079 gui->hide_window();
00080 mwindow->gui->mainmenu->set_show_video(0);
00081 }
00082 }
00083
00084 int VideoWindow::resize_window()
00085 {
00086 int proper_w = mwindow->session->output_w;
00087 int proper_h = mwindow->session->output_h;
00088
00089
00090
00091 gui->update_title();
00092 if(gui &&
00093 (gui->get_w() != proper_w ||
00094 gui->get_h() != proper_h))
00095 {
00096 gui->resize_window(proper_w, proper_h);
00097 gui->canvas->reposition_window(0, 0, proper_w, proper_h);
00098 if(video_cropping) gui->canvas->draw_crop_box();
00099 gui->flash();
00100 }
00101 }
00102
00103 int VideoWindow::fix_size(int &w, int &h, int width_given, float aspect_ratio)
00104 {
00105 w = width_given;
00106 h = (int)((float)width_given / aspect_ratio);
00107 }
00108
00109 int VideoWindow::original_size()
00110 {
00111 int w, h;
00112 get_full_sizes(w, h);
00113 video_window_w = w;
00114 resize_window();
00115 }
00116
00117 int VideoWindow::get_full_sizes(int &w, int &h)
00118 {
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129 }
00130
00131
00132 void VideoWindow::run()
00133 {
00134 if(gui) gui->run_window();
00135 }
00136
00137 int VideoWindow::init_video()
00138 {
00139 if(gui)
00140 {
00141 gui->canvas->start_video();
00142 }
00143 }
00144
00145 int VideoWindow::stop_video()
00146 {
00147 if(gui)
00148 {
00149 gui->canvas->stop_video();
00150 }
00151 }
00152
00153 int VideoWindow::update(BC_Bitmap *frame)
00154 {
00155 if(gui)
00156 {
00157 gui->lock_window();
00158
00159 gui->unlock_window();
00160 }
00161 }
00162
00163 int VideoWindow::get_w()
00164 {
00165 if(gui) return gui->get_w();
00166 else return 0;
00167 }
00168
00169 int VideoWindow::get_h()
00170 {
00171 if(gui) return gui->get_h();
00172 else return 0;
00173 }
00174
00175 BC_Bitmap* VideoWindow::get_bitmap()
00176 {
00177 return gui->canvas->new_bitmap(gui->get_w(), gui->get_h());
00178 }
00179
00180 int VideoWindow::reset()
00181 {
00182 }
00183
00184 int VideoWindow::start_cropping()
00185 {
00186 video_cropping = 1;
00187 gui->x1 = 0;
00188 gui->y1 = 0;
00189 gui->x2 = gui->get_w();
00190 gui->y2 = gui->get_h();
00191 gui->canvas->draw_crop_box();
00192 gui->canvas->flash();
00193 }
00194
00195 int VideoWindow::get_aspect_ratio(float &aspect_w, float &aspect_h)
00196 {
00197 int new_w, new_h;
00198 float zoom_factor = (float)video_window_w / mwindow->session->output_w;
00199
00200
00201 new_w = (int)((float)(gui->x2 - gui->x1) / zoom_factor);
00202 new_h = (int)((float)(gui->y2 - gui->y1) / zoom_factor);
00203
00204 mwindow->create_aspect_ratio(aspect_w, aspect_h, new_w, new_h);
00205 }
00206
00207 int VideoWindow::stop_cropping()
00208 {
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237 }