1 #include "awindowgui.h"
4 #include "cwindowgui.h"
6 #include "edlsession.h"
7 #include "levelwindowgui.h"
9 #include "localsession.h"
11 #include "mainsession.h"
13 #include "meterpanel.h"
14 #include "mwindowgui.h"
16 #include "overlayframe.h"
18 #include "playtransport.h"
19 #include "recordgui.h"
20 #include "recordmonitor.h"
21 #include "resourcepixmap.h"
22 #include "statusbar.h"
25 #include "trackcanvas.h"
27 #include "vwindowgui.h"
34 #define _(String) gettext(String)
35 #define gettext_noop(String) String
36 #define N_(String) gettext_noop (String)
46 theme_title = DEFAULT_THEME;
51 BC_WindowBase::get_resources()->bg_color = BLOND;
52 BC_WindowBase::get_resources()->button_up = 0xffc000;
53 BC_WindowBase::get_resources()->button_highlighted = 0xffe000;
54 BC_WindowBase::get_resources()->recursive_resizing = 0;
67 #include "data/about_png.h"
68 about_bg = new VFrame(about_png);
69 #include "data/microsoft_credit_png.h"
70 about_microsoft = new VFrame(microsoft_credit_png);
80 // Need to delete everything here
83 //printf("Theme::~Theme 1\n");
86 aspect_ratios.remove_all_objects();
87 frame_rates.remove_all_objects();
88 frame_sizes.remove_all_objects();
89 sample_rates.remove_all_objects();
90 zoom_values.remove_all_objects();
95 // delete about_microsoft;
96 // delete [] appendasset_data;
97 // delete [] append_data;
98 // delete [] arrow_data;
99 // delete [] asset_append_data;
100 // delete [] asset_disk_data;
101 // delete [] asset_index_data;
102 // delete [] asset_info_data;
103 // delete [] asset_project_data;
104 // delete [] autokeyframe_data;
105 // delete awindow_icon;
106 // delete [] bottom_justify;
107 // delete [] browse_data;
108 // delete [] calibrate_data;
109 // delete [] camera_data;
110 // delete camerakeyframe_data;
111 // delete [] cancel_data;
112 // delete [] center_justify;
113 // delete [] chain_data;
114 // delete channel_bg_data;
115 // delete [] channel_data;
116 // delete channel_position_data;
118 // delete [] copy_data;
119 // delete [] crop_data;
120 // delete [] cut_data;
121 // delete cwindow_icon;
122 // delete [] delete_all_indexes_data;
123 // delete [] deletebin_data;
124 // delete [] delete_data;
125 // delete [] deletedisk_data;
126 // delete [] deleteproject_data;
127 // delete [] detach_data;
128 // delete [] dntriangle_data;
129 // delete [] drawpatch_data;
130 // delete [] duplex_data;
131 // delete [] edit_data;
132 // delete [] edithandlein_data;
133 // delete [] edithandleout_data;
134 // delete [] end_data;
135 // delete [] expandpatch_data;
136 // delete [] extract_data;
137 // delete [] fastfwd_data;
138 // delete [] fastrev_data;
139 // delete [] fit_data;
140 // delete [] forward_data;
141 // delete [] framefwd_data;
142 // delete [] framerev_data;
143 // delete [] gangpatch_data;
144 // delete [] ibeam_data;
145 // delete [] in_data;
146 // delete [] indelete_data;
147 // delete [] infoasset_data;
148 // delete [] in_point;
149 // delete [] insert_data;
150 // delete keyframe_data;
151 // delete [] labelbutton_data;
152 // delete [] label_toggle;
153 // delete [] left_justify;
154 // delete [] lift_data;
155 // delete [] magnify_button_data;
156 // delete [] magnify_data;
157 // delete [] mask_data;
158 // delete maskkeyframe_data;
159 // delete [] middle_justify;
160 // delete modekeyframe_data;
161 // delete [] movedn_data;
162 // delete [] moveup_data;
163 // delete [] mutepatch_data;
164 // delete mwindow_icon;
165 // delete [] newbin_data;
166 // delete [] nextlabel_data;
167 // delete [] no_data;
168 // delete [] options_data;
169 // delete [] out_data;
170 // delete [] outdelete_data;
171 // delete [] out_point;
172 // delete [] over_button;
173 // delete [] overwrite_data;
174 // delete pankeyframe_data;
175 // delete [] pasteasset_data;
176 // delete [] paste_data;
177 // delete patchbay_bg;
178 // delete [] pause_data;
179 // delete [] paused_data;
180 // delete [] picture_data;
181 // delete [] playpatch_data;
182 // delete plugin_bg_data;
183 // delete [] presentation_data;
184 // delete [] presentation_loop;
185 // delete [] presentation_stop;
186 // delete [] prevlabel_data;
187 // delete [] proj_data;
188 // delete projectorkeyframe_data;
189 // delete [] protect_data;
190 // delete [] rec_data;
191 // delete [] recframe_data;
192 // delete record_icon;
193 // delete [] recordpatch_data;
194 // delete [] redo_data;
195 // delete [] redrawindex_data;
196 // delete [] renamebin_data;
197 // delete [] reset_data;
198 // delete resource1024_bg_data;
199 // delete resource128_bg_data;
200 // delete resource256_bg_data;
201 // delete resource32_bg_data;
202 // delete resource512_bg_data;
203 // delete resource64_bg_data;
204 // delete [] reverse_data;
205 // delete [] rewind_data;
206 // delete [] right_justify;
207 // delete [] select_data;
208 // delete [] show_meters;
209 // delete [] splice_data;
210 // delete [] start_over_data;
211 // delete [] statusbar_cancel_data;
212 // delete [] stop_data;
213 // delete [] stoprec_data;
214 // delete timebar_bg_data;
215 // delete timebar_brender_data;
216 // delete timebar_view_data;
217 // delete title_bg_data;
218 // delete [] titlesafe_data;
219 // delete [] toclip_data;
220 // delete [] tool_data;
221 // delete [] top_justify;
222 // delete [] transition_data;
223 // delete [] undo_data;
224 // delete [] uptriangle_data;
225 // delete [] viewasset_data;
226 // delete vtimebar_bg_data;
227 // delete vwindow_icon;
228 // delete [] wrench_data;
229 // delete [] yes_data;
230 //printf("Theme::~Theme 2\n");
233 void Theme::flush_images()
235 if(data_buffer) delete [] data_buffer;
236 if(contents_buffer) delete [] contents_buffer;
239 contents.remove_all();
242 void Theme::initialize()
247 unsigned char* Theme::get_image(char *title)
252 FILE *fd = fopen(path, "r");
256 fprintf(stderr, _("Theme::get_image: %s when opening %s\n"), strerror(errno), path);
258 int data_offset, contents_offset;
263 fseek(fd, -8, SEEK_END);
264 total_bytes = ftell(fd);
265 fread(&data_offset, 1, 4, fd);
266 fread(&contents_offset, 1, 4, fd);
269 fseek(fd, data_offset, SEEK_SET);
270 data_size = contents_offset - data_offset;
271 data_buffer = new char[data_size];
272 fread(data_buffer, 1, data_size, fd);
274 fseek(fd, contents_offset, SEEK_SET);
275 contents_size = total_bytes - contents_offset;
276 contents_buffer = new char[contents_size];
277 fread(contents_buffer, 1, contents_size, fd);
279 char *start_of_title = contents_buffer;
280 for(int i = 0; i < contents_size; )
282 if(contents_buffer[i] == 0)
284 contents.append(start_of_title);
286 offsets.append(*(int*)(contents_buffer + i));
288 start_of_title = contents_buffer + i;
296 if(last_image && !strcasecmp(last_image, title))
298 return (unsigned char*)(data_buffer + last_offset);
301 for(int i = 0; i < contents.total; i++)
303 if(!strcasecmp(contents.values[i], title))
305 last_offset = offsets.values[i];
306 last_image = contents.values[i];
307 return (unsigned char*)(data_buffer + offsets.values[i]);
311 fprintf(stderr, _("Theme::get_image: %s not found.\n"), title);
316 void Theme::build_menus()
320 aspect_ratios.append(new BC_ListBoxItem("3:2"));
321 aspect_ratios.append(new BC_ListBoxItem("4:3"));
322 aspect_ratios.append(new BC_ListBoxItem("16:9"));
323 aspect_ratios.append(new BC_ListBoxItem("2.10:1"));
324 aspect_ratios.append(new BC_ListBoxItem("2.20:1"));
325 aspect_ratios.append(new BC_ListBoxItem("2.25:1"));
326 aspect_ratios.append(new BC_ListBoxItem("2.30:1"));
327 aspect_ratios.append(new BC_ListBoxItem("2.35:1"));
328 aspect_ratios.append(new BC_ListBoxItem("2.66:1"));
329 frame_sizes.append(new BC_ListBoxItem("160x120"));
330 frame_sizes.append(new BC_ListBoxItem("240x180"));
331 frame_sizes.append(new BC_ListBoxItem("320x240"));
332 frame_sizes.append(new BC_ListBoxItem("360x240"));
333 frame_sizes.append(new BC_ListBoxItem("400x300"));
334 frame_sizes.append(new BC_ListBoxItem("512x384"));
335 frame_sizes.append(new BC_ListBoxItem("640x480"));
336 frame_sizes.append(new BC_ListBoxItem("720x480"));
337 frame_sizes.append(new BC_ListBoxItem("720x576"));
338 frame_sizes.append(new BC_ListBoxItem("1280x720"));
339 frame_sizes.append(new BC_ListBoxItem("960x1080"));
340 frame_sizes.append(new BC_ListBoxItem("1920x1080"));
341 frame_sizes.append(new BC_ListBoxItem("1920x1088"));
342 sample_rates.append(new BC_ListBoxItem("8000"));
343 sample_rates.append(new BC_ListBoxItem("16000"));
344 sample_rates.append(new BC_ListBoxItem("22050"));
345 sample_rates.append(new BC_ListBoxItem("32000"));
346 sample_rates.append(new BC_ListBoxItem("44100"));
347 sample_rates.append(new BC_ListBoxItem("48000"));
348 sample_rates.append(new BC_ListBoxItem("96000"));
349 sample_rates.append(new BC_ListBoxItem("192000"));
350 frame_rates.append(new BC_ListBoxItem("1"));
351 frame_rates.append(new BC_ListBoxItem("5"));
352 frame_rates.append(new BC_ListBoxItem("10"));
353 frame_rates.append(new BC_ListBoxItem("12"));
354 frame_rates.append(new BC_ListBoxItem("15"));
355 frame_rates.append(new BC_ListBoxItem("23.97"));
356 frame_rates.append(new BC_ListBoxItem("24"));
357 frame_rates.append(new BC_ListBoxItem("25"));
358 frame_rates.append(new BC_ListBoxItem("29.97"));
359 frame_rates.append(new BC_ListBoxItem("30"));
360 frame_rates.append(new BC_ListBoxItem("50"));
361 frame_rates.append(new BC_ListBoxItem("59.94"));
362 frame_rates.append(new BC_ListBoxItem("60"));
363 char string[BCTEXTLEN];
364 for(int i = 1; i < 17; i++)
366 sprintf(string, "%d", (int)pow(2, i));
367 zoom_values.append(new BC_ListBoxItem(string));
372 void Theme::overlay(VFrame *dst, VFrame *src, int in_x1, int in_x2)
376 unsigned char **in_rows;
377 unsigned char **out_rows;
381 w = MIN(src->get_w(), dst->get_w());
382 h = MIN(dst->get_h(), src->get_h());
389 h = MIN(dst->get_h(), src->get_h());
391 in_rows = src->get_rows();
392 out_rows = dst->get_rows();
394 switch(src->get_color_model())
397 switch(dst->get_color_model())
400 for(int i = 0; i < h; i++)
402 unsigned char *in_row = in_rows[i] + in_x1 * 4;
403 unsigned char *out_row = out_rows[i];
404 for(int j = 0; j < w; j++)
406 int opacity = in_row[3];
407 int transparency = 0xff - opacity;
408 out_row[0] = (in_row[0] * opacity + out_row[0] * transparency) / 0xff;
409 out_row[1] = (in_row[1] * opacity + out_row[1] * transparency) / 0xff;
410 out_row[2] = (in_row[2] * opacity + out_row[2] * transparency) / 0xff;
411 out_row[3] = MAX(in_row[3], out_row[3]);
418 for(int i = 0; i < h; i++)
420 unsigned char *in_row = in_rows[i] + in_x1 * 4;
421 unsigned char *out_row = out_rows[i];
422 for(int j = 0; j < w; j++)
424 int opacity = in_row[3];
425 int transparency = 0xff - opacity;
426 out_row[0] = (in_row[0] * opacity + out_row[0] * transparency) / 0xff;
427 out_row[1] = (in_row[1] * opacity + out_row[1] * transparency) / 0xff;
428 out_row[2] = (in_row[2] * opacity + out_row[2] * transparency) / 0xff;
439 void Theme::build_transport(VFrame** &data,
440 unsigned char *png_overlay,
444 if(!png_overlay) return;
445 VFrame default_data(png_overlay);
446 data = new VFrame*[3];
447 data[0] = new VFrame(0, default_data.get_w(), default_data.get_h(), BC_RGBA8888);
448 data[1] = new VFrame(0, default_data.get_w(), default_data.get_h(), BC_RGBA8888);
449 data[2] = new VFrame(0, default_data.get_w(), default_data.get_h(), BC_RGBA8888);
450 data[0]->clear_frame();
451 data[1]->clear_frame();
452 data[2]->clear_frame();
454 for(int i = 0; i < 3; i++)
458 if(!bg_data[i]) break;
464 in_x2 = default_data.get_w();
468 in_x1 = (int)(bg_data[i]->get_w() * 0.33);
469 in_x2 = in_x1 + default_data.get_w();
473 in_x1 = bg_data[i]->get_w() - default_data.get_w();
474 in_x2 = in_x1 + default_data.get_w();
495 void Theme::build_patches(VFrame** &data,
496 unsigned char *png_overlay,
500 if(!png_overlay || !bg_data) return;
501 VFrame default_data(png_overlay);
502 data = new VFrame*[5];
503 data[0] = new VFrame(0, default_data.get_w(), default_data.get_h(), BC_RGBA8888);
504 data[1] = new VFrame(0, default_data.get_w(), default_data.get_h(), BC_RGBA8888);
505 data[2] = new VFrame(0, default_data.get_w(), default_data.get_h(), BC_RGBA8888);
506 data[3] = new VFrame(0, default_data.get_w(), default_data.get_h(), BC_RGBA8888);
507 data[4] = new VFrame(0, default_data.get_w(), default_data.get_h(), BC_RGBA8888);
509 for(int i = 0; i < 5; i++)
518 in_x2 = default_data.get_w();
522 in_x1 = (int)(bg_data[i]->get_w() * 0.33);
523 in_x2 = in_x1 + default_data.get_w();
527 in_x1 = bg_data[i]->get_w() - default_data.get_w();
528 in_x2 = in_x1 + default_data.get_w();
546 void Theme::build_button(VFrame** &data,
547 unsigned char *png_overlay,
552 if(!png_overlay) return;
553 VFrame default_data(png_overlay);
555 if(!up_vframe || !hi_vframe || !dn_vframe) return;
556 data = new VFrame*[3];
557 data[0] = new VFrame(0, default_data.get_w(), default_data.get_h(), BC_RGBA8888);
558 data[1] = new VFrame(0, default_data.get_w(), default_data.get_h(), BC_RGBA8888);
559 data[2] = new VFrame(0, default_data.get_w(), default_data.get_h(), BC_RGBA8888);
560 data[0]->copy_from(up_vframe);
561 data[1]->copy_from(hi_vframe);
562 data[2]->copy_from(dn_vframe);
563 for(int i = 0; i < 3; i++)
568 void Theme::build_toggle(VFrame** &data,
569 unsigned char *png_overlay,
572 VFrame *checked_vframe,
574 VFrame *checkedhi_vframe)
581 !checkedhi_vframe) return;
582 VFrame default_data(png_overlay);
583 data = new VFrame*[5];
584 data[0] = new VFrame(0, default_data.get_w(), default_data.get_h(), BC_RGBA8888);
585 data[1] = new VFrame(0, default_data.get_w(), default_data.get_h(), BC_RGBA8888);
586 data[2] = new VFrame(0, default_data.get_w(), default_data.get_h(), BC_RGBA8888);
587 data[3] = new VFrame(0, default_data.get_w(), default_data.get_h(), BC_RGBA8888);
588 data[4] = new VFrame(0, default_data.get_w(), default_data.get_h(), BC_RGBA8888);
589 data[0]->copy_from(up_vframe);
590 data[1]->copy_from(hi_vframe);
591 data[2]->copy_from(checked_vframe);
592 data[3]->copy_from(dn_vframe);
593 data[4]->copy_from(checkedhi_vframe);
594 for(int i = 0; i < 5; i++)
599 #define TIMEBAR_HEIGHT 10
600 #define PATCHBAY_W 145
604 void Theme::get_mwindow_sizes(MWindowGUI *gui, int w, int h)
608 void Theme::draw_mwindow_bg(MWindowGUI *gui)
615 void Theme::draw_awindow_bg(AWindowGUI *gui)
617 gui->clear_box(0, 0, mwindow->session->awindow_w, mwindow->session->awindow_h);
621 void Theme::draw_vwindow_bg(VWindowGUI *gui)
625 // mwindow->session->vwindow_w,
626 // mwindow->session->vwindow_h);
628 // gui->draw_3segmenth(vtimebar_x,
637 void Theme::draw_cwindow_bg(CWindowGUI *gui)
639 gui->clear_box(0, 0, mwindow->session->cwindow_w, mwindow->session->cwindow_h);
643 void Theme::draw_lwindow_bg(LevelWindowGUI *gui)
645 gui->clear_box(0, 0, mwindow->session->lwindow_w, mwindow->session->lwindow_h);
650 void Theme::draw_rmonitor_bg(RecordMonitorGUI *gui)
652 gui->clear_box(0, 0, mwindow->session->rmonitor_w, mwindow->session->rmonitor_h);
657 void Theme::draw_rwindow_bg(RecordGUI *gui)
659 printf("Theme::draw_rwindow_bg 1\n");
660 gui->clear_box(0, 0, mwindow->session->rwindow_w, mwindow->session->rwindow_h);
664 void Theme::draw_resource_bg(TrackCanvas *canvas,
665 ResourcePixmap *pixmap,
676 switch(mwindow->edl->local_session->zoom_track)
678 case 1024: image = resource1024_bg_data; break;
679 case 512: image = resource512_bg_data; break;
680 case 256: image = resource256_bg_data; break;
681 case 128: image = resource128_bg_data; break;
682 case 64: image = resource64_bg_data; break;
684 case 32: image = resource32_bg_data; break;
687 canvas->draw_3segmenth(x1,
696 void Theme::get_vwindow_sizes(VWindowGUI *gui)
700 void Theme::get_cwindow_sizes(CWindowGUI *gui)
704 void Theme::get_awindow_sizes(AWindowGUI *gui)
709 // afolders_y = deletedisk_data[0]->get_h();
711 afolders_w = mwindow->session->afolders_w;
712 afolders_h = mwindow->session->awindow_h - afolders_y;
713 adivider_x = afolders_x + afolders_w;
716 adivider_h = afolders_h;
717 alist_x = afolders_x + afolders_w + 5;
718 alist_y = afolders_y;
719 alist_w = mwindow->session->awindow_w - alist_x;
720 alist_h = afolders_h;
723 void Theme::get_recordmonitor_sizes(int do_audio,
728 rmonitor_source_x = 150;
729 rmonitor_source_y = 10;
730 rmonitor_interlace_x = 455;
731 rmonitor_interlace_y = 5;
732 rmonitor_channel_x = 0;
733 rmonitor_channel_y = 0;
737 rmonitor_meter_x = mwindow->session->rmonitor_w - MeterPanel::get_meters_width(mwindow->edl->session->audio_channels, 1);
738 rmonitor_meter_y = 40;
739 rmonitor_meter_h = mwindow->session->rmonitor_h - 10 - rmonitor_meter_y;
743 rmonitor_meter_x = mwindow->session->rmonitor_w;
748 rmonitor_canvas_x = 0;
749 rmonitor_canvas_y = 35;
750 rmonitor_canvas_w = rmonitor_meter_x - rmonitor_canvas_x;
751 if(do_audio) rmonitor_canvas_w -= 10;
752 rmonitor_canvas_h = mwindow->session->rmonitor_h - rmonitor_canvas_y;
753 rmonitor_channel_x = 220;
754 rmonitor_channel_y = 5;
758 void Theme::get_recordgui_sizes(RecordGUI *gui, int w, int h)
760 recordgui_status_x = 10;
761 recordgui_status_y = 10;
762 recordgui_status_x2 = 150;
763 recordgui_batch_x = 310;
764 recordgui_batch_y = 10;
765 recordgui_batchcaption_x = recordgui_batch_x + 110;
768 recordgui_transport_x = recordgui_batch_x;
769 recordgui_transport_y = recordgui_batch_y + 150;
771 recordgui_buttons_x = recordgui_batch_x - 50;
772 recordgui_buttons_y = recordgui_transport_y + 40;
773 recordgui_options_x = recordgui_buttons_x;
774 recordgui_options_y = recordgui_buttons_y + 40;
776 recordgui_batches_x = 10;
777 recordgui_batches_y = 270;
778 recordgui_batches_w = w - 20;
779 recordgui_batches_h = h - recordgui_batches_y - 90;
780 recordgui_loadmode_x = w / 2 - loadmode_w / 2;
781 recordgui_loadmode_y = h - 85;
783 recordgui_controls_x = 10;
784 recordgui_controls_y = h - 40;
787 void Theme::get_plugindialog_sizes()
790 plugindialog_new_x = x;
791 plugindialog_new_y = y;
792 plugindialog_shared_x = mwindow->session->plugindialog_w / 3;
793 plugindialog_shared_y = y;
794 plugindialog_module_x = mwindow->session->plugindialog_w * 2 / 3;
795 plugindialog_module_y = y;
797 plugindialog_new_w = plugindialog_shared_x - plugindialog_new_x - 10;
798 plugindialog_new_h = mwindow->session->plugindialog_h - 110;
799 plugindialog_shared_w = plugindialog_module_x - plugindialog_shared_x - 10;
800 plugindialog_shared_h = mwindow->session->plugindialog_h - 110;
801 plugindialog_module_w = mwindow->session->plugindialog_w - plugindialog_module_x - 10;
802 plugindialog_module_h = mwindow->session->plugindialog_h - 110;
804 plugindialog_newattach_x = plugindialog_new_x + 20;
805 plugindialog_newattach_y = plugindialog_new_y + plugindialog_new_h + 10;
806 plugindialog_sharedattach_x = plugindialog_shared_x + 20;
807 plugindialog_sharedattach_y = plugindialog_shared_y + plugindialog_shared_h + 10;
808 plugindialog_moduleattach_x = plugindialog_module_x + 20;
809 plugindialog_moduleattach_y = plugindialog_module_y + plugindialog_module_h + 10;
812 void Theme::get_menueffect_sizes(int use_list)
816 menueffect_list_x = 10;
817 menueffect_list_y = 10;
818 menueffect_list_w = mwindow->session->menueffect_w - 400;
819 menueffect_list_h = mwindow->session->menueffect_h - 70;
823 menueffect_list_x = 0;
824 menueffect_list_y = 10;
825 menueffect_list_w = 0;
826 menueffect_list_h = 0;
829 menueffect_file_x = menueffect_list_x + menueffect_list_w + 10;
830 menueffect_file_y = 10;
832 menueffect_tools_x = menueffect_file_x;
833 menueffect_tools_y = menueffect_file_y + 20;
836 void Theme::get_preferences_sizes()
840 void Theme::draw_preferences_bg(PreferencesWindow *gui)
844 void Theme::get_new_sizes(NewWindow *gui)
848 void Theme::draw_new_bg(NewWindow *gui)
852 void Theme::draw_setformat_bg(SetFormatWindow *window)