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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 *****
30 /** \file blender/editors/interface/interface_intern.h
31 * \ingroup edinterface
38 #include "UI_resources.h"
39 #include "RNA_types.h"
44 struct uiHandleButtonData;
46 struct wmOperatorType;
50 struct uiWidgetColors;
57 /* ****************** general defines ************** */
59 /* visual types for drawing */
60 /* for time being separated from functional types */
77 UI_WTYPE_POINTER_LINK,
82 UI_WTYPE_MENU_ICON_RADIO,
83 UI_WTYPE_MENU_POINTER_LINK,
103 #define UI_MAX_DRAW_STR 400
104 #define UI_MAX_NAME_STR 128
107 #define UI_PANEL_MINX 100
108 #define UI_PANEL_MINY 70
111 #define UI_SELECT 1 /* use when the button is pressed */
112 #define UI_SCROLLED 2 /* temp hidden, scrolled away */
114 #define UI_HAS_ICON 8
115 #define UI_TEXTINPUT 16
117 /* warn: rest of uiBut->flag in UI_interface.h */
119 /* internal panel drawing defines */
120 #define PNL_GRID (UI_UNIT_Y / 5) /* 4 default */
121 #define PNL_HEADER UI_UNIT_Y /* 20 default */
125 #define PNL_CLOSEDX 2
126 #define PNL_CLOSEDY 4
128 /*#define PNL_TABBED 8*/ /*UNUSED*/
129 #define PNL_OVERLAP 16
131 /* Button text selection:
132 * extension direction, selextend, inside ui_do_but_TEX */
133 #define EXTEND_LEFT 1
134 #define EXTEND_RIGHT 2
136 /* for scope resize zone */
137 #define SCOPE_RESIZE_PAD 9
146 typedef struct uiLinkLine { /* only for draw/edit */
147 struct uiLinkLine *next, *prev;
151 struct uiBut *from, *to;
155 void **poin; /* pointer to original pointer */
156 void ***ppoin; /* pointer to original pointer-array */
157 short *totlink; /* if pointer-array, here is the total */
160 short fromcode, tocode;
166 struct uiBut *next, *prev;
167 short type, pointype, bit, bitnr, retval, strwidth, ofs, pos, selsta, selend;
172 char strdata[UI_MAX_NAME_STR];
173 char drawstr[UI_MAX_DRAW_STR];
175 float x1, y1, x2, y2;
178 float hardmin, hardmax, softmin, softmax;
183 uiButHandleFunc func;
188 uiButHandleNFunc funcN;
191 struct bContextStore *context;
193 /* not ysed yet, was used in 2.4x for ui_draw_pulldown_round & friends */
195 void (*embossfunc)(int , int , float, float, float, float, float, int);
196 void (*sliderfunc)(int , float, float, float, float, float, float, int);
199 uiButCompleteFunc autocomplete_func;
202 uiButSearchFunc search_func;
205 uiButHandleRenameFunc rename_func;
212 const char *tip, *lockstr;
216 char dt; /* drawtype: UI_EMBOSS, UI_EMBOSSN ... etc, copied from the block */
217 char changed; /* could be made into a single flag */
218 unsigned char unit_type; /* so buttons can support unit systems which are not RNA */
223 uiIDPoinFuncFP idpoin_func;
227 uiBlockCreateFunc block_create_func;
229 /* PULLDOWN/MENU data */
230 uiMenuCreateFunc menu_create_func;
233 struct PointerRNA rnapoin;
234 struct PropertyRNA *rnaprop;
237 struct PointerRNA rnasearchpoin;
238 struct PropertyRNA *rnasearchprop;
241 struct wmOperatorType *optype;
242 struct IDProperty *opproperties;
243 struct PointerRNA *opptr;
245 unsigned char menu_key; /* 'a'-'z', always lower case */
247 /* Draggable data, type is WM_DRAG_... */
253 /* active button data */
254 struct uiHandleButtonData *active;
267 uiBlock *next, *prev;
274 struct uiLayout *curlayout;
278 char name[UI_MAX_NAME_STR];
282 float minx, miny, maxx, maxy;
287 uiButHandleFunc func;
291 uiButHandleNFunc funcN;
294 uiMenuHandleFunc butm_func;
297 uiBlockHandleFunc handle_func;
298 void *handle_func_arg;
300 /* custom extra handling */
301 int (*block_event_func)(const struct bContext *C, struct uiBlock *, struct wmEvent *);
303 /* extra draw function for custom blocks */
304 void (*drawextra)(const struct bContext *C, void *idv, void *arg1, void *arg2, rcti *rect);
305 void *drawextra_arg1;
306 void *drawextra_arg2;
310 char dt; /* drawtype: UI_EMBOSS, UI_EMBOSSN ... etc, copied to buttons */
312 double auto_open_last;
317 char active; // to keep blocks while drawing and free them afterwards
318 char tooltipdisabled; // to avoid tooltip after click
319 char endblock; // uiEndBlock done?
321 float xofs, yofs; // offset to parent button
322 int dobounds, mx, my; // for doing delayed
323 int bounds, minbounds; // for doing delayed
325 rctf safety; // pulldowns, to detect outside, can differ per case how it is created
326 ListBase saferct; // uiSafetyRct list
328 uiPopupBlockHandle *handle; // handle
330 int puphash; // popup menu hash for memory
332 void *evil_C; // XXX hack for dynamic operator enums
334 float _hsv[3]; // XXX, only access via ui_block_hsv_get()
335 char color_profile; // color profile for correcting linear colors for display
336 struct UnitSettings *unit; // unit system, used a lot for numeric buttons so include here rather then fetching through the scene every time.
340 typedef struct uiSafetyRct {
341 struct uiSafetyRct *next, *prev;
348 extern void ui_delete_linkline(uiLinkLine *line, uiBut *but);
350 void ui_fontscale(short *points, float aspect);
352 extern void ui_block_to_window_fl(const struct ARegion *ar, uiBlock *block, float *x, float *y);
353 extern void ui_block_to_window(const struct ARegion *ar, uiBlock *block, int *x, int *y);
354 extern void ui_block_to_window_rct(const struct ARegion *ar, uiBlock *block, rctf *graph, rcti *winr);
355 extern void ui_window_to_block_fl(const struct ARegion *ar, uiBlock *block, float *x, float *y);
356 extern void ui_window_to_block(const struct ARegion *ar, uiBlock *block, int *x, int *y);
357 extern void ui_window_to_region(const ARegion *ar, int *x, int *y);
359 extern double ui_get_but_val(uiBut *but);
360 extern void ui_set_but_val(uiBut *but, double value);
361 extern void ui_set_but_hsv(uiBut *but);
362 extern void ui_get_but_vectorf(uiBut *but, float *vec);
363 extern void ui_set_but_vectorf(uiBut *but, float *vec);
365 extern void ui_hsvcircle_vals_from_pos(float *valrad, float *valdist, rcti *rect, float mx, float my);
367 extern void ui_get_but_string(uiBut *but, char *str, size_t maxlen);
368 extern void ui_convert_to_unit_alt_name(uiBut *but, char *str, size_t maxlen);
369 extern int ui_set_but_string(struct bContext *C, uiBut *but, const char *str);
370 extern int ui_get_but_string_max_length(uiBut *but);
372 extern void ui_set_but_default(struct bContext *C, short all);
374 extern void ui_set_but_soft_range(uiBut *but, double value);
376 extern void ui_check_but(uiBut *but);
377 extern int ui_is_but_float(uiBut *but);
378 extern int ui_is_but_unit(uiBut *but);
379 extern int ui_is_but_rna_valid(uiBut *but);
381 extern void ui_bounds_block(uiBlock *block);
382 extern void ui_block_translate(uiBlock *block, int x, int y);
383 extern void ui_block_do_align(uiBlock *block);
385 /* interface_regions.c */
387 struct uiPopupBlockHandle {
389 struct ARegion *region;
390 int towardsx, towardsy;
395 void (*popup_func)(struct bContext *C, void *arg, int event);
396 void (*cancel_func)(void *arg);
399 struct wmTimer *scrolltimer;
401 /* for operator popups */
402 struct wmOperatorType *optype;
414 uiBlock *ui_block_func_COL(struct bContext *C, uiPopupBlockHandle *handle, void *arg_but);
415 void ui_block_func_ICONROW(struct bContext *C, uiLayout *layout, void *arg_but);
416 void ui_block_func_ICONTEXTROW(struct bContext *C, uiLayout *layout, void *arg_but);
418 struct ARegion *ui_tooltip_create(struct bContext *C, struct ARegion *butregion, uiBut *but);
419 void ui_tooltip_free(struct bContext *C, struct ARegion *ar);
421 uiBut *ui_popup_menu_memory(struct uiBlock *block, struct uiBut *but);
423 float *ui_block_hsv_get(struct uiBlock *block);
424 void ui_popup_block_scrolltest(struct uiBlock *block);
427 /* searchbox for string button */
428 ARegion *ui_searchbox_create(struct bContext *C, struct ARegion *butregion, uiBut *but);
429 int ui_searchbox_inside(struct ARegion *ar, int x, int y);
430 void ui_searchbox_update(struct bContext *C, struct ARegion *ar, uiBut *but, int reset);
431 void ui_searchbox_autocomplete(struct bContext *C, struct ARegion *ar, uiBut *but, char *str);
432 void ui_searchbox_event(struct bContext *C, struct ARegion *ar, uiBut *but, struct wmEvent *event);
433 void ui_searchbox_apply(uiBut *but, struct ARegion *ar);
434 void ui_searchbox_free(struct bContext *C, struct ARegion *ar);
435 void ui_but_search_test(uiBut *but);
437 typedef uiBlock* (*uiBlockHandleCreateFunc)(struct bContext *C, struct uiPopupBlockHandle *handle, void *arg1);
439 uiPopupBlockHandle *ui_popup_block_create(struct bContext *C, struct ARegion *butregion, uiBut *but,
440 uiBlockCreateFunc create_func, uiBlockHandleCreateFunc handle_create_func, void *arg);
441 uiPopupBlockHandle *ui_popup_menu_create(struct bContext *C, struct ARegion *butregion, uiBut *but,
442 uiMenuCreateFunc create_func, void *arg, char *str);
444 void ui_popup_block_free(struct bContext *C, uiPopupBlockHandle *handle);
446 void ui_set_name_menu(uiBut *but, int value);
447 int ui_step_name_menu(uiBut *but, int step);
451 /* interface_panel.c */
452 extern int ui_handler_panel_region(struct bContext *C, struct wmEvent *event);
453 extern void ui_draw_aligned_panel(struct uiStyle *style, uiBlock *block, rcti *rect);
455 /* interface_draw.c */
456 extern void ui_dropshadow(rctf *rct, float radius, float aspect, int select);
458 void ui_draw_gradient(rcti *rect, float *hsv, int type, float alpha);
460 void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
461 void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
462 void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
463 void ui_draw_but_COLORBAND(uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
464 void ui_draw_but_NORMAL(uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
465 void ui_draw_but_CURVE(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
466 void ui_draw_but_IMAGE(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
467 void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
469 /* interface_handlers.c */
470 extern void ui_button_activate_do(struct bContext *C, struct ARegion *ar, uiBut *but);
471 extern void ui_button_active_free(const struct bContext *C, uiBut *but);
472 extern int ui_button_is_active(struct ARegion *ar);
474 /* interface_widgets.c */
475 void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3);
476 void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect);
477 void ui_draw_search_back(struct uiStyle *style, uiBlock *block, rcti *rect);
478 int ui_link_bezier_points(rcti *rect, float coord_array[][2], int resol);
479 void ui_draw_link_bezier(rcti *rect);
481 extern void ui_draw_but(const struct bContext *C, ARegion *ar, struct uiStyle *style, uiBut *but, rcti *rect);
482 /* theme color init */
484 void ui_widget_color_init(struct ThemeUI *tui);
486 void ui_draw_menu_item(struct uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state);
487 void ui_draw_preview_item(struct uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state);
489 extern unsigned char checker_stipple_sml[];
490 /* used for transp checkers */
491 #define UI_TRANSP_DARK 100
492 #define UI_TRANSP_LIGHT 160
494 /* interface_style.c */
495 void uiStyleInit(void);
497 /* interface_icons.c */
498 int ui_id_icon_get(struct bContext *C, struct ID *id, int preview);
501 void init_userdef_do_versions(void);
502 void ui_theme_init_default(void);
503 void ui_resources_init(void);
504 void ui_resources_free(void);
506 /* interface_layout.c */
507 void ui_layout_add_but(uiLayout *layout, uiBut *but);
508 int ui_but_can_align(uiBut *but);
509 void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *searchptr, PropertyRNA *searchprop);
511 /* interface_anim.c */
512 void ui_but_anim_flag(uiBut *but, float cfra);
513 void ui_but_anim_insert_keyframe(struct bContext *C);
514 void ui_but_anim_delete_keyframe(struct bContext *C);
515 void ui_but_anim_add_driver(struct bContext *C);
516 void ui_but_anim_remove_driver(struct bContext *C);
517 void ui_but_anim_copy_driver(struct bContext *C);
518 void ui_but_anim_paste_driver(struct bContext *C);
519 void ui_but_anim_add_keyingset(struct bContext *C);
520 void ui_but_anim_remove_keyingset(struct bContext *C);
521 int ui_but_anim_expression_get(uiBut *but, char *str, size_t maxlen);
522 int ui_but_anim_expression_set(uiBut *but, const char *str);
523 int ui_but_anim_expression_create(uiBut *but, const char *str);
524 void ui_but_anim_autokey(struct bContext *C, uiBut *but, struct Scene *scene, float cfra);