sams folder icons, snap drag, sort folders, in/out ptr bug, interp bg fix, filebox...
[goodguy/history.git] / cinelerra-5.1 / guicast / bcresources.C
index e370cbe7f50832e3ce409a728e9f5e359f1cc6d5..d2f0b7a912ff6cdbb5e6f68dfe0d5adab5ce6a15 100644 (file)
@@ -173,19 +173,63 @@ void BC_Resources::finit_font_defs()
        delete [] big_font_xft2;
 }
 
+
 suffix_to_type_t BC_Resources::suffix_to_type[] =
 {
-       { "m2v", ICON_FILM },
-       { "mov", ICON_FILM },
-       { "mp2", ICON_SOUND },
-       { "mp3", ICON_SOUND },
-       { "ac3", ICON_SOUND },
-       { "mpg", ICON_FILM },
-       { "vob", ICON_FILM },
-       { "ifo", ICON_FILM },
-       { "ts",  ICON_FILM },
-       { "vts", ICON_FILM },
-       { "wav", ICON_SOUND }
+    { "aac", ICON_SOUND },
+    { "ac3", ICON_SOUND },
+    { "dts", ICON_SOUND },
+    { "flac", ICON_SOUND },
+    { "mp2", ICON_SOUND },
+    { "mp3", ICON_SOUND },
+    { "wav", ICON_SOUND },
+    { "wma", ICON_SOUND },
+    { "wmv", ICON_SOUND },
+    { "avi", ICON_FILM },
+    { "bmp", ICON_FILM },
+    { "cr2", ICON_FILM },
+    { "dnxhd", ICON_FILM },
+    { "dvd", ICON_FILM },
+    { "dv", ICON_FILM },
+    { "f4v", ICON_FILM },
+    { "flv", ICON_FILM },
+    { "gif", ICON_FILM },
+    { "gxf", ICON_FILM },
+    { "h264", ICON_FILM },
+    { "h265", ICON_FILM },
+    { "hevc", ICON_FILM },
+    { "ifo", ICON_FILM },
+    { "jpeg", ICON_FILM },
+    { "jpg", ICON_FILM },
+    { "m2ts", ICON_FILM },
+    { "m2v", ICON_FILM },
+    { "m4v", ICON_FILM },
+    { "mkv", ICON_FILM },
+    { "mov", ICON_FILM },
+    { "mp4", ICON_FILM },
+    { "mpeg", ICON_FILM },
+    { "mpg", ICON_FILM },
+    { "mts", ICON_FILM },
+    { "mxf", ICON_FILM },
+    { "ogg", ICON_FILM },
+    { "ogv", ICON_FILM },
+    { "pcm", ICON_FILM },
+    { "pgm", ICON_FILM },
+    { "png", ICON_FILM },
+    { "ppm", ICON_FILM },
+    { "qt", ICON_FILM },
+    { "rm", ICON_FILM },
+    { "swf", ICON_FILM },
+    { "tiff", ICON_FILM },
+    { "tif", ICON_FILM },
+    { "ts",  ICON_FILM },
+    { "vob", ICON_FILM },
+    { "vts", ICON_FILM },
+    { "webm", ICON_FILM },
+    { "webp", ICON_FILM },
+    { "xml", ICON_FILM },
+    { "y4m", ICON_FILM },
+    { 0, 0 },
 };
 
 BC_Signals* BC_Resources::signal_handler = 0;
@@ -233,50 +277,116 @@ int BC_Resources::get_machine_cpus()
        return cpus;
 }
 
+void BC_Resources::new_vframes(int n, VFrame *vframes[], ...)
+{
+       va_list ap;
+       va_start(ap, vframes);
+       for( int i=0; i<n; ++i )
+               vframes[i] = va_arg(ap, VFrame *);
+       va_end(ap);
+}
+
+VFrame *BC_Resources::default_type_to_icon[6] = { 0, };
+VFrame *BC_Resources::default_bar = 0;
+VFrame *BC_Resources::default_cancel_images[3] = { 0, };
+VFrame *BC_Resources::default_ok_images[3] = { 0, };
+VFrame *BC_Resources::default_usethis_images[3] = { 0, };
+#if 0
+VFrame *BC_Resources::default_checkbox_images[5] = { 0, };
+VFrame *BC_Resources::default_radial_images[5] = { 0, };
+VFrame *BC_Resources::default_label_images[5] = { 0, };
+#endif
+VFrame *BC_Resources::default_menuitem_data[3] = { 0, };
+VFrame *BC_Resources::default_menubar_data[3] = { 0, };
+VFrame *BC_Resources::default_menu_popup_bg = 0;
+VFrame *BC_Resources::default_menu_bar_bg = 0;
+VFrame *BC_Resources::default_check_image = 0;
+VFrame *BC_Resources::default_filebox_text_images[3] = { 0, };
+VFrame *BC_Resources::default_filebox_icons_images[3] = { 0, };
+VFrame *BC_Resources::default_filebox_updir_images[3] = { 0, };
+VFrame *BC_Resources::default_filebox_newfolder_images[3] = { 0, };
+VFrame *BC_Resources::default_filebox_rename_images[3] = { 0, };
+VFrame *BC_Resources::default_filebox_delete_images[3] = { 0, };
+VFrame *BC_Resources::default_filebox_reload_images[3] = { 0, };
+VFrame *BC_Resources::default_listbox_button[4] = { 0, };
+VFrame *BC_Resources::default_listbox_bg = 0;
+VFrame *BC_Resources::default_listbox_expand[5] = { 0, };
+VFrame *BC_Resources::default_listbox_column[3] = { 0, };
+VFrame *BC_Resources::default_listbox_up = 0;
+VFrame *BC_Resources::default_listbox_dn = 0;
+VFrame *BC_Resources::default_pot_images[3] = { 0, };
+VFrame *BC_Resources::default_progress_images[2] = { 0, };
+VFrame *BC_Resources::default_medium_7segment[20] = { 0, };
+
+BC_Resources::BC_Resources()
+{
+       synchronous = 0;
+       vframe_shm = 0;
+       double default_scale = 1.0; // display_size/1000.;
+       char *env = getenv("BC_FONT_SCALE");
+       font_scale = env ? atof(env) : default_scale;
+       if( font_scale <= 0 ) font_scale = 1;
+       init_font_defs(font_scale);
+       env = getenv("BC_ICON_SCALE");
+       icon_scale = env ? atof(env) : default_scale;
+       if( icon_scale <= 0 ) icon_scale = 1;
+
+       id_lock = new Mutex("BC_Resources::id_lock");
+       create_window_lock = new Mutex("BC_Resources::create_window_lock", 1);
+       id = 0;
+       machine_cpus = get_machine_cpus();
+
+       for(int i = 0; i < FILEBOX_HISTORY_SIZE; i++)
+               filebox_history[i].path[0] = 0;
+
+#ifdef HAVE_XFT
+       XftInitFtLibrary();
+#endif
+
+       little_endian = (*(const u_int32_t*)"\01\0\0\0") & 1;
+       wide_encoding = little_endian ?  "UTF32LE" : "UTF32BE";
+       use_xvideo = 1;
+
 #include "images/file_folder_png.h"
 #include "images/file_unknown_png.h"
 #include "images/file_film_png.h"
 #include "images/file_sound_png.h"
 #include "images/file_label_png.h"
 #include "images/file_column_png.h"
-VFrame *BC_Resources::default_type_to_icon[] = {
+new_vframes(6,default_type_to_icon,
        new VFramePng(file_folder_png),
        new VFramePng(file_unknown_png),
        new VFramePng(file_film_png),
        new VFramePng(file_sound_png),
        new VFramePng(file_label_png),
-       new VFramePng(file_column_png)
-};
+       new VFramePng(file_column_png));
 
 #include "images/bar_png.h"
-VFrame *BC_Resources::default_bar = new VFramePng(bar_png);
+       default_bar = new VFramePng(bar_png);
 
 #include "images/cancel_up_png.h"
 #include "images/cancel_hi_png.h"
 #include "images/cancel_dn_png.h"
-VFrame *BC_Resources::default_cancel_images[] = {
+new_vframes(3,default_cancel_images,
        new VFramePng(cancel_up_png),
        new VFramePng(cancel_hi_png),
-       new VFramePng(cancel_dn_png)
-};
+       new VFramePng(cancel_dn_png));
 
 #include "images/ok_up_png.h"
 #include "images/ok_hi_png.h"
 #include "images/ok_dn_png.h"
-VFrame *BC_Resources::default_ok_images[] = {
+new_vframes(3,default_ok_images,
        new VFramePng(ok_up_png),
        new VFramePng(ok_hi_png),
-       new VFramePng(ok_dn_png)
-};
+       new VFramePng(ok_dn_png));
 
 #include "images/usethis_up_png.h"
 #include "images/usethis_uphi_png.h"
 #include "images/usethis_dn_png.h"
-VFrame *BC_Resources::default_usethis_images[] = {
+new_vframes(3,default_usethis_images,
        new VFramePng(usethis_up_png),
        new VFramePng(usethis_uphi_png),
-       new VFramePng(usethis_dn_png)
-};
+       new VFramePng(usethis_dn_png));
 
 #if 0
 #include "images/checkbox_checked_png.h"
@@ -284,63 +394,57 @@ VFrame *BC_Resources::default_usethis_images[] = {
 #include "images/checkbox_checkedhi_png.h"
 #include "images/checkbox_up_png.h"
 #include "images/checkbox_hi_png.h"
-VFrame *BC_Resources::default_checkbox_images[] = {
+new_vframes(5,default_checkbox_images,
        new VFramePng(checkbox_up_png),
        new VFramePng(checkbox_hi_png),
        new VFramePng(checkbox_checked_png),
        new VFramePng(checkbox_dn_png),
-       new VFramePng(checkbox_checkedhi_png)
-};
+       new VFramePng(checkbox_checkedhi_png));
 
 #include "images/radial_checked_png.h"
 #include "images/radial_dn_png.h"
 #include "images/radial_checkedhi_png.h"
 #include "images/radial_up_png.h"
 #include "images/radial_hi_png.h"
-VFrame *BC_Resources::default_radial_images[] = {
+new_vframes(5,default_radial_images,
        new VFramePng(radial_up_png),
        new VFramePng(radial_hi_png),
        new VFramePng(radial_checked_png),
        new VFramePng(radial_dn_png),
-       new VFramePng(radial_checkedhi_png)
-};
+       new VFramePng(radial_checkedhi_png));
 
-VFrame *BC_Resources::default_label_images[] = {
+new_vframes(5,default_label_images,
        new VFramePng(radial_up_png),
        new VFramePng(radial_hi_png),
        new VFramePng(radial_checked_png),
        new VFramePng(radial_dn_png),
-       new VFramePng(radial_checkedhi_png)
-};
+       new VFramePng(radial_checkedhi_png));
 #endif
 
 #include "images/menuitem_up_png.h"
 #include "images/menuitem_hi_png.h"
 #include "images/menuitem_dn_png.h"
-
-VFrame *BC_Resources::default_menuitem_data[] = {
+new_vframes(3,default_menuitem_data,
        new VFramePng(menuitem_up_png),
        new VFramePng(menuitem_hi_png),
-       new VFramePng(menuitem_dn_png),
-};
+       new VFramePng(menuitem_dn_png));
 
 #include "images/menubar_up_png.h"
 #include "images/menubar_hi_png.h"
 #include "images/menubar_dn_png.h"
-VFrame *BC_Resources::default_menubar_data[] = {
+new_vframes(3,default_menubar_data,
        new VFramePng(menubar_up_png),
        new VFramePng(menubar_hi_png),
-       new VFramePng(menubar_dn_png),
-};
+       new VFramePng(menubar_dn_png));
 
 #include "images/menu_popup_bg_png.h"
-VFrame *BC_Resources::default_menu_popup_bg = new VFramePng(menu_popup_bg_png);
+       default_menu_popup_bg = new VFramePng(menu_popup_bg_png);
 
 #include "images/menubar_bg_png.h"
-VFrame *BC_Resources::default_menu_bar_bg = new VFramePng(menubar_bg_png);
+       default_menu_bar_bg = new VFramePng(menubar_bg_png);
 
 #include "images/check_png.h"
-VFrame *BC_Resources::default_check_image = new VFramePng(check_png);
+       default_check_image = new VFramePng(check_png);
 
 #include "images/file_text_up_png.h"
 #include "images/file_text_hi_png.h"
@@ -363,105 +467,92 @@ VFrame *BC_Resources::default_check_image = new VFramePng(check_png);
 #include "images/file_reload_up_png.h"
 #include "images/file_reload_hi_png.h"
 #include "images/file_reload_dn_png.h"
-VFrame *BC_Resources::default_filebox_text_images[] = {
+new_vframes(3,default_filebox_text_images,
        new VFramePng(file_text_up_png),
        new VFramePng(file_text_hi_png),
-       new VFramePng(file_text_dn_png)
-};
+       new VFramePng(file_text_dn_png));
 
-VFrame *BC_Resources::default_filebox_icons_images[] = {
+new_vframes(3,default_filebox_icons_images,
        new VFramePng(file_icons_up_png),
        new VFramePng(file_icons_hi_png),
-       new VFramePng(file_icons_dn_png)
-};
+       new VFramePng(file_icons_dn_png));
 
-VFrame *BC_Resources::default_filebox_updir_images[] = {
+new_vframes(3,default_filebox_updir_images,
        new VFramePng(file_updir_up_png),
        new VFramePng(file_updir_hi_png),
-       new VFramePng(file_updir_dn_png)
-};
+       new VFramePng(file_updir_dn_png));
 
-VFrame *BC_Resources::default_filebox_newfolder_images[] = {
+new_vframes(3,default_filebox_newfolder_images,
        new VFramePng(file_newfolder_up_png),
        new VFramePng(file_newfolder_hi_png),
-       new VFramePng(file_newfolder_dn_png)
-};
+       new VFramePng(file_newfolder_dn_png));
 
-VFrame *BC_Resources::default_filebox_rename_images[] = {
+new_vframes(3,default_filebox_rename_images,
        new VFramePng(file_rename_up_png),
        new VFramePng(file_rename_hi_png),
-       new VFramePng(file_rename_dn_png)
-};
+       new VFramePng(file_rename_dn_png));
 
-VFrame *BC_Resources::default_filebox_delete_images[] = {
+new_vframes(3,default_filebox_delete_images,
        new VFramePng(file_delete_up_png),
        new VFramePng(file_delete_hi_png),
-       new VFramePng(file_delete_dn_png)
-};
+       new VFramePng(file_delete_dn_png));
 
-VFrame *BC_Resources::default_filebox_reload_images[] = {
+new_vframes(3,default_filebox_reload_images,
        new VFramePng(file_reload_up_png),
        new VFramePng(file_reload_hi_png),
-       new VFramePng(file_reload_dn_png)
-};
+       new VFramePng(file_reload_dn_png));
 
 #include "images/listbox_button_dn_png.h"
 #include "images/listbox_button_hi_png.h"
 #include "images/listbox_button_up_png.h"
 #include "images/listbox_button_disabled_png.h"
-VFrame *BC_Resources::default_listbox_button[] = {
+new_vframes(4,default_listbox_button,
        new VFramePng(listbox_button_up_png),
        new VFramePng(listbox_button_hi_png),
        new VFramePng(listbox_button_dn_png),
-       new VFramePng(listbox_button_disabled_png)
-};
+       new VFramePng(listbox_button_disabled_png));
 
-#include "images/menu_popup_bg_png.h"
-VFrame *BC_Resources::default_listbox_bg = 0;
+default_listbox_bg = 0;
 
 #include "images/listbox_expandchecked_png.h"
 #include "images/listbox_expandcheckedhi_png.h"
 #include "images/listbox_expanddn_png.h"
 #include "images/listbox_expandup_png.h"
 #include "images/listbox_expanduphi_png.h"
-VFrame *BC_Resources::default_listbox_expand[] = {
+new_vframes(5,default_listbox_expand,
        new VFramePng(listbox_expandup_png),
        new VFramePng(listbox_expanduphi_png),
        new VFramePng(listbox_expandchecked_png),
        new VFramePng(listbox_expanddn_png),
-       new VFramePng(listbox_expandcheckedhi_png),
-};
+       new VFramePng(listbox_expandcheckedhi_png));
 
 #include "images/listbox_columnup_png.h"
 #include "images/listbox_columnhi_png.h"
 #include "images/listbox_columndn_png.h"
-VFrame *BC_Resources::default_listbox_column[] = {
+new_vframes(3,default_listbox_column,
        new VFramePng(listbox_columnup_png),
        new VFramePng(listbox_columnhi_png),
-       new VFramePng(listbox_columndn_png)
-};
+       new VFramePng(listbox_columndn_png));
 
 #include "images/listbox_up_png.h"
-VFrame *BC_Resources::default_listbox_up = new VFramePng(listbox_up_png);
+       default_listbox_up = new VFramePng(listbox_up_png);
 
 #include "images/listbox_dn_png.h"
-VFrame *BC_Resources::default_listbox_dn = new VFramePng(listbox_dn_png);
+       default_listbox_dn = new VFramePng(listbox_dn_png);
 
 #include "images/pot_hi_png.h"
 #include "images/pot_up_png.h"
 #include "images/pot_dn_png.h"
-VFrame *BC_Resources::default_pot_images[] = {
+new_vframes(3,default_pot_images,
        new VFramePng(pot_up_png),
        new VFramePng(pot_hi_png),
-       new VFramePng(pot_dn_png)
-};
+       new VFramePng(pot_dn_png));
 
 #include "images/progress_up_png.h"
 #include "images/progress_hi_png.h"
-VFrame *BC_Resources::default_progress_images[] = {
+new_vframes(2,default_progress_images,
        new VFramePng(progress_up_png),
-       new VFramePng(progress_hi_png)
-};
+       new VFramePng(progress_hi_png));
 
 #include "images/7seg_small/0_png.h"
 #include "images/7seg_small/1_png.h"
@@ -483,7 +574,7 @@ VFrame *BC_Resources::default_progress_images[] = {
 #include "images/7seg_small/f_png.h"
 #include "images/7seg_small/space_png.h"
 #include "images/7seg_small/dash_png.h"
-VFrame *BC_Resources::default_medium_7segment[] = {
+new_vframes(20,default_medium_7segment,
        new VFramePng(_0_png),
        new VFramePng(_1_png),
        new VFramePng(_2_png),
@@ -503,38 +594,7 @@ VFrame *BC_Resources::default_medium_7segment[] = {
        new VFramePng(e_png),
        new VFramePng(f_png),
        new VFramePng(space_png),
-       new VFramePng(dash_png)
-};
-
-
-BC_Resources::BC_Resources()
-{
-       synchronous = 0;
-       vframe_shm = 0;
-       double default_scale = 1.0; // display_size/1000.;
-       char *env = getenv("BC_FONT_SCALE");
-       font_scale = env ? atof(env) : default_scale;
-       if( font_scale <= 0 ) font_scale = 1;
-       init_font_defs(font_scale);
-       env = getenv("BC_ICON_SCALE");
-       icon_scale = env ? atof(env) : default_scale;
-       if( icon_scale <= 0 ) icon_scale = 1;
-
-       id_lock = new Mutex("BC_Resources::id_lock");
-       create_window_lock = new Mutex("BC_Resources::create_window_lock", 1);
-       id = 0;
-       machine_cpus = get_machine_cpus();
-
-       for(int i = 0; i < FILEBOX_HISTORY_SIZE; i++)
-               filebox_history[i].path[0] = 0;
-
-#ifdef HAVE_XFT
-       XftInitFtLibrary();
-#endif
-
-       little_endian = (*(const u_int32_t*)"\01\0\0\0") & 1;
-       wide_encoding = little_endian ?  "UTF32LE" : "UTF32BE";
-       use_xvideo = 1;
+       new VFramePng(dash_png));
 
        type_to_icon = default_type_to_icon;
        bar_data = default_bar;
@@ -626,8 +686,7 @@ BC_Resources::BC_Resources()
        menu_item_text = BLACK;
        menu_highlighted_fontcolor = BLACK;
        progress_text = BLACK;
-
-
+       grab_input_focus = 1;
 
        text_default = BLACK;
        highlight_inverse = WHITE ^ BLUE;
@@ -642,6 +701,7 @@ BC_Resources::BC_Resources()
        text_border3_hi = LTPINK;
        text_border4 = WHITE;
        text_highlight = BLUE;
+       text_selected_highlight = SLBLUE;
        text_inactive_highlight = MEGREY;
 
        toggle_highlight_bg = 0;
@@ -727,7 +787,7 @@ BC_Resources::BC_Resources()
 
 }
 
-static void del_vframes(VFrame **vframes, int n)
+void BC_Resources::del_vframes(VFrame *vframes[], int n)
 {
        while( --n >= 0 ) delete vframes[n];
 }