00001 #include "cropvideo.h"
00002 #include "language.h"
00003 #include "mainundo.h"
00004 #include "mwindow.h"
00005 #include "mainsession.h"
00006 #include "tracks.h"
00007 #include "videowindow.h"
00008 #include "videowindowgui.h"
00009
00010
00011
00012
00013 CropVideo::CropVideo(MWindow *mwindow)
00014 : BC_MenuItem(_("Crop Video...")), Thread()
00015 {
00016 this->mwindow = mwindow;
00017 }
00018
00019 CropVideo::~CropVideo()
00020 {
00021 }
00022
00023 int CropVideo::handle_event()
00024 {
00025 start();
00026 }
00027
00028 void CropVideo::run()
00029 {
00030 float aspect_w, aspect_h;
00031 int result = 0;
00032 {
00033 mwindow->video_window->start_cropping();
00034 CropVideoWindow window(mwindow, this);
00035 window.create_objects();
00036 result = window.run_window();
00037 mwindow->video_window->get_aspect_ratio(aspect_w, aspect_h);
00038 mwindow->video_window->stop_cropping();
00039 }
00040
00041 if(!result)
00042 {
00043 int offsets[4], dummy_dimension[4];
00044 dummy_dimension[0] = dummy_dimension[1] = dummy_dimension[2] = dummy_dimension[3] = 0;
00045 offsets[0] = -(mwindow->video_window->gui->x1 + mwindow->video_window->gui->x2 - mwindow->session->output_w) / 2;
00046 offsets[1] = -(mwindow->video_window->gui->y1 + mwindow->video_window->gui->y2 - mwindow->session->output_h) / 2;
00047 offsets[2] = offsets[3] = 0;
00048
00049
00050 mwindow->tracks->scale_video(dummy_dimension, offsets, 0);
00051 mwindow->session->track_w = mwindow->video_window->gui->x2 - mwindow->video_window->gui->x1;
00052 mwindow->session->track_h = mwindow->video_window->gui->y2 - mwindow->video_window->gui->y1;
00053 mwindow->session->output_w = mwindow->video_window->gui->x2 - mwindow->video_window->gui->x1;
00054 mwindow->session->output_h = mwindow->video_window->gui->y2 - mwindow->video_window->gui->y1;
00055 mwindow->session->aspect_w = aspect_w;
00056 mwindow->session->aspect_h = aspect_h;
00057 mwindow->video_window->resize_window();
00058 mwindow->draw();
00059
00060 mwindow->session->changes_made = 1;
00061 }
00062 else
00063 {
00064 }
00065 }
00066
00067 int CropVideo::load_defaults()
00068 {
00069 }
00070
00071 int CropVideo::save_defaults()
00072 {
00073 }
00074
00075 CropVideoWindow::CropVideoWindow(MWindow *mwindow, CropVideo *thread)
00076 : BC_Window(PROGRAM_NAME ": Crop", 380, 75, 0, 0)
00077 {
00078 this->mwindow = mwindow;
00079 this->thread = thread;
00080 }
00081
00082 CropVideoWindow::~CropVideoWindow()
00083 {
00084 }
00085
00086 int CropVideoWindow::create_objects()
00087 {
00088 int x = 10, y = 10;
00089 add_subwindow(new BC_Title(x, y, _("Select a region to crop in the video output window")));
00090 y += 30;
00091 add_subwindow(new BC_OKButton(x, y));
00092 x = get_w() - 100;
00093 add_subwindow(new BC_CancelButton(x, y));
00094 return 0;
00095 }
00096
00097
00098