remove Features5, rework gradient plugin, fix paste_edl track title bug, gl_probe...
[goodguy/cinelerra.git] / cinelerra-5.1 / guicast / bctheme.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 BCTHEME_H
23 #define BCTHEME_H
24
25 #include "arraylist.h"
26 #include "bcresources.inc"
27 #include "bcwindowbase.inc"
28 #include "vframe.inc"
29 #include <stdarg.h>
30
31 class BC_ThemeSet;
32 class BC_ImageData;
33
34 class BC_ImageData {
35 public:
36         char *name;
37         unsigned char *data;
38         int used;
39
40         BC_ImageData(char *nm, unsigned char *dp) {
41                 name = nm;  data = dp;  used = 0;
42         }
43 };
44
45
46 class BC_Theme
47 {
48 public:
49         BC_Theme();
50         virtual ~BC_Theme();
51
52 // Set pointer to binary object containing images and contents.
53 // Immediately loads the contents from the object.
54         void set_data(unsigned char *ptr);
55
56 // Compose widgets using standard images.
57 // The arguments are copied into new VFrames for a new image set.
58 // The image set is put in the image table only if the title is nonzero.
59         VFrame** new_button(const char *overlay_path,
60                 const char *up_path,
61                 const char *hi_path,
62                 const char *dn_path,
63                 const char *title);
64         VFrame** new_button4(const char *overlay_path,
65                 const char *up_path,
66                 const char *hi_path,
67                 const char *dn_path,
68                 const char *disabled_path,
69                 const char *title);
70         VFrame** new_button(const char *overlay_path,
71                 VFrame *up,
72                 VFrame *hi,
73                 VFrame *dn,
74                 const char *title);
75         VFrame** new_toggle(const char *overlay_path,
76                 const char *up_path,
77                 const char *hi_path,
78                 const char *checked_path,
79                 const char *dn_path,
80                 const char *checkedhi_path,
81                 const char *title);
82         VFrame** new_toggle(const char *overlay_path,
83                 VFrame *up,
84                 VFrame *hi,
85                 VFrame *checked,
86                 VFrame *dn,
87                 VFrame *checkedhi,
88                 const char *title);
89
90
91 // The two main routines for creating images are new_image_set and new_image.
92 // If the title already exists in the table, the existing entry is returned.
93 // These create image sets which are stored in the set table.
94 // Takes comma delimited char* pointers to filenames.
95         VFrame** new_image_set(const char *title, int total, va_list *args);
96         VFrame** new_image_set(const char *title, int total, ...);
97         VFrame** new_image_set(int total, ...);
98 // Creates an image set from VFrame pointers.
99 // The images are considered not references and deleted with the image set.
100 // If the title already exists, the existing entry is deleted and overridden.
101         VFrame** new_image_set_images(const char *title, int total, ...);
102
103 // Decompresses image and puts on images table before returning it.
104         VFrame* new_image(const char *title, const char *path);
105         VFrame* new_image(const char *path);
106
107
108 // These retrieve images based on case sensitive title
109         VFrame* get_image(const char *title, int use_default = 1);
110         VFrame** get_image_set(const char *title, int use_default = 1);
111         BC_ThemeSet* get_image_set_object(const char *title);
112
113 // Loads compressed data into temporary
114         unsigned char* get_image_data(const char *title, int log_errs=1);
115
116 // Verify all images have been used after initialization.
117         void check_used();
118         void sort_image_sets();
119
120         void dump();
121         BC_Resources* get_resources();
122
123 private:
124         void overlay(VFrame *dst, VFrame *src, int in_x1 = -1, int in_x2 = -1, int shift = 0);
125         void init_contents();
126
127
128
129 // Decompressed image storage.
130 // Sets of images.
131         ArrayList<BC_ThemeSet*> image_sets;
132         BC_ThemeSet *last_image_set;
133         int image_sets_start;
134         static int image_set_cmpr(const void *ap, const void *bp);
135         void add_image_set(BC_ThemeSet *image_set);
136
137 // Compressed images are loaded in here.
138         ArrayList<int> data_items;
139         ArrayList<BC_ImageData *> images;
140         BC_ImageData *last_image_data;
141         static int images_cmpr(const void *ap, const void *bp);
142 };
143
144 class BC_ThemeSet
145 {
146 public:
147 // Set is_reference if the images are going to be created by new_image
148         BC_ThemeSet(int total, int is_reference, const char *title);
149         ~BC_ThemeSet();
150
151         VFrame **data;
152         char *title;
153         int total;
154         int is_reference;
155 };
156
157
158
159 #endif