add shuttle dev support, use dflt ff_a/v.png icons, mjpegtools typo patch
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / featheredits.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #include "featheredits.h"
23 #include "mainundo.h"
24 #include "mwindow.h"
25 #include "mwindowgui.h"
26
27 #include <libintl.h>
28 #define _(String) gettext(String)
29 #define gettext_noop(String) String
30 #define N_(String) gettext_noop (String)
31
32
33
34 FeatherEdits::FeatherEdits(MWindow *mwindow, int audio, int video)
35  : BC_MenuItem(_("Feather Edits...")), Thread()
36 {
37         this->mwindow = mwindow;
38         this->audio = audio;
39         this->video = video;
40 }
41
42 int FeatherEdits::handle_event()
43 {
44         set_synchronous(0);
45         Thread::start();
46 }
47
48
49 void FeatherEdits::run()
50 {
51         int result;
52         long feather_samples;
53
54         {
55                 feather_samples = mwindow->get_feather(audio, video);
56
57                 FeatherEditsWindow window(mwindow, feather_samples);
58
59                 window.create_objects(audio, video);
60                 result = window.run_window();
61                 feather_samples = window.feather_samples;
62         }
63
64         if(!result)
65         {
66                 mwindow->gui->lock_window();
67 //              mwindow->undo->update_undo_edits(_("Feather"), 0);
68
69                 mwindow->feather_edits(feather_samples, audio, video);
70
71 //              mwindow->undo->update_undo_edits();
72                 mwindow->gui->unlock_window();
73         }
74 }
75
76
77 FeatherEditsWindow::FeatherEditsWindow(MWindow *mwindow, long feather_samples)
78  : BC_Window(_(PROGRAM_NAME ": Feather Edits"),
79         mwindow->gui->get_abs_cursor_x(),
80         mwindow->gui->get_abs_cursor_y(),
81         340,
82         140)
83 {
84         this->feather_samples = feather_samples;
85 }
86
87 FeatherEditsWindow::~FeatherEditsWindow()
88 {
89         delete text;
90 }
91
92 int FeatherEditsWindow::create_objects(int audio, int video)
93 {
94         lock_window("FeatherEditsWindow::create_objects");
95         int x = 10;
96         int y = 10;
97         this->audio = audio;
98         this->video = video;
99
100         if(audio)
101                 add_subwindow(new BC_Title(x, y, _("Feather by how many samples:")));
102         else
103                 add_subwindow(new BC_Title(x, y, _("Feather by how many frames:")));
104
105         y += 20;
106         char string[1024];
107         sprintf(string, "%d", feather_samples);
108         add_subwindow(text = new FeatherEditsTextBox(this, string, x, y));
109
110         y += 20;
111         add_subwindow(new BC_OKButton(x, y));
112         add_subwindow(new BC_CancelButton(x, y));
113         return 0;
114         unlock_window();
115 }
116
117 FeatherEditsTextBox::FeatherEditsTextBox(FeatherEditsWindow *window, char *text, int x, int y)
118  : BC_TextBox(x, y, 100, 1, text)
119 {
120         this->window = window;
121 }
122
123 int FeatherEditsTextBox::handle_event()
124 {
125         window->feather_samples = atol(get_text());
126         return 0;
127 }