5 #include "mainsession.h"
7 #include "videowindow.h"
8 #include "videowindowgui.h"
13 CropVideo::CropVideo(MWindow *mwindow)
14 : BC_MenuItem(_("Crop Video...")), Thread()
16 this->mwindow = mwindow;
19 CropVideo::~CropVideo()
23 int CropVideo::handle_event()
30 float aspect_w, aspect_h;
33 mwindow->video_window->start_cropping();
34 CropVideoWindow window(mwindow, this);
35 window.create_objects();
36 result = window.run_window();
37 mwindow->video_window->get_aspect_ratio(aspect_w, aspect_h);
38 mwindow->video_window->stop_cropping();
43 int offsets[4], dummy_dimension[4];
44 dummy_dimension[0] = dummy_dimension[1] = dummy_dimension[2] = dummy_dimension[3] = 0;
45 offsets[0] = -(mwindow->video_window->gui->x1 + mwindow->video_window->gui->x2 - mwindow->session->output_w) / 2;
46 offsets[1] = -(mwindow->video_window->gui->y1 + mwindow->video_window->gui->y2 - mwindow->session->output_h) / 2;
47 offsets[2] = offsets[3] = 0;
48 // mwindow->undo->update_undo_edits(_("Crop"), 0);
50 mwindow->tracks->scale_video(dummy_dimension, offsets, 0);
51 mwindow->session->track_w = mwindow->video_window->gui->x2 - mwindow->video_window->gui->x1;
52 mwindow->session->track_h = mwindow->video_window->gui->y2 - mwindow->video_window->gui->y1;
53 mwindow->session->output_w = mwindow->video_window->gui->x2 - mwindow->video_window->gui->x1;
54 mwindow->session->output_h = mwindow->video_window->gui->y2 - mwindow->video_window->gui->y1;
55 mwindow->session->aspect_w = aspect_w;
56 mwindow->session->aspect_h = aspect_h;
57 mwindow->video_window->resize_window();
59 // mwindow->undo->update_undo_edits();
60 mwindow->session->changes_made = 1;
67 int CropVideo::load_defaults()
71 int CropVideo::save_defaults()
75 CropVideoWindow::CropVideoWindow(MWindow *mwindow, CropVideo *thread)
76 : BC_Window(PROGRAM_NAME ": Crop", 380, 75, 0, 0)
78 this->mwindow = mwindow;
79 this->thread = thread;
82 CropVideoWindow::~CropVideoWindow()
86 int CropVideoWindow::create_objects()
89 add_subwindow(new BC_Title(x, y, _("Select a region to crop in the video output window")));
91 add_subwindow(new BC_OKButton(x, y));
93 add_subwindow(new BC_CancelButton(x, y));
102 // c-file-style: "linux"