4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21 * All rights reserved.
23 * The Original Code is: all of this file.
25 * Contributor(s): none yet.
27 * ***** END GPL LICENSE BLOCK *****
30 #ifndef UI_INTERFACE_H
31 #define UI_INTERFACE_H
33 #include "RNA_types.h"
35 /* Struct Declarations */
43 struct wmWindowManager;
56 struct uiWidgetColors;
61 struct uiWidgetColors;
65 typedef struct uiBut uiBut;
66 typedef struct uiBlock uiBlock;
67 typedef struct uiPopupBlockHandle uiPopupBlockHandle;
68 typedef struct uiLayout uiLayout;
73 #define UI_EMBOSS 0 /* use widget style for drawing */
74 #define UI_EMBOSSN 1 /* Nothing, only icon and/or text */
75 #define UI_EMBOSSP 2 /* Pulldown menu style */
76 #define UI_EMBOSST 3 /* Table */
78 /* uiBlock->direction */
83 #define UI_DIRECTION 15
85 #define UI_SHIFT_FLIPPED 32
87 /* uiBlock->autofill (not yet used) */
88 #define UI_BLOCK_COLLUMNS 1
89 #define UI_BLOCK_ROWS 2
91 /* uiBlock->flag (controls) */
92 #define UI_BLOCK_LOOP 1
93 #define UI_BLOCK_REDRAW 2
94 #define UI_BLOCK_RET_1 4 /* XXX 2.5 not implemented */
95 #define UI_BLOCK_NUMSELECT 8
96 #define UI_BLOCK_ENTER_OK 16
97 #define UI_BLOCK_NOSHADOW 32
98 #define UI_BLOCK_UNUSED 64
99 #define UI_BLOCK_MOVEMOUSE_QUIT 128
100 #define UI_BLOCK_KEEP_OPEN 256
101 #define UI_BLOCK_POPUP 512
102 #define UI_BLOCK_OUT_1 1024
103 #define UI_BLOCK_NO_FLIP 2048
104 #define UI_BLOCK_POPUP_MEMORY 4096
106 /* uiPopupBlockHandle->menuretval */
107 #define UI_RETURN_CANCEL 1 /* cancel all menus cascading */
108 #define UI_RETURN_OK 2 /* choice made */
109 #define UI_RETURN_OUT 4 /* left the menu */
110 #define UI_RETURN_UPDATE 8 /* update the button that opened */
112 /* block->flag bits 12-15 are identical to but->flag bits */
115 #define UI_PNL_TRANSP 1
116 #define UI_PNL_SOLID 2
118 #define UI_PNL_CLOSE 32
119 #define UI_PNL_STOW 64
120 #define UI_PNL_TO_MOUSE 128
121 #define UI_PNL_UNSTOW 256
122 #define UI_PNL_SCALE 512
124 /* warning the first 6 flags are internal */
126 #define UI_TEXT_LEFT 64
127 #define UI_ICON_LEFT 128
128 #define UI_ICON_SUBMENU 256
129 /* control for button type block */
130 #define UI_MAKE_TOP 512
131 #define UI_MAKE_DOWN 1024
132 #define UI_MAKE_LEFT 2048
133 #define UI_MAKE_RIGHT 4096
135 /* button align flag, for drawing groups together */
136 #define UI_BUT_ALIGN (15<<14)
137 #define UI_BUT_ALIGN_TOP (1<<14)
138 #define UI_BUT_ALIGN_LEFT (1<<15)
139 #define UI_BUT_ALIGN_RIGHT (1<<16)
140 #define UI_BUT_ALIGN_DOWN (1<<17)
142 #define UI_BUT_DISABLED (1<<18)
143 #define UI_BUT_UNUSED (1<<19)
144 #define UI_BUT_ANIMATED (1<<20)
145 #define UI_BUT_ANIMATED_KEY (1<<21)
146 #define UI_BUT_DRIVEN (1<<22)
147 #define UI_BUT_INACTIVE (1<<23)
148 #define UI_BUT_LAST_ACTIVE (1<<24)
150 #define UI_PANEL_WIDTH 340
151 #define UI_COMPACT_PANEL_WIDTH 160
153 /* Button types, bits stored in 1 value... and a short even!
154 - bits 0-4: bitnr (0-31)
155 - bits 5-7: pointer type
157 - bit 9-15: button type (now 6 bits, 64 types)
167 #define BUTPOIN (128+64+32)
178 #define LABEL (10<<9)
180 #define ICONROW (12<<9)
181 #define ICONTOG (13<<9)
182 #define NUMSLI (14<<9)
184 #define IDPOIN (16<<9)
185 #define HSVSLI (17<<9)
186 #define SCROLL (18<<9)
187 #define BLOCK (19<<9)
191 #define INLINK (23<<9)
192 #define KEYEVT (24<<9)
193 #define ICONTEXTROW (25<<9)
194 #define HSVCUBE (26<<9)
195 #define PULLDOWN (27<<9)
196 #define ROUNDBOX (28<<9)
197 #define CHARTAB (29<<9)
198 #define BUT_COLORBAND (30<<9)
199 #define BUT_NORMAL (31<<9)
200 #define BUT_CURVE (32<<9)
201 #define BUT_TOGDUAL (33<<9)
202 #define ICONTOGN (34<<9)
203 #define FTPREVIEW (35<<9)
204 #define NUMABS (36<<9)
205 #define TOGBUT (37<<9)
206 #define OPTION (38<<9)
207 #define OPTIONN (39<<9)
208 #define SEARCH_MENU (40<<9)
209 #define BUT_EXTRA (41<<9)
210 #define HSVCIRCLE (42<<9)
211 #define LISTBOX (43<<9)
212 #define LISTROW (44<<9)
213 #define HOTKEYEVT (45<<9)
215 #define BUTTYPE (63<<9)
219 * Functions to draw various shapes, taking theme settings into account.
220 * Used for code that draws its own UI style elements. */
222 void uiEmboss(float x1, float y1, float x2, float y2, int sel);
223 void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad);
224 void uiSetRoundBox(int type);
225 int uiGetRoundBox(void);
226 void uiRoundRect(float minx, float miny, float maxx, float maxy, float rad);
227 void uiDrawMenuBox(float minx, float miny, float maxx, float maxy, short flag, short direction);
228 void uiDrawBoxShadow(unsigned char alpha, float minx, float miny, float maxx, float maxy);
230 /* state for scrolldrawing */
231 #define UI_SCROLL_PRESSED 1
232 #define UI_SCROLL_ARROWS 2
233 void uiWidgetScrollDraw(struct uiWidgetColors *wcol, struct rcti *rect, struct rcti *slider, int state);
237 typedef void (*uiMenuCreateFunc)(struct bContext *C, struct uiLayout *layout, void *arg1);
238 typedef void (*uiMenuHandleFunc)(struct bContext *C, void *arg, int event);
242 * Functions used to create popup menus. For more extended menus the
243 * uiPupMenuBegin/End functions can be used to define own items with
244 * the uiItem functions inbetween. If it is a simple confirmation menu
245 * or similar, popups can be created with a single function call. */
247 typedef struct uiPopupMenu uiPopupMenu;
249 uiPopupMenu *uiPupMenuBegin(struct bContext *C, const char *title, int icon);
250 void uiPupMenuEnd(struct bContext *C, struct uiPopupMenu *head);
251 struct uiLayout *uiPupMenuLayout(uiPopupMenu *head);
253 void uiPupMenuOkee(struct bContext *C, char *opname, char *str, ...);
254 void uiPupMenuSaveOver(struct bContext *C, struct wmOperator *op, char *filename);
255 void uiPupMenuNotice(struct bContext *C, char *str, ...);
256 void uiPupMenuError(struct bContext *C, char *str, ...);
257 void uiPupMenuReports(struct bContext *C, struct ReportList *reports);
261 * Functions used to create popup blocks. These are like popup menus
262 * but allow using all button types and creating an own layout. */
264 typedef uiBlock* (*uiBlockCreateFunc)(struct bContext *C, struct ARegion *ar, void *arg1);
266 void uiPupBlock(struct bContext *C, uiBlockCreateFunc func, void *arg);
267 void uiPupBlockO(struct bContext *C, uiBlockCreateFunc func, void *arg, char *opname, int opcontext);
268 void uiPupBlockOperator(struct bContext *C, uiBlockCreateFunc func, struct wmOperator *op, int opcontext);
272 * Functions for creating, drawing and freeing blocks. A Block is a
273 * container of buttons and used for various purposes.
275 * Begin/Define Buttons/End/Draw is the typical order in which these
276 * function should be called, though for popup blocks Draw is left out.
277 * Freeing blocks is done by the screen/ module automatically.
281 uiBlock *uiBeginBlock(const struct bContext *C, struct ARegion *region, const char *name, short dt);
282 void uiEndBlock(const struct bContext *C, uiBlock *block);
283 void uiDrawBlock(const struct bContext *C, struct uiBlock *block);
285 uiBlock *uiGetBlock(char *name, struct ARegion *ar);
287 void uiBlockSetEmboss(uiBlock *block, short dt);
289 void uiFreeBlock(const struct bContext *C, uiBlock *block);
290 void uiFreeBlocks(const struct bContext *C, struct ListBase *lb);
291 void uiFreeInactiveBlocks(const struct bContext *C, struct ListBase *lb);
293 void uiBlockSetRegion(uiBlock *block, struct ARegion *region);
295 void uiBlockSetButLock(uiBlock *block, int val, char *lockstr);
296 void uiBlockClearButLock(uiBlock *block);
298 /* automatic aligning, horiz or verical */
299 void uiBlockBeginAlign(uiBlock *block);
300 void uiBlockEndAlign(uiBlock *block);
302 void uiBoundsBlock(struct uiBlock *block, int addval);
303 void uiTextBoundsBlock(uiBlock *block, int addval);
304 void uiPopupBoundsBlock(uiBlock *block, int addval, int mx, int my);
305 void uiMenuPopupBoundsBlock(uiBlock *block, int addvall, int mx, int my);
307 int uiBlocksGetYMin (struct ListBase *lb);
309 void uiBlockSetDirection (uiBlock *block, int direction);
310 void uiBlockFlipOrder (uiBlock *block);
311 void uiBlockSetFlag (uiBlock *block, int flag);
312 void uiBlockClearFlag (uiBlock *block, int flag);
313 void uiBlockSetXOfs (uiBlock *block, int xofs);
315 int uiButGetRetVal (uiBut *but);
317 void uiButSetFlag (uiBut *but, int flag);
318 void uiButClearFlag (uiBut *but, int flag);
320 /* special button case, only draw it when used actively, for outliner etc */
321 int uiButActiveOnly (const struct bContext *C, uiBlock *block, uiBut *but);
326 * Functions to define various types of buttons in a block. Postfixes:
334 uiBut *uiDefBut(uiBlock *block,
335 int type, int retval, char *str,
339 float min, float max,
340 float a1, float a2, char *tip);
341 uiBut *uiDefButF(uiBlock *block, int type, int retval, char *str, short x1, short y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, char *tip);
342 uiBut *uiDefButBitF(uiBlock *block, int type, int bit, int retval, char *str, short x1, short y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, char *tip);
343 uiBut *uiDefButI(uiBlock *block, int type, int retval, char *str, short x1, short y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, char *tip);
344 uiBut *uiDefButBitI(uiBlock *block, int type, int bit, int retval, char *str, short x1, short y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, char *tip);
345 uiBut *uiDefButS(uiBlock *block, int type, int retval, char *str, short x1, short y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, char *tip);
346 uiBut *uiDefButBitS(uiBlock *block, int type, int bit, int retval, char *str, short x1, short y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, char *tip);
347 uiBut *uiDefButC(uiBlock *block, int type, int retval, char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip);
348 uiBut *uiDefButBitC(uiBlock *block, int type, int bit, int retval, char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip);
349 uiBut *uiDefButR(uiBlock *block, int type, int retval, char *str, short x1, short y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, char *tip);
350 uiBut *uiDefButO(uiBlock *block, int type, char *opname, int opcontext, char *str, short x1, short y1, short x2, short y2, char *tip);
352 uiBut *uiDefIconBut(uiBlock *block,
353 int type, int retval, int icon,
357 float min, float max,
358 float a1, float a2, char *tip);
359 uiBut *uiDefIconButF(uiBlock *block, int type, int retval, int icon, short x1, short y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, char *tip);
360 uiBut *uiDefIconButBitF(uiBlock *block, int type, int bit, int retval, int icon, short x1, short y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, char *tip);
361 uiBut *uiDefIconButI(uiBlock *block, int type, int retval, int icon, short x1, short y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, char *tip);
362 uiBut *uiDefIconButBitI(uiBlock *block, int type, int bit, int retval, int icon, short x1, short y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, char *tip);
363 uiBut *uiDefIconButS(uiBlock *block, int type, int retval, int icon, short x1, short y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, char *tip);
364 uiBut *uiDefIconButBitS(uiBlock *block, int type, int bit, int retval, int icon, short x1, short y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, char *tip);
365 uiBut *uiDefIconButC(uiBlock *block, int type, int retval, int icon, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip);
366 uiBut *uiDefIconButBitC(uiBlock *block, int type, int bit, int retval, int icon, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip);
367 uiBut *uiDefIconButR(uiBlock *block, int type, int retval, int icon, short x1, short y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, char *tip);
368 uiBut *uiDefIconButO(uiBlock *block, int type, char *opname, int opcontext, int icon, short x1, short y1, short x2, short y2, char *tip);
370 uiBut *uiDefIconTextBut(uiBlock *block,
371 int type, int retval, int icon, char *str,
375 float min, float max,
376 float a1, float a2, char *tip);
377 uiBut *uiDefIconTextButF(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, char *tip);
378 uiBut *uiDefIconTextButBitF(uiBlock *block, int type, int bit, int retval, int icon, char *str, short x1, short y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, char *tip);
379 uiBut *uiDefIconTextButI(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, char *tip);
380 uiBut *uiDefIconTextButBitI(uiBlock *block, int type, int bit, int retval, int icon, char *str, short x1, short y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, char *tip);
381 uiBut *uiDefIconTextButS(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, char *tip);
382 uiBut *uiDefIconTextButBitS(uiBlock *block, int type, int bit, int retval, int icon, char *str, short x1, short y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, char *tip);
383 uiBut *uiDefIconTextButC(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip);
384 uiBut *uiDefIconTextButBitC(uiBlock *block, int type, int bit, int retval, int icon, char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip);
385 uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, char *tip);
386 uiBut *uiDefIconTextButO(uiBlock *block, int type, char *opname, int opcontext, int icon, char *str, short x1, short y1, short x2, short y2, char *tip);
388 /* for passing inputs to ButO buttons */
389 struct PointerRNA *uiButGetOperatorPtrRNA(uiBut *but);
393 * Butons with a more specific purpose:
394 * - IDPoinBut: for creating buttons that work on a pointer to an ID block.
395 * - MenuBut: buttons that popup a menu (in headers usually).
396 * - PulldownBut: like MenuBut, but creating a uiBlock (for compatibility).
397 * - BlockBut: buttons that popup a block with more buttons.
398 * - KeyevtBut: buttons that can be used to turn key events into values.
399 * - PickerButtons: buttons like the color picker (for code sharing).
400 * - AutoButR: RNA property button with type automatically defined. */
402 #define UI_ID_RENAME 1
403 #define UI_ID_BROWSE 2
404 #define UI_ID_ADD_NEW 4
406 #define UI_ID_ALONE 16
407 #define UI_ID_DELETE 32
408 #define UI_ID_LOCAL 64
409 #define UI_ID_AUTO_NAME 128
410 #define UI_ID_FAKE_USER 256
411 #define UI_ID_PIN 512
412 #define UI_ID_BROWSE_RENDER 1024
413 #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)
415 typedef void (*uiIDPoinFuncFP)(struct bContext *C, char *str, struct ID **idpp);
416 typedef void (*uiIDPoinFunc)(struct bContext *C, struct ID *id, int event);
418 uiBut *uiDefIDPoinBut(uiBlock *block, uiIDPoinFuncFP func, short blocktype, int retval, char *str,
419 short x1, short y1, short x2, short y2, void *idpp, char *tip);
420 int uiDefIDPoinButs(uiBlock *block, struct Main *main, struct ID *parid, struct ID *id, int id_code, short *pin_p, int x, int y, uiIDPoinFunc func, int events);
422 uiBut *uiDefPulldownBut(uiBlock *block, uiBlockCreateFunc func, void *arg, char *str, short x1, short y1, short x2, short y2, char *tip);
423 uiBut *uiDefMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, char *str, short x1, short y1, short x2, short y2, char *tip);
424 uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, char *str, short x1, short y1, short x2, short y2, char *tip);
426 uiBut *uiDefBlockBut(uiBlock *block, uiBlockCreateFunc func, void *func_arg1, char *str, short x1, short y1, short x2, short y2, char *tip);
427 uiBut *uiDefBlockButN(uiBlock *block, uiBlockCreateFunc func, void *argN, char *str, short x1, short y1, short x2, short y2, char *tip);
429 uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int retval, int icon, short x1, short y1, short x2, short y2, char *tip);
430 uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int icon, char *str, short x1, short y1, short x2, short y2, char *tip);
432 void uiDefKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1, short x2, short y2, short *spoin, char *tip);
433 uiBut *uiDefHotKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1, short x2, short y2, short *keypoin, short *modkeypoin, char *tip);
435 uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, short x1, short y1, short x2, short y2, char *tip);
437 void uiBlockPickerButtons(struct uiBlock *block, float *col, float *hsv, float *old, char *hexcol, char mode, short retval);
438 void uiBlockColorbandButtons(struct uiBlock *block, struct ColorBand *coba, struct rctf *butr, int event);
440 uiBut *uiDefAutoButR(uiBlock *block, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, char *name, int icon, int x1, int y1, int x2, int y2);
441 void uiDefAutoButsRNA(const struct bContext *C, uiLayout *layout, struct PointerRNA *ptr, int columns);
445 * Game engine logic brick links. Non-functional currently in 2.5,
446 * code to handle and draw these is disabled internally. */
448 void uiSetButLink(struct uiBut *but, void **poin, void ***ppoin, short *tot, int from, int to);
450 void uiComposeLinks(uiBlock *block);
451 uiBut *uiFindInlink(uiBlock *block, void *poin);
455 * uiBlockSetHandleFunc/ButmFunc are for handling events through a callback.
456 * HandleFunc gets the retval passed on, and ButmFunc gets a2. The latter is
457 * mostly for compatibility with older code.
459 * uiButSetCompleteFunc is for tab completion.
461 * uiButSearchFunc is for name buttons, showing a popup with matches
463 * uiBlockSetFunc and uiButSetFunc are callbacks run when a button is used,
464 * in case events, operators or RNA are not sufficient to handle the button.
466 * uiButSetNFunc will free the argument with MEM_freeN. */
468 typedef struct uiSearchItems uiSearchItems;
470 typedef void (*uiButHandleFunc)(struct bContext *C, void *arg1, void *arg2);
471 typedef void (*uiButHandleRenameFunc)(struct bContext *C, void *arg, char *origstr);
472 typedef void (*uiButHandleNFunc)(struct bContext *C, void *argN, void *arg2);
473 typedef void (*uiButCompleteFunc)(struct bContext *C, char *str, void *arg);
474 typedef void (*uiButSearchFunc)(const struct bContext *C, void *arg, char *str, uiSearchItems *items);
475 typedef void (*uiBlockHandleFunc)(struct bContext *C, void *arg, int event);
477 /* use inside searchfunc to add items */
478 int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin, int iconid);
479 /* bfunc gets search item *poin as arg2, or if NULL the old string */
480 void uiButSetSearchFunc (uiBut *but, uiButSearchFunc sfunc, void *arg1, uiButHandleFunc bfunc, void *active);
481 /* height in pixels, it's using hardcoded values still */
482 int uiSearchBoxhHeight(void);
484 void uiBlockSetHandleFunc(uiBlock *block, uiBlockHandleFunc func, void *arg);
485 void uiBlockSetButmFunc (uiBlock *block, uiMenuHandleFunc func, void *arg);
486 void uiBlockSetFunc (uiBlock *block, uiButHandleFunc func, void *arg1, void *arg2);
488 void uiButSetRenameFunc (uiBut *but, uiButHandleRenameFunc func, void *arg1);
489 void uiButSetFunc (uiBut *but, uiButHandleFunc func, void *arg1, void *arg2);
490 void uiButSetNFunc (uiBut *but, uiButHandleNFunc func, void *argN, void *arg2);
492 void uiButSetCompleteFunc(uiBut *but, uiButCompleteFunc func, void *arg);
494 void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)(const struct bContext *C, void *, void *, void *, struct rcti *rect), void *arg1, void *arg2);
498 * Tab complete helper functions, for use in uiButCompleteFunc callbacks.
499 * Call begin once, then multiple times do_name with all possibilities,
500 * and finally end to finish and get the completed name. */
502 typedef struct AutoComplete AutoComplete;
504 AutoComplete *autocomplete_begin(char *startname, int maxlen);
505 void autocomplete_do_name(AutoComplete *autocpl, const char *name);
506 void autocomplete_end(AutoComplete *autocpl, char *autoname);
510 * Functions for creating, freeing and drawing panels. The API here
511 * could use a good cleanup, though how they will function in 2.5 is
512 * not clear yet so we postpone that. */
514 void uiBeginPanels(const struct bContext *C, struct ARegion *ar);
515 void uiEndPanels(const struct bContext *C, struct ARegion *ar);
517 struct Panel *uiBeginPanel(struct ScrArea *sa, struct ARegion *ar, uiBlock *block, struct PanelType *pt, int *open);
518 void uiEndPanel(uiBlock *block, int width, int height);
522 * Handlers that can be registered in regions, areas and windows for
523 * handling WM events. Mostly this is done automatic by modules such
524 * as screen/ if ED_KEYMAP_UI is set, or internally in popup functions. */
526 void UI_add_region_handlers(struct ListBase *handlers);
527 void UI_add_area_handlers(struct ListBase *handlers);
528 void UI_add_popup_handlers(struct bContext *C, struct ListBase *handlers, uiPopupBlockHandle *menu);
531 * Callbacks and utils to get 2.48 work */
533 void test_idbutton_cb(struct bContext *C, void *namev, void *arg2);
534 void test_scriptpoin_but(struct bContext *C, char *name, struct ID **idpp);
535 void test_actionpoin_but(struct bContext *C, char *name, struct ID **idpp);
536 void test_obpoin_but(struct bContext *C, char *name, struct ID **idpp);
537 void test_meshobpoin_but(struct bContext *C, char *name, struct ID **idpp);
538 void test_meshpoin_but(struct bContext *C, char *name, struct ID **idpp);
539 void test_matpoin_but(struct bContext *C, char *name, struct ID **idpp);
540 void test_scenepoin_but(struct bContext *C, char *name, struct ID **idpp);
541 void test_grouppoin_but(struct bContext *C, char *name, struct ID **idpp);
542 void test_texpoin_but(struct bContext *C, char *name, struct ID **idpp);
543 void test_imapoin_but(struct bContext *C, char *name, struct ID **idpp);
544 void autocomplete_bone(struct bContext *C, char *str, void *arg_v);
545 void autocomplete_vgroup(struct bContext *C, char *str, void *arg_v);
548 void curvemap_buttons(uiBlock *block, struct CurveMapping *cumap, char labeltype, short event, short redraw, struct rctf *rect);
549 void curvemap_layout(uiLayout *layout, struct CurveMapping *cumap, char labeltype, short event, short redraw, struct rctf *rect);
550 void colorband_buttons(uiBlock *block, struct ColorBand *coba, struct rctf *rect, int small);
555 * init and exit should be called before using this module. init_userdef must
556 * be used to reinitialize some internal state if user preferences change. */
559 void UI_init_userdef(void);
564 * More automated layout of buttons. Has three levels:
565 * - Layout: contains a number templates, within a bounded width or height.
566 * - Template: predefined layouts for buttons with a number of slots, each
567 * slot can contain multiple items.
568 * - Item: item to put in a template slot, being either an RNA property,
569 * operator, label or menu. Also regular buttons can be used when setting
570 * uiBlockCurLayout. */
573 #define UI_LAYOUT_HORIZONTAL 0
574 #define UI_LAYOUT_VERTICAL 1
576 #define UI_LAYOUT_PANEL 0
577 #define UI_LAYOUT_HEADER 1
578 #define UI_LAYOUT_MENU 2
583 #define UI_LAYOUT_ALIGN_EXPAND 0
584 #define UI_LAYOUT_ALIGN_LEFT 1
585 #define UI_LAYOUT_ALIGN_CENTER 2
586 #define UI_LAYOUT_ALIGN_RIGHT 3
588 #define UI_ITEM_O_RETURN_PROPS 1
589 #define UI_ITEM_R_EXPAND 2
590 #define UI_ITEM_R_SLIDER 4
591 #define UI_ITEM_R_TOGGLE 8
593 uiLayout *uiBlockLayout(uiBlock *block, int dir, int type, int x, int y, int size, int em, struct uiStyle *style);
594 void uiBlockSetCurLayout(uiBlock *block, uiLayout *layout);
595 void uiBlockLayoutResolve(const struct bContext *C, uiBlock *block, int *x, int *y);
597 uiBlock *uiLayoutGetBlock(uiLayout *layout);
599 void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv);
600 void uiLayoutSetContextPointer(uiLayout *layout, char *name, struct PointerRNA *ptr);
602 void uiLayoutSetOperatorContext(uiLayout *layout, int opcontext);
603 void uiLayoutSetActive(uiLayout *layout, int active);
604 void uiLayoutSetEnabled(uiLayout *layout, int enabled);
605 void uiLayoutSetRedAlert(uiLayout *layout, int redalert);
606 void uiLayoutSetAlignment(uiLayout *layout, int alignment);
607 void uiLayoutSetKeepAspect(uiLayout *layout, int keepaspect);
608 void uiLayoutSetScaleX(uiLayout *layout, float scale);
609 void uiLayoutSetScaleY(uiLayout *layout, float scale);
611 int uiLayoutGetOperatorContext(uiLayout *layout);
612 int uiLayoutGetActive(uiLayout *layout);
613 int uiLayoutGetEnabled(uiLayout *layout);
614 int uiLayoutGetRedAlert(uiLayout *layout);
615 int uiLayoutGetAlignment(uiLayout *layout);
616 int uiLayoutGetKeepAspect(uiLayout *layout);
617 int uiLayoutGetWidth(uiLayout *layout);
618 float uiLayoutGetScaleX(uiLayout *layout);
619 float uiLayoutGetScaleY(uiLayout *layout);
620 ListBase *uiLayoutBoxGetList(uiLayout *layout);
622 /* layout specifiers */
623 uiLayout *uiLayoutRow(uiLayout *layout, int align);
624 uiLayout *uiLayoutColumn(uiLayout *layout, int align);
625 uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, int align);
626 uiLayout *uiLayoutBox(uiLayout *layout);
627 uiLayout *uiLayoutListBox(uiLayout *layout);
628 uiLayout *uiLayoutFree(uiLayout *layout, int align);
629 uiLayout *uiLayoutSplit(uiLayout *layout, float percentage);
631 uiBlock *uiLayoutFreeBlock(uiLayout *layout);
634 void uiTemplateHeader(uiLayout *layout, struct bContext *C, int menus);
635 void uiTemplateID(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname,
636 char *newop, char *unlinkop);
637 uiLayout *uiTemplateModifier(uiLayout *layout, struct PointerRNA *ptr);
638 uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr);
639 void uiTemplatePreview(uiLayout *layout, struct ID *id, struct ID *parent, struct MTex *slot);
640 void uiTemplateColorRamp(uiLayout *layout, struct ColorBand *coba, int expand);
641 void uiTemplateCurveMapping(uiLayout *layout, struct CurveMapping *cumap, int type, int compact);
642 void uiTemplateTriColorSet(uiLayout *layout, struct PointerRNA *ptr, char *propname);
643 void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, char *propname);
644 void uiTemplateImageLayers(uiLayout *layout, struct bContext *C, struct Image *ima, struct ImageUser *iuser);
645 void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C);
646 void uiTemplateOperatorSearch(uiLayout *layout);
647 void uiTemplateHeader3D(uiLayout *layout, struct bContext *C);
648 void uiTemplate_view3d_select_faceselmenu(uiLayout *layout, struct bContext *C);
649 void uiTemplateTextureImage(uiLayout *layout, struct bContext *C, struct Tex *tex);
651 typedef struct uiListItem {
652 struct uiListItem *next, *prev;
654 struct PointerRNA data;
658 ListBase uiTemplateList(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, struct PointerRNA *activeptr, char *activeprop, int rows, int type);
661 void uiItemO(uiLayout *layout, char *name, int icon, char *opname);
662 void uiItemEnumO(uiLayout *layout, char *name, int icon, char *opname, char *propname, int value);
663 void uiItemEnumO_string(uiLayout *layout, char *name, int icon, char *opname, char *propname, char *value);
664 void uiItemsEnumO(uiLayout *layout, char *opname, char *propname);
665 void uiItemBooleanO(uiLayout *layout, char *name, int icon, char *opname, char *propname, int value);
666 void uiItemIntO(uiLayout *layout, char *name, int icon, char *opname, char *propname, int value);
667 void uiItemFloatO(uiLayout *layout, char *name, int icon, char *opname, char *propname, float value);
668 void uiItemStringO(uiLayout *layout, char *name, int icon, char *opname, char *propname, char *value);
669 PointerRNA uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, struct IDProperty *properties, int context, int flag);
671 void uiItemR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, int flag);
672 void uiItemFullR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, int value, int flag);
673 void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, int value);
674 void uiItemEnumR_string(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, char *value);
675 void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname);
676 void uiItemPointerR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, struct PointerRNA *searchptr, char *searchpropname);
678 void uiItemL(uiLayout *layout, char *name, int icon); /* label */
679 void uiItemM(uiLayout *layout, struct bContext *C, char *name, int icon, char *menuname); /* menu */
680 void uiItemV(uiLayout *layout, char *name, int icon, int argval); /* value */
681 void uiItemS(uiLayout *layout); /* separator */
683 void uiItemMenuF(uiLayout *layout, char *name, int icon, uiMenuCreateFunc func, void *arg);
684 void uiItemMenuEnumO(uiLayout *layout, char *name, int icon, char *opname, char *propname);
685 void uiItemMenuEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname);
687 /* Helpers for Operators */
688 void uiAnimContextProperty(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index);
689 void uiFileBrowseContextProperty(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop);
691 /* Styled text draw */
692 void uiStyleFontSet(struct uiFontStyle *fs);
693 void uiStyleFontDraw(struct uiFontStyle *fs, struct rcti *rect, char *str);
695 int UI_GetStringWidth(char *str); // XXX temp
696 void UI_DrawString(float x, float y, char *str); // XXX temp
698 #endif /* UI_INTERFACE_H */