4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21 * All rights reserved.
23 * The Original Code is: all of this file.
25 * Contributor(s): none yet.
27 * ***** END GPL LICENSE BLOCK *****
30 /** \file UI_interface.h
34 #ifndef UI_INTERFACE_H
35 #define UI_INTERFACE_H
37 #include "BLO_sys_types.h" /* size_t */
38 #include "RNA_types.h"
39 #include "DNA_userdef_types.h"
41 /* Struct Declarations */
49 struct wmWindowManager;
62 struct uiWidgetColors;
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_EMBOSS 0 /* use widget style for drawing */
84 #define UI_EMBOSSN 1 /* Nothing, only icon and/or text */
85 #define UI_EMBOSSP 2 /* Pulldown menu style */
86 #define UI_EMBOSST 3 /* Table */
88 /* uiBlock->direction */
89 #define UI_DIRECTION (UI_TOP|UI_DOWN|UI_LEFT|UI_RIGHT)
96 #define UI_SHIFT_FLIPPED 32
98 /* uiBlock->autofill (not yet used) */
99 // #define UI_BLOCK_COLLUMNS 1
100 // #define UI_BLOCK_ROWS 2
102 /* uiBlock->flag (controls) */
103 #define UI_BLOCK_LOOP 1
104 #define UI_BLOCK_REDRAW 2
105 #define UI_BLOCK_RET_1 4 /* XXX 2.5 not implemented */
106 #define UI_BLOCK_NUMSELECT 8
107 /*#define UI_BLOCK_ENTER_OK 16*/ /*UNUSED*/
108 #define UI_BLOCK_CLIPBOTTOM 32
109 #define UI_BLOCK_CLIPTOP 64
110 #define UI_BLOCK_MOVEMOUSE_QUIT 128
111 #define UI_BLOCK_KEEP_OPEN 256
112 #define UI_BLOCK_POPUP 512
113 #define UI_BLOCK_OUT_1 1024
114 #define UI_BLOCK_NO_FLIP 2048
115 #define UI_BLOCK_POPUP_MEMORY 4096
117 /* uiPopupBlockHandle->menuretval */
118 #define UI_RETURN_CANCEL 1 /* cancel all menus cascading */
119 #define UI_RETURN_OK 2 /* choice made */
120 #define UI_RETURN_OUT 4 /* left the menu */
121 #define UI_RETURN_UPDATE 8 /* update the button that opened */
123 /* block->flag bits 12-15 are identical to but->flag bits */
126 #define UI_PNL_SOLID 2
127 #define UI_PNL_CLOSE 32
128 #define UI_PNL_SCALE 512
130 /* warning the first 6 flags are internal */
132 #define UI_TEXT_LEFT 64
133 #define UI_ICON_LEFT 128
134 #define UI_ICON_SUBMENU 256
135 #define UI_ICON_PREVIEW 512
136 /* control for button type block */
137 #define UI_MAKE_TOP 1024
138 #define UI_MAKE_DOWN 2048
139 #define UI_MAKE_LEFT 4096
140 #define UI_MAKE_RIGHT 8192
142 /* button align flag, for drawing groups together */
143 #define UI_BUT_ALIGN (UI_BUT_ALIGN_TOP|UI_BUT_ALIGN_LEFT|UI_BUT_ALIGN_RIGHT|UI_BUT_ALIGN_DOWN)
144 #define UI_BUT_ALIGN_TOP (1<<14)
145 #define UI_BUT_ALIGN_LEFT (1<<15)
146 #define UI_BUT_ALIGN_RIGHT (1<<16)
147 #define UI_BUT_ALIGN_DOWN (1<<17)
149 #define UI_BUT_DISABLED (1<<18)
150 #define UI_BUT_COLOR_LOCK (1<<19)
151 #define UI_BUT_ANIMATED (1<<20)
152 #define UI_BUT_ANIMATED_KEY (1<<21)
153 #define UI_BUT_DRIVEN (1<<22)
154 #define UI_BUT_REDALERT (1<<23)
155 #define UI_BUT_INACTIVE (1<<24)
156 #define UI_BUT_LAST_ACTIVE (1<<25)
157 #define UI_BUT_UNDO (1<<26)
158 #define UI_BUT_IMMEDIATE (1<<27)
159 #define UI_BUT_NO_TOOLTIP (1<<28)
160 #define UI_BUT_NO_UTF8 (1<<29)
162 #define UI_BUT_VEC_SIZE_LOCK (1<<30) /* used to flag if color hsv-circle should keep luminance */
163 #define UI_BUT_COLOR_CUBIC (1<<31) /* cubic saturation for the color wheel */
164 #define UI_BUT_NODE_LINK (1<<30) /* node link drawing hint for pulldowns */
165 #define UI_BUT_NODE_ACTIVE (1<<31) /* node link drawing hint for pulldowns */
167 #define UI_PANEL_WIDTH 340
168 #define UI_COMPACT_PANEL_WIDTH 160
170 /* scale fixed button widths by this to account for DPI
171 * 8.4852 == sqrtf(72.0f)) */
172 #define UI_DPI_FAC (sqrtf((float)U.dpi) / 8.48528137423857f)
173 #define UI_DPI_ICON_FAC (((float)U.dpi) / 72.0f)
174 /* 16 to copy ICON_DEFAULT_HEIGHT */
175 #define UI_DPI_ICON_SIZE ((float)16 * UI_DPI_ICON_FAC)
177 /* Button types, bits stored in 1 value... and a short even!
178 - bits 0-4: bitnr (0-31)
179 - bits 5-7: pointer type
181 - bit 9-15: button type (now 6 bits, 64 types)
188 /*#define FUN 192*/ /*UNUSED*/
191 #define BUTPOIN (128+64+32)
202 #define LABEL (10<<9)
204 #define ICONROW (12<<9)
205 #define ICONTOG (13<<9)
206 #define NUMSLI (14<<9)
208 #define IDPOIN (16<<9)
209 #define HSVSLI (17<<9)
210 #define SCROLL (18<<9)
211 #define BLOCK (19<<9)
215 #define INLINK (23<<9)
216 #define KEYEVT (24<<9)
217 #define ICONTEXTROW (25<<9)
218 #define HSVCUBE (26<<9)
219 #define PULLDOWN (27<<9)
220 #define ROUNDBOX (28<<9)
221 #define CHARTAB (29<<9)
222 #define BUT_COLORBAND (30<<9)
223 #define BUT_NORMAL (31<<9)
224 #define BUT_CURVE (32<<9)
225 #define BUT_TOGDUAL (33<<9)
226 #define ICONTOGN (34<<9)
227 #define FTPREVIEW (35<<9)
228 #define NUMABS (36<<9)
229 #define TOGBUT (37<<9)
230 #define OPTION (38<<9)
231 #define OPTIONN (39<<9)
232 /* buttons with value >= SEARCH_MENU don't get undo pushes */
233 #define SEARCH_MENU (40<<9)
234 #define BUT_EXTRA (41<<9)
235 #define HSVCIRCLE (42<<9)
236 #define LISTBOX (43<<9)
237 #define LISTROW (44<<9)
238 #define HOTKEYEVT (45<<9)
239 #define BUT_IMAGE (46<<9)
240 #define HISTOGRAM (47<<9)
241 #define WAVEFORM (48<<9)
242 #define VECTORSCOPE (49<<9)
243 #define PROGRESSBAR (50<<9)
245 #define BUTTYPE (63<<9)
247 /* gradient types, for color picker HSVCUBE etc */
255 #define UI_GRAD_V_ALT 9
259 * Functions to draw various shapes, taking theme settings into account.
260 * Used for code that draws its own UI style elements. */
262 void uiEmboss(float x1, float y1, float x2, float y2, int sel);
263 void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad);
264 void uiSetRoundBox(int type);
265 int uiGetRoundBox(void);
266 void uiRoundRect(float minx, float miny, float maxx, float maxy, float rad);
267 void uiDrawMenuBox(float minx, float miny, float maxx, float maxy, short flag, short direction);
268 void uiDrawBoxShadow(unsigned char alpha, float minx, float miny, float maxx, float maxy);
269 void uiDrawBox(int mode, float minx, float miny, float maxx, float maxy, float rad);
270 void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown);
271 void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadeLeft, float shadeRight);
273 /* state for scrolldrawing */
274 #define UI_SCROLL_PRESSED 1
275 #define UI_SCROLL_ARROWS 2
276 #define UI_SCROLL_NO_OUTLINE 4
277 void uiWidgetScrollDraw(struct uiWidgetColors *wcol, struct rcti *rect, struct rcti *slider, int state);
281 typedef void (*uiMenuCreateFunc)(struct bContext *C, struct uiLayout *layout, void *arg1);
282 typedef void (*uiMenuHandleFunc)(struct bContext *C, void *arg, int event);
286 * Functions used to create popup menus. For more extended menus the
287 * uiPupMenuBegin/End functions can be used to define own items with
288 * the uiItem functions in between. If it is a simple confirmation menu
289 * or similar, popups can be created with a single function call. */
291 typedef struct uiPopupMenu uiPopupMenu;
293 uiPopupMenu *uiPupMenuBegin(struct bContext *C, const char *title, int icon);
294 void uiPupMenuEnd(struct bContext *C, struct uiPopupMenu *head);
295 struct uiLayout *uiPupMenuLayout(uiPopupMenu *head);
297 void uiPupMenuOkee(struct bContext *C, const char *opname, const char *str, ...);
298 void uiPupMenuSaveOver(struct bContext *C, struct wmOperator *op, const char *filename);
299 void uiPupMenuNotice(struct bContext *C, const char *str, ...);
300 void uiPupMenuError(struct bContext *C, const char *str, ...);
301 void uiPupMenuReports(struct bContext *C, struct ReportList *reports);
302 void uiPupMenuInvoke(struct bContext *C, const char *idname); /* popup registered menu */
306 * Functions used to create popup blocks. These are like popup menus
307 * but allow using all button types and creating an own layout. */
309 typedef uiBlock* (*uiBlockCreateFunc)(struct bContext *C, struct ARegion *ar, void *arg1);
310 typedef void (*uiBlockCancelFunc)(void *arg1);
312 void uiPupBlock(struct bContext *C, uiBlockCreateFunc func, void *arg);
313 void uiPupBlockO(struct bContext *C, uiBlockCreateFunc func, void *arg, const char *opname, int opcontext);
314 void uiPupBlockEx(struct bContext *C, uiBlockCreateFunc func, uiBlockCancelFunc cancel_func, void *arg);
315 /* void uiPupBlockOperator(struct bContext *C, uiBlockCreateFunc func, struct wmOperator *op, int opcontext); */ /* UNUSED */
317 void uiPupBlockClose(struct bContext *C, uiBlock *block);
321 * Functions for creating, drawing and freeing blocks. A Block is a
322 * container of buttons and used for various purposes.
324 * Begin/Define Buttons/End/Draw is the typical order in which these
325 * function should be called, though for popup blocks Draw is left out.
326 * Freeing blocks is done by the screen/ module automatically.
330 uiBlock *uiBeginBlock(const struct bContext *C, struct ARegion *region, const char *name, short dt);
331 void uiEndBlock(const struct bContext *C, uiBlock *block);
332 void uiDrawBlock(const struct bContext *C, struct uiBlock *block);
334 uiBlock *uiGetBlock(const char *name, struct ARegion *ar);
336 void uiBlockSetEmboss(uiBlock *block, char dt);
338 void uiFreeBlock(const struct bContext *C, uiBlock *block);
339 void uiFreeBlocks(const struct bContext *C, struct ListBase *lb);
340 void uiFreeInactiveBlocks(const struct bContext *C, struct ListBase *lb);
341 void uiFreeActiveButtons(const struct bContext *C, struct bScreen *screen);
343 void uiBlockSetRegion(uiBlock *block, struct ARegion *region);
345 void uiBlockSetButLock(uiBlock *block, int val, const char *lockstr);
346 void uiBlockClearButLock(uiBlock *block);
348 /* automatic aligning, horiz or verical */
349 void uiBlockBeginAlign(uiBlock *block);
350 void uiBlockEndAlign(uiBlock *block);
352 /* block bounds/position calculation */
355 UI_BLOCK_BOUNDS_TEXT,
356 UI_BLOCK_BOUNDS_POPUP_MOUSE,
357 UI_BLOCK_BOUNDS_POPUP_MENU,
358 UI_BLOCK_BOUNDS_POPUP_CENTER
361 void uiBoundsBlock(struct uiBlock *block, int addval);
362 void uiTextBoundsBlock(uiBlock *block, int addval);
363 void uiPopupBoundsBlock(uiBlock *block, int addval, int mx, int my);
364 void uiMenuPopupBoundsBlock(uiBlock *block, int addvall, int mx, int my);
365 void uiCenteredBoundsBlock(uiBlock *block, int addval);
367 int uiBlocksGetYMin (struct ListBase *lb);
369 void uiBlockSetDirection (uiBlock *block, int direction);
370 void uiBlockFlipOrder (uiBlock *block);
371 void uiBlockSetFlag (uiBlock *block, int flag);
372 void uiBlockClearFlag (uiBlock *block, int flag);
373 void uiBlockSetXOfs (uiBlock *block, int xofs);
375 int uiButGetRetVal (uiBut *but);
377 void uiButSetDragID(uiBut *but, struct ID *id);
378 void uiButSetDragRNA(uiBut *but, struct PointerRNA *ptr);
379 void uiButSetDragPath(uiBut *but, const char *path);
380 void uiButSetDragName(uiBut *but, const char *name);
381 void uiButSetDragValue(uiBut *but);
382 void uiButSetDragImage(uiBut *but, const char *path, int icon, struct ImBuf *ima, float scale);
384 int UI_but_active_drop_name(struct bContext *C);
386 void uiButSetFlag (uiBut *but, int flag);
387 void uiButClearFlag (uiBut *but, int flag);
389 /* special button case, only draw it when used actively, for outliner etc */
390 int uiButActiveOnly (const struct bContext *C, uiBlock *block, uiBut *but);
395 * Functions to define various types of buttons in a block. Postfixes:
403 uiBut *uiDefBut(uiBlock *block,
404 int type, int retval, const char *str,
408 float min, float max,
409 float a1, float a2, const char *tip);
410 uiBut *uiDefButF(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip);
411 uiBut *uiDefButBitF(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip);
412 uiBut *uiDefButI(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip);
413 uiBut *uiDefButBitI(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip);
414 uiBut *uiDefButS(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip);
415 uiBut *uiDefButBitS(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip);
416 uiBut *uiDefButC(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip);
417 uiBut *uiDefButBitC(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip);
418 uiBut *uiDefButR(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip);
419 uiBut *uiDefButR_prop(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip);
420 uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip);
421 uiBut *uiDefButTextO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip);
423 uiBut *uiDefIconBut(uiBlock *block,
424 int type, int retval, int icon,
428 float min, float max,
429 float a1, float a2, const char *tip);
430 uiBut *uiDefIconButF(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip);
431 uiBut *uiDefIconButBitF(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip);
432 uiBut *uiDefIconButI(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip);
433 uiBut *uiDefIconButBitI(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip);
434 uiBut *uiDefIconButS(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip);
435 uiBut *uiDefIconButBitS(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip);
436 uiBut *uiDefIconButC(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip);
437 uiBut *uiDefIconButBitC(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip);
438 uiBut *uiDefIconButR(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip);
439 uiBut *uiDefIconButR_prop(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip);
440 uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip);
442 uiBut *uiDefIconTextBut(uiBlock *block,
443 int type, int retval, int icon, const char *str,
447 float min, float max,
448 float a1, float a2, const char *tip);
449 uiBut *uiDefIconTextButF(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip);
450 uiBut *uiDefIconTextButBitF(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip);
451 uiBut *uiDefIconTextButI(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip);
452 uiBut *uiDefIconTextButBitI(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip);
453 uiBut *uiDefIconTextButS(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip);
454 uiBut *uiDefIconTextButBitS(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip);
455 uiBut *uiDefIconTextButC(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip);
456 uiBut *uiDefIconTextButBitC(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip);
457 uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip);
458 uiBut *uiDefIconTextButR_prop(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip);
459 uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip);
461 /* for passing inputs to ButO buttons */
462 struct PointerRNA *uiButGetOperatorPtrRNA(uiBut *but);
464 void uiButSetUnitType(uiBut *but, const int unit_type);
465 int uiButGetUnitType(uiBut *but);
469 * Butons with a more specific purpose:
470 * - IDPoinBut: for creating buttons that work on a pointer to an ID block.
471 * - MenuBut: buttons that popup a menu (in headers usually).
472 * - PulldownBut: like MenuBut, but creating a uiBlock (for compatibility).
473 * - BlockBut: buttons that popup a block with more buttons.
474 * - KeyevtBut: buttons that can be used to turn key events into values.
475 * - PickerButtons: buttons like the color picker (for code sharing).
476 * - AutoButR: RNA property button with type automatically defined. */
478 #define UI_ID_RENAME 1
479 #define UI_ID_BROWSE 2
480 #define UI_ID_ADD_NEW 4
482 #define UI_ID_ALONE 16
483 #define UI_ID_DELETE 32
484 #define UI_ID_LOCAL 64
485 #define UI_ID_AUTO_NAME 128
486 #define UI_ID_FAKE_USER 256
487 #define UI_ID_PIN 512
488 #define UI_ID_BROWSE_RENDER 1024
489 #define UI_ID_PREVIEWS 2048
490 #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)
492 typedef void (*uiIDPoinFuncFP)(struct bContext *C, const char *str, struct ID **idpp);
493 typedef void (*uiIDPoinFunc)(struct bContext *C, struct ID *id, int event);
495 uiBut *uiDefIDPoinBut(uiBlock *block, uiIDPoinFuncFP func, short blocktype, int retval, const char *str,
496 int x1, int y1, short x2, short y2, void *idpp, const char *tip);
498 int uiIconFromID(struct ID *id);
500 uiBut *uiDefPulldownBut(uiBlock *block, uiBlockCreateFunc func, void *arg, const char *str, int x1, int y1, short x2, short y2, const char *tip);
501 uiBut *uiDefMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, const char *str, int x1, int y1, short x2, short y2, const char *tip);
502 uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip);
503 uiBut *uiDefIconMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, int x1, int y1, short x2, short y2, const char *tip);
505 uiBut *uiDefBlockBut(uiBlock *block, uiBlockCreateFunc func, void *func_arg1, const char *str, int x1, int y1, short x2, short y2, const char *tip);
506 uiBut *uiDefBlockButN(uiBlock *block, uiBlockCreateFunc func, void *argN, const char *str, int x1, int y1, short x2, short y2, const char *tip);
508 uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int retval, int icon, int x1, int y1, short x2, short y2, const char *tip);
509 uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip);
511 uiBut *uiDefKeyevtButS(uiBlock *block, int retval, const char *str, int x1, int y1, short x2, short y2, short *spoin, const char *tip);
512 uiBut *uiDefHotKeyevtButS(uiBlock *block, int retval, const char *str, int x1, int y1, short x2, short y2, short *keypoin, short *modkeypoin, const char *tip);
514 uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, int x1, int y1, short x2, short y2, float a1, float a2, const char *tip);
516 void uiBlockPickerButtons(struct uiBlock *block, float *col, float *hsv, float *old, char *hexcol, char mode, short retval);
518 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);
519 int uiDefAutoButsRNA(uiLayout *layout, struct PointerRNA *ptr, int (*check_prop)(struct PropertyRNA *), const char label_align);
523 * Game engine logic brick links. Non-functional currently in 2.5,
524 * code to handle and draw these is disabled internally. */
526 void uiSetButLink(struct uiBut *but, void **poin, void ***ppoin, short *tot, int from, int to);
528 void uiComposeLinks(uiBlock *block);
529 uiBut *uiFindInlink(uiBlock *block, void *poin);
533 * uiBlockSetHandleFunc/ButmFunc are for handling events through a callback.
534 * HandleFunc gets the retval passed on, and ButmFunc gets a2. The latter is
535 * mostly for compatibility with older code.
537 * uiButSetCompleteFunc is for tab completion.
539 * uiButSearchFunc is for name buttons, showing a popup with matches
541 * uiBlockSetFunc and uiButSetFunc are callbacks run when a button is used,
542 * in case events, operators or RNA are not sufficient to handle the button.
544 * uiButSetNFunc will free the argument with MEM_freeN. */
546 typedef struct uiSearchItems uiSearchItems;
548 typedef void (*uiButHandleFunc)(struct bContext *C, void *arg1, void *arg2);
549 typedef void (*uiButHandleRenameFunc)(struct bContext *C, void *arg, char *origstr);
550 typedef void (*uiButHandleNFunc)(struct bContext *C, void *argN, void *arg2);
551 typedef void (*uiButCompleteFunc)(struct bContext *C, char *str, void *arg);
552 typedef void (*uiButSearchFunc)(const struct bContext *C, void *arg, const char *str, uiSearchItems *items);
553 typedef void (*uiBlockHandleFunc)(struct bContext *C, void *arg, int event);
555 /* use inside searchfunc to add items */
556 int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin, int iconid);
557 /* bfunc gets search item *poin as arg2, or if NULL the old string */
558 void uiButSetSearchFunc (uiBut *but, uiButSearchFunc sfunc, void *arg1, uiButHandleFunc bfunc, void *active);
559 /* height in pixels, it's using hardcoded values still */
560 int uiSearchBoxhHeight(void);
562 void uiBlockSetHandleFunc(uiBlock *block, uiBlockHandleFunc func, void *arg);
563 void uiBlockSetButmFunc (uiBlock *block, uiMenuHandleFunc func, void *arg);
564 void uiBlockSetFunc (uiBlock *block, uiButHandleFunc func, void *arg1, void *arg2);
565 void uiBlockSetNFunc (uiBlock *block, uiButHandleFunc func, void *argN, void *arg2);
567 void uiButSetRenameFunc (uiBut *but, uiButHandleRenameFunc func, void *arg1);
568 void uiButSetFunc (uiBut *but, uiButHandleFunc func, void *arg1, void *arg2);
569 void uiButSetNFunc (uiBut *but, uiButHandleNFunc func, void *argN, void *arg2);
571 void uiButSetCompleteFunc(uiBut *but, uiButCompleteFunc func, void *arg);
573 void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)(const struct bContext *C, void *, void *, void *, struct rcti *rect), void *arg1, void *arg2);
575 void uiButSetFocusOnEnter (struct wmWindow *win, uiBut *but);
579 * Tab complete helper functions, for use in uiButCompleteFunc callbacks.
580 * Call begin once, then multiple times do_name with all possibilities,
581 * and finally end to finish and get the completed name. */
583 typedef struct AutoComplete AutoComplete;
585 AutoComplete *autocomplete_begin(const char *startname, size_t maxlen);
586 void autocomplete_do_name(AutoComplete *autocpl, const char *name);
587 void autocomplete_end(AutoComplete *autocpl, char *autoname);
591 * Functions for creating, freeing and drawing panels. The API here
592 * could use a good cleanup, though how they will function in 2.5 is
593 * not clear yet so we postpone that. */
595 void uiBeginPanels(const struct bContext *C, struct ARegion *ar);
596 void uiEndPanels(const struct bContext *C, struct ARegion *ar);
597 void uiDrawPanels(const struct bContext *C, struct ARegion *ar);
599 struct Panel *uiBeginPanel(struct ScrArea *sa, struct ARegion *ar, uiBlock *block, struct PanelType *pt, int *open);
600 void uiEndPanel(uiBlock *block, int width, int height);
604 * Handlers that can be registered in regions, areas and windows for
605 * handling WM events. Mostly this is done automatic by modules such
606 * as screen/ if ED_KEYMAP_UI is set, or internally in popup functions. */
608 void UI_add_region_handlers(struct ListBase *handlers);
609 void UI_add_area_handlers(struct ListBase *handlers);
610 void UI_add_popup_handlers(struct bContext *C, struct ListBase *handlers, uiPopupBlockHandle *popup);
611 void UI_remove_popup_handlers(struct ListBase *handlers, uiPopupBlockHandle *popup);
615 * init and exit should be called before using this module. init_userdef must
616 * be used to reinitialize some internal state if user preferences change. */
619 void UI_init_userdef(void);
620 void UI_reinit_font(void);
625 * More automated layout of buttons. Has three levels:
626 * - Layout: contains a number templates, within a bounded width or height.
627 * - Template: predefined layouts for buttons with a number of slots, each
628 * slot can contain multiple items.
629 * - Item: item to put in a template slot, being either an RNA property,
630 * operator, label or menu. Also regular buttons can be used when setting
631 * uiBlockCurLayout. */
634 #define UI_LAYOUT_HORIZONTAL 0
635 #define UI_LAYOUT_VERTICAL 1
637 #define UI_LAYOUT_PANEL 0
638 #define UI_LAYOUT_HEADER 1
639 #define UI_LAYOUT_MENU 2
640 #define UI_LAYOUT_TOOLBAR 3
642 #define UI_UNIT_X U.widget_unit
643 #define UI_UNIT_Y U.widget_unit
645 #define UI_LAYOUT_ALIGN_EXPAND 0
646 #define UI_LAYOUT_ALIGN_LEFT 1
647 #define UI_LAYOUT_ALIGN_CENTER 2
648 #define UI_LAYOUT_ALIGN_RIGHT 3
650 #define UI_ITEM_O_RETURN_PROPS 1
651 #define UI_ITEM_R_EXPAND 2
652 #define UI_ITEM_R_SLIDER 4
653 #define UI_ITEM_R_TOGGLE 8
654 #define UI_ITEM_R_ICON_ONLY 16
655 #define UI_ITEM_R_EVENT 32
656 #define UI_ITEM_R_FULL_EVENT 64
657 #define UI_ITEM_R_NO_BG 128
658 #define UI_ITEM_R_IMMEDIATE 256
660 /* uiLayoutOperatorButs flags */
661 #define UI_LAYOUT_OP_SHOW_TITLE 1
662 #define UI_LAYOUT_OP_SHOW_EMPTY 2
664 /* flags to set which corners will become rounded:
673 UI_CNR_BOTTOM_RIGHT= 4,
674 UI_CNR_BOTTOM_LEFT= 8,
675 /* just for convenience */
677 UI_CNR_ALL= (UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT)
680 /* not apart of the corner flags but mixed in some functions */
681 #define UI_RB_ALPHA (UI_CNR_ALL + 1)
683 uiLayout *uiBlockLayout(uiBlock *block, int dir, int type, int x, int y, int size, int em, struct uiStyle *style);
684 void uiBlockSetCurLayout(uiBlock *block, uiLayout *layout);
685 void uiBlockLayoutResolve(uiBlock *block, int *x, int *y);
687 uiBlock *uiLayoutGetBlock(uiLayout *layout);
689 void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv);
690 void uiLayoutSetContextPointer(uiLayout *layout, const char *name, struct PointerRNA *ptr);
691 const char *uiLayoutIntrospect(uiLayout *layout); // XXX - testing
692 void uiLayoutOperatorButs(const struct bContext *C, struct uiLayout *layout, struct wmOperator *op, int (*check_prop)(struct PropertyRNA *), const char label_align, const short flag);
694 void uiLayoutSetOperatorContext(uiLayout *layout, int opcontext);
695 void uiLayoutSetActive(uiLayout *layout, int active);
696 void uiLayoutSetEnabled(uiLayout *layout, int enabled);
697 void uiLayoutSetRedAlert(uiLayout *layout, int redalert);
698 void uiLayoutSetAlignment(uiLayout *layout, int alignment);
699 void uiLayoutSetKeepAspect(uiLayout *layout, int keepaspect);
700 void uiLayoutSetScaleX(uiLayout *layout, float scale);
701 void uiLayoutSetScaleY(uiLayout *layout, float scale);
703 int uiLayoutGetOperatorContext(uiLayout *layout);
704 int uiLayoutGetActive(uiLayout *layout);
705 int uiLayoutGetEnabled(uiLayout *layout);
706 int uiLayoutGetRedAlert(uiLayout *layout);
707 int uiLayoutGetAlignment(uiLayout *layout);
708 int uiLayoutGetKeepAspect(uiLayout *layout);
709 int uiLayoutGetWidth(uiLayout *layout);
710 float uiLayoutGetScaleX(uiLayout *layout);
711 float uiLayoutGetScaleY(uiLayout *layout);
713 /* layout specifiers */
714 uiLayout *uiLayoutRow(uiLayout *layout, int align);
715 uiLayout *uiLayoutColumn(uiLayout *layout, int align);
716 uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, int align);
717 uiLayout *uiLayoutBox(uiLayout *layout);
718 uiLayout *uiLayoutListBox(uiLayout *layout, struct PointerRNA *ptr, struct PropertyRNA *prop,
719 struct PointerRNA *actptr, struct PropertyRNA *actprop);
720 uiLayout *uiLayoutAbsolute(uiLayout *layout, int align);
721 uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, int align);
722 uiLayout *uiLayoutOverlap(uiLayout *layout);
724 uiBlock *uiLayoutAbsoluteBlock(uiLayout *layout);
727 void uiTemplateHeader(uiLayout *layout, struct bContext *C, int menus);
728 void uiTemplateDopeSheetFilter(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr);
729 void uiTemplateID(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname,
730 const char *newop, const char *openop, const char *unlinkop);
731 void uiTemplateIDBrowse(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname,
732 const char *newop, const char *openop, const char *unlinkop);
733 void uiTemplateIDPreview(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname,
734 const char *newop, const char *openop, const char *unlinkop, int rows, int cols);
735 void uiTemplateAnyID(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
736 const char *proptypename, const char *text);
737 void uiTemplatePathBuilder(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
738 struct PointerRNA *root_ptr, const char *text);
739 uiLayout *uiTemplateModifier(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr);
740 uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr);
741 void uiTemplatePreview(uiLayout *layout, struct ID *id, int show_buttons, struct ID *parent, struct MTex *slot);
742 void uiTemplateColorRamp(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int expand);
743 void uiTemplateHistogram(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
744 void uiTemplateWaveform(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
745 void uiTemplateVectorscope(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
746 void uiTemplateCurveMapping(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int type, int levels, int brush);
747 void uiTemplateColorWheel(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int value_slider, int lock, int lock_luminosity, int cubic);
748 void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
749 PointerRNA *used_ptr, const char *used_propname, int active_layer);
750 void uiTemplateImage(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr, int compact);
751 void uiTemplateImageLayers(uiLayout *layout, struct bContext *C, struct Image *ima, struct ImageUser *iuser);
752 void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C);
753 void uiTemplateOperatorSearch(uiLayout *layout);
754 void uiTemplateHeader3D(uiLayout *layout, struct bContext *C);
755 void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C);
756 void uiTemplateTextureImage(uiLayout *layout, struct bContext *C, struct Tex *tex);
757 void uiTemplateReportsBanner(uiLayout *layout, struct bContext *C);
758 void uiTemplateKeymapItemProperties(uiLayout *layout, struct PointerRNA *ptr);
760 void uiTemplateList(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *activeptr, const char *activeprop, int rows, int maxrows, int type);
761 void uiTemplateNodeLink(uiLayout *layout, struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *input);
762 void uiTemplateNodeView(uiLayout *layout, struct bContext *C, struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *input);
763 void uiTemplateTextureUser(uiLayout *layout, struct bContext *C);
764 void uiTemplateTextureShow(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop);
767 void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname);
768 void uiItemEnumO(uiLayout *layout, const char *opname, const char *name, int icon, const char *propname, int value);
769 void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value);
770 void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value);
771 void uiItemsEnumO(uiLayout *layout, const char *opname, const char *propname);
772 void uiItemBooleanO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value);
773 void uiItemIntO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value);
774 void uiItemFloatO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, float value);
775 void uiItemStringO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value);
776 PointerRNA uiItemFullO(uiLayout *layout, const char *idname, const char *name, int icon, struct IDProperty *properties, int context, int flag);
778 void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon);
779 void uiItemFullR(uiLayout *layout, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, int value, int flag, const char *name, int icon);
780 void uiItemEnumR(uiLayout *layout, const char *name, int icon, struct PointerRNA *ptr, const char *propname, int value);
781 void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *value, const char *name, int icon);
782 void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
783 void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *searchptr, const char *searchpropname, const char *name, int icon);
784 void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname, struct IDProperty *properties, int context, int flag);
786 void uiItemL(uiLayout *layout, const char *name, int icon); /* label */
787 void uiItemLDrag(uiLayout *layout, struct PointerRNA *ptr, const char *name, int icon); /* label icon for dragging */
788 void uiItemM(uiLayout *layout, struct bContext *C, const char *menuname, const char *name, int icon); /* menu */
789 void uiItemV(uiLayout *layout, const char *name, int icon, int argval); /* value */
790 void uiItemS(uiLayout *layout); /* separator */
792 void uiItemMenuF(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *arg);
793 void uiItemMenuEnumO(uiLayout *layout, const char *opname, const char *propname, const char *name, int icon);
794 void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name, int icon);
797 void UI_buttons_operatortypes(void);
799 /* Helpers for Operators */
800 void uiContextActiveProperty(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index);
801 void uiContextActivePropertyHandle(struct bContext *C);
802 void uiContextAnimUpdate(const struct bContext *C);
803 void uiFileBrowseContextProperty(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop);
804 void uiIDContextProperty(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop);
806 /* Styled text draw */
807 void uiStyleFontSet(struct uiFontStyle *fs);
808 void uiStyleFontDrawExt(struct uiFontStyle *fs, struct rcti *rect, const char *str,
809 float *r_xofs, float *r_yofs);
810 void uiStyleFontDraw(struct uiFontStyle *fs, struct rcti *rect, const char *str);
811 void uiStyleFontDrawRotated(struct uiFontStyle *fs, struct rcti *rect, const char *str);
813 int UI_GetStringWidth(const char *str); // XXX temp
814 void UI_DrawString(float x, float y, const char *str); // XXX temp
815 void UI_DrawTriIcon(float x, float y, char dir);
816 uiStyle* UI_GetStyle(void);
817 /* linker workaround ack! */
818 void UI_template_fix_linking(void);
821 int UI_translate_iface(void);
822 int UI_translate_tooltips(void);
823 const char *UI_translate_do_iface(const char *msgid);
824 const char *UI_translate_do_tooltip(const char *msgid);
826 /* Those macros should be used everywhere in UI code. */
827 #define IFACE_(msgid) UI_translate_do_iface(msgid)
828 #define TIP_(msgid) UI_translate_do_tooltip(msgid)
830 #endif /* UI_INTERFACE_H */