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 "BLO_sys_types.h" /* size_t */
36 #include "RNA_types.h"
37 #include "DNA_userdef_types.h"
39 /* Struct Declarations */
47 struct wmWindowManager;
61 struct uiWidgetColors;
66 struct wmOperatorType;
67 struct uiWidgetColors;
75 typedef struct uiBut uiBut;
76 typedef struct uiBlock uiBlock;
77 typedef struct uiPopupBlockHandle uiPopupBlockHandle;
78 typedef struct uiLayout uiLayout;
83 #define UI_MAX_DRAW_STR 400
84 #define UI_MAX_NAME_STR 128
87 #define UI_EMBOSS 0 /* use widget style for drawing */
88 #define UI_EMBOSSN 1 /* Nothing, only icon and/or text */
89 #define UI_EMBOSSP 2 /* Pulldown menu style */
90 #define UI_EMBOSST 3 /* Table */
92 /* uiBlock->direction */
93 #define UI_DIRECTION (UI_TOP | UI_DOWN | UI_LEFT | UI_RIGHT)
100 #define UI_SHIFT_FLIPPED 32
102 /* uiBlock->autofill (not yet used) */
103 // #define UI_BLOCK_COLLUMNS 1
104 // #define UI_BLOCK_ROWS 2
106 /* uiBlock->flag (controls) */
107 #define UI_BLOCK_LOOP 1
108 #define UI_BLOCK_REDRAW 2
109 #define UI_BLOCK_RET_1 4 /* XXX 2.5 not implemented */
110 #define UI_BLOCK_NUMSELECT 8
111 /*#define UI_BLOCK_ENTER_OK 16*/ /*UNUSED*/
112 #define UI_BLOCK_CLIPBOTTOM 32
113 #define UI_BLOCK_CLIPTOP 64
114 #define UI_BLOCK_MOVEMOUSE_QUIT 128
115 #define UI_BLOCK_KEEP_OPEN 256
116 #define UI_BLOCK_POPUP 512
117 #define UI_BLOCK_OUT_1 1024
118 #define UI_BLOCK_NO_FLIP 2048
119 #define UI_BLOCK_POPUP_MEMORY 4096
120 #define UI_BLOCK_CLIP_EVENTS 8192 /* stop handling mouse events */
122 /* uiPopupBlockHandle->menuretval */
123 #define UI_RETURN_CANCEL 1 /* cancel all menus cascading */
124 #define UI_RETURN_OK 2 /* choice made */
125 #define UI_RETURN_OUT 4 /* left the menu */
126 #define UI_RETURN_UPDATE 8 /* update the button that opened */
127 #define UI_RETURN_POPUP_OK 16 /* popup is ok to be handled */
129 /* block->flag bits 12-15 are identical to but->flag bits */
132 #define UI_PNL_SOLID 2
133 #define UI_PNL_CLOSE 32
134 #define UI_PNL_SCALE 512
136 /* warning the first 6 flags are internal */
138 #define UI_TEXT_LEFT 64
139 #define UI_ICON_LEFT 128
140 #define UI_ICON_SUBMENU 256
141 #define UI_ICON_PREVIEW 512
143 #define UI_TEXT_RIGHT 1024
144 #define UI_BUT_NODE_LINK 2048
145 #define UI_BUT_NODE_ACTIVE 4096
146 #define UI_FLAG_UNUSED 8192
148 /* button align flag, for drawing groups together */
149 #define UI_BUT_ALIGN (UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_LEFT | UI_BUT_ALIGN_RIGHT | UI_BUT_ALIGN_DOWN)
150 #define UI_BUT_ALIGN_TOP (1 << 14)
151 #define UI_BUT_ALIGN_LEFT (1 << 15)
152 #define UI_BUT_ALIGN_RIGHT (1 << 16)
153 #define UI_BUT_ALIGN_DOWN (1 << 17)
155 #define UI_BUT_DISABLED (1 << 18)
156 #define UI_BUT_COLOR_LOCK (1 << 19)
157 #define UI_BUT_ANIMATED (1 << 20)
158 #define UI_BUT_ANIMATED_KEY (1 << 21)
159 #define UI_BUT_DRIVEN (1 << 22)
160 #define UI_BUT_REDALERT (1 << 23)
161 #define UI_BUT_INACTIVE (1 << 24)
162 #define UI_BUT_LAST_ACTIVE (1 << 25)
163 #define UI_BUT_UNDO (1 << 26)
164 #define UI_BUT_IMMEDIATE (1 << 27)
165 #define UI_BUT_NO_TOOLTIP (1 << 28)
166 #define UI_BUT_NO_UTF8 (1 << 29)
168 #define UI_BUT_VEC_SIZE_LOCK (1 << 30) /* used to flag if color hsv-circle should keep luminance */
169 #define UI_BUT_COLOR_CUBIC (1 << 31) /* cubic saturation for the color wheel */
171 #define UI_PANEL_WIDTH 340
172 #define UI_COMPACT_PANEL_WIDTH 160
174 /* uiBut->drawflag */
175 #define UI_BUT_DRAW_ENUM_ARROWS (1 << 0) /* draw enum-like up/down arrows for button */
177 /* scale fixed button widths by this to account for DPI
178 * 8.4852 == sqrtf(72.0f)) */
179 #define UI_DPI_FAC (sqrtf((float)U.dpi) / 8.48528137423857f)
180 #define UI_DPI_ICON_FAC (((float)U.dpi) / 72.0f)
181 /* 16 to copy ICON_DEFAULT_HEIGHT */
182 #define UI_DPI_ICON_SIZE ((float)16 * UI_DPI_ICON_FAC)
184 /* Button types, bits stored in 1 value... and a short even!
185 * - bits 0-4: bitnr (0-31)
186 * - bits 5-7: pointer type
188 * - bit 9-15: button type (now 6 bits, 64 types)
195 /*#define FUN 192*/ /*UNUSED*/
198 /* button reqyires a pointer */
199 #define BUTPOIN (FLO | SHO | CHA)
201 /* assigned to but->type, OR'd with the flags above when passing args */
208 #define TOG3 (7 << 9)
209 #define TOGR (8 << 9)
210 #define TOGN (9 << 9)
211 #define LABEL (10 << 9)
212 #define MENU (11 << 9)
213 #define ICONROW (12 << 9)
214 #define ICONTOG (13 << 9)
215 #define NUMSLI (14 << 9)
216 #define COL (15 << 9)
217 #define IDPOIN (16 << 9)
218 #define HSVSLI (17 << 9)
219 #define SCROLL (18 << 9)
220 #define BLOCK (19 << 9)
221 #define BUTM (20 << 9)
222 #define SEPR (21 << 9)
223 #define LINK (22 << 9)
224 #define INLINK (23 << 9)
225 #define KEYEVT (24 << 9)
226 #define ICONTEXTROW (25 << 9)
227 #define HSVCUBE (26 << 9)
228 #define PULLDOWN (27 << 9)
229 #define ROUNDBOX (28 << 9)
230 #define CHARTAB (29 << 9)
231 #define BUT_COLORBAND (30 << 9)
232 #define BUT_NORMAL (31 << 9)
233 #define BUT_CURVE (32 << 9)
234 #define BUT_TOGDUAL (33 << 9)
235 #define ICONTOGN (34 << 9)
236 #define FTPREVIEW (35 << 9)
237 #define NUMABS (36 << 9)
238 #define TOGBUT (37 << 9)
239 #define OPTION (38 << 9)
240 #define OPTIONN (39 << 9)
241 #define TRACKPREVIEW (40 << 9)
242 /* buttons with value >= SEARCH_MENU don't get undo pushes */
243 #define SEARCH_MENU (41 << 9)
244 #define BUT_EXTRA (42 << 9)
245 #define HSVCIRCLE (43 << 9)
246 #define LISTBOX (44 << 9)
247 #define LISTROW (45 << 9)
248 #define HOTKEYEVT (46 << 9)
249 #define BUT_IMAGE (47 << 9)
250 #define HISTOGRAM (48 << 9)
251 #define WAVEFORM (49 << 9)
252 #define VECTORSCOPE (50 << 9)
253 #define PROGRESSBAR (51 << 9)
255 #define BUTTYPE (63 << 9)
257 /* gradient types, for color picker HSVCUBE etc */
265 #define UI_GRAD_V_ALT 9
269 * Functions to draw various shapes, taking theme settings into account.
270 * Used for code that draws its own UI style elements. */
272 void uiEmboss(float x1, float y1, float x2, float y2, int sel);
273 void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad);
274 void uiSetRoundBox(int type);
275 int uiGetRoundBox(void);
276 void uiRoundRect(float minx, float miny, float maxx, float maxy, float rad);
277 void uiDrawBoxShadow(unsigned char alpha, float minx, float miny, float maxx, float maxy);
278 void uiDrawBox(int mode, float minx, float miny, float maxx, float maxy, float rad);
279 void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown);
280 void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadeLeft, float shadeRight);
282 /* state for scrolldrawing */
283 #define UI_SCROLL_PRESSED 1
284 #define UI_SCROLL_ARROWS 2
285 #define UI_SCROLL_NO_OUTLINE 4
286 void uiWidgetScrollDraw(struct uiWidgetColors *wcol, struct rcti *rect, struct rcti *slider, int state);
290 * uiBlockSetHandleFunc/ButmFunc are for handling events through a callback.
291 * HandleFunc gets the retval passed on, and ButmFunc gets a2. The latter is
292 * mostly for compatibility with older code.
294 * uiButSetCompleteFunc is for tab completion.
296 * uiButSearchFunc is for name buttons, showing a popup with matches
298 * uiBlockSetFunc and uiButSetFunc are callbacks run when a button is used,
299 * in case events, operators or RNA are not sufficient to handle the button.
301 * uiButSetNFunc will free the argument with MEM_freeN. */
303 typedef struct uiSearchItems uiSearchItems;
305 typedef void (*uiButHandleFunc)(struct bContext *C, void *arg1, void *arg2);
306 typedef void (*uiButHandleRenameFunc)(struct bContext *C, void *arg, char *origstr);
307 typedef void (*uiButHandleNFunc)(struct bContext *C, void *argN, void *arg2);
308 typedef void (*uiButCompleteFunc)(struct bContext *C, char *str, void *arg);
309 typedef void (*uiButSearchFunc)(const struct bContext *C, void *arg, const char *str, uiSearchItems *items);
310 typedef void (*uiBlockHandleFunc)(struct bContext *C, void *arg, int event);
314 typedef void (*uiMenuCreateFunc)(struct bContext *C, struct uiLayout *layout, void *arg1);
315 typedef void (*uiMenuHandleFunc)(struct bContext *C, void *arg, int event);
319 * Functions used to create popup menus. For more extended menus the
320 * uiPupMenuBegin/End functions can be used to define own items with
321 * the uiItem functions in between. If it is a simple confirmation menu
322 * or similar, popups can be created with a single function call. */
324 typedef struct uiPopupMenu uiPopupMenu;
326 uiPopupMenu *uiPupMenuBegin(struct bContext *C, const char *title, int icon);
327 void uiPupMenuEnd(struct bContext *C, struct uiPopupMenu *head);
328 struct uiLayout *uiPupMenuLayout(uiPopupMenu *head);
330 void uiPupMenuOkee(struct bContext *C, const char *opname, const char *str, ...)
332 __attribute__ ((format(printf, 3, 4)))
335 void uiPupMenuSaveOver(struct bContext *C, struct wmOperator *op, const char *filename);
336 void uiPupMenuNotice(struct bContext *C, const char *str, ...)
338 __attribute__ ((format(printf, 2, 3)))
341 void uiPupMenuError(struct bContext *C, const char *str, ...)
343 __attribute__ ((format(printf, 2, 3)))
346 void uiPupMenuReports(struct bContext *C, struct ReportList *reports);
347 void uiPupMenuInvoke(struct bContext *C, const char *idname); /* popup registered menu */
351 * Functions used to create popup blocks. These are like popup menus
352 * but allow using all button types and creating an own layout. */
354 typedef uiBlock * (*uiBlockCreateFunc)(struct bContext *C, struct ARegion *ar, void *arg1);
355 typedef void (*uiBlockCancelFunc)(void *arg1);
357 void uiPupBlock(struct bContext *C, uiBlockCreateFunc func, void *arg);
358 void uiPupBlockO(struct bContext *C, uiBlockCreateFunc func, void *arg, const char *opname, int opcontext);
359 void uiPupBlockEx(struct bContext *C, uiBlockCreateFunc func, uiBlockHandleFunc popup_func, uiBlockCancelFunc cancel_func, void *arg);
360 /* void uiPupBlockOperator(struct bContext *C, uiBlockCreateFunc func, struct wmOperator *op, int opcontext); */ /* UNUSED */
362 void uiPupBlockClose(struct bContext *C, uiBlock *block);
366 * Functions for creating, drawing and freeing blocks. A Block is a
367 * container of buttons and used for various purposes.
369 * Begin/Define Buttons/End/Draw is the typical order in which these
370 * function should be called, though for popup blocks Draw is left out.
371 * Freeing blocks is done by the screen/ module automatically.
375 uiBlock *uiBeginBlock(const struct bContext *C, struct ARegion *region, const char *name, short dt);
376 void uiEndBlock(const struct bContext *C, uiBlock *block);
377 void uiDrawBlock(const struct bContext *C, struct uiBlock *block);
379 uiBlock *uiGetBlock(const char *name, struct ARegion *ar);
381 void uiBlockSetEmboss(uiBlock *block, char dt);
383 void uiFreeBlock(const struct bContext *C, uiBlock *block);
384 void uiFreeBlocks(const struct bContext *C, struct ListBase *lb);
385 void uiFreeInactiveBlocks(const struct bContext *C, struct ListBase *lb);
386 void uiFreeActiveButtons(const struct bContext *C, struct bScreen *screen);
388 void uiBlockSetRegion(uiBlock *block, struct ARegion *region);
390 void uiBlockSetButLock(uiBlock *block, int val, const char *lockstr);
391 void uiBlockClearButLock(uiBlock *block);
393 /* automatic aligning, horiz or verical */
394 void uiBlockBeginAlign(uiBlock *block);
395 void uiBlockEndAlign(uiBlock *block);
397 /* block bounds/position calculation */
400 UI_BLOCK_BOUNDS_TEXT,
401 UI_BLOCK_BOUNDS_POPUP_MOUSE,
402 UI_BLOCK_BOUNDS_POPUP_MENU,
403 UI_BLOCK_BOUNDS_POPUP_CENTER
406 void uiBoundsBlock(struct uiBlock *block, int addval);
407 void uiTextBoundsBlock(uiBlock *block, int addval);
408 void uiPopupBoundsBlock(uiBlock *block, int addval, int mx, int my);
409 void uiMenuPopupBoundsBlock(uiBlock *block, int addvall, int mx, int my);
410 void uiCenteredBoundsBlock(uiBlock *block, int addval);
411 void uiExplicitBoundsBlock(uiBlock *block, int minx, int miny, int maxx, int maxy);
413 int uiBlocksGetYMin(struct ListBase *lb);
415 void uiBlockSetDirection(uiBlock *block, int direction);
416 void uiBlockFlipOrder(uiBlock *block);
417 void uiBlockSetFlag(uiBlock *block, int flag);
418 void uiBlockClearFlag(uiBlock *block, int flag);
419 void uiBlockSetXOfs(uiBlock *block, int xofs);
421 int uiButGetRetVal(uiBut *but);
423 void uiButSetDragID(uiBut *but, struct ID *id);
424 void uiButSetDragRNA(uiBut *but, struct PointerRNA *ptr);
425 void uiButSetDragPath(uiBut *but, const char *path);
426 void uiButSetDragName(uiBut *but, const char *name);
427 void uiButSetDragValue(uiBut *but);
428 void uiButSetDragImage(uiBut *but, const char *path, int icon, struct ImBuf *ima, float scale);
430 int UI_but_active_drop_name(struct bContext *C);
432 void uiButSetFlag(uiBut *but, int flag);
433 void uiButClearFlag(uiBut *but, int flag);
435 void uiButSetDrawFlag(uiBut *but, int flag);
436 void uiButClearDrawFlag(uiBut *but, int flag);
438 /* special button case, only draw it when used actively, for outliner etc */
439 int uiButActiveOnly(const struct bContext *C, uiBlock *block, uiBut *but);
444 * Functions to define various types of buttons in a block. Postfixes:
452 uiBut *uiDefBut(uiBlock *block,
453 int type, int retval, const char *str,
457 float min, float max,
458 float a1, float a2, const char *tip);
459 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);
460 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);
461 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);
462 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);
463 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);
464 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);
465 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);
466 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);
467 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);
468 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);
469 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);
470 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);
471 uiBut *uiDefButTextO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip);
473 uiBut *uiDefIconBut(uiBlock *block,
474 int type, int retval, int icon,
478 float min, float max,
479 float a1, float a2, const char *tip);
480 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);
481 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);
482 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);
483 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);
484 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);
485 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);
486 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);
487 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);
488 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);
489 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);
490 uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, int x, int y, short width, short height, const char *tip);
491 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);
493 uiBut *uiDefIconTextBut(uiBlock *block,
494 int type, int retval, int icon, const char *str,
498 float min, float max,
499 float a1, float a2, const char *tip);
500 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);
501 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);
502 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);
503 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);
504 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);
505 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);
506 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);
507 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);
508 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);
509 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);
510 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);
511 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);
513 /* for passing inputs to ButO buttons */
514 struct PointerRNA *uiButGetOperatorPtrRNA(uiBut *but);
516 void uiButSetUnitType(uiBut *but, const int unit_type);
517 int uiButGetUnitType(uiBut *but);
520 BUT_GET_RNAPROP_IDENTIFIER = 1,
521 BUT_GET_RNASTRUCT_IDENTIFIER,
522 BUT_GET_RNAENUM_IDENTIFIER,
525 BUT_GET_RNAENUM_LABEL,
526 BUT_GET_RNA_LABEL_CONTEXT, /* Context specified in CTX_XXX_ macros are just unreachable! */
533 typedef struct uiStringInfo {
538 /* Note: Expects pointers to uiStringInfo structs as parameters.
539 * Will fill them with translated strings, when possible.
540 * Strings in uiStringInfo must be MEM_freeN'ed by caller. */
541 void uiButGetStrInfo(struct bContext *C, uiBut *but, int nbr, ...);
543 /* Edit i18n stuff. */
544 /* Name of the main py op from i18n addon. */
545 #define EDTSRC_I18N_OP_NAME "UI_OT_edittranslation"
549 * Buttons with a more specific purpose:
550 * - IDPoinBut: for creating buttons that work on a pointer to an ID block.
551 * - MenuBut: buttons that popup a menu (in headers usually).
552 * - PulldownBut: like MenuBut, but creating a uiBlock (for compatibility).
553 * - BlockBut: buttons that popup a block with more buttons.
554 * - KeyevtBut: buttons that can be used to turn key events into values.
555 * - PickerButtons: buttons like the color picker (for code sharing).
556 * - AutoButR: RNA property button with type automatically defined. */
558 #define UI_ID_RENAME 1
559 #define UI_ID_BROWSE 2
560 #define UI_ID_ADD_NEW 4
562 #define UI_ID_ALONE 16
563 #define UI_ID_DELETE 32
564 #define UI_ID_LOCAL 64
565 #define UI_ID_AUTO_NAME 128
566 #define UI_ID_FAKE_USER 256
567 #define UI_ID_PIN 512
568 #define UI_ID_BROWSE_RENDER 1024
569 #define UI_ID_PREVIEWS 2048
570 #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)
572 typedef void (*uiIDPoinFuncFP)(struct bContext *C, const char *str, struct ID **idpp);
573 typedef void (*uiIDPoinFunc)(struct bContext *C, struct ID *id, int event);
575 uiBut *uiDefIDPoinBut(uiBlock *block, uiIDPoinFuncFP func, short blocktype, int retval, const char *str,
576 int x, int y, short width, short height, void *idpp, const char *tip);
578 int uiIconFromID(struct ID *id);
580 uiBut *uiDefPulldownBut(uiBlock *block, uiBlockCreateFunc func, void *arg, const char *str, int x, int y, short width, short height, const char *tip);
581 uiBut *uiDefMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, const char *str, int x, int y, short width, short height, const char *tip);
582 uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, const char *str, int x, int y, short width, short height, const char *tip);
583 uiBut *uiDefIconMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, int x, int y, short width, short height, const char *tip);
585 uiBut *uiDefBlockBut(uiBlock *block, uiBlockCreateFunc func, void *func_arg1, const char *str, int x, int y, short width, short height, const char *tip);
586 uiBut *uiDefBlockButN(uiBlock *block, uiBlockCreateFunc func, void *argN, const char *str, int x, int y, short width, short height, const char *tip);
588 uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int retval, int icon, int x, int y, short width, short height, const char *tip);
589 uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int icon, const char *str, int x, int y, short width, short height, const char *tip);
591 uiBut *uiDefKeyevtButS(uiBlock *block, int retval, const char *str, int x, int y, short width, short height, short *spoin, const char *tip);
592 uiBut *uiDefHotKeyevtButS(uiBlock *block, int retval, const char *str, int x, int y, short width, short height, short *keypoin, short *modkeypoin, const char *tip);
594 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);
596 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);
597 int uiDefAutoButsRNA(uiLayout *layout, struct PointerRNA *ptr, int (*check_prop)(struct PointerRNA *, struct PropertyRNA *), const char label_align);
601 * Game engine logic brick links. Non-functional currently in 2.5,
602 * code to handle and draw these is disabled internally. */
604 void uiSetButLink(struct uiBut *but, void **poin, void ***ppoin, short *tot, int from, int to);
606 void uiComposeLinks(uiBlock *block);
607 uiBut *uiFindInlink(uiBlock *block, void *poin);
609 /* use inside searchfunc to add items */
610 int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin, int iconid);
611 /* bfunc gets search item *poin as arg2, or if NULL the old string */
612 void uiButSetSearchFunc(uiBut *but, uiButSearchFunc sfunc, void *arg1, uiButHandleFunc bfunc, void *active);
613 /* height in pixels, it's using hardcoded values still */
614 int uiSearchBoxhHeight(void);
616 void uiBlockSetHandleFunc(uiBlock *block, uiBlockHandleFunc func, void *arg);
617 void uiBlockSetButmFunc(uiBlock *block, uiMenuHandleFunc func, void *arg);
618 void uiBlockSetFunc(uiBlock *block, uiButHandleFunc func, void *arg1, void *arg2);
619 void uiBlockSetNFunc(uiBlock *block, uiButHandleFunc func, void *argN, void *arg2);
621 void uiButSetRenameFunc(uiBut *but, uiButHandleRenameFunc func, void *arg1);
622 void uiButSetFunc(uiBut *but, uiButHandleFunc func, void *arg1, void *arg2);
623 void uiButSetNFunc(uiBut *but, uiButHandleNFunc func, void *argN, void *arg2);
625 void uiButSetCompleteFunc(uiBut *but, uiButCompleteFunc func, void *arg);
627 void uiBlockSetDrawExtraFunc(uiBlock *block,
628 void (*func)(const struct bContext *C, void *, void *, void *, struct rcti *rect),
629 void *arg1, void *arg2);
631 void uiButSetFocusOnEnter(struct wmWindow *win, uiBut *but);
635 * Tab complete helper functions, for use in uiButCompleteFunc callbacks.
636 * Call begin once, then multiple times do_name with all possibilities,
637 * and finally end to finish and get the completed name. */
639 typedef struct AutoComplete AutoComplete;
641 AutoComplete *autocomplete_begin(const char *startname, size_t maxlen);
642 void autocomplete_do_name(AutoComplete *autocpl, const char *name);
643 void autocomplete_end(AutoComplete *autocpl, char *autoname);
647 * Functions for creating, freeing and drawing panels. The API here
648 * could use a good cleanup, though how they will function in 2.5 is
649 * not clear yet so we postpone that. */
651 void uiBeginPanels(const struct bContext *C, struct ARegion *ar);
652 void uiEndPanels(const struct bContext *C, struct ARegion *ar, int *x, int *y);
653 void uiDrawPanels(const struct bContext *C, struct ARegion *ar);
655 struct Panel *uiBeginPanel(struct ScrArea *sa, struct ARegion *ar, uiBlock *block, struct PanelType *pt, int *open);
656 void uiEndPanel(uiBlock *block, int width, int height);
660 * Handlers that can be registered in regions, areas and windows for
661 * handling WM events. Mostly this is done automatic by modules such
662 * as screen/ if ED_KEYMAP_UI is set, or internally in popup functions. */
664 void UI_add_region_handlers(struct ListBase *handlers);
665 void UI_add_popup_handlers(struct bContext *C, struct ListBase *handlers, uiPopupBlockHandle *popup);
666 void UI_remove_popup_handlers(struct ListBase *handlers, uiPopupBlockHandle *popup);
670 * init and exit should be called before using this module. init_userdef must
671 * be used to reinitialize some internal state if user preferences change. */
674 void UI_init_userdef(void);
675 void UI_reinit_font(void);
680 * More automated layout of buttons. Has three levels:
681 * - Layout: contains a number templates, within a bounded width or height.
682 * - Template: predefined layouts for buttons with a number of slots, each
683 * slot can contain multiple items.
684 * - Item: item to put in a template slot, being either an RNA property,
685 * operator, label or menu. Also regular buttons can be used when setting
686 * uiBlockCurLayout. */
689 #define UI_LAYOUT_HORIZONTAL 0
690 #define UI_LAYOUT_VERTICAL 1
692 #define UI_LAYOUT_PANEL 0
693 #define UI_LAYOUT_HEADER 1
694 #define UI_LAYOUT_MENU 2
695 #define UI_LAYOUT_TOOLBAR 3
697 #define UI_UNIT_X U.widget_unit
698 #define UI_UNIT_Y U.widget_unit
700 #define UI_LAYOUT_ALIGN_EXPAND 0
701 #define UI_LAYOUT_ALIGN_LEFT 1
702 #define UI_LAYOUT_ALIGN_CENTER 2
703 #define UI_LAYOUT_ALIGN_RIGHT 3
705 #define UI_ITEM_O_RETURN_PROPS 1
706 #define UI_ITEM_R_EXPAND 2
707 #define UI_ITEM_R_SLIDER 4
708 #define UI_ITEM_R_TOGGLE 8
709 #define UI_ITEM_R_ICON_ONLY 16
710 #define UI_ITEM_R_EVENT 32
711 #define UI_ITEM_R_FULL_EVENT 64
712 #define UI_ITEM_R_NO_BG 128
713 #define UI_ITEM_R_IMMEDIATE 256
715 /* uiLayoutOperatorButs flags */
716 #define UI_LAYOUT_OP_SHOW_TITLE 1
717 #define UI_LAYOUT_OP_SHOW_EMPTY 2
719 /* flags to set which corners will become rounded:
727 UI_CNR_TOP_RIGHT = 2,
728 UI_CNR_BOTTOM_RIGHT = 4,
729 UI_CNR_BOTTOM_LEFT = 8,
730 /* just for convenience */
732 UI_CNR_ALL = (UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT)
735 /* not apart of the corner flags but mixed in some functions */
736 #define UI_RB_ALPHA (UI_CNR_ALL + 1)
738 uiLayout *uiBlockLayout(uiBlock *block, int dir, int type, int x, int y, int size, int em, struct uiStyle *style);
739 void uiBlockSetCurLayout(uiBlock *block, uiLayout *layout);
740 void uiBlockLayoutResolve(uiBlock *block, int *x, int *y);
742 uiBlock *uiLayoutGetBlock(uiLayout *layout);
744 void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv);
745 void uiLayoutSetContextPointer(uiLayout *layout, const char *name, struct PointerRNA *ptr);
746 void uiLayoutContextCopy(uiLayout *layout, struct bContextStore *context);
747 const char *uiLayoutIntrospect(uiLayout *layout); // XXX - testing
748 void uiLayoutOperatorButs(const struct bContext *C, struct uiLayout *layout, struct wmOperator *op, int (*check_prop)(struct PointerRNA *, struct PropertyRNA *), const char label_align, const short flag);
749 struct MenuType *uiButGetMenuType(uiBut *but);
751 void uiLayoutSetOperatorContext(uiLayout *layout, int opcontext);
752 void uiLayoutSetActive(uiLayout *layout, int active);
753 void uiLayoutSetEnabled(uiLayout *layout, int enabled);
754 void uiLayoutSetRedAlert(uiLayout *layout, int redalert);
755 void uiLayoutSetAlignment(uiLayout *layout, int alignment);
756 void uiLayoutSetKeepAspect(uiLayout *layout, int keepaspect);
757 void uiLayoutSetScaleX(uiLayout *layout, float scale);
758 void uiLayoutSetScaleY(uiLayout *layout, float scale);
760 int uiLayoutGetOperatorContext(uiLayout *layout);
761 int uiLayoutGetActive(uiLayout *layout);
762 int uiLayoutGetEnabled(uiLayout *layout);
763 int uiLayoutGetRedAlert(uiLayout *layout);
764 int uiLayoutGetAlignment(uiLayout *layout);
765 int uiLayoutGetKeepAspect(uiLayout *layout);
766 int uiLayoutGetWidth(uiLayout *layout);
767 float uiLayoutGetScaleX(uiLayout *layout);
768 float uiLayoutGetScaleY(uiLayout *layout);
770 /* layout specifiers */
771 uiLayout *uiLayoutRow(uiLayout *layout, int align);
772 uiLayout *uiLayoutColumn(uiLayout *layout, int align);
773 uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, int align);
774 uiLayout *uiLayoutBox(uiLayout *layout);
775 uiLayout *uiLayoutListBox(uiLayout *layout, struct PointerRNA *ptr, struct PropertyRNA *prop,
776 struct PointerRNA *actptr, struct PropertyRNA *actprop);
777 uiLayout *uiLayoutAbsolute(uiLayout *layout, int align);
778 uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, int align);
779 uiLayout *uiLayoutOverlap(uiLayout *layout);
781 uiBlock *uiLayoutAbsoluteBlock(uiLayout *layout);
784 void uiTemplateHeader(uiLayout *layout, struct bContext *C, int menus);
785 void uiTemplateDopeSheetFilter(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr);
786 void uiTemplateID(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname,
787 const char *newop, const char *openop, const char *unlinkop);
788 void uiTemplateIDBrowse(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname,
789 const char *newop, const char *openop, const char *unlinkop);
790 void uiTemplateIDPreview(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname,
791 const char *newop, const char *openop, const char *unlinkop, int rows, int cols);
792 void uiTemplateAnyID(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
793 const char *proptypename, const char *text);
794 void uiTemplatePathBuilder(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
795 struct PointerRNA *root_ptr, const char *text);
796 uiLayout *uiTemplateModifier(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr);
797 uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr);
798 void uiTemplatePreview(uiLayout *layout, struct ID *id, int show_buttons, struct ID *parent, struct MTex *slot);
799 void uiTemplateColorRamp(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int expand);
800 void uiTemplateHistogram(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
801 void uiTemplateWaveform(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
802 void uiTemplateVectorscope(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
803 void uiTemplateCurveMapping(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int type, int levels, int brush);
804 void uiTemplateColorWheel(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int value_slider, int lock, int lock_luminosity, int cubic);
805 void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
806 PointerRNA *used_ptr, const char *used_propname, int active_layer);
807 void uiTemplateImage(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr, int compact);
808 void uiTemplateImageSettings(uiLayout *layout, struct PointerRNA *imfptr);
809 void uiTemplateImageLayers(uiLayout *layout, struct bContext *C, struct Image *ima, struct ImageUser *iuser);
810 void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C);
811 void uiTemplateOperatorSearch(uiLayout *layout);
812 void uiTemplateHeader3D(uiLayout *layout, struct bContext *C);
813 void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C);
814 void uiTemplateTextureImage(uiLayout *layout, struct bContext *C, struct Tex *tex);
815 void uiTemplateReportsBanner(uiLayout *layout, struct bContext *C);
816 void uiTemplateKeymapItemProperties(uiLayout *layout, struct PointerRNA *ptr);
818 void uiTemplateList(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *activeptr, const char *activeprop, const char *prop_list, int rows, int maxrows, int type);
819 void uiTemplateNodeLink(uiLayout *layout, struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *input);
820 void uiTemplateNodeView(uiLayout *layout, struct bContext *C, struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *input);
821 void uiTemplateTextureUser(uiLayout *layout, struct bContext *C);
822 void uiTemplateTextureShow(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop);
824 void uiTemplateMovieClip(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, int compact);
825 void uiTemplateTrack(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname);
826 void uiTemplateMarker(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, PointerRNA *userptr, PointerRNA *trackptr, int cmpact);
829 void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname);
830 void uiItemEnumO_ptr(uiLayout *layout, struct wmOperatorType *ot, const char *name, int icon, const char *propname, int value);
831 void uiItemEnumO(uiLayout *layout, const char *opname, const char *name, int icon, const char *propname, int value);
832 void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value);
833 void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value);
834 void uiItemsEnumO(uiLayout *layout, const char *opname, const char *propname);
835 void uiItemBooleanO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value);
836 void uiItemIntO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value);
837 void uiItemFloatO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, float value);
838 void uiItemStringO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value);
840 PointerRNA uiItemFullO_ptr(uiLayout *layout, struct wmOperatorType *ot, const char *name, int icon, IDProperty *properties, int context, int flag);
841 PointerRNA uiItemFullO(uiLayout *layout, const char *idname, const char *name, int icon, struct IDProperty *properties, int context, int flag);
843 void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon);
844 void uiItemFullR(uiLayout *layout, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, int value, int flag, const char *name, int icon);
845 void uiItemEnumR(uiLayout *layout, const char *name, int icon, struct PointerRNA *ptr, const char *propname, int value);
846 void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *value, const char *name, int icon);
847 void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
848 void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *searchptr, const char *searchpropname, const char *name, int icon);
849 void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname, struct IDProperty *properties, int context, int flag);
851 void uiItemL(uiLayout *layout, const char *name, int icon); /* label */
852 void uiItemLDrag(uiLayout *layout, struct PointerRNA *ptr, const char *name, int icon); /* label icon for dragging */
853 void uiItemM(uiLayout *layout, struct bContext *C, const char *menuname, const char *name, int icon); /* menu */
854 void uiItemV(uiLayout *layout, const char *name, int icon, int argval); /* value */
855 void uiItemS(uiLayout *layout); /* separator */
857 void uiItemMenuF(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *arg);
858 void uiItemMenuEnumO(uiLayout *layout, const char *opname, const char *propname, const char *name, int icon);
859 void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name, int icon);
862 void UI_buttons_operatortypes(void);
864 /* Helpers for Operators */
865 uiBut *uiContextActiveButton(const struct bContext *C);
866 void uiContextActiveProperty(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index);
867 void uiContextActivePropertyHandle(struct bContext *C);
868 struct wmOperator *uiContextActiveOperator(const struct bContext *C);
869 void uiContextAnimUpdate(const struct bContext *C);
870 void uiFileBrowseContextProperty(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop);
871 void uiIDContextProperty(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop);
873 /* Styled text draw */
874 void uiStyleFontSet(struct uiFontStyle *fs);
875 void uiStyleFontDrawExt(struct uiFontStyle *fs, struct rcti *rect, const char *str,
876 float *r_xofs, float *r_yofs);
877 void uiStyleFontDraw(struct uiFontStyle *fs, struct rcti *rect, const char *str);
878 void uiStyleFontDrawRotated(struct uiFontStyle *fs, struct rcti *rect, const char *str);
880 int UI_GetStringWidth(const char *str); // XXX temp
881 void UI_DrawString(float x, float y, const char *str); // XXX temp
882 void UI_DrawTriIcon(float x, float y, char dir);
883 uiStyle *UI_GetStyle(void);
884 /* linker workaround ack! */
885 void UI_template_fix_linking(void);
887 /* UI_OT_editsource helpers */
888 int UI_editsource_enable_check(void);
889 void UI_editsource_active_but_test(uiBut *but);
891 #endif /* __UI_INTERFACE_H__ */