add bluray dv, misc fixes
[goodguy/history.git] / cinelerra-5.1 / cinelerra / cpanel.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 "cpanel.h"
23 #include "cwindowgui.h"
24 #include "cwindowtool.h"
25 #include "edl.h"
26 #include "edlsession.h"
27 #include "language.h"
28 #include "mbuttons.h"
29 #include "mwindow.h"
30 #include "theme.h"
31
32
33
34
35 CPanel::CPanel(MWindow *mwindow,
36         CWindowGUI *subwindow,
37         int x,
38         int y,
39         int w,
40         int h)
41 {
42         this->mwindow = mwindow;
43         this->subwindow = subwindow;
44         this->x = x;
45         this->y = y;
46         this->w = w;
47         this->h = h;
48 }
49
50 CPanel::~CPanel()
51 {
52 }
53
54 void CPanel::create_objects()
55 {
56         int x = this->x, y = this->y;
57         subwindow->add_subwindow(operation[CWINDOW_PROTECT] = new CPanelProtect(mwindow, this, x, y));
58         y += operation[CWINDOW_PROTECT]->get_h();
59         subwindow->add_subwindow(operation[CWINDOW_ZOOM] = new CPanelMagnify(mwindow, this, x, y));
60         y += operation[CWINDOW_ZOOM]->get_h();
61         subwindow->add_subwindow(operation[CWINDOW_MASK] = new CPanelMask(mwindow, this, x, y));
62         y += operation[CWINDOW_MASK]->get_h();
63         subwindow->add_subwindow(operation[CWINDOW_RULER] = new CPanelRuler(mwindow, this, x, y));
64         y += operation[CWINDOW_RULER]->get_h();
65         subwindow->add_subwindow(operation[CWINDOW_CAMERA] = new CPanelCamera(mwindow, this, x, y));
66         y += operation[CWINDOW_CAMERA]->get_h();
67         subwindow->add_subwindow(operation[CWINDOW_PROJECTOR] = new CPanelProj(mwindow, this, x, y));
68         y += operation[CWINDOW_PROJECTOR]->get_h();
69         subwindow->add_subwindow(operation[CWINDOW_CROP] = new CPanelCrop(mwindow, this, x, y));
70         y += operation[CWINDOW_CROP]->get_h();
71         subwindow->add_subwindow(operation[CWINDOW_EYEDROP] = new CPanelEyedrop(mwindow, this, x, y));
72         y += operation[CWINDOW_EYEDROP]->get_h();
73         subwindow->add_subwindow(operation[CWINDOW_TOOL_WINDOW] = new CPanelToolWindow(mwindow, this, x, y));
74         y += operation[CWINDOW_TOOL_WINDOW]->get_h();
75         subwindow->add_subwindow(operation[CWINDOW_TITLESAFE] = new CPanelTitleSafe(mwindow, this, x, y));
76 }
77
78 void CPanel::reposition_buttons(int x, int y)
79 {
80         this->x = x;
81         this->y = y;
82
83         for(int i = 0; i < CPANEL_OPERATIONS; i++)
84         {
85                 operation[i]->reposition_window(x, y);
86                 y += operation[i]->get_h();
87         }
88 }
89
90
91 void CPanel::set_operation(int value)
92 {
93         for(int i = 0; i < CPANEL_OPERATIONS; i++)
94         {
95                 if(i == CWINDOW_TOOL_WINDOW)
96                 {
97                         operation[i]->update(mwindow->edl->session->tool_window);
98                 }
99                 else
100                 if(i == CWINDOW_TITLESAFE)
101                 {
102                         operation[i]->update(mwindow->edl->session->safe_regions);
103                 }
104                 else
105 //              if(i == CWINDOW_SHOW_METERS)
106 //              {
107 //                      operation[i]->update(mwindow->edl->session->cwindow_meter);
108 //              }
109 //              else
110                 {
111                         if(i != value)
112                                 operation[i]->update(0);
113                         else
114                                 operation[i]->update(1);
115                 }
116         }
117 }
118
119
120
121
122
123 CPanelProtect::CPanelProtect(MWindow *mwindow, CPanel *gui, int x, int y)
124  : BC_Toggle(x,
125         y,
126         mwindow->theme->get_image_set("protect"),
127         mwindow->edl->session->cwindow_operation == CWINDOW_PROTECT)
128 {
129         this->mwindow = mwindow;
130         this->gui = gui;
131         set_tooltip(_("Protect video from changes"));
132 }
133 CPanelProtect::~CPanelProtect()
134 {
135 }
136 int CPanelProtect::handle_event()
137 {
138         gui->subwindow->set_operation(CWINDOW_PROTECT);
139         return 1;
140 }
141
142
143
144
145
146
147 CPanelMask::CPanelMask(MWindow *mwindow, CPanel *gui, int x, int y)
148  : BC_Toggle(x,
149         y,
150         mwindow->theme->get_image_set("mask"),
151         mwindow->edl->session->cwindow_operation == CWINDOW_MASK)
152 {
153         this->mwindow = mwindow;
154         this->gui = gui;
155         set_tooltip(_("Edit mask"));
156 }
157 CPanelMask::~CPanelMask()
158 {
159 }
160 int CPanelMask::handle_event()
161 {
162         gui->subwindow->set_operation(CWINDOW_MASK);
163         return 1;
164 }
165
166
167
168
169 CPanelRuler::CPanelRuler(MWindow *mwindow, CPanel *gui, int x, int y)
170  : BC_Toggle(x,
171         y,
172         mwindow->theme->get_image_set("ruler"),
173         mwindow->edl->session->cwindow_operation == CWINDOW_RULER)
174 {
175         this->mwindow = mwindow;
176         this->gui = gui;
177         set_tooltip(_("Ruler"));
178 }
179 CPanelRuler::~CPanelRuler()
180 {
181 }
182 int CPanelRuler::handle_event()
183 {
184         gui->subwindow->set_operation(CWINDOW_RULER);
185         return 1;
186 }
187
188
189
190
191 CPanelMagnify::CPanelMagnify(MWindow *mwindow, CPanel *gui, int x, int y)
192  : BC_Toggle(x,
193         y,
194         mwindow->theme->get_image_set("magnify"),
195         mwindow->edl->session->cwindow_operation == CWINDOW_ZOOM)
196 {
197         this->mwindow = mwindow;
198         this->gui = gui;
199         set_tooltip(_("Zoom view"));
200 }
201 CPanelMagnify::~CPanelMagnify()
202 {
203 }
204 int CPanelMagnify::handle_event()
205 {
206         gui->subwindow->set_operation(CWINDOW_ZOOM);
207         return 1;
208 }
209
210
211 CPanelCamera::CPanelCamera(MWindow *mwindow, CPanel *gui, int x, int y)
212  : BC_Toggle(x,
213         y,
214         mwindow->theme->get_image_set("camera"),
215         mwindow->edl->session->cwindow_operation == CWINDOW_CAMERA)
216 {
217         this->mwindow = mwindow;
218         this->gui = gui;
219         set_tooltip(_("Adjust camera automation"));
220 }
221 CPanelCamera::~CPanelCamera()
222 {
223 }
224 int CPanelCamera::handle_event()
225 {
226         gui->subwindow->set_operation(CWINDOW_CAMERA);
227         return 1;
228 }
229
230
231 CPanelProj::CPanelProj(MWindow *mwindow, CPanel *gui, int x, int y)
232  : BC_Toggle(x,
233         y,
234         mwindow->theme->get_image_set("projector"),
235         mwindow->edl->session->cwindow_operation == CWINDOW_PROJECTOR)
236 {
237         this->mwindow = mwindow;
238         this->gui = gui;
239         set_tooltip(_("Adjust projector automation"));
240 }
241 CPanelProj::~CPanelProj()
242 {
243 }
244 int CPanelProj::handle_event()
245 {
246         gui->subwindow->set_operation(CWINDOW_PROJECTOR);
247         return 1;
248 }
249
250
251 CPanelCrop::CPanelCrop(MWindow *mwindow, CPanel *gui, int x, int y)
252  : BC_Toggle(x,
253         y,
254         mwindow->theme->get_image_set("crop"),
255         mwindow->edl->session->cwindow_operation == CWINDOW_CROP)
256 {
257         this->mwindow = mwindow;
258         this->gui = gui;
259         set_tooltip(_("Crop a layer or output"));
260 }
261
262 CPanelCrop::~CPanelCrop()
263 {
264 }
265
266 int CPanelCrop::handle_event()
267 {
268         gui->subwindow->set_operation(CWINDOW_CROP);
269         return 1;
270 }
271
272
273
274
275 CPanelEyedrop::CPanelEyedrop(MWindow *mwindow, CPanel *gui, int x, int y)
276  : BC_Toggle(x,
277         y,
278         mwindow->theme->get_image_set("eyedrop"),
279         mwindow->edl->session->cwindow_operation == CWINDOW_EYEDROP)
280 {
281         this->mwindow = mwindow;
282         this->gui = gui;
283         set_tooltip(_("Get color"));
284 }
285
286 CPanelEyedrop::~CPanelEyedrop()
287 {
288 }
289
290 int CPanelEyedrop::handle_event()
291 {
292         gui->subwindow->set_operation(CWINDOW_EYEDROP);
293         return 1;
294 }
295
296
297
298
299 CPanelToolWindow::CPanelToolWindow(MWindow *mwindow, CPanel *gui, int x, int y)
300  : BC_Toggle(x,
301         y,
302         mwindow->theme->get_image_set("tool"),
303         mwindow->edl->session->tool_window)
304 {
305         this->mwindow = mwindow;
306         this->gui = gui;
307         set_tooltip(_("Show tool info"));
308 }
309
310 CPanelToolWindow::~CPanelToolWindow()
311 {
312 }
313
314 int CPanelToolWindow::handle_event()
315 {
316         mwindow->edl->session->tool_window = get_value();
317         gui->subwindow->tool_panel->update_show_window();
318         return 1;
319 }
320
321 int CPanelToolWindow::set_shown(int shown)
322 {
323         set_value(shown);
324         mwindow->edl->session->tool_window = shown;
325         gui->subwindow->tool_panel->update_show_window();
326         return 1;
327 }
328
329
330 CPanelTitleSafe::CPanelTitleSafe(MWindow *mwindow, CPanel *gui, int x, int y)
331  : BC_Toggle(x,
332         y,
333         mwindow->theme->get_image_set("titlesafe"),
334         mwindow->edl->session->safe_regions)
335 {
336         this->mwindow = mwindow;
337         this->gui = gui;
338         set_tooltip(_("Show safe regions"));
339 }
340 CPanelTitleSafe::~CPanelTitleSafe()
341 {
342 }
343 int CPanelTitleSafe::handle_event()
344 {
345         mwindow->edl->session->safe_regions = get_value();
346         gui->subwindow->canvas->draw_refresh();
347         return 1;
348 }
349