add bluray dv, misc fixes
[goodguy/history.git] / cinelerra-5.1 / cinelerra / theme.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 1997-2011 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 "awindowgui.h"
23 #include "bcsignals.h"
24 #include "clip.h"
25 #include "colors.h"
26 #include "cwindowgui.h"
27 #include "edl.h"
28 #include "edlsession.h"
29 #include "keyframegui.h"
30 #include "language.h"
31 #include "levelwindowgui.h"
32 #include "loadmode.h"
33 #include "localsession.h"
34 #include "mainmenu.h"
35 #include "mainsession.h"
36 #include "mbuttons.h"
37 #include "meterpanel.h"
38 #include "mwindowgui.h"
39 #include "mwindow.h"
40 #include "overlayframe.h"
41 #include "patchbay.h"
42 #include "playtransport.h"
43 //#include "presetsgui.h"
44 #include "recordgui.h"
45 #include "recordmonitor.h"
46 #include "resourcepixmap.h"
47 #include "statusbar.h"
48 #include "theme.h"
49 #include "timebar.h"
50 #include "trackcanvas.h"
51 #include "vframe.h"
52 #include "vwindowgui.h"
53 #include "zoombar.h"
54
55
56 #include <errno.h>
57 #include <string.h>
58
59 #define NEW_VFRAME \
60 new VFrame(0, -1, default_data.get_w(), default_data.get_h(), BC_RGBA8888, -1)
61
62 Theme::Theme()
63  : BC_Theme()
64 {
65         window_border = 10;
66         widget_border = 5;
67         this->mwindow = 0;
68         theme_title = DEFAULT_THEME;
69         data_buffer = 0;
70         contents_buffer = 0;
71         last_image = 0;
72         mtransport_margin = 0;
73         toggle_margin = 0;
74         control_pixels = 50;
75         timebar_cursor_color = RED;
76
77         BC_WindowBase::get_resources()->bg_color = BLOND;
78         BC_WindowBase::get_resources()->button_up = 0xffc000;
79         BC_WindowBase::get_resources()->button_highlighted = 0xffe000;
80         BC_WindowBase::get_resources()->recursive_resizing = 0;
81         audio_color = BLACK;
82         fade_h = 22;
83         meter_h = 17;
84         mode_h = 30;
85         pan_h = 32;
86         pan_x = 50;
87         play_h = 22;
88         title_h = 23;
89         clock_bg_color = BLACK;
90         assetedit_color = YELLOW;
91         const char *cp = getenv("BC_USE_COMMERCIALS");
92         use_commercials = !cp ? 0 : atoi(cp);
93
94         preferences_category_overlap = 0;
95
96         loadmode_w = 350;
97         czoom_w = 80;
98
99 #include "data/about_png.h"
100         about_bg = new VFramePng(about_png);
101
102         pane_color = BLACK;
103         drag_pane_color = WHITE;
104
105         appendasset_data = 0;
106         append_data = 0;
107         asset_append_data = 0;
108         asset_disk_data = 0;
109         asset_index_data = 0;
110         asset_info_data = 0;
111         asset_project_data = 0;
112         browse_data = 0;
113         calibrate_data = 0;
114         camerakeyframe_data = 0;
115         cancel_data = 0;
116         chain_data = 0;
117         channel_bg_data = 0;
118         channel_position_data = 0;
119         delete_all_indexes_data = 0;
120         deletebin_data = 0;
121         delete_data = 0;
122         deletedisk_data = 0;
123         deleteproject_data = 0;
124         detach_data = 0;
125         dntriangle_data = 0;
126
127         edit_data = 0;
128         edithandlein_data = 0;
129         edithandleout_data = 0;
130         extract_data = 0;
131         ffmpeg_toggle = 0;
132         infoasset_data = 0;
133         in_point = 0;
134         insert_data = 0;
135         keyframe_data = 0;
136         label_toggle = 0;
137         lift_data = 0;
138         maskkeyframe_data = 0;
139         modekeyframe_data = 0;
140         movedn_data = 0;
141         moveup_data = 0;
142         newbin_data = 0;
143         no_data = 0;
144         options_data = 0;
145         out_point = 0;
146         over_button = 0;
147         overwrite_data = 0;
148         pankeyframe_data = 0;
149         pasteasset_data = 0;
150         paused_data = 0;
151         picture_data = 0;
152         presentation_data = 0;
153         presentation_loop = 0;
154         presentation_stop = 0;
155         projectorkeyframe_data = 0;
156         redrawindex_data = 0;
157         renamebin_data = 0;
158         reset_data = 0;
159         reverse_data = 0;
160         rewind_data = 0;
161         select_data = 0;
162         shbtn_data = 0;
163         splice_data = 0;
164         start_over_data = 0;
165         statusbar_cancel_data = 0;
166         timebar_view_data = 0;
167         transition_data = 0;
168         uptriangle_data = 0;
169         viewasset_data = 0;
170         vtimebar_bg_data = 0;
171 }
172
173
174 // Need to delete everything here
175 Theme::~Theme()
176 {
177         flush_images();
178
179         aspect_ratios.remove_all_objects();
180         frame_rates.remove_all_objects();
181         frame_sizes.remove_all_objects();
182         sample_rates.remove_all_objects();
183         zoom_values.remove_all_objects();
184
185         delete about_bg;
186 }
187
188 void Theme::flush_images()
189 {
190         if(data_buffer) delete [] data_buffer;
191         if(contents_buffer) delete [] contents_buffer;
192         data_buffer = 0;
193         contents_buffer = 0;
194         contents.remove_all();
195 }
196
197 void Theme::initialize()
198 {
199         message_normal = BLACK;
200         message_error = RED;
201
202 // Force to use local data for images
203         extern unsigned char _binary_theme_data_start[];
204         set_data(_binary_theme_data_start);
205
206 // Set images which weren't set by subclass
207         new_image("mode_normal", "mode_normal.png");
208         new_image("mode_add", "mode_add.png");
209         new_image("mode_subtract", "mode_subtract.png");
210         new_image("mode_multiply", "mode_multiply.png");
211         new_image("mode_divide", "mode_divide.png");
212         new_image("mode_replace", "mode_replace.png");
213         new_image("mode_max", "mode_max.png");
214         new_image("mode_min", "mode_min.png");
215         new_image("mode_darken", "mode_darken.png");
216         new_image("mode_lighten", "mode_lighten.png");
217         new_image("mode_dst", "mode_dst.png");
218         new_image("mode_dstatop", "mode_dstatop.png");
219         new_image("mode_dstin", "mode_dstin.png");
220         new_image("mode_dstout", "mode_dstout.png");
221         new_image("mode_dstover", "mode_dstover.png");
222         new_image("mode_src", "mode_src.png");
223         new_image("mode_srcatop", "mode_srcatop.png");
224         new_image("mode_srcin", "mode_srcin.png");
225         new_image("mode_srcout", "mode_srcout.png");
226         new_image("mode_srcover", "mode_srcover.png");
227         new_image("mode_and", "mode_and.png");
228         new_image("mode_or", "mode_or.png");
229         new_image("mode_xor", "mode_xor.png");
230         new_image("mode_overlay", "mode_overlay.png");
231         new_image("mode_screen", "mode_screen.png");
232         new_image("mode_burn", "mode_burn.png");
233         new_image("mode_dodge", "mode_dodge.png");
234         new_image("mode_hardlight", "mode_hardlight.png");
235         new_image("mode_softlight", "mode_softlight.png");
236         new_image("mode_difference", "mode_difference.png");
237
238         new_image_set("mode_popup", 3, "mode_up.png", "mode_hi.png", "mode_dn.png");
239
240 // Images all themes have
241         new_image("mwindow_icon", "heroine_icon.png");
242         new_image("vwindow_icon", "heroine_icon.png");
243         new_image("cwindow_icon", "heroine_icon.png");
244         new_image("awindow_icon", "heroine_icon.png");
245         new_image("record_icon", "heroine_icon.png");
246         new_image("clip_icon", "clip_icon.png");
247
248
249         new_image("aeffect_icon", "aeffect_icon.png");
250         new_image("veffect_icon", "veffect_icon.png");
251         new_image("atransition_icon", "atransition_icon.png");
252         new_image("vtransition_icon", "atransition_icon.png");
253 }
254
255
256
257
258
259
260 void Theme::build_menus()
261 {
262         aspect_ratios.append(new BC_ListBoxItem("3:2"));
263         aspect_ratios.append(new BC_ListBoxItem("4:3"));
264         aspect_ratios.append(new BC_ListBoxItem("16:9"));
265         aspect_ratios.append(new BC_ListBoxItem("2.10:1"));
266         aspect_ratios.append(new BC_ListBoxItem("2.20:1"));
267         aspect_ratios.append(new BC_ListBoxItem("2.25:1"));
268         aspect_ratios.append(new BC_ListBoxItem("2.30:1"));
269         aspect_ratios.append(new BC_ListBoxItem("2.35:1"));
270         aspect_ratios.append(new BC_ListBoxItem("2.66:1"));
271
272         frame_sizes.append(new BC_ListBoxItem("128x96"));
273         frame_sizes.append(new BC_ListBoxItem("160x120"));
274         frame_sizes.append(new BC_ListBoxItem("176x144"));
275         frame_sizes.append(new BC_ListBoxItem("240x180"));
276         frame_sizes.append(new BC_ListBoxItem("320x200"));
277         frame_sizes.append(new BC_ListBoxItem("320x240"));
278         frame_sizes.append(new BC_ListBoxItem("352x288"));
279         frame_sizes.append(new BC_ListBoxItem("360x240"));
280         frame_sizes.append(new BC_ListBoxItem("400x300"));
281         frame_sizes.append(new BC_ListBoxItem("424x318"));
282         frame_sizes.append(new BC_ListBoxItem("512x384"));
283         frame_sizes.append(new BC_ListBoxItem("640x350"));
284         frame_sizes.append(new BC_ListBoxItem("640x480"));
285         frame_sizes.append(new BC_ListBoxItem("704x576"));
286         frame_sizes.append(new BC_ListBoxItem("720x480"));
287         frame_sizes.append(new BC_ListBoxItem("720x576"));
288         frame_sizes.append(new BC_ListBoxItem("800x600"));
289         frame_sizes.append(new BC_ListBoxItem("852x480"));
290         frame_sizes.append(new BC_ListBoxItem("852x480"));
291         frame_sizes.append(new BC_ListBoxItem("960x540"));
292         frame_sizes.append(new BC_ListBoxItem("960x1080"));
293         frame_sizes.append(new BC_ListBoxItem("1024x768"));
294         frame_sizes.append(new BC_ListBoxItem("1280x720"));
295         frame_sizes.append(new BC_ListBoxItem("1280x1024"));
296         frame_sizes.append(new BC_ListBoxItem("1368x768"));
297         frame_sizes.append(new BC_ListBoxItem("1408x1152"));
298         frame_sizes.append(new BC_ListBoxItem("1600x1024"));
299         frame_sizes.append(new BC_ListBoxItem("1600x1200"));
300         frame_sizes.append(new BC_ListBoxItem("1920x1080"));
301         frame_sizes.append(new BC_ListBoxItem("1920x1088"));
302         frame_sizes.append(new BC_ListBoxItem("1920x1200"));
303         frame_sizes.append(new BC_ListBoxItem("2048x1536"));
304         frame_sizes.append(new BC_ListBoxItem("2560x1600"));
305         frame_sizes.append(new BC_ListBoxItem("2560x2048"));
306         frame_sizes.append(new BC_ListBoxItem("3200x2048"));
307         frame_sizes.append(new BC_ListBoxItem("3840x2400"));
308         frame_sizes.append(new BC_ListBoxItem("5120x4096"));
309         frame_sizes.append(new BC_ListBoxItem("6400x4096"));
310         frame_sizes.append(new BC_ListBoxItem("7680x4800"));
311
312         sample_rates.append(new BC_ListBoxItem("8000"));
313         sample_rates.append(new BC_ListBoxItem("16000"));
314         sample_rates.append(new BC_ListBoxItem("22050"));
315         sample_rates.append(new BC_ListBoxItem("32000"));
316         sample_rates.append(new BC_ListBoxItem("44100"));
317         sample_rates.append(new BC_ListBoxItem("48000"));
318         sample_rates.append(new BC_ListBoxItem("96000"));
319         sample_rates.append(new BC_ListBoxItem("192000"));
320
321         frame_rates.append(new BC_ListBoxItem("1"));
322         frame_rates.append(new BC_ListBoxItem("5"));
323         frame_rates.append(new BC_ListBoxItem("10"));
324         frame_rates.append(new BC_ListBoxItem("12"));
325         frame_rates.append(new BC_ListBoxItem("15"));
326         frame_rates.append(new BC_ListBoxItem("23.976"));
327         frame_rates.append(new BC_ListBoxItem("24"));
328         frame_rates.append(new BC_ListBoxItem("25"));
329         frame_rates.append(new BC_ListBoxItem("29.97"));
330         frame_rates.append(new BC_ListBoxItem("30"));
331         frame_rates.append(new BC_ListBoxItem("50"));
332         frame_rates.append(new BC_ListBoxItem("59.94"));
333         frame_rates.append(new BC_ListBoxItem("60"));
334
335         char string[BCTEXTLEN];
336         for(int i = 1; i < 17; i++)
337         {
338                 sprintf(string, "%d", (int)pow(2, i));
339                 zoom_values.append(new BC_ListBoxItem(string));
340         }
341 }
342
343
344 void Theme::overlay(VFrame *dst, VFrame *src, int in_x1, int in_x2)
345 {
346         int w;
347         int h;
348         unsigned char **in_rows;
349         unsigned char **out_rows;
350
351         if(in_x1 < 0)
352         {
353                 w = MIN(src->get_w(), dst->get_w());
354                 h = MIN(dst->get_h(), src->get_h());
355                 in_x1 = 0;
356                 in_x2 = w;
357         }
358         else
359         {
360                 w = in_x2 - in_x1;
361                 h = MIN(dst->get_h(), src->get_h());
362         }
363         in_rows = src->get_rows();
364         out_rows = dst->get_rows();
365
366         switch(src->get_color_model())
367         {
368                 case BC_RGBA8888:
369                         switch(dst->get_color_model())
370                         {
371                                 case BC_RGBA8888:
372                                         for(int i = 0; i < h; i++)
373                                         {
374                                                 unsigned char *in_row = in_rows[i] + in_x1 * 4;
375                                                 unsigned char *out_row = out_rows[i];
376                                                 for(int j = 0; j < w; j++)
377                                                 {
378                                                         int opacity = in_row[3];
379                                                         int transparency = out_row[3] * (0xff - opacity) / 0xff;
380                                                         out_row[0] = (in_row[0] * opacity + out_row[0] * transparency) / 0xff;
381                                                         out_row[1] = (in_row[1] * opacity + out_row[1] * transparency) / 0xff;
382                                                         out_row[2] = (in_row[2] * opacity + out_row[2] * transparency) / 0xff;
383                                                         out_row[3] = MAX(in_row[3], out_row[3]);
384                                                         out_row += 4;
385                                                         in_row += 4;
386                                                 }
387                                         }
388                                         break;
389                                 case BC_RGB888:
390                                         for(int i = 0; i < h; i++)
391                                         {
392                                                 unsigned char *in_row = in_rows[i] + in_x1 * 4;
393                                                 unsigned char *out_row = out_rows[i];
394                                                 for(int j = 0; j < w; j++)
395                                                 {
396                                                         int opacity = in_row[3];
397                                                         int transparency = 0xff - opacity;
398                                                         out_row[0] = (in_row[0] * opacity + out_row[0] * transparency) / 0xff;
399                                                         out_row[1] = (in_row[1] * opacity + out_row[1] * transparency) / 0xff;
400                                                         out_row[2] = (in_row[2] * opacity + out_row[2] * transparency) / 0xff;
401                                                         out_row += 3;
402                                                         in_row += 4;
403                                                 }
404                                         }
405                                         break;
406                         }
407                         break;
408         }
409 }
410
411 void Theme::build_transport(char *title,
412         unsigned char *png_overlay,
413         VFrame **bg_data,
414         int third)
415 {
416         if(!png_overlay) return;
417         VFramePng default_data(png_overlay);
418         VFrame *data[3];
419         data[0] = NEW_VFRAME;
420         data[1] = NEW_VFRAME;
421         data[2] = NEW_VFRAME;
422         data[0]->clear_frame();
423         data[1]->clear_frame();
424         data[2]->clear_frame();
425
426         for(int i = 0; i < 3; i++)
427         {
428                 int in_x1 = 0;
429                 int in_x2 = 0;
430                 if(!bg_data[i]) break;
431
432                 switch(third)
433                 {
434                         case 0:
435                                 in_x1 = 0;
436                                 in_x2 = default_data.get_w();
437                                 break;
438
439                         case 1:
440                                 in_x1 = (int)(bg_data[i]->get_w() * 0.33);
441                                 in_x2 = in_x1 + default_data.get_w();
442                                 break;
443
444                         case 2:
445                                 in_x1 = bg_data[i]->get_w() - default_data.get_w();
446                                 in_x2 = in_x1 + default_data.get_w();
447                                 break;
448                 }
449
450                 overlay(data[i], bg_data[i], in_x1, in_x2);
451                 overlay(data[i], &default_data);
452         }
453
454         new_image_set_images(title, 3, data[0], data[1], data[2]);
455 }
456
457
458
459
460
461
462
463
464
465 void Theme::build_patches(VFrame** &data,
466         unsigned char *png_overlay,
467         VFrame **bg_data,
468         int region)
469 {
470         if(!png_overlay || !bg_data) return;
471         VFramePng default_data(png_overlay);
472         data = new VFrame*[5];
473         data[0] = NEW_VFRAME;
474         data[1] = NEW_VFRAME;
475         data[2] = NEW_VFRAME;
476         data[3] = NEW_VFRAME;
477         data[4] = NEW_VFRAME;
478
479         for(int i = 0; i < 5; i++)
480         {
481 #if 0
482                 int in_x1;
483                 int in_x2;
484
485                 switch(region)
486                 {
487                         case 0:
488                                 in_x1 = 0;
489                                 in_x2 = default_data.get_w();
490                                 break;
491
492                         case 1:
493                                 in_x1 = (int)(bg_data[i]->get_w() * 0.33);
494                                 in_x2 = in_x1 + default_data.get_w();
495                                 break;
496
497                         case 2:
498                                 in_x1 = bg_data[i]->get_w() - default_data.get_w();
499                                 in_x2 = in_x1 + default_data.get_w();
500                                 break;
501                 }
502 #endif
503                 overlay(data[i],
504                         bg_data[i]);
505                 overlay(data[i],
506                         &default_data);
507         }
508 }
509
510
511
512
513
514
515
516
517 void Theme::build_button(VFrame** &data,
518         unsigned char *png_overlay,
519         VFrame *up_vframe,
520         VFrame *hi_vframe,
521         VFrame *dn_vframe)
522 {
523         if(!png_overlay) return;
524         VFramePng default_data(png_overlay);
525
526         if(!up_vframe || !hi_vframe || !dn_vframe) return;
527         data = new VFrame*[3];
528         data[0] = NEW_VFRAME;
529         data[1] = NEW_VFRAME;
530         data[2] = NEW_VFRAME;
531         data[0]->copy_from(up_vframe);
532         data[1]->copy_from(hi_vframe);
533         data[2]->copy_from(dn_vframe);
534         for(int i = 0; i < 3; i++)
535                 overlay(data[i],
536                         &default_data);
537 }
538
539 void Theme::build_button(VFrame** &data,
540         unsigned char *png_overlay,
541         VFrame *up_vframe,
542         VFrame *hi_vframe,
543         VFrame *dn_vframe,
544         VFrame *at_vframe)
545 {
546         if(!png_overlay) return;
547         VFramePng default_data(png_overlay);
548
549         if(!up_vframe || !hi_vframe || !dn_vframe) return;
550         data = new VFrame*[4];
551         data[0] = NEW_VFRAME;
552         data[1] = NEW_VFRAME;
553         data[2] = NEW_VFRAME;
554         data[3] = NEW_VFRAME;
555         data[0]->copy_from(up_vframe);
556         data[1]->copy_from(hi_vframe);
557         data[2]->copy_from(dn_vframe);
558         data[2]->copy_from(at_vframe);
559         for(int i = 0; i < 4; i++)
560                 overlay(data[i],
561                         &default_data);
562 }
563
564 void Theme::build_toggle(VFrame** &data,
565         unsigned char *png_overlay,
566         VFrame *up_vframe,
567         VFrame *hi_vframe,
568         VFrame *checked_vframe,
569         VFrame *dn_vframe,
570         VFrame *checkedhi_vframe)
571 {
572         if(!png_overlay ||
573                 !up_vframe ||
574                 !hi_vframe ||
575                 !checked_vframe ||
576                 !dn_vframe ||
577                 !checkedhi_vframe) return;
578         VFramePng default_data(png_overlay);
579         data = new VFrame*[5];
580         data[0] = NEW_VFRAME;
581         data[1] = NEW_VFRAME;
582         data[2] = NEW_VFRAME;
583         data[3] = NEW_VFRAME;
584         data[4] = NEW_VFRAME;
585         data[0]->copy_from(up_vframe);
586         data[1]->copy_from(hi_vframe);
587         data[2]->copy_from(checked_vframe);
588         data[3]->copy_from(dn_vframe);
589         data[4]->copy_from(checkedhi_vframe);
590         for(int i = 0; i < 5; i++)
591                 overlay(data[i],
592                         &default_data);
593 }
594
595
596 void Theme::get_mwindow_sizes(MWindowGUI *gui, int w, int h)
597 {
598         mbuttons_x = 0;
599         mbuttons_y = gui->menu_h() + 1;
600         mbuttons_w = gui->menu_w();
601         mbuttons_h = get_image("mbutton_bg")->get_h();
602         mclock_x = 10;
603         mclock_y = mbuttons_y - 1 + mbuttons_h + widget_border;
604         mclock_w = get_image("clock_bg")->get_w() - 40;
605         mclock_h = get_image("clock_bg")->get_h();
606         mtimebar_x = get_image("patchbay_bg")->get_w();
607         mtimebar_y = mbuttons_y - 1 + mbuttons_h;
608         mtimebar_w = w - mtimebar_x;
609         mtimebar_h = get_image("timebar_bg")->get_h();
610         mzoom_h = 25;
611         mzoom_x = 0;
612         mzoom_y = h - get_image("statusbar")->get_h();
613         mzoom_w = w;
614         mstatus_x = 0;
615         mstatus_y = mzoom_y + mzoom_h;
616         mstatus_w = w;
617         mstatus_h = h - mstatus_y;
618         mstatus_message_x = 10;
619         mstatus_message_y = 5;
620         mstatus_progress_x = mstatus_w - statusbar_cancel_data[0]->get_w() - 240;
621         mstatus_progress_y = mstatus_h - BC_WindowBase::get_resources()->progress_images[0]->get_h() - 3;
622         mstatus_progress_w = 230;
623         mstatus_cancel_x = mstatus_w - statusbar_cancel_data[0]->get_w();
624         mstatus_cancel_y = mstatus_h - statusbar_cancel_data[0]->get_h();
625         mcanvas_x = 0;
626         mcanvas_y = mbuttons_y - 1 + mbuttons_h;
627         mcanvas_w = w;
628         mcanvas_h = mzoom_y - mtimebar_y;
629         control_pixels = (mcanvas_w * control_pixels) / 1000;
630         patchbay_x = 0;
631         patchbay_y = mcanvas_y + mclock_h;
632         patchbay_w = get_image("patchbay_bg")->get_w();
633         patchbay_h = mcanvas_h - mclock_h;
634         pane_w = get_image_set("xpane")[0]->get_w();
635         pane_h = get_image_set("ypane")[0]->get_h();
636         pane_x = mcanvas_x + mcanvas_w;
637         pane_y = mcanvas_y + mcanvas_h;
638         mhscroll_x = 0;
639         mhscroll_y = mcanvas_y + mcanvas_h - BC_ScrollBar::get_span(SCROLL_HORIZ);
640         mhscroll_w = w - BC_ScrollBar::get_span(SCROLL_VERT);
641         mvscroll_x = mcanvas_x + mcanvas_w;
642         mvscroll_y = mcanvas_y;
643         mvscroll_h = mcanvas_h;
644 }
645
646 void Theme::get_pane_sizes(MWindowGUI *gui,
647         int *view_x,
648         int *view_y,
649         int *view_w,
650         int *view_h,
651         int number,
652         int x,
653         int y,
654         int w,
655         int h)
656 {
657         *view_x = x;
658         *view_y = y;
659         *view_w = w;
660         *view_h = h;
661
662 // patchbay
663         if(number == TOP_LEFT_PANE ||
664                 number == BOTTOM_LEFT_PANE)
665         {
666                 *view_x += patchbay_w;
667                 *view_w -= patchbay_w;
668         }
669
670 // timebar
671         if(number == TOP_LEFT_PANE ||
672                 number == TOP_RIGHT_PANE)
673         {
674                 *view_y += mtimebar_h;
675                 *view_h -= mtimebar_h;
676         }
677
678 // samplescroll
679         if(number == BOTTOM_LEFT_PANE ||
680                 number == BOTTOM_RIGHT_PANE ||
681                 gui->horizontal_panes() ||
682                 gui->total_panes() == 1)
683         {
684                 *view_h -= BC_ScrollBar::get_span(SCROLL_HORIZ);
685         }
686
687 // trackscroll
688         if(number == TOP_RIGHT_PANE ||
689                 number == BOTTOM_RIGHT_PANE ||
690                 gui->vertical_panes() ||
691                 gui->total_panes() == 1)
692         {
693                 *view_w -= BC_ScrollBar::get_span(SCROLL_VERT);
694         }
695 }
696
697 void Theme::draw_mwindow_bg(MWindowGUI *gui)
698 {
699 }
700
701
702 void Theme::get_cwindow_sizes(CWindowGUI *gui, int cwindow_controls)
703 {
704         int total_buttons = !use_commercials ? 15 : 16;
705         int edit_w = EditPanel::calculate_w(mwindow, 1, total_buttons);
706         int transport_w = PlayTransport::get_transport_width(mwindow) + toggle_margin;
707         int zoom_w = ZoomPanel::calculate_w(czoom_w);
708         int status_w = get_image("cwindow_active")->get_w();
709 // Space between buttons & status icon
710         int division_w = 24;
711
712         ctimebar_h = 16;
713
714         if(cwindow_controls)
715         {
716 SET_TRACE
717                 if(mwindow->edl->session->cwindow_meter)
718                 {
719                         cmeter_x = mwindow->session->cwindow_w -
720                                 MeterPanel::get_meters_width(this,
721                                         mwindow->edl->session->audio_channels,
722                                         mwindow->edl->session->cwindow_meter);
723                 }
724                 else
725                 {
726                         cmeter_x = mwindow->session->cwindow_w + widget_border;
727                 }
728
729                 int buttons_h;
730
731                 if(edit_w +
732                         widget_border * 2 +
733                         transport_w + widget_border +
734                         zoom_w + widget_border +
735                         division_w +
736                         status_w > cmeter_x)
737                 {
738                         buttons_h = get_image("cbuttons_left")->get_h();
739
740                         cedit_x = widget_border;
741                         cedit_y = mwindow->session->cwindow_h -
742                                 buttons_h +
743                                 ctimebar_h +
744                                 widget_border;
745
746                         ctransport_x = widget_border;
747                         ctransport_y = mwindow->session->cwindow_h -
748                                 get_image_set("autokeyframe")[0]->get_h() -
749                                 widget_border;
750
751                         czoom_x = ctransport_x + transport_w + widget_border;
752                         czoom_y = ctransport_y + widget_border;
753
754                         cstatus_x = 426;
755                         cstatus_y = mwindow->session->cwindow_h -
756                                 get_image("cwindow_active")->get_h() - 30;
757                 }
758                 else
759                 {
760                         buttons_h = ctimebar_h +
761                                 widget_border +
762                                 EditPanel::calculate_h(mwindow) +
763                                 widget_border;
764                         ctransport_x = widget_border;
765                         ctransport_y = mwindow->session->cwindow_h -
766                                 buttons_h +
767                                 ctimebar_h +
768                                 widget_border;
769
770                         cedit_x = ctransport_x + transport_w + widget_border;
771                         cedit_y = ctransport_y;
772
773                         czoom_x = cedit_x + edit_w + widget_border;
774                         czoom_y = cedit_y + widget_border;
775 //printf("Theme::get_cwindow_sizes %d %d %d\n", __LINE__, czoom_x, zoom_w);
776                         cstatus_x = czoom_x + zoom_w + division_w;
777                         cstatus_y = ctransport_y;
778                 }
779
780
781                 ccomposite_x = 0;
782                 ccomposite_y = 5;
783                 ccomposite_w = get_image("cpanel_bg")->get_w();
784                 ccomposite_h = mwindow->session->cwindow_h - buttons_h;
785
786
787
788
789
790
791
792                 ccanvas_x = ccomposite_x + ccomposite_w;
793                 ccanvas_y = 0;
794                 ccanvas_h = ccomposite_h;
795
796
797                 ccanvas_w = cmeter_x - ccanvas_x - widget_border;
798 SET_TRACE
799         }
800         else
801 // no controls
802         {
803 SET_TRACE
804                 ccomposite_x = -get_image("cpanel_bg")->get_w();
805                 ccomposite_y = 0;
806                 ccomposite_w = get_image("cpanel_bg")->get_w();
807                 ccomposite_h = mwindow->session->cwindow_h - get_image("cbuttons_left")->get_h();
808
809                 cedit_x = 10;
810                 cedit_y = mwindow->session->cwindow_h + 17;
811                 ctransport_x = 10;
812                 ctransport_y = cedit_y + 40;
813                 ccanvas_x = 0;
814                 ccanvas_y = 0;
815                 ccanvas_w = mwindow->session->cwindow_w;
816                 ccanvas_h = mwindow->session->cwindow_h;
817                 cmeter_x = mwindow->session->cwindow_w;
818                 cstatus_x = mwindow->session->cwindow_w;
819                 cstatus_y = mwindow->session->cwindow_h;
820                 czoom_x = mwindow->session->cwindow_w;
821                 czoom_y = mwindow->session->cwindow_h;
822 SET_TRACE
823         }
824
825 SET_TRACE
826
827
828         cmeter_y = widget_border;
829         cmeter_h = mwindow->session->cwindow_h - cmeter_y - widget_border;
830
831 //      ctimebar_x = ccanvas_x;
832 //      ctimebar_y = ccanvas_y + ccanvas_h;
833 //      ctimebar_w = ccanvas_w;
834         ctimebar_x = 0;
835         ctimebar_y = ccanvas_y + ccanvas_h;
836         ctimebar_w = mwindow->session->cwindow_w;
837         if(mwindow->edl->session->cwindow_meter)
838         {
839                 ctimebar_w = cmeter_x - widget_border;
840         }
841
842 SET_TRACE
843 }
844
845
846
847
848
849 void Theme::draw_awindow_bg(AWindowGUI *gui)
850 {
851         gui->clear_box(0, 0, mwindow->session->awindow_w, mwindow->session->awindow_h);
852         gui->flash();
853 }
854
855 void Theme::draw_vwindow_bg(VWindowGUI *gui)
856 {
857 //      gui->clear_box(0,
858 //              0,
859 //              mwindow->session->vwindow_w,
860 //              mwindow->session->vwindow_h);
861 // // Timebar
862 //      gui->draw_3segmenth(vtimebar_x,
863 //              vtimebar_y,
864 //              vtimebar_w,
865 //              vtimebar_bg_data,
866 //              0);
867 //      gui->flash();
868 }
869
870
871 void Theme::draw_cwindow_bg(CWindowGUI *gui)
872 {
873         gui->clear_box(0, 0, mwindow->session->cwindow_w, mwindow->session->cwindow_h);
874         gui->flash();
875 }
876
877 void Theme::draw_lwindow_bg(LevelWindowGUI *gui)
878 {
879         gui->clear_box(0, 0, mwindow->session->lwindow_w, mwindow->session->lwindow_h);
880         gui->flash();
881 }
882
883
884 void Theme::draw_rmonitor_bg(RecordMonitorGUI *gui)
885 {
886         gui->clear_box(0, 0, mwindow->session->rmonitor_w, mwindow->session->rmonitor_h);
887         gui->flash();
888 }
889
890
891 void Theme::draw_rwindow_bg(RecordGUI *gui)
892 {
893         gui->clear_box(0, 0, mwindow->session->rwindow_w, mwindow->session->rwindow_h);
894 }
895
896
897 void Theme::draw_resource_bg(TrackCanvas *canvas,
898         ResourcePixmap *pixmap,
899         int edit_x,
900         int edit_w,
901         int pixmap_x,
902         int x1,
903         int y1,
904         int x2,
905         int y2)
906 {
907         VFrame *image;
908
909         switch(mwindow->edl->local_session->zoom_track)
910         {
911                 case 1024: image = get_image("resource1024");  break;
912                 case 512: image = get_image("resource512");  break;
913                 case 256: image = get_image("resource256");  break;
914                 case 128: image = get_image("resource128");  break;
915                 case 64:  image = get_image("resource64");   break;
916                 default:
917                 case 32:  image = get_image("resource32");   break;
918         }
919
920         canvas->draw_3segmenth(x1,
921                 y1,
922                 x2 - x1,
923                 edit_x - pixmap_x,
924                 edit_w,
925                 image,
926                 pixmap);
927 }
928
929
930 void Theme::get_vwindow_sizes(VWindowGUI *gui)
931 {
932         int edit_w = EditPanel::calculate_w(mwindow, 0, 10);
933         int transport_w = PlayTransport::get_transport_width(mwindow) + toggle_margin;
934 // Space between buttons & time
935         int division_w = 30;
936         vtime_w = 150;
937         vtimebar_h = 16;
938         int vtime_border = 15;
939
940         vmeter_y = widget_border;
941         vmeter_h = mwindow->session->vwindow_h - cmeter_y - widget_border;
942
943         int buttons_h;
944         if(mwindow->edl->session->vwindow_meter)
945         {
946                 vmeter_x = mwindow->session->vwindow_w -
947                         MeterPanel::get_meters_width(this,
948                                 mwindow->edl->session->audio_channels,
949                                 mwindow->edl->session->vwindow_meter);
950         }
951         else
952         {
953                 vmeter_x = mwindow->session->vwindow_w + widget_border;
954         }
955
956         vcanvas_x = 0;
957         vcanvas_y = 0;
958         vcanvas_w = vmeter_x - vcanvas_x - widget_border;
959
960         if(edit_w +
961                 widget_border * 2 +
962                 transport_w + widget_border +
963                 vtime_w + division_w +
964                 vtime_border > vmeter_x)
965         {
966                 buttons_h = get_image("vbuttons_left")->get_h();
967                 vedit_x = widget_border;
968                 vedit_y = mwindow->session->vwindow_h -
969                         buttons_h +
970                         vtimebar_h +
971                         widget_border;
972
973                 vtransport_x = widget_border;
974                 vtransport_y = mwindow->session->vwindow_h -
975                         get_image_set("autokeyframe")[0]->get_h() -
976                         widget_border;
977
978                 vdivision_x = 280;
979                 vtime_x = vdivision_x;
980                 vtime_y = vedit_y + 20;
981         }
982         else
983         {
984                 buttons_h = vtimebar_h +
985                         widget_border +
986                         EditPanel::calculate_h(mwindow) +
987                         widget_border;
988                 vtransport_x = widget_border;
989                 vtransport_y = mwindow->session->vwindow_h -
990                         buttons_h +
991                         vtimebar_h +
992                         widget_border;
993
994                 vedit_x = vtransport_x + transport_w + widget_border;
995                 vedit_y = vtransport_y;
996
997                 vdivision_x = vedit_x + edit_w + division_w;
998                 vtime_x = vdivision_x + vtime_border;
999                 vtime_y = vedit_y + widget_border;
1000         }
1001
1002
1003 //      vtimebar_x = vcanvas_x;
1004 //      vtimebar_y = vcanvas_y + vcanvas_h;
1005 //      vtimebar_w = vcanvas_w;
1006
1007         vcanvas_h = mwindow->session->vwindow_h - buttons_h;
1008         vtimebar_x = 0;
1009         vtimebar_y = vcanvas_y + vcanvas_h;
1010         vtimebar_w = vmeter_x - widget_border;
1011
1012 }
1013
1014
1015 void Theme::get_awindow_sizes(AWindowGUI *gui)
1016 {
1017         abuttons_x = 0;
1018         abuttons_y = 0;
1019         afolders_x = 0;
1020 //      afolders_y = deletedisk_data[0]->get_h();
1021         afolders_y = 0;
1022         afolders_w = mwindow->session->afolders_w;
1023         afolders_h = mwindow->session->awindow_h - afolders_y;
1024         adivider_x = afolders_x + afolders_w;
1025         adivider_y = 0;
1026         adivider_w = 5;
1027         adivider_h = afolders_h;
1028         alist_x = afolders_x + afolders_w + 5;
1029         alist_y = afolders_y;
1030         alist_w = mwindow->session->awindow_w - alist_x;
1031         alist_h = afolders_h;
1032 }
1033
1034 void Theme::get_rmonitor_sizes(int do_audio,
1035         int do_video,
1036         int do_channel,
1037         int do_interlace,
1038         int do_avc,
1039         int audio_channels)
1040 {
1041         int x = 10;
1042         int y = 3;
1043
1044
1045         if(do_avc)
1046         {
1047                 rmonitor_canvas_y = 30;
1048                 rmonitor_tx_x = 10;
1049                 rmonitor_tx_y = 0;
1050         }
1051         else
1052         {
1053                 rmonitor_canvas_y = 0;
1054                 rmonitor_tx_x = 0;
1055                 rmonitor_tx_y = 0;
1056         }
1057
1058
1059         if(do_channel)
1060         {
1061                 y = 5;
1062                 rmonitor_channel_x = x;
1063                 rmonitor_channel_y = 5;
1064                 x += 280;
1065                 rmonitor_canvas_y = 35;
1066         }
1067
1068         if(do_interlace)
1069         {
1070                 y = 4;
1071                 rmonitor_interlace_x = x;
1072                 rmonitor_interlace_y = y;
1073         }
1074
1075
1076         if(do_audio)
1077         {
1078                 if(do_video)
1079                 {
1080                         rmonitor_meter_x = mwindow->session->rmonitor_w -
1081                                 MeterPanel::get_meters_width(this, audio_channels, 1);
1082                         rmonitor_meter_w = mwindow->session->rmonitor_w;
1083                 }
1084                 else
1085                 {
1086                         rmonitor_meter_x = widget_border;
1087                         rmonitor_meter_w = mwindow->session->rmonitor_w - widget_border * 2;
1088                 }
1089
1090                 rmonitor_meter_y = 40;
1091                 rmonitor_meter_h = mwindow->session->rmonitor_h - 10 - rmonitor_meter_y;
1092         }
1093         else
1094         {
1095                 rmonitor_meter_x = mwindow->session->rmonitor_w;
1096         }
1097
1098         rmonitor_canvas_x = 0;
1099         rmonitor_canvas_w = rmonitor_meter_x - rmonitor_canvas_x;
1100         if(do_audio) rmonitor_canvas_w -= 10;
1101         rmonitor_canvas_h = mwindow->session->rmonitor_h - rmonitor_canvas_y;
1102
1103         if(!do_video && do_audio)
1104         {
1105                 rmonitor_meter_y -= 30;
1106                 rmonitor_meter_h += 30;
1107         }
1108
1109 }
1110
1111 void Theme::get_recordgui_sizes(RecordGUI *gui, int w, int h)
1112 {
1113 }
1114
1115 void Theme::get_batchrender_sizes(BatchRenderGUI *gui,
1116         int w,
1117         int h)
1118 {
1119         batchrender_x1 = 10;
1120         batchrender_x2 = 300;
1121         batchrender_x3 = 400;
1122 }
1123
1124 void Theme::get_plugindialog_sizes()
1125 {
1126         int x = 10, y = 30;
1127         plugindialog_new_x = x;
1128         plugindialog_new_y = y;
1129         plugindialog_shared_x = mwindow->session->plugindialog_w / 3;
1130         plugindialog_shared_y = y;
1131         plugindialog_module_x = mwindow->session->plugindialog_w * 2 / 3;
1132         plugindialog_module_y = y;
1133
1134         plugindialog_new_w = plugindialog_shared_x - plugindialog_new_x - 10;
1135         plugindialog_new_h = mwindow->session->plugindialog_h - 100;
1136         plugindialog_shared_w = plugindialog_module_x - plugindialog_shared_x - 10;
1137         plugindialog_shared_h = mwindow->session->plugindialog_h - 100;
1138         plugindialog_module_w = mwindow->session->plugindialog_w - plugindialog_module_x - 10;
1139         plugindialog_module_h = mwindow->session->plugindialog_h - 100;
1140
1141         plugindialog_newattach_x = plugindialog_new_x + 20;
1142         plugindialog_newattach_y = plugindialog_new_y + plugindialog_new_h + 10;
1143         plugindialog_sharedattach_x = plugindialog_shared_x + 20;
1144         plugindialog_sharedattach_y = plugindialog_shared_y + plugindialog_shared_h + 10;
1145         plugindialog_moduleattach_x = plugindialog_module_x + 20;
1146         plugindialog_moduleattach_y = plugindialog_module_y + plugindialog_module_h + 10;
1147 }
1148
1149 // void Theme::get_presetdialog_sizes(PresetsWindow *gui)
1150 // {
1151 //      int x = window_border;
1152 //      int y = window_border + BC_Title::calculate_h(gui, "P") + widget_border;
1153 //
1154 //      presets_list_x = x;
1155 //      presets_list_y = y;
1156 //      presets_list_w = mwindow->session->presetdialog_w / 2;
1157 //      presets_list_h = mwindow->session->presetdialog_h -
1158 //              BC_OKButton::calculate_h() -
1159 //              presets_list_y -
1160 //              widget_border -
1161 //              window_border;
1162 //      presets_text_x = presets_list_x + presets_list_w + widget_border;
1163 //      presets_text_y = y;
1164 //      presets_text_w = mwindow->session->presetdialog_w - presets_text_x - window_border;
1165 //      y += BC_TextBox::calculate_h(gui,
1166 //              MEDIUMFONT,
1167 //              1,
1168 //              1) + widget_border;
1169 //
1170 //      presets_delete_x = presets_text_x;
1171 //      presets_delete_y = y;
1172 //      y += BC_GenericButton::calculate_h() + widget_border;
1173 //
1174 //      presets_save_x = presets_text_x;
1175 //      presets_save_y = y;
1176 //      y += BC_GenericButton::calculate_h() + widget_border;
1177 //
1178 //      presets_apply_x = presets_text_x;
1179 //      presets_apply_y = y;
1180 //      y += BC_GenericButton::calculate_h();
1181 // }
1182
1183 void Theme::get_keyframedialog_sizes(KeyFrameWindow *gui)
1184 {
1185         int x = widget_border;
1186         int y = window_border +
1187                 BC_Title::calculate_h(gui, "P", LARGEFONT) +
1188                 widget_border;
1189
1190         keyframe_list_x = x;
1191         keyframe_list_y = y;
1192         keyframe_list_w = mwindow->session->keyframedialog_w - widget_border * 2;
1193         keyframe_list_h = mwindow->session->keyframedialog_h - widget_border -
1194                 widget_border - keyframe_list_y - BC_Title::calculate_h(gui, "P") -
1195                 widget_border - BC_TextBox::calculate_h(gui, MEDIUMFONT, 1, 1) -
1196                 widget_border - BC_Title::calculate_h(gui, "P") -
1197                 widget_border - BC_OKButton::calculate_h() -
1198                 window_border;
1199 //      keyframe_text_x = keyframe_list_x + keyframe_list_w + widget_border;
1200 //      keyframe_text_y = y;
1201 //      keyframe_text_w = mwindow->session->keyframedialog_w - keyframe_text_x - window_border;
1202 //      y += BC_TextBox::calculate_h(gui,
1203 //              MEDIUMFONT,
1204 //              1,
1205 //              1) + widget_border;
1206 //
1207
1208         y += keyframe_list_h + BC_Title::calculate_h(gui, "P") + widget_border + widget_border;
1209         keyframe_value_x = keyframe_list_x;
1210         keyframe_value_y = y;
1211         keyframe_value_w = keyframe_list_w;
1212         y += BC_TextBox::calculate_h(gui,
1213                 MEDIUMFONT,
1214                 1,
1215                 1) + widget_border;
1216
1217         keyframe_all_x = keyframe_value_x;
1218         keyframe_all_y = y;
1219 }
1220
1221
1222 void Theme::get_menueffect_sizes(int use_list)
1223 {
1224         if(use_list)
1225         {
1226                 menueffect_list_x = 10;
1227                 menueffect_list_y = 10;
1228                 menueffect_list_w = mwindow->session->menueffect_w - 400;
1229                 menueffect_list_h = mwindow->session->menueffect_h -
1230                         menueffect_list_y -
1231                         BC_OKButton::calculate_h() - 10;
1232         }
1233         else
1234         {
1235                 menueffect_list_x = 0;
1236                 menueffect_list_y = 10;
1237                 menueffect_list_w = 0;
1238                 menueffect_list_h = 0;
1239         }
1240
1241         menueffect_file_x = menueffect_list_x + menueffect_list_w + 10;
1242         menueffect_file_y = 10;
1243
1244         menueffect_tools_x = menueffect_file_x;
1245         menueffect_tools_y = menueffect_file_y + 20;
1246 }
1247
1248 void Theme::get_preferences_sizes()
1249 {
1250 }
1251
1252 void Theme::draw_preferences_bg(PreferencesWindow *gui)
1253 {
1254 }
1255
1256 void Theme::get_new_sizes(NewWindow *gui)
1257 {
1258 }
1259
1260 void Theme::draw_new_bg(NewWindow *gui)
1261 {
1262 }
1263
1264 void Theme::draw_setformat_bg(SetFormatWindow *window)
1265 {
1266 }
1267
1268
1269
1270
1271
1272
1273