2 #include "levelwindow.h"
5 #include "mwindowgui.h"
6 #include "mainsession.h"
8 #include "videowindow.h"
9 #include "videowindowgui.h"
12 VideoWindow::VideoWindow(MWindow *mwindow)
15 this->mwindow = mwindow;
23 VideoWindow::~VideoWindow()
33 int VideoWindow::load_defaults(Defaults *defaults)
35 video_visible = defaults->get("VIDEOVISIBLE", 1);
36 video_window_w = defaults->get("PLAYVIDEOW", video_window_w);
39 int VideoWindow::update_defaults(Defaults *defaults)
41 defaults->update("VIDEOVISIBLE", video_visible);
42 defaults->update("PLAYVIDEOW", video_window_w);
45 int VideoWindow::create_objects()
54 int VideoWindow::init_window()
56 // int w = mwindow->session->output_w;
57 // int h = mwindow->session->output_h;
59 // fix_size(w, h, video_window_w, mwindow->get_aspect_ratio());
60 // gui = new VideoWindowGUI(this, w, h);
61 // gui->create_objects();
64 int VideoWindow::show_window()
70 mwindow->gui->mainmenu->set_show_video(1);
74 int VideoWindow::hide_window()
80 mwindow->gui->mainmenu->set_show_video(0);
84 int VideoWindow::resize_window()
86 int proper_w = mwindow->session->output_w;
87 int proper_h = mwindow->session->output_h;
89 // fix_size(proper_w, proper_h, video_window_w, mwindow->get_aspect_ratio());
93 (gui->get_w() != proper_w ||
94 gui->get_h() != proper_h))
96 gui->resize_window(proper_w, proper_h);
97 gui->canvas->reposition_window(0, 0, proper_w, proper_h);
98 if(video_cropping) gui->canvas->draw_crop_box();
103 int VideoWindow::fix_size(int &w, int &h, int width_given, float aspect_ratio)
106 h = (int)((float)width_given / aspect_ratio);
109 int VideoWindow::original_size()
112 get_full_sizes(w, h);
117 int VideoWindow::get_full_sizes(int &w, int &h)
119 // if(mwindow->get_aspect_ratio() > (float)mwindow->session->output_w / mwindow->session->output_h)
121 // w = (int)((float)mwindow->session->output_h * mwindow->get_aspect_ratio() + 0.5);
122 // h = mwindow->session->output_h;
126 // w = mwindow->session->output_w;
127 // h = (int)((float)mwindow->session->output_w / mwindow->get_aspect_ratio() + 0.5);
132 void VideoWindow::run()
134 if(gui) gui->run_window();
137 int VideoWindow::init_video()
141 gui->canvas->start_video();
145 int VideoWindow::stop_video()
149 gui->canvas->stop_video();
153 int VideoWindow::update(BC_Bitmap *frame)
158 // gui->canvas->draw_bitmap(frame, 1);
159 gui->unlock_window();
163 int VideoWindow::get_w()
165 if(gui) return gui->get_w();
169 int VideoWindow::get_h()
171 if(gui) return gui->get_h();
175 BC_Bitmap* VideoWindow::get_bitmap()
177 return gui->canvas->new_bitmap(gui->get_w(), gui->get_h());
180 int VideoWindow::reset()
184 int VideoWindow::start_cropping()
189 gui->x2 = gui->get_w();
190 gui->y2 = gui->get_h();
191 gui->canvas->draw_crop_box();
192 gui->canvas->flash();
195 int VideoWindow::get_aspect_ratio(float &aspect_w, float &aspect_h)
198 float zoom_factor = (float)video_window_w / mwindow->session->output_w;
200 // For new aspect ratio
201 new_w = (int)((float)(gui->x2 - gui->x1) / zoom_factor);
202 new_h = (int)((float)(gui->y2 - gui->y1) / zoom_factor);
204 mwindow->create_aspect_ratio(aspect_w, aspect_h, new_w, new_h);
207 int VideoWindow::stop_cropping()
209 // float x_zoom, y_zoom;
211 // float zoom_factor;
213 // if(mwindow->get_aspect_ratio() < (float)mwindow->session->output_w / mwindow->session->output_h)
216 // y_zoom = (float)mwindow->session->output_w / mwindow->get_aspect_ratio() / mwindow->session->output_h;
217 // zoom_factor = (float)video_window_w / mwindow->session->output_w;
221 // x_zoom = (float)mwindow->session->output_h * mwindow->get_aspect_ratio() / mwindow->session->output_w;
223 // zoom_factor = (float)video_window_w / (mwindow->session->output_h * mwindow->get_aspect_ratio());
227 // gui->canvas->draw_crop_box();
228 // gui->canvas->flash();
229 // video_window_w = gui->x2 - gui->x1;
231 // gui->x1 = (int)(gui->x1 / zoom_factor / x_zoom);
232 // gui->y1 = (int)(gui->y1 / zoom_factor / y_zoom);
233 // gui->x2 = (int)(gui->x2 / zoom_factor / x_zoom);
234 // gui->y2 = (int)(gui->y2 / zoom_factor / y_zoom);
236 // video_cropping = 0;