4 #include "mainsession.h"
6 #include "videowindow.h"
7 #include "videowindowgui.h"
11 #define _(String) gettext(String)
12 #define gettext_noop(String) String
13 #define N_(String) gettext_noop (String)
16 CropVideo::CropVideo(MWindow *mwindow)
17 : BC_MenuItem(_("Crop Video...")), Thread()
19 this->mwindow = mwindow;
22 CropVideo::~CropVideo()
26 int CropVideo::handle_event()
33 float aspect_w, aspect_h;
36 mwindow->video_window->start_cropping();
37 CropVideoWindow window(mwindow, this);
38 window.create_objects();
39 result = window.run_window();
40 mwindow->video_window->get_aspect_ratio(aspect_w, aspect_h);
41 mwindow->video_window->stop_cropping();
46 int offsets[4], dummy_dimension[4];
47 dummy_dimension[0] = dummy_dimension[1] = dummy_dimension[2] = dummy_dimension[3] = 0;
48 offsets[0] = -(mwindow->video_window->gui->x1 + mwindow->video_window->gui->x2 - mwindow->session->output_w) / 2;
49 offsets[1] = -(mwindow->video_window->gui->y1 + mwindow->video_window->gui->y2 - mwindow->session->output_h) / 2;
50 offsets[2] = offsets[3] = 0;
51 // mwindow->undo->update_undo_edits(_("Crop"), 0);
53 mwindow->tracks->scale_video(dummy_dimension, offsets, 0);
54 mwindow->session->track_w = mwindow->video_window->gui->x2 - mwindow->video_window->gui->x1;
55 mwindow->session->track_h = mwindow->video_window->gui->y2 - mwindow->video_window->gui->y1;
56 mwindow->session->output_w = mwindow->video_window->gui->x2 - mwindow->video_window->gui->x1;
57 mwindow->session->output_h = mwindow->video_window->gui->y2 - mwindow->video_window->gui->y1;
58 mwindow->session->aspect_w = aspect_w;
59 mwindow->session->aspect_h = aspect_h;
60 mwindow->video_window->resize_window();
62 // mwindow->undo->update_undo_edits();
63 mwindow->session->changes_made = 1;
70 int CropVideo::load_defaults()
74 int CropVideo::save_defaults()
78 CropVideoWindow::CropVideoWindow(MWindow *mwindow, CropVideo *thread)
79 : BC_Window(PROGRAM_NAME ": Crop", 380, 75, 0, 0)
81 this->mwindow = mwindow;
82 this->thread = thread;
85 CropVideoWindow::~CropVideoWindow()
89 int CropVideoWindow::create_objects()
92 add_subwindow(new BC_Title(x, y, _("Select a region to crop in the video output window")));
94 add_subwindow(new BC_OKButton(x, y));
96 add_subwindow(new BC_CancelButton(x, y));