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;
196 short but_align; /* aligning buttons, horiz/vertical */
201 uiIDPoinFuncFP idpoin_func;
205 uiBlockCreateFunc block_create_func;
207 /* PULLDOWN/MENU data */
208 uiMenuCreateFunc menu_create_func;
211 struct PointerRNA rnapoin;
212 struct PropertyRNA *rnaprop;
215 struct PointerRNA rnasearchpoin;
216 struct PropertyRNA *rnasearchprop;
219 struct wmOperatorType *optype;
221 struct IDProperty *opproperties;
222 struct PointerRNA *opptr;
224 /* active button data */
225 struct uiHandleButtonData *active;
238 uiBlock *next, *prev;
245 struct uiLayout *curlayout;
249 char name[UI_MAX_NAME_STR];
253 float minx, miny, maxx, maxy;
258 uiButHandleFunc func;
262 uiMenuHandleFunc butm_func;
265 uiBlockHandleFunc handle_func;
266 void *handle_func_arg;
268 /* custom extra handling */
269 int (*block_event_func)(const struct bContext *C, struct uiBlock *, struct wmEvent *);
271 /* extra draw function for custom blocks */
272 void (*drawextra)(const struct bContext *C, void *idv, void *argv, rcti *rect);
278 short auto_open, in_use;
279 double auto_open_last;
284 float xofs, yofs; // offset to parent button
285 int bounds, dobounds, mx, my; // for doing delayed
286 int endblock; // uiEndBlock done?
288 rctf safety; // pulldowns, to detect outside, can differ per case how it is created
289 ListBase saferct; // uiSafetyRct list
291 uiPopupBlockHandle *handle; // handle
292 int tooltipdisabled; // to avoid tooltip after click
294 int active; // to keep blocks while drawing and free them afterwards
296 void *evil_C; // XXX hack for dynamic operator enums
299 typedef struct uiSafetyRct {
300 struct uiSafetyRct *next, *prev;
307 extern int ui_translate_buttons(void);
308 extern int ui_translate_menus(void);
309 extern int ui_translate_tooltips(void);
311 void ui_fontscale(short *points, float aspect);
313 extern void ui_block_to_window_fl(const struct ARegion *ar, uiBlock *block, float *x, float *y);
314 extern void ui_block_to_window(const struct ARegion *ar, uiBlock *block, int *x, int *y);
315 extern void ui_block_to_window_rct(const struct ARegion *ar, uiBlock *block, rctf *graph, rcti *winr);
316 extern void ui_window_to_block_fl(const struct ARegion *ar, uiBlock *block, float *x, float *y);
317 extern void ui_window_to_block(const struct ARegion *ar, uiBlock *block, int *x, int *y);
318 extern void ui_window_to_region(const ARegion *ar, int *x, int *y);
320 extern double ui_get_but_val(uiBut *but);
321 extern void ui_set_but_val(uiBut *but, double value);
322 extern void ui_set_but_hsv(uiBut *but);
323 extern void ui_get_but_vectorf(uiBut *but, float *vec);
324 extern void ui_set_but_vectorf(uiBut *but, float *vec);
326 extern void ui_hsvcircle_vals_from_pos(float *valrad, float *valdist, rcti *rect, float mx, float my);
328 extern void ui_get_but_string(uiBut *but, char *str, int maxlen);
329 extern int ui_set_but_string(struct bContext *C, uiBut *but, const char *str);
330 extern int ui_get_but_string_max_length(uiBut *but);
332 extern void ui_set_but_soft_range(uiBut *but, double value);
334 extern void ui_check_but(uiBut *but);
335 extern int ui_is_but_float(uiBut *but);
336 extern void ui_update_block_buts_hsv(uiBlock *block, float *hsv);
338 extern void ui_bounds_block(uiBlock *block);
339 extern void ui_block_translate(uiBlock *block, int x, int y);
340 extern void ui_block_do_align(uiBlock *block);
342 /* interface_regions.c */
344 struct uiPopupBlockHandle {
346 struct ARegion *region;
347 int towardsx, towardsy;
352 void (*popup_func)(struct bContext *C, void *arg, int event);
353 void (*cancel_func)(void *arg);
356 /* for operator popups */
357 struct wmOperatorType *optype;
369 uiBlock *ui_block_func_MENU(struct bContext *C, uiPopupBlockHandle *handle, void *arg_but);
370 uiBlock *ui_block_func_ICONROW(struct bContext *C, uiPopupBlockHandle *handle, void *arg_but);
371 uiBlock *ui_block_func_ICONTEXTROW(struct bContext *C, uiPopupBlockHandle *handle, void *arg_but);
372 uiBlock *ui_block_func_COL(struct bContext *C, uiPopupBlockHandle *handle, void *arg_but);
374 struct ARegion *ui_tooltip_create(struct bContext *C, struct ARegion *butregion, uiBut *but);
375 void ui_tooltip_free(struct bContext *C, struct ARegion *ar);
377 /* searchbox for string button */
378 ARegion *ui_searchbox_create(struct bContext *C, struct ARegion *butregion, uiBut *but);
379 int ui_searchbox_inside(struct ARegion *ar, int x, int y);
380 void ui_searchbox_update(struct bContext *C, struct ARegion *ar, uiBut *but, int reset);
381 void ui_searchbox_autocomplete(struct bContext *C, struct ARegion *ar, uiBut *but, char *str);
382 void ui_searchbox_event(struct bContext *C, struct ARegion *ar, uiBut *but, struct wmEvent *event);
383 void ui_searchbox_apply(uiBut *but, struct ARegion *ar);
384 void ui_searchbox_free(struct bContext *C, struct ARegion *ar);
386 typedef uiBlock* (*uiBlockHandleCreateFunc)(struct bContext *C, struct uiPopupBlockHandle *handle, void *arg1);
388 uiPopupBlockHandle *ui_popup_block_create(struct bContext *C, struct ARegion *butregion, uiBut *but,
389 uiBlockCreateFunc create_func, uiBlockHandleCreateFunc handle_create_func, void *arg);
390 uiPopupBlockHandle *ui_popup_menu_create(struct bContext *C, struct ARegion *butregion, uiBut *but,
391 uiMenuCreateFunc create_func, void *arg);
392 void ui_popup_block_free(struct bContext *C, uiPopupBlockHandle *handle);
394 void ui_set_name_menu(uiBut *but, int value);
395 int ui_step_name_menu(uiBut *but, int step);
398 struct AutoComplete *autocomplete_begin(char *startname, int maxlen);
399 void autocomplete_do_name(struct AutoComplete *autocpl, const char *name);
400 void autocomplete_end(struct AutoComplete *autocpl, char *autoname);
402 /* interface_panel.c */
403 extern int ui_handler_panel_region(struct bContext *C, struct wmEvent *event);
404 extern void ui_draw_aligned_panel(struct ARegion *ar, struct uiStyle *style, uiBlock *block, rcti *rect);
406 /* interface_draw.c */
407 extern void ui_dropshadow(rctf *rct, float radius, float aspect, int select);
409 extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad);
410 extern void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown);
411 extern void gl_round_box_vertical_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadeLeft, float shadeRight);
413 void ui_draw_but_COLORBAND(uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
414 void ui_draw_but_NORMAL(uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
415 void ui_draw_but_CURVE(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
418 /* interface_handlers.c */
419 extern void ui_button_active_cancel(const struct bContext *C, uiBut *but);
420 extern int ui_button_is_active(struct ARegion *ar);
422 /* interface_widgets.c */
423 void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3);
424 void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect);
425 void ui_draw_search_back(struct uiStyle *style, uiBlock *block, rcti *rect);
426 void ui_draw_link_bezier(rcti *rect);
428 extern void ui_draw_but(const struct bContext *C, ARegion *ar, struct uiStyle *style, uiBut *but, rcti *rect);
429 /* theme color init */
431 void ui_widget_color_init(struct ThemeUI *tui);
433 void ui_draw_menu_item(struct uiFontStyle *fstyle, rcti *rect, char *name, int iconid, int state);
435 /* interface_style.c */
436 void uiStyleInit(void);
438 /* interface_icons.c */
439 void ui_id_icon_render(struct Scene *scene, struct ID *id);
440 int ui_id_icon_get(struct Scene *scene, struct ID *id);
443 void init_userdef_do_versions(void);
444 void ui_theme_init_userdef(void);
445 void ui_resources_init(void);
446 void ui_resources_free(void);
448 /* interface_layout.c */
449 void ui_layout_add_but(uiLayout *layout, uiBut *but);
450 int ui_but_can_align(uiBut *but);
451 void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *searchptr, PropertyRNA *searchprop);
453 /* interface_anim.c */
454 void ui_but_anim_flag(uiBut *but, float cfra);
455 void ui_but_anim_insert_keyframe(struct bContext *C);
456 void ui_but_anim_delete_keyframe(struct bContext *C);
457 void ui_but_anim_add_driver(struct bContext *C);
458 void ui_but_anim_remove_driver(struct bContext *C);
459 void ui_but_anim_menu(struct bContext *C, uiBut *but);
460 int ui_but_anim_expression_get(uiBut *but, char *str, int maxlen);
461 int ui_but_anim_expression_set(uiBut *but, const char *str);
462 void ui_but_anim_autokey(uiBut *but, struct Scene *scene, float cfra);