4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
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.
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 Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21 * All rights reserved.
23 * The Original Code is: all of this file.
25 * Contributor(s): none yet.
27 * ***** END GPL LICENSE BLOCK *****
33 #include "UI_resources.h"
34 #include "RNA_types.h"
39 struct uiHandleButtonData;
41 struct wmOperatorType;
44 struct uiWidgetColors;
50 /* ****************** general defines ************** */
52 /* visual types for drawing */
53 /* for time being separated from functional types */
70 UI_WTYPE_POINTER_LINK,
75 UI_WTYPE_MENU_POINTER_LINK,
94 #define UI_MAX_DRAW_STR 400
95 #define UI_MAX_NAME_STR 64
99 #define UI_PANEL_MINX 100
100 #define UI_PANEL_MINY 70
104 #define UI_MOUSE_OVER 2
106 #define UI_HAS_ICON 8
107 #define UI_TEXTINPUT 16
109 /* warn: rest of uiBut->flag in UI_interface.h */
111 /* internal panel drawing defines */
113 #define PNL_HEADER 20
117 #define PNL_CLOSEDX 2
118 #define PNL_CLOSEDY 4
121 #define PNL_OVERLAP 16
123 /* Button text selection:
124 * extension direction, selextend, inside ui_do_but_TEX */
125 #define EXTEND_LEFT 1
126 #define EXTEND_RIGHT 2
135 typedef struct uiLinkLine { /* only for draw/edit */
136 struct uiLinkLine *next, *prev;
140 struct uiBut *from, *to;
144 void **poin; /* pointer to original pointer */
145 void ***ppoin; /* pointer to original pointer-array */
146 short *totlink; /* if pointer-array, here is the total */
149 short fromcode, tocode;
155 struct uiBut *next, *prev;
156 short type, pointype, bit, bitnr, retval, strwidth, ofs, pos, selsta, selend;
161 char strdata[UI_MAX_NAME_STR];
162 char drawstr[UI_MAX_DRAW_STR];
164 float x1, y1, x2, y2;
167 float hardmin, hardmax, softmin, softmax;
168 float a1, a2, hsv[3]; // hsv is temp memory for hsv buttons
171 uiButHandleFunc func;
176 uiButHandleNFunc funcN;
179 struct bContextStore *context;
181 void (*embossfunc)(int , int , float, float, float, float, float, int);
182 void (*sliderfunc)(int , float, float, float, float, float, float, int);
184 uiButCompleteFunc autocomplete_func;
187 uiButSearchFunc search_func;
190 uiButHandleRenameFunc rename_func;
200 short but_align; /* aligning buttons, horiz/vertical */
205 uiIDPoinFuncFP idpoin_func;
209 uiBlockCreateFunc block_create_func;
211 /* PULLDOWN/MENU data */
212 uiMenuCreateFunc menu_create_func;
215 struct PointerRNA rnapoin;
216 struct PropertyRNA *rnaprop;
219 struct PointerRNA rnasearchpoin;
220 struct PropertyRNA *rnasearchprop;
223 struct wmOperatorType *optype;
225 struct IDProperty *opproperties;
226 struct PointerRNA *opptr;
228 /* active button data */
229 struct uiHandleButtonData *active;
242 uiBlock *next, *prev;
249 struct uiLayout *curlayout;
253 char name[UI_MAX_NAME_STR];
257 float minx, miny, maxx, maxy;
262 uiButHandleFunc func;
266 uiMenuHandleFunc butm_func;
269 uiBlockHandleFunc handle_func;
270 void *handle_func_arg;
272 /* custom extra handling */
273 int (*block_event_func)(const struct bContext *C, struct uiBlock *, struct wmEvent *);
275 /* extra draw function for custom blocks */
276 void (*drawextra)(const struct bContext *C, void *idv, void *argv, rcti *rect);
282 short auto_open, in_use;
283 double auto_open_last;
288 float xofs, yofs; // offset to parent button
289 int bounds, dobounds, mx, my; // for doing delayed
290 int endblock; // uiEndBlock done?
292 rctf safety; // pulldowns, to detect outside, can differ per case how it is created
293 ListBase saferct; // uiSafetyRct list
295 uiPopupBlockHandle *handle; // handle
296 int tooltipdisabled; // to avoid tooltip after click
298 int active; // to keep blocks while drawing and free them afterwards
300 void *evil_C; // XXX hack for dynamic operator enums
303 typedef struct uiSafetyRct {
304 struct uiSafetyRct *next, *prev;
311 extern int ui_translate_buttons(void);
312 extern int ui_translate_menus(void);
313 extern int ui_translate_tooltips(void);
315 void ui_fontscale(short *points, float aspect);
317 extern void ui_block_to_window_fl(const struct ARegion *ar, uiBlock *block, float *x, float *y);
318 extern void ui_block_to_window(const struct ARegion *ar, uiBlock *block, int *x, int *y);
319 extern void ui_block_to_window_rct(const struct ARegion *ar, uiBlock *block, rctf *graph, rcti *winr);
320 extern void ui_window_to_block_fl(const struct ARegion *ar, uiBlock *block, float *x, float *y);
321 extern void ui_window_to_block(const struct ARegion *ar, uiBlock *block, int *x, int *y);
322 extern void ui_window_to_region(const ARegion *ar, int *x, int *y);
324 extern double ui_get_but_val(uiBut *but);
325 extern void ui_set_but_val(uiBut *but, double value);
326 extern void ui_set_but_hsv(uiBut *but);
327 extern void ui_get_but_vectorf(uiBut *but, float *vec);
328 extern void ui_set_but_vectorf(uiBut *but, float *vec);
330 extern void ui_hsvcircle_vals_from_pos(float *valrad, float *valdist, rcti *rect, float mx, float my);
332 extern void ui_get_but_string(uiBut *but, char *str, int maxlen);
333 extern int ui_set_but_string(struct bContext *C, uiBut *but, const char *str);
334 extern int ui_get_but_string_max_length(uiBut *but);
336 extern void ui_set_but_soft_range(uiBut *but, double value);
338 extern void ui_check_but(uiBut *but);
339 extern int ui_is_but_float(uiBut *but);
340 extern void ui_update_block_buts_hsv(uiBlock *block, float *hsv);
342 extern void ui_bounds_block(uiBlock *block);
343 extern void ui_block_translate(uiBlock *block, int x, int y);
344 extern void ui_block_do_align(uiBlock *block);
346 /* interface_regions.c */
348 struct uiPopupBlockHandle {
350 struct ARegion *region;
351 int towardsx, towardsy;
356 void (*popup_func)(struct bContext *C, void *arg, int event);
357 void (*cancel_func)(void *arg);
360 /* for operator popups */
361 struct wmOperatorType *optype;
373 uiBlock *ui_block_func_MENU(struct bContext *C, uiPopupBlockHandle *handle, void *arg_but);
374 uiBlock *ui_block_func_ICONROW(struct bContext *C, uiPopupBlockHandle *handle, void *arg_but);
375 uiBlock *ui_block_func_ICONTEXTROW(struct bContext *C, uiPopupBlockHandle *handle, void *arg_but);
376 uiBlock *ui_block_func_COL(struct bContext *C, uiPopupBlockHandle *handle, void *arg_but);
378 struct ARegion *ui_tooltip_create(struct bContext *C, struct ARegion *butregion, uiBut *but);
379 void ui_tooltip_free(struct bContext *C, struct ARegion *ar);
381 /* searchbox for string button */
382 ARegion *ui_searchbox_create(struct bContext *C, struct ARegion *butregion, uiBut *but);
383 int ui_searchbox_inside(struct ARegion *ar, int x, int y);
384 void ui_searchbox_update(struct bContext *C, struct ARegion *ar, uiBut *but, int reset);
385 void ui_searchbox_autocomplete(struct bContext *C, struct ARegion *ar, uiBut *but, char *str);
386 void ui_searchbox_event(struct bContext *C, struct ARegion *ar, uiBut *but, struct wmEvent *event);
387 void ui_searchbox_apply(uiBut *but, struct ARegion *ar);
388 void ui_searchbox_free(struct bContext *C, struct ARegion *ar);
390 typedef uiBlock* (*uiBlockHandleCreateFunc)(struct bContext *C, struct uiPopupBlockHandle *handle, void *arg1);
392 uiPopupBlockHandle *ui_popup_block_create(struct bContext *C, struct ARegion *butregion, uiBut *but,
393 uiBlockCreateFunc create_func, uiBlockHandleCreateFunc handle_create_func, void *arg);
394 uiPopupBlockHandle *ui_popup_menu_create(struct bContext *C, struct ARegion *butregion, uiBut *but,
395 uiMenuCreateFunc create_func, void *arg);
396 void ui_popup_block_free(struct bContext *C, uiPopupBlockHandle *handle);
398 void ui_set_name_menu(uiBut *but, int value);
399 int ui_step_name_menu(uiBut *but, int step);
402 struct AutoComplete *autocomplete_begin(char *startname, int maxlen);
403 void autocomplete_do_name(struct AutoComplete *autocpl, const char *name);
404 void autocomplete_end(struct AutoComplete *autocpl, char *autoname);
406 /* interface_panel.c */
407 extern int ui_handler_panel_region(struct bContext *C, struct wmEvent *event);
408 extern void ui_draw_aligned_panel(struct ARegion *ar, struct uiStyle *style, uiBlock *block, rcti *rect);
410 /* interface_draw.c */
411 extern void ui_dropshadow(rctf *rct, float radius, float aspect, int select);
413 extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad);
414 extern void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown);
415 extern void gl_round_box_vertical_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadeLeft, float shadeRight);
417 void ui_draw_but_COLORBAND(uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
418 void ui_draw_but_NORMAL(uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
419 void ui_draw_but_CURVE(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
422 /* interface_handlers.c */
423 extern void ui_button_activate_do(struct bContext *C, struct ARegion *ar, uiBut *but);
424 extern void ui_button_active_cancel(const struct bContext *C, uiBut *but);
425 extern int ui_button_is_active(struct ARegion *ar);
427 /* interface_widgets.c */
428 void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3);
429 void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect);
430 void ui_draw_search_back(struct uiStyle *style, uiBlock *block, rcti *rect);
431 void ui_draw_link_bezier(rcti *rect);
433 extern void ui_draw_but(const struct bContext *C, ARegion *ar, struct uiStyle *style, uiBut *but, rcti *rect);
434 /* theme color init */
436 void ui_widget_color_init(struct ThemeUI *tui);
438 void ui_draw_menu_item(struct uiFontStyle *fstyle, rcti *rect, char *name, int iconid, int state);
440 /* interface_style.c */
441 void uiStyleInit(void);
443 /* interface_icons.c */
444 void ui_id_icon_render(struct Scene *scene, struct ID *id);
445 int ui_id_icon_get(struct Scene *scene, struct ID *id);
448 void init_userdef_do_versions(void);
449 void ui_theme_init_userdef(void);
450 void ui_resources_init(void);
451 void ui_resources_free(void);
453 /* interface_layout.c */
454 void ui_layout_add_but(uiLayout *layout, uiBut *but);
455 int ui_but_can_align(uiBut *but);
456 void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *searchptr, PropertyRNA *searchprop);
458 /* interface_anim.c */
459 void ui_but_anim_flag(uiBut *but, float cfra);
460 void ui_but_anim_insert_keyframe(struct bContext *C);
461 void ui_but_anim_delete_keyframe(struct bContext *C);
462 void ui_but_anim_add_driver(struct bContext *C);
463 void ui_but_anim_remove_driver(struct bContext *C);
464 void ui_but_anim_menu(struct bContext *C, uiBut *but);
465 int ui_but_anim_expression_get(uiBut *but, char *str, int maxlen);
466 int ui_but_anim_expression_set(uiBut *but, const char *str);
467 void ui_but_anim_autokey(uiBut *but, struct Scene *scene, float cfra);