gmerlin
parameter.h
1 /*****************************************************************
2  * gmerlin - a general purpose multimedia framework and applications
3  *
4  * Copyright (c) 2001 - 2011 Members of the Gmerlin project
5  * gmerlin-general@lists.sourceforge.net
6  * http://gmerlin.sourceforge.net
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  * *****************************************************************/
21 
22 #ifndef __BG_PARAMETER_H_
23 #define __BG_PARAMETER_H_
24 
25 #include <libxml/tree.h>
26 #include <libxml/parser.h>
27 
28 #include <gavl/gavl.h>
29 
44 /* Universal Parameter setting mechanism */
45 
53 typedef enum
54  {
77 
82 typedef union
83  {
84  double val_f;
85  int val_i;
86  char * val_str;
87  float val_color[4];
89  double val_pos[2];
91 
92 /* Flags */
93 
97 #define BG_PARAMETER_SYNC (1<<0)
98 
99 
102 #define BG_PARAMETER_HIDE_DIALOG (1<<1)
103 
104 
107 #define BG_PARAMETER_NO_SORT (1<<2)
108 
109 
112 #define BG_PARAMETER_PLUGIN (1<<3)
113 
114 
117 #define BG_PARAMETER_OWN_SECTION (1<<4)
118 
119 
123 #define BG_PARAMETER_GLOBAL_PRESET (1<<5)
124 
125 
127 
135  {
136  char * name;
137  char * long_name;
138  char * opt;
139 
140  char * gettext_domain;
142 
144 
145  int flags;
146 
150 
151  /* Names which can be passed to set_parameter (NULL terminated) */
152 
153  char const * const * multi_names;
154 
155  /* Long names are optional, if they are NULL,
156  the short names are used */
157 
158  char const * const * multi_labels;
159  char const * const * multi_descriptions;
160 
161  /*
162  * These are parameters for each codec.
163  * The name members of these MUST be unique with respect to the rest
164  * of the parameters passed to the same set_parameter func
165  */
166 
167  struct bg_parameter_info_s const * const * multi_parameters;
168 
170 
171  char * help_string;
172 
173  char * preset_path;
174 
175  char ** multi_names_nc;
176 
177  char ** multi_labels_nc;
178 
180 
182 
183  };
184 
185 /* Prototype for setting/getting parameters */
186 
187 /*
188  * NOTE: All applications MUST call a bg_set_parameter_func with
189  * a NULL name argument to signal, that all parameters are set now
190  */
191 
205 typedef void (*bg_set_parameter_func_t)(void * data, const char * name,
206  const bg_parameter_value_t * v);
207 
221 typedef int (*bg_get_parameter_func_t)(void * data, const char * name,
223 
231  const bg_parameter_info_t * src);
232 
244 
253 void
255 
262 
274  const bg_parameter_value_t * src,
275  const bg_parameter_info_t * info);
276 
285 
286 
296 
308  const char * val);
309 
310 
322 const bg_parameter_info_t *
324  const char * name);
325 
326 
337 bg_parameter_info_t * bg_xml_2_parameters(xmlDocPtr xml_doc,
338  xmlNodePtr xml_parameters);
339 
349 void
350 bg_parameters_2_xml(const bg_parameter_info_t * info, xmlNodePtr xml_parameters);
351 
360 void
361 bg_parameters_dump(const bg_parameter_info_t * info, const char * filename);
362 
363 
364 #endif /* __BG_PARAMETER_H_ */
365 
char ** multi_descriptions_nc
When allocating dynamically, use this instead of multi_descriptions and call bg_parameter_info_set_co...
Definition: parameter.h:179
Pressing the button causes set_parameter to be called with NULL value.
Definition: parameter.h:75
Directory.
Definition: parameter.h:69
RGB Color.
Definition: parameter.h:64
char * gettext_directory
Second argument for bindtextdomain(). In an array, it's valid for subsequent entries too...
Definition: parameter.h:141
Float spinbutton.
Definition: parameter.h:58
Position (x/y coordinates, scaled 0..1)
Definition: parameter.h:74
int bg_parameter_get_selected(const bg_parameter_info_t *info, const char *val)
Get the index for a multi-options parameter.
void bg_parameter_info_copy(bg_parameter_info_t *dst, const bg_parameter_info_t *src)
Copy a single parameter info.
bg_parameter_type_t type
Type.
Definition: parameter.h:143
const bg_parameter_info_t * bg_parameter_find(const bg_parameter_info_t *info, const char *name)
Find a parameter info.
void bg_parameters_2_xml(const bg_parameter_info_t *info, xmlNodePtr xml_parameters)
Convert a parameter array into a libxml2 node.
Popdown menu with string values.
Definition: parameter.h:63
bg_parameter_value_t val_min
Minimum value (for arithmetic types)
Definition: parameter.h:148
int num_digits
Number of digits for floating point parameters.
Definition: parameter.h:169
bg_parameter_value_t val_default
Default value.
Definition: parameter.h:147
char * opt
ultrashort name (optional for commandline). If missing, the name will be used.
Definition: parameter.h:138
Encrypted string (displays as ***)
Definition: parameter.h:62
bg_parameter_value_t val_max
Maximum value (for arithmetic types)
Definition: parameter.h:149
Menu with config- and infobutton.
Definition: parameter.h:70
Font (contains fontconfig compatible fontname)
Definition: parameter.h:66
char * long_name
Long name (for labels)
Definition: parameter.h:137
Integer spinbutton.
Definition: parameter.h:57
char const *const * multi_names
Names for multi option parameters (NULL terminated)
Definition: parameter.h:153
Parmeter description.
Definition: parameter.h:134
int(* bg_get_parameter_func_t)(void *data, const char *name, bg_parameter_value_t *v)
Generic prototype for getting parameters from a module.
Definition: parameter.h:221
void bg_parameters_dump(const bg_parameter_info_t *info, const char *filename)
Dump a parameter array into a xml file.
RGBA Color.
Definition: parameter.h:65
char * val_str
For BG_PARAMETER_STRING, BG_PARAMETER_STRING_HIDDEN, BG_PARAMETER_STRINGLIST, BG_PARAMETER_FONT, BG_PARAMETER_FILE, BG_PARAMETER_DIRECTORY, BG_PARAMETER_MULTI_MENU, BG_PARAMETER_MULTI_LIST.
Definition: parameter.h:86
char const *const * multi_labels
Optional labels for multi option parameters.
Definition: parameter.h:158
Time.
Definition: parameter.h:73
Several subitems (including suboptions) can be arranged in a chain.
Definition: parameter.h:72
struct bg_parameter_info_s ** multi_parameters_nc
When allocating dynamically, use this instead of multi_parameters and call bg_parameter_info_set_cons...
Definition: parameter.h:181
struct bg_parameter_info_s const *const * multi_parameters
Parameters for each option. The name members of these MUST be unique with respect to the rest of the ...
Definition: parameter.h:167
int val_i
For BG_PARAMETER_CHECKBUTTON, BG_PARAMETER_INT and BG_PARAMETER_SLIDER_INT.
Definition: parameter.h:85
gavl_time_t val_time
For BG_PARAMETER_TIME.
Definition: parameter.h:88
double val_f
For BG_PARAMETER_FLOAT and BG_PARAMETER_SLIDER_FLOAT.
Definition: parameter.h:84
String (one line only)
Definition: parameter.h:61
char * preset_path
Path for storing configuration presets.
Definition: parameter.h:173
List with config- and infobutton.
Definition: parameter.h:71
Integer slider.
Definition: parameter.h:59
void(* bg_set_parameter_func_t)(void *data, const char *name, const bg_parameter_value_t *v)
Generic prototype for setting parameters in a module.
Definition: parameter.h:205
void bg_parameter_value_free(bg_parameter_value_t *val, bg_parameter_type_t type)
Free a parameter value.
char * help_string
Help strings for tooltips or –help option.
Definition: parameter.h:171
int64_t gavl_time_t
int flags
Mask of BG_PARAMETER_* defines.
Definition: parameter.h:145
void bg_parameter_value_copy(bg_parameter_value_t *dst, const bg_parameter_value_t *src, const bg_parameter_info_t *info)
Copy a parameter value.
Device.
Definition: parameter.h:67
bg_parameter_type_t
Parameter type.
Definition: parameter.h:53
char * name
Unique name. Can contain alphanumeric characters plus underscore.
Definition: parameter.h:136
bg_parameter_info_t * bg_parameter_info_copy_array(const bg_parameter_info_t *src)
Copy a NULL terminated parameter array.
void bg_parameter_info_set_const_ptrs(bg_parameter_info_t *info)
Set the const pointers of a dynamically allocated parameter info.
Container for a parameter value.
Definition: parameter.h:82
Bool.
Definition: parameter.h:56
char * gettext_domain
First argument for bindtextdomain(). In an array, it's valid for subsequent entries too...
Definition: parameter.h:140
char ** multi_labels_nc
When allocating dynamically, use this instead of multi_labels and call bg_parameter_info_set_const_pt...
Definition: parameter.h:177
void bg_parameter_info_destroy_array(bg_parameter_info_t *info)
Free a NULL terminated parameter array.
Float slider.
Definition: parameter.h:60
File.
Definition: parameter.h:68
bg_parameter_info_t * bg_parameter_info_concat_arrays(bg_parameter_info_t const **srcs)
Concatenate multiple arrays into one.
char const *const * multi_descriptions
Optional descriptions (will be displayed by info buttons)
Definition: parameter.h:159
bg_parameter_info_t * bg_xml_2_parameters(xmlDocPtr xml_doc, xmlNodePtr xml_parameters)
Convert a libxml2 node into a parameter array.
char ** multi_names_nc
When allocating dynamically, use this instead of multi_names and call bg_parameter_info_set_const_ptr...
Definition: parameter.h:175
Dummy type. It contains no data but acts as a separator in notebook style configuration windows...
Definition: parameter.h:55