2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19 * All rights reserved.
21 * The Original Code is: all of this file.
23 * Contributor(s): none yet.
25 * ***** END GPL LICENSE BLOCK *****
28 /** \file UI_interface.h
32 #ifndef __UI_INTERFACE_H__
33 #define __UI_INTERFACE_H__
35 #include "BLI_compiler_attrs.h"
36 #include "BLI_sys_types.h" /* size_t */
37 #include "RNA_types.h"
38 #include "DNA_userdef_types.h"
40 /* Struct Declarations */
50 struct wmWindowManager;
65 struct uiWidgetColors;
70 struct wmOperatorType;
71 struct uiWidgetColors;
82 typedef struct uiBut uiBut;
83 typedef struct uiBlock uiBlock;
84 typedef struct uiPopupBlockHandle uiPopupBlockHandle;
85 typedef struct uiLayout uiLayout;
89 /* char for splitting strings, aligning shortcuts in menus, users never see */
90 #define UI_SEP_CHAR '|'
91 #define UI_SEP_CHAR_S "|"
94 #define UI_MAX_DRAW_STR 400
95 #define UI_MAX_NAME_STR 128
97 /* use for clamping popups within the screen */
98 #define UI_SCREEN_MARGIN 10
100 /* uiBlock->dt and uiBut->dt */
102 UI_EMBOSS = 0, /* use widget style for drawing */
103 UI_EMBOSS_NONE = 1, /* Nothing, only icon and/or text */
104 UI_EMBOSS_PULLDOWN = 2, /* Pulldown menu style */
105 UI_EMBOSS_TABLE = 3, /* Table */
106 UI_EMBOSS_RADIAL = 4, /* Pie Menu */
109 /* uiBlock->direction */
111 UI_DIR_UP = (1 << 0),
112 UI_DIR_DOWN = (1 << 1),
113 UI_DIR_LEFT = (1 << 2),
114 UI_DIR_RIGHT = (1 << 3),
115 UI_DIR_CENTER_Y = (1 << 4),
117 UI_DIR_ALL = (UI_DIR_UP | UI_DIR_DOWN | UI_DIR_LEFT | UI_DIR_RIGHT),
121 /* uiBlock->autofill (not yet used) */
122 #define UI_BLOCK_COLLUMNS 1
123 #define UI_BLOCK_ROWS 2
126 /* uiBlock->flag (controls) */
127 #define UI_BLOCK_LOOP (1 << 0)
128 #define UI_BLOCK_REDRAW (1 << 1)
129 #define UI_BLOCK_SEARCH_MENU (1 << 2)
130 #define UI_BLOCK_NUMSELECT (1 << 3)
131 #define UI_BLOCK_NO_WIN_CLIP (1 << 4) /* don't apply window clipping */ /* was UI_BLOCK_ENTER_OK */
132 #define UI_BLOCK_CLIPBOTTOM (1 << 5)
133 #define UI_BLOCK_CLIPTOP (1 << 6)
134 #define UI_BLOCK_MOVEMOUSE_QUIT (1 << 7)
135 #define UI_BLOCK_KEEP_OPEN (1 << 8)
136 #define UI_BLOCK_POPUP (1 << 9)
137 #define UI_BLOCK_OUT_1 (1 << 10)
138 #define UI_BLOCK_NO_FLIP (1 << 11)
139 #define UI_BLOCK_POPUP_MEMORY (1 << 12)
140 #define UI_BLOCK_CLIP_EVENTS (1 << 13) /* stop handling mouse events */
142 /* block->flag bits 14-17 are identical to but->drawflag bits */
144 #define UI_BLOCK_LIST_ITEM (1 << 19)
145 #define UI_BLOCK_RADIAL (1 << 20)
147 /* uiPopupBlockHandle->menuretval */
148 #define UI_RETURN_CANCEL (1 << 0) /* cancel all menus cascading */
149 #define UI_RETURN_OK (1 << 1) /* choice made */
150 #define UI_RETURN_OUT (1 << 2) /* left the menu */
151 #define UI_RETURN_OUT_PARENT (1 << 3) /* let the parent handle this event */
152 #define UI_RETURN_UPDATE (1 << 4) /* update the button that opened */
153 #define UI_RETURN_POPUP_OK (1 << 5) /* popup is ok to be handled */
156 #define UI_PNL_SOLID (1 << 1)
157 #define UI_PNL_CLOSE (1 << 5)
158 #define UI_PNL_SCALE (1 << 9)
160 /* but->flag - general state flags. */
162 /* warning, the first 6 flags are internal */
163 UI_BUT_ICON_SUBMENU = (1 << 6),
164 UI_BUT_ICON_PREVIEW = (1 << 7),
166 UI_BUT_NODE_LINK = (1 << 8),
167 UI_BUT_NODE_ACTIVE = (1 << 9),
168 UI_BUT_DRAG_LOCK = (1 << 10),
169 UI_BUT_DISABLED = (1 << 11),
170 UI_BUT_COLOR_LOCK = (1 << 12),
171 UI_BUT_ANIMATED = (1 << 13),
172 UI_BUT_ANIMATED_KEY = (1 << 14),
173 UI_BUT_DRIVEN = (1 << 15),
174 UI_BUT_REDALERT = (1 << 16),
175 UI_BUT_INACTIVE = (1 << 17),
176 UI_BUT_LAST_ACTIVE = (1 << 18),
177 UI_BUT_UNDO = (1 << 19),
178 UI_BUT_IMMEDIATE = (1 << 20),
179 UI_BUT_NO_UTF8 = (1 << 21),
181 UI_BUT_VEC_SIZE_LOCK = (1 << 22), /* used to flag if color hsv-circle should keep luminance */
182 UI_BUT_COLOR_CUBIC = (1 << 23), /* cubic saturation for the color wheel */
183 UI_BUT_LIST_ITEM = (1 << 24), /* This but is "inside" a list item (currently used to change theme colors). */
184 UI_BUT_DRAG_MULTI = (1 << 25), /* edit this button as well as the active button (not just dragging) */
185 UI_BUT_SCA_LINK_GREY = (1 << 26), /* used to flag if sca links shoud be grey out */
186 UI_BUT_HAS_SEP_CHAR = (1 << 27), /* but->str contains UI_SEP_CHAR, used for key shortcuts */
187 UI_BUT_TIP_FORCE = (1 << 28), /* force show tooltips when holding option/alt if U's USER_TOOLTIPS is off */
190 #define UI_PANEL_WIDTH 340
191 #define UI_COMPACT_PANEL_WIDTH 160
193 #define UI_PANEL_CATEGORY_MARGIN_WIDTH (U.widget_unit * 1.0f)
195 /* but->drawflag - these flags should only affect how the button is drawn. */
196 /* Note: currently, these flags _are not passed_ to the widget's state() or draw() functions
197 * (except for the 'align' ones)!
200 /* Text and icon alignment (by default, they are centered). */
201 UI_BUT_TEXT_LEFT = (1 << 1),
202 UI_BUT_ICON_LEFT = (1 << 2),
203 UI_BUT_TEXT_RIGHT = (1 << 3),
204 /* Prevent the button to show any tooltip. */
205 UI_BUT_NO_TOOLTIP = (1 << 4),
206 /* button align flag, for drawing groups together (also used in uiBlock->flag!) */
207 UI_BUT_ALIGN_TOP = (1 << 14),
208 UI_BUT_ALIGN_LEFT = (1 << 15),
209 UI_BUT_ALIGN_RIGHT = (1 << 16),
210 UI_BUT_ALIGN_DOWN = (1 << 17),
211 UI_BUT_ALIGN = (UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_LEFT | UI_BUT_ALIGN_RIGHT | UI_BUT_ALIGN_DOWN),
214 /* scale fixed button widths by this to account for DPI */
216 #define UI_DPI_FAC ((U.pixelsize * (float)U.dpi) / 72.0f)
217 #define UI_DPI_WINDOW_FAC (((float)U.dpi) / 72.0f)
218 /* 16 to copy ICON_DEFAULT_HEIGHT */
219 #define UI_DPI_ICON_SIZE ((float)16 * UI_DPI_FAC)
221 /* Button types, bits stored in 1 value... and a short even!
222 * - bits 0-4: bitnr (0-31)
223 * - bits 5-7: pointer type
225 * - bit 9-15: button type (now 6 bits, 64 types)
228 UI_BUT_POIN_CHAR = 32,
229 UI_BUT_POIN_SHORT = 64,
230 UI_BUT_POIN_INT = 96,
231 UI_BUT_POIN_FLOAT = 128,
232 /* UI_BUT_POIN_FUNCTION = 192, */ /*UNUSED*/
233 UI_BUT_POIN_BIT = 256 /* OR'd with a bit index*/
236 /* requires (but->poin != NULL) */
237 #define UI_BUT_POIN_TYPES (UI_BUT_POIN_FLOAT | UI_BUT_POIN_SHORT | UI_BUT_POIN_CHAR)
239 /* assigned to but->type, OR'd with the flags above when passing args */
241 UI_BTYPE_BUT = (1 << 9),
242 UI_BTYPE_ROW = (2 << 9),
243 UI_BTYPE_TOGGLE = (3 << 9),
244 UI_BTYPE_NUM = (5 << 9),
245 UI_BTYPE_TEXT = (6 << 9),
246 UI_BTYPE_TOGGLE_N = (9 << 9),
247 UI_BTYPE_LABEL = (10 << 9),
248 UI_BTYPE_MENU = (11 << 9), /* Dropdown list, actually! */
249 UI_BTYPE_ICON_TOGGLE = (13 << 9),
250 UI_BTYPE_NUM_SLIDER = (14 << 9),
251 UI_BTYPE_COLOR = (15 << 9),
252 UI_BTYPE_SCROLL = (18 << 9),
253 UI_BTYPE_BLOCK = (19 << 9),
254 UI_BTYPE_BUT_MENU = (20 << 9),
255 UI_BTYPE_SEPR = (21 << 9),
256 UI_BTYPE_LINK = (22 << 9),
257 UI_BTYPE_INLINK = (23 << 9),
258 UI_BTYPE_KEY_EVENT = (24 << 9),
259 UI_BTYPE_HSVCUBE = (26 << 9),
260 UI_BTYPE_PULLDOWN = (27 << 9), /* Menu, actually! */
261 UI_BTYPE_ROUNDBOX = (28 << 9),
262 UI_BTYPE_COLORBAND = (30 << 9),
263 UI_BTYPE_UNITVEC = (31 << 9),
264 UI_BTYPE_CURVE = (32 << 9),
265 UI_BTYPE_ICON_TOGGLE_N = (34 << 9),
266 UI_BTYPE_LISTBOX = (35 << 9),
267 UI_BTYPE_LISTROW = (36 << 9),
268 UI_BTYPE_BUT_TOGGLE = (37 << 9),
269 UI_BTYPE_CHECKBOX = (38 << 9),
270 UI_BTYPE_CHECKBOX_N = (39 << 9),
271 UI_BTYPE_TRACK_PREVIEW = (40 << 9),
272 /* buttons with value >= UI_BTYPE_SEARCH_MENU don't get undo pushes */
273 UI_BTYPE_SEARCH_MENU = (41 << 9),
274 UI_BTYPE_EXTRA = (42 << 9),
275 UI_BTYPE_HSVCIRCLE = (43 << 9),
276 UI_BTYPE_HOTKEY_EVENT = (46 << 9),
277 UI_BTYPE_IMAGE = (47 << 9),
278 UI_BTYPE_HISTOGRAM = (48 << 9),
279 UI_BTYPE_WAVEFORM = (49 << 9),
280 UI_BTYPE_VECTORSCOPE = (50 << 9),
281 UI_BTYPE_PROGRESS_BAR = (51 << 9),
282 UI_BTYPE_SEARCH_MENU_UNLINK = (52 << 9),
283 UI_BTYPE_NODE_SOCKET = (53 << 9),
284 UI_BTYPE_SEPR_LINE = (54 << 9),
285 UI_BTYPE_GRIP = (55 << 9),
288 #define BUTTYPE (63 << 9)
290 /* gradient types, for color picker UI_BTYPE_HSVCUBE etc */
298 #define UI_GRAD_V_ALT 9
299 #define UI_GRAD_L_ALT 10
301 #define UI_PALETTE_COLOR 20
305 * Functions to draw various shapes, taking theme settings into account.
306 * Used for code that draws its own UI style elements. */
308 void UI_draw_roundbox(float minx, float miny, float maxx, float maxy, float rad);
309 void UI_draw_roundbox_corner_set(int type);
310 int UI_draw_roundbox_corner_get(void);
311 void UI_draw_roundbox_unfilled(float minx, float miny, float maxx, float maxy, float rad);
312 void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx, float maxy);
313 void UI_draw_roundbox_gl_mode(int mode, float minx, float miny, float maxx, float maxy, float rad);
314 void UI_draw_roundbox_shade_x(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown);
315 void UI_draw_roundbox_shade_y(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadeLeft, float shadeRight);
317 /* state for scrolldrawing */
318 #define UI_SCROLL_PRESSED (1 << 0)
319 #define UI_SCROLL_ARROWS (1 << 1)
320 #define UI_SCROLL_NO_OUTLINE (1 << 2)
321 void UI_draw_widget_scroll(struct uiWidgetColors *wcol, const struct rcti *rect, const struct rcti *slider, int state);
325 * UI_block_func_handle_set/ButmFunc are for handling events through a callback.
326 * HandleFunc gets the retval passed on, and ButmFunc gets a2. The latter is
327 * mostly for compatibility with older code.
329 * UI_but_func_complete_set is for tab completion.
331 * uiButSearchFunc is for name buttons, showing a popup with matches
333 * UI_block_func_set and UI_but_func_set are callbacks run when a button is used,
334 * in case events, operators or RNA are not sufficient to handle the button.
336 * UI_but_funcN_set will free the argument with MEM_freeN. */
338 typedef struct uiSearchItems uiSearchItems;
340 typedef void (*uiButHandleFunc)(struct bContext *C, void *arg1, void *arg2);
341 typedef void (*uiButHandleRenameFunc)(struct bContext *C, void *arg, char *origstr);
342 typedef void (*uiButHandleNFunc)(struct bContext *C, void *argN, void *arg2);
343 typedef int (*uiButCompleteFunc)(struct bContext *C, char *str, void *arg);
344 typedef void (*uiButSearchFunc)(const struct bContext *C, void *arg, const char *str, uiSearchItems *items);
345 typedef void (*uiBlockHandleFunc)(struct bContext *C, void *arg, int event);
349 typedef void (*uiMenuCreateFunc)(struct bContext *C, struct uiLayout *layout, void *arg1);
350 typedef void (*uiMenuHandleFunc)(struct bContext *C, void *arg, int event);
354 * Functions used to create popup menus. For more extended menus the
355 * UI_popup_menu_begin/End functions can be used to define own items with
356 * the uiItem functions in between. If it is a simple confirmation menu
357 * or similar, popups can be created with a single function call. */
359 typedef struct uiPopupMenu uiPopupMenu;
361 struct uiPopupMenu *UI_popup_menu_begin(struct bContext *C, const char *title, int icon) ATTR_NONNULL();
362 void UI_popup_menu_end(struct bContext *C, struct uiPopupMenu *head);
363 struct uiLayout *UI_popup_menu_layout(uiPopupMenu *head);
365 void UI_popup_menu_reports(struct bContext *C, struct ReportList *reports) ATTR_NONNULL();
366 int UI_popup_menu_invoke(struct bContext *C, const char *idname, struct ReportList *reports) ATTR_NONNULL(1, 2);
369 typedef struct uiPieMenu uiPieMenu;
371 int UI_pie_menu_invoke(struct bContext *C, const char *idname, const struct wmEvent *event);
372 int UI_pie_menu_invoke_from_operator_enum(
373 struct bContext *C, const char *title, const char *opname,
374 const char *propname, const struct wmEvent *event);
375 int UI_pie_menu_invoke_from_rna_enum(
376 struct bContext *C, const char *title,
377 const char *path, const struct wmEvent *event);
379 struct uiPieMenu *UI_pie_menu_begin(
380 struct bContext *C, const char *title, int icon,
381 const struct wmEvent *event) ATTR_NONNULL();
382 void UI_pie_menu_end(struct bContext *C, uiPieMenu *pie);
383 struct uiLayout *UI_pie_menu_layout(struct uiPieMenu *pie);
386 * Functions used to create popup blocks. These are like popup menus
387 * but allow using all button types and creating an own layout. */
389 typedef uiBlock * (*uiBlockCreateFunc)(struct bContext *C, struct ARegion *ar, void *arg1);
390 typedef void (*uiBlockCancelFunc)(struct bContext *C, void *arg1);
392 void UI_popup_block_invoke(struct bContext *C, uiBlockCreateFunc func, void *arg);
393 void UI_popup_block_invoke_ex(struct bContext *C, uiBlockCreateFunc func, void *arg, const char *opname, int opcontext);
394 void UI_popup_block_ex(struct bContext *C, uiBlockCreateFunc func, uiBlockHandleFunc popup_func, uiBlockCancelFunc cancel_func, void *arg);
395 /* void uiPupBlockOperator(struct bContext *C, uiBlockCreateFunc func, struct wmOperator *op, int opcontext); */ /* UNUSED */
397 void UI_popup_block_close(struct bContext *C, uiBlock *block);
401 * Functions for creating, drawing and freeing blocks. A Block is a
402 * container of buttons and used for various purposes.
404 * Begin/Define Buttons/End/Draw is the typical order in which these
405 * function should be called, though for popup blocks Draw is left out.
406 * Freeing blocks is done by the screen/ module automatically.
410 uiBlock *UI_block_begin(const struct bContext *C, struct ARegion *region, const char *name, short dt);
411 void UI_block_end_ex(const struct bContext *C, uiBlock *block, const int xy[2]);
412 void UI_block_end(const struct bContext *C, uiBlock *block);
413 void UI_block_draw(const struct bContext *C, struct uiBlock *block);
414 void UI_block_update_from_old(const struct bContext *C, struct uiBlock *block);
416 uiBlock *UI_block_find_in_region(const char *name, struct ARegion *ar);
418 void UI_block_emboss_set(uiBlock *block, char dt);
420 void UI_block_free(const struct bContext *C, uiBlock *block);
421 void UI_blocklist_free(const struct bContext *C, struct ListBase *lb);
422 void UI_blocklist_free_inactive(const struct bContext *C, struct ListBase *lb);
423 void UI_screen_free_active_but(const struct bContext *C, struct bScreen *screen);
425 void UI_block_region_set(uiBlock *block, struct ARegion *region);
427 void UI_block_lock_set(uiBlock *block, bool val, const char *lockstr);
428 void UI_block_lock_clear(uiBlock *block);
430 /* automatic aligning, horiz or verical */
431 void UI_block_align_begin(uiBlock *block);
432 void UI_block_align_end(uiBlock *block);
434 /* block bounds/position calculation */
436 UI_BLOCK_BOUNDS_NONE = 0,
438 UI_BLOCK_BOUNDS_TEXT,
439 UI_BLOCK_BOUNDS_POPUP_MOUSE,
440 UI_BLOCK_BOUNDS_POPUP_MENU,
441 UI_BLOCK_BOUNDS_POPUP_CENTER,
442 UI_BLOCK_BOUNDS_PIE_CENTER,
445 void UI_block_bounds_set_normal(struct uiBlock *block, int addval);
446 void UI_block_bounds_set_text(uiBlock *block, int addval);
447 void UI_block_bounds_set_popup(uiBlock *block, int addval, int mx, int my);
448 void UI_block_bounds_set_menu(uiBlock *block, int addvall, int mx, int my);
449 void UI_block_bounds_set_centered(uiBlock *block, int addval);
450 void UI_block_bounds_set_explicit(uiBlock *block, int minx, int miny, int maxx, int maxy);
452 int UI_blocklist_min_y_get(struct ListBase *lb);
454 void UI_block_direction_set(uiBlock *block, char direction);
455 void UI_block_order_flip(uiBlock *block);
456 void UI_block_flag_enable(uiBlock *block, int flag);
457 void UI_block_flag_disable(uiBlock *block, int flag);
459 int UI_but_return_value_get(uiBut *but);
461 void UI_but_drag_set_id(uiBut *but, struct ID *id);
462 void UI_but_drag_set_rna(uiBut *but, struct PointerRNA *ptr);
463 void UI_but_drag_set_path(uiBut *but, const char *path);
464 void UI_but_drag_set_name(uiBut *but, const char *name);
465 void UI_but_drag_set_value(uiBut *but);
466 void UI_but_drag_set_image(uiBut *but, const char *path, int icon, struct ImBuf *ima, float scale);
468 bool UI_but_active_drop_name(struct bContext *C);
469 bool UI_but_active_drop_color(struct bContext *C);
471 void UI_but_flag_enable(uiBut *but, int flag);
472 void UI_but_flag_disable(uiBut *but, int flag);
474 void UI_but_drawflag_enable(uiBut *but, int flag);
475 void UI_but_drawflag_disable(uiBut *but, int flag);
477 void UI_but_type_set_menu_from_pulldown(uiBut *but);
479 /* special button case, only draw it when used actively, for outliner etc */
480 bool UI_but_active_only(const struct bContext *C, struct ARegion *ar, uiBlock *block, uiBut *but);
482 void UI_but_execute(const struct bContext *C, uiBut *but);
487 * Functions to define various types of buttons in a block. Postfixes:
495 uiBut *uiDefBut(uiBlock *block,
496 int type, int retval, const char *str,
500 float min, float max,
501 float a1, float a2, const char *tip);
502 uiBut *uiDefButF(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip);
503 uiBut *uiDefButBitF(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip);
504 uiBut *uiDefButI(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip);
505 uiBut *uiDefButBitI(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip);
506 uiBut *uiDefButS(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip);
507 uiBut *uiDefButBitS(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip);
508 uiBut *uiDefButC(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip);
509 uiBut *uiDefButBitC(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip);
510 uiBut *uiDefButR(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip);
511 uiBut *uiDefButR_prop(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip);
512 uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x, int y, short width, short height, const char *tip);
513 uiBut *uiDefButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, const char *str, int x, int y, short width, short height, const char *tip);
515 uiBut *uiDefIconBut(uiBlock *block,
516 int type, int retval, int icon,
520 float min, float max,
521 float a1, float a2, const char *tip);
522 uiBut *uiDefIconButF(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip);
523 uiBut *uiDefIconButBitF(uiBlock *block, int type, int bit, int retval, int icon, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip);
524 uiBut *uiDefIconButI(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip);
525 uiBut *uiDefIconButBitI(uiBlock *block, int type, int bit, int retval, int icon, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip);
526 uiBut *uiDefIconButS(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip);
527 uiBut *uiDefIconButBitS(uiBlock *block, int type, int bit, int retval, int icon, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip);
528 uiBut *uiDefIconButC(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip);
529 uiBut *uiDefIconButBitC(uiBlock *block, int type, int bit, int retval, int icon, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip);
530 uiBut *uiDefIconButR(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip);
531 uiBut *uiDefIconButR_prop(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, struct PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip);
532 uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, int x, int y, short width, short height, const char *tip);
533 uiBut *uiDefIconButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, int icon, int x, int y, short width, short height, const char *tip);
535 uiBut *uiDefIconTextBut(uiBlock *block,
536 int type, int retval, int icon, const char *str,
540 float min, float max,
541 float a1, float a2, const char *tip);
542 uiBut *uiDefIconTextButF(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip);
543 uiBut *uiDefIconTextButBitF(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip);
544 uiBut *uiDefIconTextButI(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip);
545 uiBut *uiDefIconTextButBitI(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip);
546 uiBut *uiDefIconTextButS(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip);
547 uiBut *uiDefIconTextButBitS(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip);
548 uiBut *uiDefIconTextButC(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip);
549 uiBut *uiDefIconTextButBitC(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip);
550 uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip);
551 uiBut *uiDefIconTextButR_prop(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip);
552 uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x, int y, short width, short height, const char *tip);
553 uiBut *uiDefIconTextButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, int icon, const char *str, int x, int y, short width, short height, const char *tip);
555 /* for passing inputs to ButO buttons */
556 struct PointerRNA *UI_but_operator_ptr_get(uiBut *but);
558 void UI_but_unit_type_set(uiBut *but, const int unit_type);
559 int UI_but_unit_type_get(const uiBut *but);
562 BUT_GET_RNAPROP_IDENTIFIER = 1,
563 BUT_GET_RNASTRUCT_IDENTIFIER,
564 BUT_GET_RNAENUM_IDENTIFIER,
567 BUT_GET_RNAENUM_LABEL,
568 BUT_GET_RNA_LABEL_CONTEXT, /* Context specified in CTX_XXX_ macros are just unreachable! */
576 typedef struct uiStringInfo {
581 /* Note: Expects pointers to uiStringInfo structs as parameters.
582 * Will fill them with translated strings, when possible.
583 * Strings in uiStringInfo must be MEM_freeN'ed by caller. */
584 void UI_but_string_info_get(struct bContext *C, uiBut *but, ...) ATTR_SENTINEL(0);
586 /* Edit i18n stuff. */
587 /* Name of the main py op from i18n addon. */
588 #define EDTSRC_I18N_OP_NAME "UI_OT_edittranslation"
592 * Buttons with a more specific purpose:
593 * - MenuBut: buttons that popup a menu (in headers usually).
594 * - PulldownBut: like MenuBut, but creating a uiBlock (for compatibility).
595 * - BlockBut: buttons that popup a block with more buttons.
596 * - KeyevtBut: buttons that can be used to turn key events into values.
597 * - PickerButtons: buttons like the color picker (for code sharing).
598 * - AutoButR: RNA property button with type automatically defined. */
600 #define UI_ID_RENAME (1 << 0)
601 #define UI_ID_BROWSE (1 << 1)
602 #define UI_ID_ADD_NEW (1 << 2)
603 #define UI_ID_OPEN (1 << 3)
604 #define UI_ID_ALONE (1 << 4)
605 #define UI_ID_DELETE (1 << 5)
606 #define UI_ID_LOCAL (1 << 6)
607 #define UI_ID_AUTO_NAME (1 << 7)
608 #define UI_ID_FAKE_USER (1 << 8)
609 #define UI_ID_PIN (1 << 9)
610 #define UI_ID_BROWSE_RENDER (1 << 10)
611 #define UI_ID_PREVIEWS (1 << 11)
612 #define UI_ID_FULL (UI_ID_RENAME | UI_ID_BROWSE | UI_ID_ADD_NEW | UI_ID_OPEN | UI_ID_ALONE | UI_ID_DELETE | UI_ID_LOCAL)
614 int UI_icon_from_id(struct ID *id);
615 int UI_icon_from_report_type(int type);
617 uiBut *uiDefPulldownBut(uiBlock *block, uiBlockCreateFunc func, void *arg, const char *str, int x, int y, short width, short height, const char *tip);
618 uiBut *uiDefMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, const char *str, int x, int y, short width, short height, const char *tip);
619 uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, const char *str, int x, int y, short width, short height, const char *tip);
620 uiBut *uiDefIconMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, int x, int y, short width, short height, const char *tip);
622 uiBut *uiDefBlockBut(uiBlock *block, uiBlockCreateFunc func, void *func_arg1, const char *str, int x, int y, short width, short height, const char *tip);
623 uiBut *uiDefBlockButN(uiBlock *block, uiBlockCreateFunc func, void *argN, const char *str, int x, int y, short width, short height, const char *tip);
625 uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int retval, int icon, int x, int y, short width, short height, const char *tip);
626 uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int icon, const char *str, int x, int y, short width, short height, const char *tip);
628 uiBut *uiDefKeyevtButS(uiBlock *block, int retval, const char *str, int x, int y, short width, short height, short *spoin, const char *tip);
629 uiBut *uiDefHotKeyevtButS(uiBlock *block, int retval, const char *str, int x, int y, short width, short height, short *keypoin, short *modkeypoin, const char *tip);
631 uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, int x, int y, short width, short height, float a1, float a2, const char *tip);
632 uiBut *uiDefSearchButO_ptr(uiBlock *block, struct wmOperatorType *ot, IDProperty *properties,
633 void *arg, int retval, int icon, int maxlen, int x, int y,
634 short width, short height, float a1, float a2, const char *tip);
636 uiBut *uiDefAutoButR(uiBlock *block, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, const char *name, int icon, int x1, int y1, int x2, int y2);
637 int uiDefAutoButsRNA(uiLayout *layout, struct PointerRNA *ptr, bool (*check_prop)(struct PointerRNA *, struct PropertyRNA *), const char label_align);
641 * Game engine logic brick links. Non-functional currently in 2.5,
642 * code to handle and draw these is disabled internally. */
644 void UI_but_link_set(struct uiBut *but, void **poin, void ***ppoin, short *tot, int from, int to);
646 void UI_block_links_compose(uiBlock *block);
647 uiBut *UI_block_links_find_inlink(uiBlock *block, void *poin);
649 /* use inside searchfunc to add items */
650 bool UI_search_item_add(uiSearchItems *items, const char *name, void *poin, int iconid);
651 /* bfunc gets search item *poin as arg2, or if NULL the old string */
652 void UI_but_func_search_set(uiBut *but, uiButSearchFunc sfunc, void *arg1, uiButHandleFunc bfunc, void *active);
653 /* height in pixels, it's using hardcoded values still */
654 int UI_searchbox_size_y(void);
655 int UI_searchbox_size_x(void);
656 /* check if a string is in an existing search box */
657 int UI_search_items_find_index(uiSearchItems *items, const char *name);
659 void UI_block_func_handle_set(uiBlock *block, uiBlockHandleFunc func, void *arg);
660 void UI_block_func_butmenu_set(uiBlock *block, uiMenuHandleFunc func, void *arg);
661 void UI_block_func_set(uiBlock *block, uiButHandleFunc func, void *arg1, void *arg2);
662 void UI_block_funcN_set(uiBlock *block, uiButHandleNFunc funcN, void *argN, void *arg2);
664 void UI_but_func_rename_set(uiBut *but, uiButHandleRenameFunc func, void *arg1);
665 void UI_but_func_set(uiBut *but, uiButHandleFunc func, void *arg1, void *arg2);
666 void UI_but_funcN_set(uiBut *but, uiButHandleNFunc funcN, void *argN, void *arg2);
668 void UI_but_func_complete_set(uiBut *but, uiButCompleteFunc func, void *arg);
670 void UI_but_func_drawextra_set(
672 void (*func)(const struct bContext *C, void *, void *, void *, struct rcti *rect),
673 void *arg1, void *arg2);
675 bool UI_textbutton_activate_rna(const struct bContext *C, struct ARegion *ar,
676 const void *rna_poin_data, const char *rna_prop_id);
677 bool UI_textbutton_activate_but(const struct bContext *C, uiBut *but);
679 void UI_but_focus_on_enter_event(struct wmWindow *win, uiBut *but);
683 * Tab complete helper functions, for use in uiButCompleteFunc callbacks.
684 * Call begin once, then multiple times do_name with all possibilities,
685 * and finally end to finish and get the completed name. */
687 typedef struct AutoComplete AutoComplete;
689 #define AUTOCOMPLETE_NO_MATCH 0
690 #define AUTOCOMPLETE_FULL_MATCH 1
691 #define AUTOCOMPLETE_PARTIAL_MATCH 2
693 AutoComplete *UI_autocomplete_begin(const char *startname, size_t maxlen);
694 void UI_autocomplete_update_name(AutoComplete *autocpl, const char *name);
695 int UI_autocomplete_end(AutoComplete *autocpl, char *autoname);
699 * Functions for creating, freeing and drawing panels. The API here
700 * could use a good cleanup, though how they will function in 2.5 is
701 * not clear yet so we postpone that. */
703 void UI_panels_begin(const struct bContext *C, struct ARegion *ar);
704 void UI_panels_end(const struct bContext *C, struct ARegion *ar, int *x, int *y);
705 void UI_panels_draw(const struct bContext *C, struct ARegion *ar);
707 struct Panel *UI_panel_find_by_type(struct ARegion *ar, struct PanelType *pt);
708 struct Panel *UI_panel_begin(struct ScrArea *sa, struct ARegion *ar, uiBlock *block,
709 struct PanelType *pt, struct Panel *pa, bool *r_open);
710 void UI_panel_end(uiBlock *block, int width, int height);
711 void UI_panels_scale(struct ARegion *ar, float new_width);
713 bool UI_panel_category_is_visible(struct ARegion *ar);
714 void UI_panel_category_add(struct ARegion *ar, const char *name);
715 struct PanelCategoryDyn *UI_panel_category_find(struct ARegion *ar, const char *idname);
716 struct PanelCategoryStack *UI_panel_category_active_find(struct ARegion *ar, const char *idname);
717 const char *UI_panel_category_active_get(struct ARegion *ar, bool set_fallback);
718 void UI_panel_category_active_set(struct ARegion *ar, const char *idname);
719 struct PanelCategoryDyn *UI_panel_category_find_mouse_over_ex(struct ARegion *ar, const int x, const int y);
720 struct PanelCategoryDyn *UI_panel_category_find_mouse_over(struct ARegion *ar, const struct wmEvent *event);
721 void UI_panel_category_clear_all(struct ARegion *ar);
722 void UI_panel_category_draw_all(struct ARegion *ar, const char *category_id_active);
726 * Handlers that can be registered in regions, areas and windows for
727 * handling WM events. Mostly this is done automatic by modules such
728 * as screen/ if ED_KEYMAP_UI is set, or internally in popup functions. */
730 void UI_region_handlers_add(struct ListBase *handlers);
731 void UI_popup_handlers_add(struct bContext *C, struct ListBase *handlers, uiPopupBlockHandle *popup, const bool accept_dbl_click);
732 void UI_popup_handlers_remove(struct ListBase *handlers, uiPopupBlockHandle *popup);
733 void UI_popup_handlers_remove_all(struct bContext *C, struct ListBase *handlers);
737 * init and exit should be called before using this module. init_userdef must
738 * be used to reinitialize some internal state if user preferences change. */
741 void UI_init_userdef(void);
742 void UI_reinit_font(void);
747 * More automated layout of buttons. Has three levels:
748 * - Layout: contains a number templates, within a bounded width or height.
749 * - Template: predefined layouts for buttons with a number of slots, each
750 * slot can contain multiple items.
751 * - Item: item to put in a template slot, being either an RNA property,
752 * operator, label or menu. Also regular buttons can be used when setting
753 * uiBlockCurLayout. */
756 #define UI_LAYOUT_HORIZONTAL 0
757 #define UI_LAYOUT_VERTICAL 1
759 #define UI_LAYOUT_PANEL 0
760 #define UI_LAYOUT_HEADER 1
761 #define UI_LAYOUT_MENU 2
762 #define UI_LAYOUT_TOOLBAR 3
763 #define UI_LAYOUT_PIEMENU 4
765 #define UI_UNIT_X ((void)0, U.widget_unit)
766 #define UI_UNIT_Y ((void)0, U.widget_unit)
768 #define UI_LAYOUT_ALIGN_EXPAND 0
769 #define UI_LAYOUT_ALIGN_LEFT 1
770 #define UI_LAYOUT_ALIGN_CENTER 2
771 #define UI_LAYOUT_ALIGN_RIGHT 3
773 #define UI_ITEM_O_RETURN_PROPS (1 << 0)
774 #define UI_ITEM_R_EXPAND (1 << 1)
775 #define UI_ITEM_R_SLIDER (1 << 2)
776 #define UI_ITEM_R_TOGGLE (1 << 3)
777 #define UI_ITEM_R_ICON_ONLY (1 << 4)
778 #define UI_ITEM_R_EVENT (1 << 5)
779 #define UI_ITEM_R_FULL_EVENT (1 << 6)
780 #define UI_ITEM_R_NO_BG (1 << 7)
781 #define UI_ITEM_R_IMMEDIATE (1 << 8)
783 /* uiLayoutOperatorButs flags */
784 #define UI_LAYOUT_OP_SHOW_TITLE 1
785 #define UI_LAYOUT_OP_SHOW_EMPTY 2
787 /* used for transp checkers */
788 #define UI_ALPHA_CHECKER_DARK 100
789 #define UI_ALPHA_CHECKER_LIGHT 160
791 /* flags to set which corners will become rounded:
798 UI_CNR_TOP_LEFT = (1 << 0),
799 UI_CNR_TOP_RIGHT = (1 << 1),
800 UI_CNR_BOTTOM_RIGHT = (1 << 2),
801 UI_CNR_BOTTOM_LEFT = (1 << 3),
802 /* just for convenience */
804 UI_CNR_ALL = (UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT)
807 /* not apart of the corner flags but mixed in some functions */
808 #define UI_RB_ALPHA (UI_CNR_ALL + 1)
810 uiLayout *UI_block_layout(uiBlock *block, int dir, int type, int x, int y, int size, int em, int padding, struct uiStyle *style);
811 void UI_block_layout_set_current(uiBlock *block, uiLayout *layout);
812 void UI_block_layout_resolve(uiBlock *block, int *x, int *y);
814 uiBlock *uiLayoutGetBlock(uiLayout *layout);
816 void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv);
817 void uiLayoutSetContextPointer(uiLayout *layout, const char *name, struct PointerRNA *ptr);
818 void uiLayoutContextCopy(uiLayout *layout, struct bContextStore *context);
819 const char *uiLayoutIntrospect(uiLayout *layout); // XXX - testing
820 void uiLayoutOperatorButs(const struct bContext *C, struct uiLayout *layout, struct wmOperator *op,
821 bool (*check_prop)(struct PointerRNA *, struct PropertyRNA *),
822 const char label_align, const short flag);
823 struct MenuType *UI_but_menutype_get(uiBut *but);
825 void uiLayoutSetOperatorContext(uiLayout *layout, int opcontext);
826 void uiLayoutSetActive(uiLayout *layout, bool active);
827 void uiLayoutSetEnabled(uiLayout *layout, bool enabled);
828 void uiLayoutSetRedAlert(uiLayout *layout, bool redalert);
829 void uiLayoutSetAlignment(uiLayout *layout, char alignment);
830 void uiLayoutSetKeepAspect(uiLayout *layout, bool keepaspect);
831 void uiLayoutSetScaleX(uiLayout *layout, float scale);
832 void uiLayoutSetScaleY(uiLayout *layout, float scale);
834 int uiLayoutGetOperatorContext(uiLayout *layout);
835 bool uiLayoutGetActive(uiLayout *layout);
836 bool uiLayoutGetEnabled(uiLayout *layout);
837 bool uiLayoutGetRedAlert(uiLayout *layout);
838 int uiLayoutGetAlignment(uiLayout *layout);
839 bool uiLayoutGetKeepAspect(uiLayout *layout);
840 int uiLayoutGetWidth(uiLayout *layout);
841 float uiLayoutGetScaleX(uiLayout *layout);
842 float uiLayoutGetScaleY(uiLayout *layout);
844 /* layout specifiers */
845 uiLayout *uiLayoutRow(uiLayout *layout, int align);
846 uiLayout *uiLayoutColumn(uiLayout *layout, int align);
847 uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, int align);
848 uiLayout *uiLayoutBox(uiLayout *layout);
849 uiLayout *uiLayoutListBox(uiLayout *layout, struct uiList *ui_list, struct PointerRNA *ptr, struct PropertyRNA *prop,
850 struct PointerRNA *actptr, struct PropertyRNA *actprop);
851 uiLayout *uiLayoutAbsolute(uiLayout *layout, int align);
852 uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, int align);
853 uiLayout *uiLayoutOverlap(uiLayout *layout);
854 uiBlock *uiLayoutAbsoluteBlock(uiLayout *layout);
855 uiLayout *uiLayoutRadial(uiLayout *layout);
858 void uiTemplateHeader(uiLayout *layout, struct bContext *C);
859 void uiTemplateID(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname,
860 const char *newop, const char *openop, const char *unlinkop);
861 void uiTemplateIDBrowse(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname,
862 const char *newop, const char *openop, const char *unlinkop);
863 void uiTemplateIDPreview(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname,
864 const char *newop, const char *openop, const char *unlinkop, int rows, int cols);
865 void uiTemplateAnyID(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
866 const char *proptypename, const char *text);
867 void uiTemplatePathBuilder(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
868 struct PointerRNA *root_ptr, const char *text);
869 uiLayout *uiTemplateModifier(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr);
870 uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr);
871 void uiTemplatePreview(uiLayout *layout, struct bContext *C, struct ID *id, int show_buttons, struct ID *parent,
872 struct MTex *slot, const char *preview_id);
873 void uiTemplateColorRamp(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int expand);
874 void uiTemplateIconView(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
875 void uiTemplateHistogram(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
876 void uiTemplateWaveform(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
877 void uiTemplateVectorscope(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
878 void uiTemplateCurveMapping(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int type,
879 int levels, int brush, int neg_slope);
880 void uiTemplateColorPicker(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int value_slider, int lock, int lock_luminosity, int cubic);
881 void uiTemplatePalette(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int color);
882 void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
883 PointerRNA *used_ptr, const char *used_propname, int active_layer);
884 void uiTemplateGameStates(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
885 PointerRNA *used_ptr, const char *used_propname, int active_state);
886 void uiTemplateImage(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr, int compact);
887 void uiTemplateImageSettings(uiLayout *layout, struct PointerRNA *imfptr, int color_management);
888 void uiTemplateImageLayers(uiLayout *layout, struct bContext *C, struct Image *ima, struct ImageUser *iuser);
889 void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C);
890 void UI_but_func_operator_search(uiBut *but);
891 void uiTemplateOperatorSearch(uiLayout *layout);
892 void uiTemplateHeader3D(uiLayout *layout, struct bContext *C);
893 void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C);
894 void uiTemplateReportsBanner(uiLayout *layout, struct bContext *C);
895 void uiTemplateKeymapItemProperties(uiLayout *layout, struct PointerRNA *ptr);
896 void uiTemplateComponentMenu(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name);
897 void uiTemplateNodeSocket(uiLayout *layout, struct bContext *C, float *color);
899 /* Default UIList class name, keep in sync with its declaration in bl_ui/__init__.py */
900 #define UI_UL_DEFAULT_CLASS_NAME "UI_UL_list"
901 void uiTemplateList(uiLayout *layout, struct bContext *C, const char *listtype_name, const char *list_id,
902 struct PointerRNA *dataptr, const char *propname, struct PointerRNA *active_dataptr,
903 const char *active_propname, int rows, int maxrows, int layout_type, int columns);
904 void uiTemplateNodeLink(uiLayout *layout, struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *input);
905 void uiTemplateNodeView(uiLayout *layout, struct bContext *C, struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *input);
906 void uiTemplateTextureUser(uiLayout *layout, struct bContext *C);
907 void uiTemplateTextureShow(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop);
909 void uiTemplateMovieClip(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, int compact);
910 void uiTemplateTrack(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname);
911 void uiTemplateMarker(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, PointerRNA *userptr, PointerRNA *trackptr, int cmpact);
912 void uiTemplateMovieclipInformation(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr);
914 void uiTemplateColorspaceSettings(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname);
915 void uiTemplateColormanagedViewSettings(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname);
918 void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname);
919 void uiItemEnumO_ptr(uiLayout *layout, struct wmOperatorType *ot, const char *name, int icon, const char *propname, int value);
920 void uiItemEnumO(uiLayout *layout, const char *opname, const char *name, int icon, const char *propname, int value);
921 void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value);
922 void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value);
923 void uiItemsEnumO(uiLayout *layout, const char *opname, const char *propname);
924 void uiItemBooleanO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value);
925 void uiItemIntO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value);
926 void uiItemFloatO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, float value);
927 void uiItemStringO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value);
929 PointerRNA uiItemFullO_ptr(uiLayout *layout, struct wmOperatorType *ot, const char *name, int icon, IDProperty *properties, int context, int flag);
930 PointerRNA uiItemFullO(uiLayout *layout, const char *idname, const char *name, int icon, struct IDProperty *properties, int context, int flag);
932 void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon);
933 void uiItemFullR(uiLayout *layout, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, int value, int flag, const char *name, int icon);
934 void uiItemEnumR(uiLayout *layout, const char *name, int icon, struct PointerRNA *ptr, const char *propname, int value);
935 void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *value, const char *name, int icon);
936 void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
937 void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *searchptr, const char *searchpropname, const char *name, int icon);
938 void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname, struct IDProperty *properties, int context, int flag);
940 void uiItemL(uiLayout *layout, const char *name, int icon); /* label */
941 void uiItemLDrag(uiLayout *layout, struct PointerRNA *ptr, const char *name, int icon); /* label icon for dragging */
942 void uiItemM(uiLayout *layout, struct bContext *C, const char *menuname, const char *name, int icon); /* menu */
943 void uiItemV(uiLayout *layout, const char *name, int icon, int argval); /* value */
944 void uiItemS(uiLayout *layout); /* separator */
946 void uiItemMenuF(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *arg);
947 void uiItemMenuEnumO(uiLayout *layout, struct bContext *C, const char *opname, const char *propname, const char *name, int icon);
948 void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name, int icon);
951 typedef struct uiDragColorHandle {
953 bool gamma_corrected;
956 void ED_button_operatortypes(void);
957 void UI_drop_color_copy(struct wmDrag *drag, struct wmDropBox *drop);
958 int UI_drop_color_poll(struct bContext *C, struct wmDrag *drag, const struct wmEvent *event);
960 /* Helpers for Operators */
961 uiBut *UI_context_active_but_get(const struct bContext *C);
962 void UI_context_active_but_prop_get(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index);
963 void UI_context_active_but_prop_handle(struct bContext *C);
964 struct wmOperator *UI_context_active_operator_get(const struct bContext *C);
965 void UI_context_update_anim_flag(const struct bContext *C);
966 void UI_context_active_but_prop_get_filebrowser(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop);
967 void UI_context_active_but_prop_get_templateID(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop);
969 /* Styled text draw */
970 void UI_fontstyle_set(struct uiFontStyle *fs);
971 void UI_fontstyle_draw_ex(
972 struct uiFontStyle *fs, const struct rcti *rect, const char *str,
973 size_t len, float *r_xofs, float *r_yofs);
974 void UI_fontstyle_draw(struct uiFontStyle *fs, const struct rcti *rect, const char *str);
975 void UI_fontstyle_draw_rotated(struct uiFontStyle *fs, const struct rcti *rect, const char *str);
977 int UI_fontstyle_string_width(const char *str); // XXX temp
978 void UI_draw_string(float x, float y, const char *str); // XXX temp
979 void UI_draw_icon_tri(float x, float y, char dir);
981 uiStyle *UI_style_get(void); /* use for fonts etc */
982 uiStyle *UI_style_get_dpi(void); /* DPI scaled settings for drawing */
984 /* linker workaround ack! */
985 void UI_template_fix_linking(void);
987 /* UI_OT_editsource helpers */
988 bool UI_editsource_enable_check(void);
989 void UI_editsource_active_but_test(uiBut *but);
991 /* UI_butstore_ helpers */
992 typedef struct uiButStore uiButStore;
993 typedef struct uiButStoreElem uiButStoreElem;
995 uiButStore *UI_butstore_create(uiBlock *block);
996 void UI_butstore_clear(uiBlock *block);
997 void UI_butstore_update(uiBlock *block);
998 void UI_butstore_free(uiBlock *block, uiButStore *bs);
999 bool UI_butstore_is_valid(uiButStore *bs);
1000 bool UI_butstore_is_registered(uiBlock *block, uiBut *but);
1001 void UI_butstore_register(uiButStore *bs_handle, uiBut **but_p);
1002 void UI_butstore_unregister(uiButStore *bs_handle, uiBut **but_p);
1005 /* Float precision helpers */
1006 #define UI_PRECISION_FLOAT_MAX 7
1008 int UI_calc_float_precision(int prec, double value);
1010 #endif /* __UI_INTERFACE_H__ */