comparison libvisual/lv_ui.h @ 23:0db4a1dc75c4 trunk

[svn] libvisual. P3 detection appears to be borked. I'll work on it later.
author nenolod
date Mon, 24 Oct 2005 23:13:56 -0700
parents
children
comparison
equal deleted inserted replaced
22:696f87ed66e2 23:0db4a1dc75c4
1 /* Libvisual - The audio visualisation framework.
2 *
3 * Copyright (C) 2004, 2005 Dennis Smit <ds@nerds-incorporated.org>
4 *
5 * Authors: Dennis Smit <ds@nerds-incorporated.org>
6 *
7 * $Id:
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as
11 * published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24 #ifndef _LV_UI_H
25 #define _LV_UI_H
26
27 #include <libvisual/lv_list.h>
28 #include <libvisual/lv_param.h>
29 #include <libvisual/lv_video.h>
30 #include <libvisual/lv_common.h>
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif /* __cplusplus */
35
36 #define VISUAL_UI_WIDGET(obj) (VISUAL_CHECK_CAST ((obj), VISUAL_WIDGET_TYPE_WIDGET, VisUIWidget))
37 #define VISUAL_UI_CONTAINER(obj) (VISUAL_CHECK_CAST ((obj), VISUAL_WIDGET_TYPE_CONTAINER, VisUIContainer))
38 #define VISUAL_UI_BOX(obj) (VISUAL_CHECK_CAST ((obj), VISUAL_WIDGET_TYPE_BOX, VisUIBox))
39 #define VISUAL_UI_TABLE_ENTRY(obj) (VISUAL_CHECK_CAST ((obj), VISUAL_WIDGET_TYPE_TABLE, VisUITableEntry))
40 #define VISUAL_UI_TABLE(obj) (VISUAL_CHECK_CAST ((obj), VISUAL_WIDGET_TYPE_TABLE, VisUITable))
41 #define VISUAL_UI_FRAME(obj) (VISUAL_CHECK_CAST ((obj), VISUAL_WIDGET_TYPE_FRAME, VisUIFrame))
42 #define VISUAL_UI_LABEL(obj) (VISUAL_CHECK_CAST ((obj), VISUAL_WIDGET_TYPE_LABEL, VisUILabel))
43 #define VISUAL_UI_IMAGE(obj) (VISUAL_CHECK_CAST ((obj), VISUAL_WIDGET_TYPE_IMAGE, VisUIImage))
44 #define VISUAL_UI_SEPARATOR(obj) (VISUAL_CHECK_CAST ((obj), VISUAL_WIDGET_TYPE_SEPARATOR, VisUISeparator))
45 #define VISUAL_UI_MUTATOR(obj) (VISUAL_CHECK_CAST ((obj), VISUAL_WIDGET_TYPE_MUTATOR, VisUIMutator))
46 #define VISUAL_UI_RANGE(obj) (VISUAL_CHECK_CAST ((obj), VISUAL_WIDGET_TYPE_RANGE, VisUIRange))
47 #define VISUAL_UI_ENTRY(obj) (VISUAL_CHECK_CAST ((obj), VISUAL_WIDGET_TYPE_ENTRY, VisUIEntry))
48 #define VISUAL_UI_SLIDER(obj) (VISUAL_CHECK_CAST ((obj), VISUAL_WIDGET_TYPE_SLIDER, VisUISlider))
49 #define VISUAL_UI_NUMERIC(obj) (VISUAL_CHECK_CAST ((obj), VISUAL_WIDGET_TYPE_NUMERIC, VisUINumeric))
50 #define VISUAL_UI_COLOR(obj) (VISUAL_CHECK_CAST ((obj), VISUAL_WIDGET_TYPE_COLOR, VisUIColor))
51 #define VISUAL_UI_CHOICE_ENTRY(obj) (VISUAL_CHECK_CAST ((obj), VISUAL_WIDGET_TYPE_CHOICE, VisUIChoiceEntry))
52 #define VISUAL_UI_CHOICE(obj) (VISUAL_CHECK_CAST ((obj), VISUAL_WIDGET_TYPE_CHOICE, VisUIChoice))
53 #define VISUAL_UI_POPUP(obj) (VISUAL_CHECK_CAST ((obj), VISUAL_WIDGET_TYPE_POPUP, VisUIPopup))
54 #define VISUAL_UI_LIST(obj) (VISUAL_CHECK_CAST ((obj), VISUAL_WIDGET_TYPE_LIST, VisUIList))
55 #define VISUAL_UI_RADIO(obj) (VISUAL_CHECK_CAST ((obj), VISUAL_WIDGET_TYPE_RADIO, VisUIRadio))
56 #define VISUAL_UI_CHECKBOX(obj) (VISUAL_CHECK_CAST ((obj), VISUAL_WIDGET_TYPE_CHECKBOX, VisUICheckbox))
57
58 /**
59 * Enumerate to define the different types of VisUIWidgets.
60 */
61 typedef enum {
62 VISUAL_WIDGET_TYPE_NULL, /**< NULL widget */
63 VISUAL_WIDGET_TYPE_WIDGET, /**< Base widget: \a VisUIWidget. */
64 VISUAL_WIDGET_TYPE_CONTAINER, /**< Container widget: \a VisUIContainer. */
65 VISUAL_WIDGET_TYPE_BOX, /**< Box widget: \a VisUIBox. */
66 VISUAL_WIDGET_TYPE_TABLE, /**< Table widget: \a VisUITable. */
67 VISUAL_WIDGET_TYPE_FRAME, /**< Frame widget: \a VisUIFrame. */
68 VISUAL_WIDGET_TYPE_LABEL, /**< Label widget: \a VisUILabel. */
69 VISUAL_WIDGET_TYPE_IMAGE, /**< Image widget: \a VisUIImage. */
70 VISUAL_WIDGET_TYPE_SEPARATOR, /**< Separator widget: \a VisUISeparator. */
71 VISUAL_WIDGET_TYPE_MUTATOR, /**< Mutator base widget: \a VisUIMutator. */
72 VISUAL_WIDGET_TYPE_RANGE, /**< Range base widget: \a VisUIRange. */
73 VISUAL_WIDGET_TYPE_ENTRY, /**< Entry box widget: \a VisUIEntry. */
74 VISUAL_WIDGET_TYPE_SLIDER, /**< Slider widget: \a VisUISlider. */
75 VISUAL_WIDGET_TYPE_NUMERIC, /**< Numeric widget: \a VisUINumeric. */
76 VISUAL_WIDGET_TYPE_COLOR, /**< Color widget: \a VisUIColor. */
77 VISUAL_WIDGET_TYPE_CHOICE, /**< Choice base widget: \a VisUIChoice. */
78 VISUAL_WIDGET_TYPE_POPUP, /**< Popup widget: \a VisUIPopup. */
79 VISUAL_WIDGET_TYPE_LIST, /**< List widget: \a VisUIList. */
80 VISUAL_WIDGET_TYPE_RADIO, /**< Radio widget: \a VisUIRadio. */
81 VISUAL_WIDGET_TYPE_CHECKBOX /**< Checkbox widget: \a VisUICheckbox. */
82 } VisUIWidgetType;
83
84 /**
85 * Enumerate to define the different types of widget orientation. This is used
86 * by a few widgets that can be aligned both vertical and horizontal.
87 */
88 typedef enum {
89 VISUAL_ORIENT_TYPE_NONE, /**< No orientation, use the default. */
90 VISUAL_ORIENT_TYPE_HORIZONTAL, /**< Horizontal orientation. */
91 VISUAL_ORIENT_TYPE_VERTICAL /**< Vertical orientation. */
92 } VisUIOrientType;
93
94 typedef struct _VisUIWidget VisUIWidget;
95 typedef struct _VisUIContainer VisUIContainer;
96 typedef struct _VisUIBox VisUIBox;
97 typedef struct _VisUITableEntry VisUITableEntry;
98 typedef struct _VisUITable VisUITable;
99 typedef struct _VisUIFrame VisUIFrame;
100 typedef struct _VisUILabel VisUILabel;
101 typedef struct _VisUIImage VisUIImage;
102 typedef struct _VisUISeparator VisUISeparator;
103 typedef struct _VisUIMutator VisUIMutator;
104 typedef struct _VisUIRange VisUIRange;
105 typedef struct _VisUIEntry VisUIEntry;
106 typedef struct _VisUISlider VisUISlider;
107 typedef struct _VisUINumeric VisUINumeric;
108 typedef struct _VisUIColor VisUIColor;
109 typedef struct _VisUIChoiceList VisUIChoiceList;
110 typedef struct _VisUIChoiceEntry VisUIChoiceEntry;
111 typedef struct _VisUIChoice VisUIChoice;
112 typedef struct _VisUIPopup VisUIPopup;
113 typedef struct _VisUIList VisUIList;
114 typedef struct _VisUIRadio VisUIRadio;
115 typedef struct _VisUICheckbox VisUICheckbox;
116
117 /* FIXME, fix the links, they are screwed up because of the typedefs, there is some way around it
118 * but hey. */
119 /**
120 *
121 * The super class for al VisUIWidgets. All the typical VisUIWidgets
122 * derive from this. VisUIWidget is used as an intermediate user interface
123 * description. Mainly to set up configuration dialogs for plugins that
124 * are not widget set dependant.
125 *
126 * The VisUIWidget class hierarchy looks like following:
127 * - \a _VisUIWidget
128 * - \a VisUILabel
129 * - \a VisUIImage
130 * - \a VisUIContainer
131 * - \a VisUIBox
132 * - \a VisUITable
133 * - \a VisUIFrame
134 * - \a VisUIMutator
135 * - \a VisUIText
136 * - \a VisUIColor
137 * - \a VisUIRange
138 * - \a VisUISlider
139 * - \a VisUINumeric
140 * - \a VisUIChoice
141 * - \a VisUIPopup
142 * - \a VisUIList
143 * - \a VisUIRadio
144 * - \a VisUICheckbox
145 */
146 struct _VisUIWidget {
147 VisObject object; /**< The VisObject data. */
148
149 VisUIWidget *parent; /**< Parent in which this VisUIWidget is packed.
150 * This is possibly NULL. */
151
152 VisUIWidgetType type; /**< Type of VisUIWidget. */
153
154 const char *tooltip; /**< Optional tooltip text, this can be used to
155 * give the user some extra explanation about the
156 * user interface. */
157
158 int width; /**< When size requisition is used, the width value will
159 * be stored in this. */
160 int height; /**< When size requisition is used. the height value will
161 * be stored in this. When size requisition is not being
162 * done both width and height will contain of -1. */
163 };
164
165 /**
166 * The VisUIContainer is a VisUIWidget that is used to pack other widgets in.
167 * A basic container can contain just one VisUIWidget, however when VisUIBox or
168 * VisUITable is used, it's possible to add more elements.
169 */
170 struct _VisUIContainer {
171 VisUIWidget widget; /**< The VisUIWidget data. */
172
173 VisUIWidget *child; /**< Pointer to the child VisUIWidget that is packed in this VisUIContainer. */
174 };
175
176 /**
177 * The VisUIBox inherents from VisUIContainer, but is capable to contain more childeren.
178 * The VisUIBox is used as a box of VisUIWidgets, packed vertical or horizontal.
179 */
180 struct _VisUIBox {
181 VisUIContainer container; /**< The VisUIContainer data. */
182
183 VisUIOrientType orient; /**< Orientation, whatever the box packs the item in a vertical
184 * order or in a horizontal order. */
185
186 VisList childs; /**< A list of all child VisUIWidgets. */
187 };
188
189 /**
190 * VisUITableEntry is an entry in a VisUITable. the VisUITableEntry is not a VisUIWidget on
191 * itself. Instead it rembers the cell in which a VisUIWidget is placed in VisUITable and
192 * also has a reference to the VisUIWidget.
193 */
194 struct _VisUITableEntry {
195 VisObject object; /**< The VisObject data. */
196
197 int row; /**< Row to which the VisUITableEntry is associated. */
198 int col; /**< Column to which the VisUITableEntry is associated. */
199
200 VisUIWidget *widget; /**< The VisUIWidget that is connected to this entry in the VisUITable. */
201 };
202
203 /**
204 * The VisUITable inherents from VisUIContainer, but is capable of placing VisUIWidgets in an aligned grid.
205 */
206 struct _VisUITable {
207 VisUIContainer container; /**< The VisUIContainer data. */
208
209 int rows; /**< The number of rows in this VisUITable. */
210 int cols; /**< The number of columns in this VisUITable. */
211
212 VisList childs; /**< A list of all VisUITableEntry items that are related to
213 * this table. */
214 };
215
216 /**
217 * The VisUIFrame inherents from VisUIContainer, it's used to put a frame with a label around a VisUIWidget.
218 */
219 struct _VisUIFrame {
220 VisUIContainer container; /**< The VisUIContainer data. */
221
222 const char *name; /**< The frame label text. */
223 };
224
225 /**
226 * The VisUILabel inherents from a VisUIWidget, it's used to as a label item in the user interface.
227 */
228 struct _VisUILabel {
229 VisUIWidget widget; /**< The VisUIWidget data. */
230
231 const char *text; /**< The label text. */
232 int bold; /**< Whatever the label is being printed in bold or not. */
233 };
234
235 /**
236 * The VisUIImage inherents from a VisUIWidget, it's used to display a VisVideo within the user interface. For
237 * example it can be used to show a picture.
238 */
239 struct _VisUIImage {
240 VisUIWidget widget; /**< The VisUIWidget data. */
241
242 VisVideo *image; /**< The VisUIImage containing the image data. */
243 };
244
245 /**
246 * The VisUISeparator inherents from a VisUIWidget, it's used to display a separator between different user interface
247 * elements.
248 */
249 struct _VisUISeparator {
250 VisUIWidget widget; /**< The VisUIWidget data. */
251
252 VisUIOrientType orient; /**< The orientation, whatever the separator is drawn in vertical
253 * or horizontal style. */
254 };
255
256 /**
257 * The VisUIMutator inherents from a VisUIWidget, it's used as a super class for different type of mutator VisUIWidgets.
258 * Mutator VisUIWidgets are used to change a value in a VisParamEntry.
259 */
260 struct _VisUIMutator {
261 VisUIWidget widget; /**< The VisUIWidget data. */
262
263 VisParamEntry *param; /**< The VisParamEntry parameter that is associated with this
264 * VisUIMutator. */
265 };
266
267 /**
268 * The VisUIRange inherents from a VisUIMutator, it's a type of mutator widget that focus on numeric input and
269 * numeric adjustment within a range.
270 */
271 struct _VisUIRange {
272 VisUIMutator mutator; /**< The VisUIMutator data. */
273
274 double min; /**< The minimal value. */
275 double max; /**< The maximal value. */
276 double step; /**< Increase / decrease steps. */
277
278 int precision; /**< Precision, in the fashion of how many numbers behind
279 * the point. */
280 };
281
282 /**
283 * The VisUIEntry inherents from a VisUIMutator, it's used as a way to input text.
284 */
285 struct _VisUIEntry {
286 VisUIMutator mutator; /**< The VisUIMutator data. */
287
288 int length; /**< Maximal length for the text. */
289 };
290
291 /**
292 * The VisUISlider inherents from a VisUIRange, it's used to display a slider which can be used
293 * to adjust a numeric value.
294 */
295 struct _VisUISlider {
296 VisUIRange range; /**< The VisUIRange data. */
297
298 int showvalue; /**< Don't show just the slider, but also the value it
299 * represents at it's current position. */
300 };
301
302 /**
303 * The VisUINumeric inherents from a VisUIRange, it's used to display a numeric spin button that
304 * can be used to adjust a numeric value. A numeric spin button contains out of a small text field
305 * displaying the actual value, followed by two buttons which are used to increase or decrease the value.
306 *
307 * In most VisUI native implementations it's also possible to adjust the text field directly using
308 * the keyboard.
309 */
310 struct _VisUINumeric {
311 VisUIRange range; /**< The VisUIRange data. */
312 };
313
314 /**
315 * The VisUIColor inherents from a VisUIMutator, it's used to adjust the color that is encapsulated by
316 * a VisParamEntry.
317 */
318 struct _VisUIColor {
319 VisUIMutator mutator; /**< The VisUIMutator data. */
320 };
321
322 /**
323 * The VisUIChoiceList is not a VisUIWidget, but it's used by the different types of VisUIChoice widgets to
324 * store information about choices.
325 */
326 struct _VisUIChoiceList {
327 VisObject object; /**< The VisObject data. */
328
329 int count; /**< The amount of choices that are present. */
330 VisList choices; /**< A list of VisUIChoiceEntry elements. */
331 };
332
333 /**
334 * The VisUIChoiceEntry is not a VisUIWidget, but it's used by the different types of VisUIChoice widgets to
335 * store information regarding a choice within a VisUIChoiceList.
336 */
337 struct _VisUIChoiceEntry {
338 VisObject object; /**< The VisObject data. */
339
340 const char *name; /**< Name of this VisChoiceEntry. */
341
342 VisParamEntry *value; /**< Link to the VisParamEntry that contains the value
343 * for this VisChoiceEntry. */
344 };
345
346 /**
347 * The VisUIChoice inherents from a VisUIMutator, it's used as a super class for the different types of
348 * VisUIChoice VisUIWidgets.
349 */
350 struct _VisUIChoice {
351 VisUIMutator mutator; /**< The VisUIMutator data. */
352
353 VisParamEntry *param; /**< Pointer to the VisParamEntry that is the target to
354 * contain the actual value. */
355
356 VisUIChoiceList choices; /**< The different choices present. */
357 };
358
359 /**
360 * The VisUIPopup inherents from a VisUIChoice, it's used to represent choices in a popup fashion, where you
361 * can select an item.
362 */
363 struct _VisUIPopup {
364 VisUIChoice choice; /**< The VisUIChoice data. */
365 };
366
367 /**
368 * The VisUIList inherents from a VisUIChoice, it's used to represent choices in a list fashion.
369 */
370 struct _VisUIList {
371 VisUIChoice choice; /**< The VisUIChoice data. */
372 };
373
374 /**
375 * The VisUIRadio inherents from a VisUIChoice, it's used to represent choices in the fashion of radio buttons. These
376 * are a grouped type of checkboxes where only one item can be active at once.
377 */
378 struct _VisUIRadio {
379 VisUIChoice choice; /**< The VisUIChoice data. */
380
381 VisUIOrientType orient; /**< Orientation of how the different radio buttons in the VisUIRadio button
382 * group is ordered. */
383 };
384
385 /**
386 * The VisUICheckbox inherents from a VisUIChoice, it's used to represent one single checkbox widget. For this reason it
387 * can only represent two choices. One for the toggled state and one for the untoggled state.
388 */
389 struct _VisUICheckbox {
390 VisUIChoice choice; /**< The VisUIChoice data. */
391
392 const char *name; /**< Optional text behind the textbox. */
393 };
394
395 /* prototypes */
396 VisUIWidget *visual_ui_widget_new (void);
397 int visual_ui_widget_set_size_request (VisUIWidget *widget, int width, int height);
398 int visual_ui_widget_set_tooltip (VisUIWidget *widget, const char *tooltip);
399 const char *visual_ui_widget_get_tooltip (VisUIWidget *widget);
400 VisUIWidget *visual_ui_widget_get_top (VisUIWidget *widget);
401 VisUIWidget *visual_ui_widget_get_parent (VisUIWidget *widget);
402 VisUIWidgetType visual_ui_widget_get_type (VisUIWidget *widget);
403
404 int visual_ui_container_add (VisUIContainer *container, VisUIWidget *widget);
405 VisUIWidget *visual_ui_container_get_child (VisUIContainer *container);
406
407 VisUIWidget *visual_ui_box_new (VisUIOrientType orient);
408 int visual_ui_box_pack (VisUIBox *box, VisUIWidget *widget);
409 VisList *visual_ui_box_get_childs (VisUIBox *box);
410 VisUIOrientType visual_ui_box_get_orient (VisUIBox *box);
411
412 VisUIWidget *visual_ui_table_new (int rows, int cols);
413 VisUITableEntry *visual_ui_table_entry_new (VisUIWidget *widget, int row, int col);
414 int visual_ui_table_attach (VisUITable *table, VisUIWidget *widget, int row, int col);
415 VisList *visual_ui_table_get_childs (VisUITable *table);
416
417 VisUIWidget *visual_ui_frame_new (const char *name);
418
419 VisUIWidget *visual_ui_label_new (const char *text, int bold);
420 int visual_ui_label_set_text (VisUILabel *label, const char *text);
421 int visual_ui_label_set_bold (VisUILabel *label, int bold);
422 const char *visual_ui_label_get_text (VisUILabel *label);
423
424 VisUIWidget *visual_ui_image_new (VisVideo *video);
425 int visual_ui_image_set_video (VisUIImage *image, VisVideo *video);
426 VisVideo *visual_ui_image_get_video (VisUIImage *image);
427
428 VisUIWidget *visual_ui_separator_new (VisUIOrientType orient);
429 VisUIOrientType visual_ui_separator_get_orient (VisUISeparator *separator);
430
431 int visual_ui_mutator_set_param (VisUIMutator *mutator, VisParamEntry *param);
432 VisParamEntry *visual_ui_mutator_get_param (VisUIMutator *mutator);
433
434 int visual_ui_range_set_properties (VisUIRange *range, double min, double max, double step, int precision);
435 int visual_ui_range_set_max (VisUIRange *range, double max);
436 int visual_ui_range_set_min (VisUIRange *range, double min);
437 int visual_ui_range_set_step (VisUIRange *range, double step);
438 int visual_ui_range_set_precision (VisUIRange *range, int precision);
439
440 VisUIWidget *visual_ui_entry_new (void);
441 int visual_ui_entry_set_length (VisUIEntry *entry, int length);
442
443 VisUIWidget *visual_ui_slider_new (int showvalue);
444
445 VisUIWidget *visual_ui_numeric_new (void);
446
447 VisUIWidget *visual_ui_color_new (void);
448
449 VisUIChoiceEntry *visual_ui_choice_entry_new (const char *name, VisParamEntry *value);
450 int visual_ui_choice_add (VisUIChoice *choice, const char *name, VisParamEntry *value);
451 int visual_ui_choice_add_many (VisUIChoice *choice, VisParamEntry *paramchoices);
452 int visual_ui_choice_free_choices (VisUIChoice *choice);
453 int visual_ui_choice_set_active (VisUIChoice *choice, int index);
454 int visual_ui_choice_get_active (VisUIChoice *choice);
455 VisUIChoiceEntry *visual_ui_choice_get_choice (VisUIChoice *choice, int index);
456 VisUIChoiceList *visual_ui_choice_get_choices (VisUIChoice *choice);
457
458 /* FIXME look at lists with multiple selections... */
459
460 VisUIWidget *visual_ui_popup_new (void);
461
462 VisUIWidget *visual_ui_list_new (void);
463
464 VisUIWidget *visual_ui_radio_new (VisUIOrientType orient);
465
466 VisUIWidget *visual_ui_checkbox_new (const char *name, int boolcheck);
467
468 #ifdef __cplusplus
469 }
470 #endif /* __cplusplus */
471
472 #endif /* _LV_UI_H */