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