r1006: configure: Use libx264_pic instead of libx264 if available.
[cinelerra_cv/mob.git] / cinelerra / cropvideo.C
blob91bbdc2c9dc308745ffcc903c8a5db785535d1ac
1 #include "cropvideo.h"
2 #include "language.h"
3 #include "mainundo.h"
4 #include "mwindow.h"
5 #include "mainsession.h"
6 #include "tracks.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()
25         start();
28 void CropVideo::run()
30         float aspect_w, aspect_h;
31         int result = 0;
32         {
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();
39         }
41         if(!result)
42         {
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);
49                 
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();
58                 mwindow->draw();
59 //              mwindow->undo->update_undo_edits();
60                 mwindow->session->changes_made = 1;
61         }
62         else
63         {
64         }
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()
88         int x = 10, y = 10;
89         add_subwindow(new BC_Title(x, y, _("Select a region to crop in the video output window")));
90         y += 30;
91         add_subwindow(new BC_OKButton(x, y));
92         x = get_w() - 100;
93         add_subwindow(new BC_CancelButton(x, y));
94         return 0;