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 /* Struct Declarations */
41 struct wmWindowManager;
59 typedef struct uiBut uiBut;
60 typedef struct uiBlock uiBlock;
61 typedef struct uiPopupBlockHandle uiPopupBlockHandle;
62 typedef struct uiLayout uiLayout;
67 #define UI_EMBOSS 0 /* use widget style for drawing */
68 #define UI_EMBOSSN 1 /* Nothing, only icon and/or text */
69 #define UI_EMBOSSP 2 /* Pulldown menu style */
70 #define UI_EMBOSST 3 /* Table */
72 /* uiBlock->direction */
77 #define UI_DIRECTION 15
79 #define UI_SHIFT_FLIPPED 32
81 /* uiBlock->autofill (not yet used) */
82 #define UI_BLOCK_COLLUMNS 1
83 #define UI_BLOCK_ROWS 2
85 /* uiBlock->flag (controls) */
86 #define UI_BLOCK_LOOP 1
87 #define UI_BLOCK_REDRAW 2
88 #define UI_BLOCK_RET_1 4 /* XXX 2.5 not implemented */
89 #define UI_BLOCK_NUMSELECT 8
90 #define UI_BLOCK_ENTER_OK 16
91 #define UI_BLOCK_NOSHADOW 32
92 #define UI_BLOCK_UNUSED 64
93 #define UI_BLOCK_MOVEMOUSE_QUIT 128
94 #define UI_BLOCK_KEEP_OPEN 256
95 #define UI_BLOCK_POPUP 512
96 #define UI_BLOCK_OUT_1 1024
98 /* uiPopupBlockHandle->menuretval */
99 #define UI_RETURN_CANCEL 1 /* cancel all menus cascading */
100 #define UI_RETURN_OK 2 /* choice made */
101 #define UI_RETURN_OUT 4 /* left the menu */
102 #define UI_RETURN_UPDATE 8 /* update the button that opened */
104 /* block->flag bits 12-15 are identical to but->flag bits */
107 #define UI_PNL_TRANSP 1
108 #define UI_PNL_SOLID 2
110 #define UI_PNL_CLOSE 32
111 #define UI_PNL_STOW 64
112 #define UI_PNL_TO_MOUSE 128
113 #define UI_PNL_UNSTOW 256
114 #define UI_PNL_SCALE 512
116 /* warning the first 6 flags are internal */
118 #define UI_TEXT_LEFT 64
119 #define UI_ICON_LEFT 128
120 #define UI_ICON_SUBMENU 256
121 /* control for button type block */
122 #define UI_MAKE_TOP 512
123 #define UI_MAKE_DOWN 1024
124 #define UI_MAKE_LEFT 2048
125 #define UI_MAKE_RIGHT 4096
127 /* button align flag, for drawing groups together */
128 #define UI_BUT_ALIGN (15<<14)
129 #define UI_BUT_ALIGN_TOP (1<<14)
130 #define UI_BUT_ALIGN_LEFT (1<<15)
131 #define UI_BUT_ALIGN_RIGHT (1<<16)
132 #define UI_BUT_ALIGN_DOWN (1<<17)
134 #define UI_BUT_DISABLED (1<<18)
135 #define UI_BUT_UNUSED (1<<19)
136 #define UI_BUT_ANIMATED (1<<20)
137 #define UI_BUT_ANIMATED_KEY (1<<21)
138 #define UI_BUT_DRIVEN (1<<22)
139 #define UI_BUT_INACTIVE (1<<23)
141 #define UI_PANEL_WIDTH 340
142 #define UI_COMPACT_PANEL_WIDTH 160
144 /* Button types, bits stored in 1 value... and a short even!
145 - bits 0-4: bitnr (0-31)
146 - bits 5-7: pointer type
148 - bit 9-15: button type (now 6 bits, 64 types)
158 #define BUTPOIN (128+64+32)
169 #define LABEL (10<<9)
171 #define ICONROW (12<<9)
172 #define ICONTOG (13<<9)
173 #define NUMSLI (14<<9)
175 #define IDPOIN (16<<9)
176 #define HSVSLI (17<<9)
177 #define SCROLL (18<<9)
178 #define BLOCK (19<<9)
182 #define INLINK (23<<9)
183 #define KEYEVT (24<<9)
184 #define ICONTEXTROW (25<<9)
185 #define HSVCUBE (26<<9)
186 #define PULLDOWN (27<<9)
187 #define ROUNDBOX (28<<9)
188 #define CHARTAB (29<<9)
189 #define BUT_COLORBAND (30<<9)
190 #define BUT_NORMAL (31<<9)
191 #define BUT_CURVE (32<<9)
192 #define BUT_TOGDUAL (33<<9)
193 #define ICONTOGN (34<<9)
194 #define FTPREVIEW (35<<9)
195 #define NUMABS (36<<9)
196 #define TOGBUT (37<<9)
197 #define OPTION (38<<9)
198 #define OPTIONN (39<<9)
199 #define SEARCH_MENU (40<<9)
200 #define BUT_EXTRA (41<<9)
201 #define HSVCIRCLE (42<<9)
202 #define BUTTYPE (63<<9)
206 * Functions to draw various shapes, taking theme settings into account.
207 * Used for code that draws its own UI style elements. */
209 void uiEmboss(float x1, float y1, float x2, float y2, int sel);
210 void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad);
211 void uiSetRoundBox(int type);
212 int uiGetRoundBox(void);
213 void uiRoundRect(float minx, float miny, float maxx, float maxy, float rad);
214 void uiDrawMenuBox(float minx, float miny, float maxx, float maxy, short flag, short direction);
215 void uiDrawBoxShadow(unsigned char alpha, float minx, float miny, float maxx, float maxy);
219 typedef void (*uiMenuCreateFunc)(struct bContext *C, struct uiLayout *layout, void *arg1);
220 typedef void (*uiMenuHandleFunc)(struct bContext *C, void *arg, int event);
224 * Functions used to create popup menus. For more extended menus the
225 * uiPupMenuBegin/End functions can be used to define own items with
226 * the uiItem functions inbetween. If it is a simple confirmation menu
227 * or similar, popups can be created with a single function call. */
229 typedef struct uiPopupMenu uiPopupMenu;
231 uiPopupMenu *uiPupMenuBegin(struct bContext *C, const char *title, int icon);
232 void uiPupMenuEnd(struct bContext *C, struct uiPopupMenu *head);
233 struct uiLayout *uiPupMenuLayout(uiPopupMenu *head);
235 void uiPupMenuOkee(struct bContext *C, char *opname, char *str, ...);
236 void uiPupMenuSaveOver(struct bContext *C, struct wmOperator *op, char *filename);
237 void uiPupMenuNotice(struct bContext *C, char *str, ...);
238 void uiPupMenuError(struct bContext *C, char *str, ...);
239 void uiPupMenuReports(struct bContext *C, struct ReportList *reports);
241 void uiPupMenuSetActive(int val);
245 * Functions used to create popup blocks. These are like popup menus
246 * but allow using all button types and creating an own layout. */
248 typedef uiBlock* (*uiBlockCreateFunc)(struct bContext *C, struct ARegion *ar, void *arg1);
250 void uiPupBlock(struct bContext *C, uiBlockCreateFunc func, void *arg);
251 void uiPupBlockO(struct bContext *C, uiBlockCreateFunc func, void *arg, char *opname, int opcontext);
252 void uiPupBlockOperator(struct bContext *C, uiBlockCreateFunc func, struct wmOperator *op, int opcontext);
256 * Functions for creating, drawing and freeing blocks. A Block is a
257 * container of buttons and used for various purposes.
259 * Begin/Define Buttons/End/Draw is the typical order in which these
260 * function should be called, though for popup blocks Draw is left out.
261 * Freeing blocks is done by the screen/ module automatically.
265 uiBlock *uiBeginBlock(const struct bContext *C, struct ARegion *region, const char *name, short dt);
266 void uiEndBlock(const struct bContext *C, uiBlock *block);
267 void uiDrawBlock(const struct bContext *C, struct uiBlock *block);
269 uiBlock *uiGetBlock(char *name, struct ARegion *ar);
271 void uiBlockSetEmboss(uiBlock *block, short dt);
273 void uiFreeBlock(const struct bContext *C, uiBlock *block);
274 void uiFreeBlocks(const struct bContext *C, struct ListBase *lb);
275 void uiFreeInactiveBlocks(const struct bContext *C, struct ListBase *lb);
277 void uiBlockSetRegion(uiBlock *block, struct ARegion *region);
279 void uiBlockSetButLock(uiBlock *block, int val, char *lockstr);
280 void uiBlockClearButLock(uiBlock *block);
282 /* automatic aligning, horiz or verical */
283 void uiBlockBeginAlign(uiBlock *block);
284 void uiBlockEndAlign(uiBlock *block);
286 void uiBoundsBlock(struct uiBlock *block, int addval);
287 void uiTextBoundsBlock(uiBlock *block, int addval);
288 void uiPopupBoundsBlock(uiBlock *block, int addval, int mx, int my);
289 void uiMenuPopupBoundsBlock(uiBlock *block, int addvall, int mx, int my);
291 int uiBlocksGetYMin (struct ListBase *lb);
293 void uiBlockSetDirection (uiBlock *block, int direction);
294 void uiBlockFlipOrder (uiBlock *block);
295 void uiBlockSetFlag (uiBlock *block, int flag);
296 void uiBlockClearFlag (uiBlock *block, int flag);
297 void uiBlockSetXOfs (uiBlock *block, int xofs);
299 int uiButGetRetVal (uiBut *but);
301 void uiButSetFlag (uiBut *but, int flag);
302 void uiButClearFlag (uiBut *but, int flag);
306 * Functions to define various types of buttons in a block. Postfixes:
314 uiBut *uiDefBut(uiBlock *block,
315 int type, int retval, char *str,
319 float min, float max,
320 float a1, float a2, char *tip);
321 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);
322 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);
323 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);
324 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);
325 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);
326 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);
327 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);
328 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);
329 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);
330 uiBut *uiDefButO(uiBlock *block, int type, char *opname, int opcontext, char *str, short x1, short y1, short x2, short y2, char *tip);
332 uiBut *uiDefIconBut(uiBlock *block,
333 int type, int retval, int icon,
337 float min, float max,
338 float a1, float a2, char *tip);
339 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);
340 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);
341 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);
342 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);
343 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);
344 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);
345 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);
346 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);
347 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);
348 uiBut *uiDefIconButO(uiBlock *block, int type, char *opname, int opcontext, int icon, short x1, short y1, short x2, short y2, char *tip);
350 uiBut *uiDefIconTextBut(uiBlock *block,
351 int type, int retval, int icon, char *str,
355 float min, float max,
356 float a1, float a2, char *tip);
357 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);
358 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);
359 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);
360 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);
361 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);
362 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);
363 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);
364 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);
365 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);
366 uiBut *uiDefIconTextButO(uiBlock *block, int type, char *opname, int opcontext, int icon, char *str, short x1, short y1, short x2, short y2, char *tip);
368 /* for passing inputs to ButO buttons */
369 struct PointerRNA *uiButGetOperatorPtrRNA(uiBut *but);
373 * Butons with a more specific purpose:
374 * - IDPoinBut: for creating buttons that work on a pointer to an ID block.
375 * - MenuBut: buttons that popup a menu (in headers usually).
376 * - PulldownBut: like MenuBut, but creating a uiBlock (for compatibility).
377 * - BlockBut: buttons that popup a block with more buttons.
378 * - KeyevtBut: buttons that can be used to turn key events into values.
379 * - PickerButtons: buttons like the color picker (for code sharing).
380 * - AutoButR: RNA property button with type automatically defined. */
382 #define UI_ID_RENAME 1
383 #define UI_ID_BROWSE 2
384 #define UI_ID_ADD_NEW 4
386 #define UI_ID_ALONE 16
387 #define UI_ID_DELETE 32
388 #define UI_ID_LOCAL 64
389 #define UI_ID_AUTO_NAME 128
390 #define UI_ID_FAKE_USER 256
391 #define UI_ID_PIN 512
392 #define UI_ID_BROWSE_RENDER 1024
393 #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)
395 typedef void (*uiIDPoinFuncFP)(struct bContext *C, char *str, struct ID **idpp);
396 typedef void (*uiIDPoinFunc)(struct bContext *C, struct ID *id, int event);
398 uiBut *uiDefIDPoinBut(uiBlock *block, uiIDPoinFuncFP func, short blocktype, int retval, char *str,
399 short x1, short y1, short x2, short y2, void *idpp, char *tip);
400 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);
402 uiBut *uiDefPulldownBut(uiBlock *block, uiBlockCreateFunc func, void *arg, char *str, short x1, short y1, short x2, short y2, char *tip);
403 uiBut *uiDefMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, char *str, short x1, short y1, short x2, short y2, char *tip);
404 uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, char *str, short x1, short y1, short x2, short y2, char *tip);
406 uiBut *uiDefBlockBut(uiBlock *block, uiBlockCreateFunc func, void *func_arg1, char *str, short x1, short y1, short x2, short y2, char *tip);
407 uiBut *uiDefBlockButN(uiBlock *block, uiBlockCreateFunc func, void *argN, char *str, short x1, short y1, short x2, short y2, char *tip);
409 uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int retval, int icon, short x1, short y1, short x2, short y2, char *tip);
410 uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int icon, char *str, short x1, short y1, short x2, short y2, char *tip);
412 void uiDefKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1, short x2, short y2, short *spoin, char *tip);
414 uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, short x1, short y1, short x2, short y2, char *tip);
416 void uiBlockPickerButtons(struct uiBlock *block, float *col, float *hsv, float *old, char *hexcol, char mode, short retval);
417 void uiBlockColorbandButtons(struct uiBlock *block, struct ColorBand *coba, struct rctf *butr, int event);
419 uiBut *uiDefAutoButR(uiBlock *block, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, char *name, int icon, int x1, int y1, int x2, int y2);
420 void uiDefAutoButsRNA(const struct bContext *C, uiLayout *layout, struct PointerRNA *ptr, int columns);
424 * Game engine logic brick links. Non-functional currently in 2.5,
425 * code to handle and draw these is disabled internally. */
427 void uiSetButLink(struct uiBut *but, void **poin, void ***ppoin, short *tot, int from, int to);
429 void uiComposeLinks(uiBlock *block);
430 uiBut *uiFindInlink(uiBlock *block, void *poin);
434 * uiBlockSetHandleFunc/ButmFunc are for handling events through a callback.
435 * HandleFunc gets the retval passed on, and ButmFunc gets a2. The latter is
436 * mostly for compatibility with older code.
438 * uiButSetCompleteFunc is for tab completion.
440 * uiButSearchFunc is for name buttons, showing a popup with matches
442 * uiBlockSetFunc and uiButSetFunc are callbacks run when a button is used,
443 * in case events, operators or RNA are not sufficient to handle the button.
445 * uiButSetNFunc will free the argument with MEM_freeN. */
447 typedef struct uiSearchItems uiSearchItems;
449 typedef void (*uiButHandleFunc)(struct bContext *C, void *arg1, void *arg2);
450 typedef void (*uiButHandleRenameFunc)(struct bContext *C, void *arg, char *origstr);
451 typedef void (*uiButHandleNFunc)(struct bContext *C, void *argN, void *arg2);
452 typedef void (*uiButCompleteFunc)(struct bContext *C, char *str, void *arg);
453 typedef void (*uiButSearchFunc)(const struct bContext *C, void *arg, char *str, uiSearchItems *items);
454 typedef void (*uiBlockHandleFunc)(struct bContext *C, void *arg, int event);
456 /* use inside searchfunc to add items */
457 int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin, int iconid);
458 /* bfunc gets search item *poin as arg2, or if NULL the old string */
459 void uiButSetSearchFunc (uiBut *but, uiButSearchFunc sfunc, void *arg1, uiButHandleFunc bfunc);
460 /* height in pixels, it's using hardcoded values still */
461 int uiSearchBoxhHeight(void);
463 void uiBlockSetHandleFunc(uiBlock *block, uiBlockHandleFunc func, void *arg);
464 void uiBlockSetButmFunc (uiBlock *block, uiMenuHandleFunc func, void *arg);
466 void uiBlockSetFunc (uiBlock *block, uiButHandleFunc func, void *arg1, void *arg2);
467 void uiBlockSetRenameFunc(uiBlock *block, uiButHandleRenameFunc func, void *arg1);
468 void uiButSetFunc (uiBut *but, uiButHandleFunc func, void *arg1, void *arg2);
469 void uiButSetNFunc (uiBut *but, uiButHandleNFunc func, void *argN, void *arg2);
471 void uiButSetCompleteFunc(uiBut *but, uiButCompleteFunc func, void *arg);
473 void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)(const struct bContext *C, void *, struct rcti *rect));
477 * Tab complete helper functions, for use in uiButCompleteFunc callbacks.
478 * Call begin once, then multiple times do_name with all possibilities,
479 * and finally end to finish and get the completed name. */
481 typedef struct AutoComplete AutoComplete;
483 AutoComplete *autocomplete_begin(char *startname, int maxlen);
484 void autocomplete_do_name(AutoComplete *autocpl, const char *name);
485 void autocomplete_end(AutoComplete *autocpl, char *autoname);
489 * Functions for creating, freeing and drawing panels. The API here
490 * could use a good cleanup, though how they will function in 2.5 is
491 * not clear yet so we postpone that. */
493 void uiBeginPanels(const struct bContext *C, struct ARegion *ar);
494 void uiEndPanels(const struct bContext *C, struct ARegion *ar);
496 struct Panel *uiBeginPanel(struct ScrArea *sa, struct ARegion *ar, uiBlock *block, struct PanelType *pt, int *open);
497 void uiEndPanel(uiBlock *block, int width, int height);
501 * Handlers that can be registered in regions, areas and windows for
502 * handling WM events. Mostly this is done automatic by modules such
503 * as screen/ if ED_KEYMAP_UI is set, or internally in popup functions. */
505 void UI_add_region_handlers(struct ListBase *handlers);
506 void UI_add_area_handlers(struct ListBase *handlers);
507 void UI_add_popup_handlers(struct bContext *C, struct ListBase *handlers, uiPopupBlockHandle *menu);
510 * Callbacks and utils to get 2.48 work */
512 void test_idbutton_cb(struct bContext *C, void *namev, void *arg2);
513 void test_scriptpoin_but(struct bContext *C, char *name, struct ID **idpp);
514 void test_actionpoin_but(struct bContext *C, char *name, struct ID **idpp);
515 void test_obpoin_but(struct bContext *C, char *name, struct ID **idpp);
516 void test_meshobpoin_but(struct bContext *C, char *name, struct ID **idpp);
517 void test_meshpoin_but(struct bContext *C, char *name, struct ID **idpp);
518 void test_matpoin_but(struct bContext *C, char *name, struct ID **idpp);
519 void test_scenepoin_but(struct bContext *C, char *name, struct ID **idpp);
520 void test_grouppoin_but(struct bContext *C, char *name, struct ID **idpp);
521 void test_texpoin_but(struct bContext *C, char *name, struct ID **idpp);
522 void test_imapoin_but(struct bContext *C, char *name, struct ID **idpp);
523 void autocomplete_bone(struct bContext *C, char *str, void *arg_v);
524 void autocomplete_vgroup(struct bContext *C, char *str, void *arg_v);
527 void curvemap_buttons(uiBlock *block, struct CurveMapping *cumap, char labeltype, short event, short redraw, struct rctf *rect);
528 void colorband_buttons(uiBlock *block, struct ColorBand *coba, struct rctf *rect, int small);
533 * init and exit should be called before using this module. init_userdef must
534 * be used to reinitialize some internal state if user preferences change. */
537 void UI_init_userdef(void);
542 uiBut *uiDefMenuButO(uiBlock *block, char *opname, char *name);
543 uiBut *uiDefMenuSep(uiBlock *block);
547 * More automated layout of buttons. Has three levels:
548 * - Layout: contains a number templates, within a bounded width or height.
549 * - Template: predefined layouts for buttons with a number of slots, each
550 * slot can contain multiple items.
551 * - Item: item to put in a template slot, being either an RNA property,
552 * operator, label or menu. Also regular buttons can be used when setting
553 * uiBlockCurLayout. */
556 #define UI_LAYOUT_HORIZONTAL 0
557 #define UI_LAYOUT_VERTICAL 1
559 #define UI_LAYOUT_PANEL 0
560 #define UI_LAYOUT_HEADER 1
561 #define UI_LAYOUT_MENU 2
566 #define UI_LAYOUT_ALIGN_EXPAND 0
567 #define UI_LAYOUT_ALIGN_LEFT 1
568 #define UI_LAYOUT_ALIGN_CENTER 2
569 #define UI_LAYOUT_ALIGN_RIGHT 3
571 uiLayout *uiBlockLayout(uiBlock *block, int dir, int type, int x, int y, int size, int em, struct uiStyle *style);
572 void uiBlockSetCurLayout(uiBlock *block, uiLayout *layout);
573 void uiBlockLayoutResolve(const struct bContext *C, uiBlock *block, int *x, int *y);
575 uiBlock *uiLayoutGetBlock(uiLayout *layout);
577 void uiLayoutSetOperatorContext(uiLayout *layout, int opcontext);
578 void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv);
579 void uiLayoutSetContextPointer(uiLayout *layout, char *name, struct PointerRNA *ptr);
581 void uiLayoutSetActive(uiLayout *layout, int active);
582 void uiLayoutSetEnabled(uiLayout *layout, int enabled);
583 void uiLayoutSetRedAlert(uiLayout *layout, int redalert);
584 void uiLayoutSetAlignment(uiLayout *layout, int alignment);
585 void uiLayoutSetKeepAspect(uiLayout *layout, int keepaspect);
586 void uiLayoutSetScaleX(uiLayout *layout, float scale);
587 void uiLayoutSetScaleY(uiLayout *layout, float scale);
590 int uiLayoutGetOperatorContext(uiLayout *layout);
591 int uiLayoutGetActive(uiLayout *layout);
592 int uiLayoutGetEnabled(uiLayout *layout);
593 int uiLayoutGetRedAlert(uiLayout *layout);
594 int uiLayoutGetAlignment(uiLayout *layout);
595 int uiLayoutGetKeepAspect(uiLayout *layout);
596 float uiLayoutGetScaleX(uiLayout *layout);
597 float uiLayoutGetScaleY(uiLayout *layout);
599 /* layout specifiers */
600 uiLayout *uiLayoutRow(uiLayout *layout, int align);
601 uiLayout *uiLayoutColumn(uiLayout *layout, int align);
602 uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, int align);
603 uiLayout *uiLayoutBox(uiLayout *layout);
604 uiLayout *uiLayoutFree(uiLayout *layout, int align);
605 uiLayout *uiLayoutSplit(uiLayout *layout, float percentage);
607 uiBlock *uiLayoutFreeBlock(uiLayout *layout);
610 void uiTemplateHeader(uiLayout *layout, struct bContext *C);
611 void uiTemplateID(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname,
612 char *newop, char *openop, char *unlinkop);
613 uiLayout *uiTemplateModifier(uiLayout *layout, struct PointerRNA *ptr);
614 uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr);
615 void uiTemplatePreview(uiLayout *layout, struct ID *id);
616 void uiTemplateColorRamp(uiLayout *layout, struct ColorBand *coba, int expand);
617 void uiTemplateCurveMapping(uiLayout *layout, struct CurveMapping *cumap, int type);
618 void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, char *propname);
619 void uiTemplateImageLayers(uiLayout *layout, struct bContext *C, struct Image *ima, struct ImageUser *iuser);
620 void uiTemplateList(uiLayout *layout, struct PointerRNA *ptr, char *propname, char *activeprop, int items);
623 void uiItemO(uiLayout *layout, char *name, int icon, char *opname);
624 void uiItemEnumO(uiLayout *layout, char *name, int icon, char *opname, char *propname, int value);
625 void uiItemEnumO_string(uiLayout *layout, char *name, int icon, char *opname, char *propname, char *value);
626 void uiItemsEnumO(uiLayout *layout, char *opname, char *propname);
627 void uiItemBooleanO(uiLayout *layout, char *name, int icon, char *opname, char *propname, int value);
628 void uiItemIntO(uiLayout *layout, char *name, int icon, char *opname, char *propname, int value);
629 void uiItemFloatO(uiLayout *layout, char *name, int icon, char *opname, char *propname, float value);
630 void uiItemStringO(uiLayout *layout, char *name, int icon, char *opname, char *propname, char *value);
631 void uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, struct IDProperty *properties, int context);
633 void uiItemR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, int expand, int slider, int toggle);
634 void uiItemFullR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, int value, int expand, int slider, int toggle);
635 void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, int value);
636 void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname);
638 void uiItemL(uiLayout *layout, char *name, int icon); /* label */
639 void uiItemM(uiLayout *layout, struct bContext *C, char *name, int icon, char *menuname); /* menu */
640 void uiItemV(uiLayout *layout, char *name, int icon, int argval); /* value */
641 void uiItemS(uiLayout *layout); /* separator */
643 void uiItemMenuF(uiLayout *layout, char *name, int icon, uiMenuCreateFunc func);
644 void uiItemMenuEnumO(uiLayout *layout, char *name, int icon, char *opname, char *propname);
645 void uiItemMenuEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname);
649 void uiAnimContextProperty(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index);
651 /* Styled text draw */
652 void uiStyleFontSet(struct uiFontStyle *fs);
653 void uiStyleFontDraw(struct uiFontStyle *fs, struct rcti *rect, char *str);
655 int UI_GetStringWidth(char *str); // XXX temp
656 void UI_DrawString(float x, float y, char *str); // XXX temp
658 #endif /* UI_INTERFACE_H */