r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / cropvideo.C
blob448ab5b94dfde680141f74d723698bf6bd5421aa
1 #include "cropvideo.h"
2 #include "mainundo.h"
3 #include "mwindow.h"
4 #include "mainsession.h"
5 #include "tracks.h"
6 #include "videowindow.h"
7 #include "videowindowgui.h"
10 #include <libintl.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()
28         start();
31 void CropVideo::run()
33         float aspect_w, aspect_h;
34         int result = 0;
35         {
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();
42         }
44         if(!result)
45         {
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);
52                 
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();
61                 mwindow->draw();
62 //              mwindow->undo->update_undo_edits();
63                 mwindow->session->changes_made = 1;
64         }
65         else
66         {
67         }
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()
91         int x = 10, y = 10;
92         add_subwindow(new BC_Title(x, y, _("Select a region to crop in the video output window")));
93         y += 30;
94         add_subwindow(new BC_OKButton(x, y));
95         x = get_w() - 100;
96         add_subwindow(new BC_CancelButton(x, y));
97         return 0;