improve delays created by vicon drawing locks, reset_cache segv fix, gang track toolt...
[goodguy/cinelerra.git] / cinelerra-5.1 / guicast / bcresources.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #ifndef BCRESOURCES_H
23 #define BCRESOURCES_H
24
25
26
27 // Global objects for the user interface
28
29
30
31
32 #include "bcdisplayinfo.inc"
33 #include "bcfilebox.h"
34 #include "bcfontentry.inc"
35 #include "bcresources.inc"
36 #include "bcsignals.inc"
37 #include "bcsynchronous.inc"
38 #include "bcwindowbase.inc"
39 #include "vframe.inc"
40
41 #include <X11/Xlib.h>
42
43 typedef struct
44 {
45         const char *suffix;
46         int icon_type;
47 } suffix_to_type_t;
48
49 typedef struct
50 {
51         char path[BCTEXTLEN];
52         int id;
53 } filebox_history_t;
54
55 class BC_Resources
56 {
57 public:
58 // The window parameter is used to get the display information initially
59         BC_Resources(float x_scale, float y_scale);
60         ~BC_Resources();
61
62         friend class BC_WindowBase;
63
64         int initialize_display(BC_WindowBase *window);
65
66 // Get unique ID
67         int get_id();
68 // Get ID for filebox history.  Persistent.
69         int get_filebox_id();
70         int get_bg_color();          // window backgrounds
71         int get_bg_shadow1();        // border for windows
72         int get_bg_shadow2();
73         int get_bg_light1();
74         int get_bg_light2();
75 // Get synchronous thread for OpenGL
76         BC_Synchronous* get_synchronous();
77 // Called by user after synchronous thread is created.
78         void set_synchronous(BC_Synchronous *synchronous);
79 // Set signal handler
80         static void set_signals(BC_Signals *signal_handler);
81         static BC_Signals* get_signals();
82
83
84 // These values should be changed before the first window is created.
85 // colors
86         int bg_color;          // window backgrounds
87         int border_light1;
88         int border_light2;
89         int border_shadow1;
90         int border_shadow2;
91
92         int bg_shadow1;        // border for windows
93         int bg_shadow2;
94         int bg_light1;
95         int bg_light2;
96         int default_text_color;
97         int disabled_text_color;
98
99
100 // beveled box colors
101         int button_light;
102         int button_highlighted;
103         int button_down;
104         int button_up;
105         int button_shadow;
106         int button_uphighlighted;
107
108 // highlighting
109         int highlight_inverse;
110
111 // 3D box colors for menus
112         int menu_light;
113         int menu_highlighted;
114         int menu_down;
115         int menu_up;
116         int menu_shadow;
117 // If these are nonzero, they override the menu backgrounds.
118         VFrame *menu_popup_bg;
119         VFrame **menu_title_bg;
120         VFrame *menu_bar_bg;
121         VFrame **popupmenu_images;
122
123 // Minimum menu width
124         int min_menu_w;
125 // Menu bar text color
126         int menu_title_text;
127 // color of popup title
128         int popup_title_text;
129 // Right and left margin for text not including triangle space.
130         int popupmenu_margin;
131 // post popup on button release event
132         int popupmenu_btnup;
133 // Right margin for triangle not including text margin.
134         int popupmenu_triangle_margin;
135 // color for item text
136         int menu_item_text;
137 // Override the menu item background if nonzero.
138         VFrame **menu_item_bg;
139
140
141 // color for progress text
142         int progress_text;
143 // set focus on enter
144         int grab_input_focus;
145
146         int menu_highlighted_fontcolor;
147
148 // ms for double click
149         long double_click;
150 // ms for cursor flash
151         int blink_rate;
152 // ms for scroll repeats
153         int scroll_repeat;
154 // ms before tooltip
155         int tooltip_delay;
156         int tooltip_bg_color;
157         int tooltips_enabled;
158         int textbox_focus_policy;
159
160         int audiovideo_color;
161
162 // default color of text
163         int text_default;
164 // background color of textboxes and list boxes
165         int text_border1;
166         int text_border2;
167         int text_border2_hi;
168         int text_background;
169         int text_background_disarmed;
170         int text_background_hi;
171         int text_background_noborder_hi;
172         int text_border3;
173         int text_border3_hi;
174         int text_border4;
175         int text_highlight;
176         int text_inactive_highlight;
177         int text_selected_highlight;
178 // Not used
179         int text_background_noborder;
180
181 // Optional background for highlighted text in toggle
182         VFrame *toggle_highlight_bg;
183         int toggle_text_margin;
184
185 // Background images
186         static VFrame *bg_image;
187         static VFrame *menu_bg;
188
189 // default icon
190         VFrame *default_icon;
191 // Buttons
192         VFrame **ok_images;
193         VFrame **cancel_images;
194         VFrame **filebox_text_images;
195         VFrame **filebox_icons_images;
196         VFrame **filebox_updir_images;
197         VFrame **filebox_newfolder_images;
198         VFrame **filebox_rename_images;
199         VFrame **filebox_descend_images;
200         VFrame **filebox_delete_images;
201         VFrame **filebox_reload_images;
202         VFrame **filebox_szfmt_images;
203
204 // Generic button images
205         VFrame **generic_button_images;
206 // Generic button text margin
207         int generic_button_margin;
208         VFrame **usethis_button_images;
209
210 // Toggles
211         VFrame **checkbox_images;
212         VFrame **radial_images;
213         VFrame **label_images;
214 // menu check
215         VFrame *check;
216
217         VFrame **tumble_data;
218         VFrame **tumblepatch_data;
219         int tumble_duration;
220
221 // Horizontal bar
222         VFrame *bar_data;
223
224 // Listbox
225         VFrame *listbox_bg;
226         VFrame **listbox_button;
227         VFrame **listbox_expand;
228         VFrame **listbox_column;
229         VFrame *listbox_up;
230         VFrame *listbox_dn;
231         int listbox_title_overlap;
232 // Margin for titles in addition to listbox border
233         int listbox_title_margin;
234         int listbox_title_color;
235         int listbox_title_hotspot;
236         int listbox_border1;
237         int listbox_border2_hi;
238         int listbox_border2;
239         int listbox_border3_hi;
240         int listbox_border3;
241         int listbox_border4;
242 // Selected row color
243         int listbox_selected;
244 // Highlighted row color
245         int listbox_highlighted;
246 // Inactive row color
247         int listbox_inactive;
248 // Default text color
249         int listbox_text;
250
251
252 // Sliders
253         VFrame **horizontal_slider_data;
254         VFrame **vertical_slider_data;
255         VFrame **hscroll_data;
256
257         VFrame **vscroll_data;
258 // Minimum pixels in handle
259         int scroll_minhandle;
260
261 // Pans
262         VFrame **pan_data;
263         int pan_text_color;
264
265 // Pots
266         VFrame **pot_images;
267         int pot_x1, pot_y1, pot_r;
268 // Amount of deflection of pot when down
269         int pot_offset;
270         int pot_needle_color;
271
272 // Meters
273         VFrame **xmeter_images, **ymeter_images;
274         int meter_font;
275         int meter_font_color;
276         int meter_title_w;
277         int meter_3d;
278
279 // Progress bar
280         VFrame **progress_images;
281
282 // Motion required to start a drag
283         int drag_radius;
284
285 // Filebox
286         static suffix_to_type_t suffix_to_type[];
287         VFrame **type_to_icon;
288 // Display mode for fileboxes
289         int filebox_mode;
290 // Filter currently used in filebox
291         char filebox_filter[BCTEXTLEN];
292 // History of submitted files
293         filebox_history_t filebox_history[FILEBOX_HISTORY_SIZE];
294 // filebox size
295         int filebox_w;
296         int filebox_h;
297 // Column types for filebox
298         int filebox_columntype[FILEBOX_COLUMNS];
299         int filebox_columnwidth[FILEBOX_COLUMNS];
300         int filebox_sortcolumn;
301         int filebox_sortorder;
302 // Column types for filebox in directory mode
303         int dirbox_columntype[FILEBOX_COLUMNS];
304         int dirbox_columnwidth[FILEBOX_COLUMNS];
305         int dirbox_sortcolumn;
306         int dirbox_sortorder;
307 // Bottom margin between list and window
308         int filebox_margin;
309         int dirbox_margin;
310         int directory_color;
311         int file_color;
312         double font_scale, icon_scale;
313         double x_scale, y_scale;
314 // fonts
315         static const char *small_font, *small_font2;
316         static const char *medium_font, *medium_font2;
317         static const char *large_font, *large_font2;
318         static const char *big_font, *big_font2;
319         static const char *clock_font, *clock_font2;
320
321         static const char *small_fontset;
322         static const char *medium_fontset;
323         static const char *large_fontset;
324         static const char *big_fontset;
325         static const char *clock_fontset;
326
327         static const char *small_font_xft, *small_b_font_xft;
328         static const char *medium_font_xft, *medium_b_font_xft;
329         static const char *large_font_xft, *large_b_font_xft;
330         static const char *big_font_xft, *big_b_font_xft;
331         static const char *clock_font_xft, *clock_b_font_xft;
332
333 // Backup of fonts in case the first choices don't exist
334         static const char *small_font_xft2;
335         static const char *medium_font_xft2;
336         static const char *large_font_xft2;
337         static const char *big_font_xft2;
338         static const char *clock_font_xft2;
339
340         void init_font_defs(double scale);
341         void finit_font_defs();
342
343         VFrame **medium_7segment;
344
345 //clock
346         int draw_clock_background;
347
348         int use_fontset;
349         int use_xft;
350
351 // Current locale uses utf8
352         static int locale_utf8;
353 // Byte order is little_endian
354         static int little_endian;
355 // Language and region
356         static char language[LEN_LANG];
357         static char region[LEN_LANG];
358         static char encoding[LEN_ENCOD];
359         static const char *wide_encoding;
360         static ArrayList<BC_FontEntry*> *fontlist;
361         static int init_fontconfig(const char *search_path);
362         static BC_FontEntry *find_fontentry(const char *displayname, int style,
363                 int mask, int preferred_style = 0);
364         static void encode_to_utf8(char *buffer, int buflen);
365         static FcPattern* find_similar_font(FT_ULong char_code, FcPattern *oldfont);
366         static size_t encode(const char *from_enc, const char *to_enc,
367                 char *input, int input_length, char *output, int output_length);
368         static int find_font_by_char(FT_ULong char_code, char *path_new, const FT_Face oldface);
369         static int font_debug;
370         static void dump_fonts(FILE *fp = stdout);
371         static void dump_font_entry(FILE *fp, const char *cp,  BC_FontEntry *ep);
372
373         static void new_vframes(int n, VFrame *vframes[], ...);
374         static void del_vframes(VFrame *vframes[], int n);
375 // default images
376         static VFrame *default_type_to_icon[6];
377         static VFrame *default_bar;
378         static VFrame *default_cancel_images[3];
379         static VFrame *default_ok_images[3];
380         static VFrame *default_usethis_images[3];
381 #if 0
382         static VFrame *default_checkbox_images[5];
383         static VFrame *default_radial_images[5];
384         static VFrame *default_label_images[5];
385 #endif
386         static VFrame *default_menuitem_data[3];
387         static VFrame *default_menubar_data[3];
388         static VFrame *default_menu_popup_bg;
389         static VFrame *default_menu_bar_bg;
390         static VFrame *default_check_image;
391         static VFrame *default_filebox_text_images[3];
392         static VFrame *default_filebox_icons_images[3];
393         static VFrame *default_filebox_updir_images[3];
394         static VFrame *default_filebox_newfolder_images[3];
395         static VFrame *default_filebox_rename_images[3];
396         static VFrame *default_filebox_delete_images[3];
397         static VFrame *default_filebox_reload_images[3];
398         static VFrame *default_filebox_szfmt_images[12];
399         static VFrame *default_listbox_button[4];
400         static VFrame *default_listbox_bg;
401         static VFrame *default_listbox_expand[5];
402         static VFrame *default_listbox_column[3];
403         static VFrame *default_listbox_up;
404         static VFrame *default_listbox_dn;
405         static VFrame *default_pot_images[3];
406         static VFrame *default_progress_images[2];
407         static VFrame *default_medium_7segment[20];
408         static VFrame *default_vscroll_data[10];
409         static VFrame *default_hscroll_data[10];
410         static VFrame *default_icon_img;
411
412 // Make VFrame use shm
413         int vframe_shm;
414         int use_vframe_shm() { return use_shm && vframe_shm ? 1 : 0; }
415
416         static int get_machine_cpus();
417         static int machine_cpus;
418 // Available display extensions
419         int use_shm;
420         int shm_reply;
421         static int error;
422 // If the program uses recursive_resizing
423         int recursive_resizing;
424 // Work around X server bugs
425         int use_xvideo;
426 // Seems to help if only 1 window is created at a time.
427         Mutex *create_window_lock;
428 // size raw, 1000, 1024, thou
429         int filebox_size_format;
430 private:
431 // Test for availability of shared memory pixmaps
432         void init_shm(BC_WindowBase *window);
433         void init_sizes(BC_WindowBase *window);
434         static int x_error_handler(Display *display, XErrorEvent *event);
435         VFrame **list_pointers[100];
436         int list_lengths[100];
437         int list_total;
438         static const char *fc_properties[];
439
440
441         Mutex *id_lock;
442         static Mutex fontconfig_lock;
443
444 // Pointer to signal handler class to run after ipc
445         static BC_Signals *signal_handler;
446         BC_Synchronous *synchronous;
447
448         int id;
449         int filebox_id;
450 };
451
452
453 #endif