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;
64 typedef struct uiBut uiBut;
65 typedef struct uiBlock uiBlock;
66 typedef struct uiPopupBlockHandle uiPopupBlockHandle;
67 typedef struct uiLayout uiLayout;
72 #define UI_EMBOSS 0 /* use widget style for drawing */
73 #define UI_EMBOSSN 1 /* Nothing, only icon and/or text */
74 #define UI_EMBOSSP 2 /* Pulldown menu style */
75 #define UI_EMBOSST 3 /* Table */
77 /* uiBlock->direction */
82 #define UI_DIRECTION 15
84 #define UI_SHIFT_FLIPPED 32
86 /* uiBlock->autofill (not yet used) */
87 #define UI_BLOCK_COLLUMNS 1
88 #define UI_BLOCK_ROWS 2
90 /* uiBlock->flag (controls) */
91 #define UI_BLOCK_LOOP 1
92 #define UI_BLOCK_REDRAW 2
93 #define UI_BLOCK_RET_1 4 /* XXX 2.5 not implemented */
94 #define UI_BLOCK_NUMSELECT 8
95 #define UI_BLOCK_ENTER_OK 16
96 #define UI_BLOCK_NOSHADOW 32
97 #define UI_BLOCK_UNUSED 64
98 #define UI_BLOCK_MOVEMOUSE_QUIT 128
99 #define UI_BLOCK_KEEP_OPEN 256
100 #define UI_BLOCK_POPUP 512
101 #define UI_BLOCK_OUT_1 1024
103 /* uiPopupBlockHandle->menuretval */
104 #define UI_RETURN_CANCEL 1 /* cancel all menus cascading */
105 #define UI_RETURN_OK 2 /* choice made */
106 #define UI_RETURN_OUT 4 /* left the menu */
107 #define UI_RETURN_UPDATE 8 /* update the button that opened */
109 /* block->flag bits 12-15 are identical to but->flag bits */
112 #define UI_PNL_TRANSP 1
113 #define UI_PNL_SOLID 2
115 #define UI_PNL_CLOSE 32
116 #define UI_PNL_STOW 64
117 #define UI_PNL_TO_MOUSE 128
118 #define UI_PNL_UNSTOW 256
119 #define UI_PNL_SCALE 512
121 /* warning the first 6 flags are internal */
123 #define UI_TEXT_LEFT 64
124 #define UI_ICON_LEFT 128
125 #define UI_ICON_SUBMENU 256
126 /* control for button type block */
127 #define UI_MAKE_TOP 512
128 #define UI_MAKE_DOWN 1024
129 #define UI_MAKE_LEFT 2048
130 #define UI_MAKE_RIGHT 4096
132 /* button align flag, for drawing groups together */
133 #define UI_BUT_ALIGN (15<<14)
134 #define UI_BUT_ALIGN_TOP (1<<14)
135 #define UI_BUT_ALIGN_LEFT (1<<15)
136 #define UI_BUT_ALIGN_RIGHT (1<<16)
137 #define UI_BUT_ALIGN_DOWN (1<<17)
139 #define UI_BUT_DISABLED (1<<18)
140 #define UI_BUT_UNUSED (1<<19)
141 #define UI_BUT_ANIMATED (1<<20)
142 #define UI_BUT_ANIMATED_KEY (1<<21)
143 #define UI_BUT_DRIVEN (1<<22)
144 #define UI_BUT_INACTIVE (1<<23)
145 #define UI_BUT_LAST_ACTIVE (1<<24)
147 #define UI_PANEL_WIDTH 340
148 #define UI_COMPACT_PANEL_WIDTH 160
150 /* Button types, bits stored in 1 value... and a short even!
151 - bits 0-4: bitnr (0-31)
152 - bits 5-7: pointer type
154 - bit 9-15: button type (now 6 bits, 64 types)
164 #define BUTPOIN (128+64+32)
175 #define LABEL (10<<9)
177 #define ICONROW (12<<9)
178 #define ICONTOG (13<<9)
179 #define NUMSLI (14<<9)
181 #define IDPOIN (16<<9)
182 #define HSVSLI (17<<9)
183 #define SCROLL (18<<9)
184 #define BLOCK (19<<9)
188 #define INLINK (23<<9)
189 #define KEYEVT (24<<9)
190 #define ICONTEXTROW (25<<9)
191 #define HSVCUBE (26<<9)
192 #define PULLDOWN (27<<9)
193 #define ROUNDBOX (28<<9)
194 #define CHARTAB (29<<9)
195 #define BUT_COLORBAND (30<<9)
196 #define BUT_NORMAL (31<<9)
197 #define BUT_CURVE (32<<9)
198 #define BUT_TOGDUAL (33<<9)
199 #define ICONTOGN (34<<9)
200 #define FTPREVIEW (35<<9)
201 #define NUMABS (36<<9)
202 #define TOGBUT (37<<9)
203 #define OPTION (38<<9)
204 #define OPTIONN (39<<9)
205 #define SEARCH_MENU (40<<9)
206 #define BUT_EXTRA (41<<9)
207 #define HSVCIRCLE (42<<9)
208 #define LISTBOX (43<<9)
209 #define LISTROW (44<<9)
210 #define HOTKEYEVT (45<<9)
212 #define BUTTYPE (63<<9)
216 * Functions to draw various shapes, taking theme settings into account.
217 * Used for code that draws its own UI style elements. */
219 void uiEmboss(float x1, float y1, float x2, float y2, int sel);
220 void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad);
221 void uiSetRoundBox(int type);
222 int uiGetRoundBox(void);
223 void uiRoundRect(float minx, float miny, float maxx, float maxy, float rad);
224 void uiDrawMenuBox(float minx, float miny, float maxx, float maxy, short flag, short direction);
225 void uiDrawBoxShadow(unsigned char alpha, float minx, float miny, float maxx, float maxy);
227 /* state for scrolldrawing */
228 #define UI_SCROLL_PRESSED 1
229 #define UI_SCROLL_ARROWS 2
230 void uiWidgetScrollDraw(struct uiWidgetColors *wcol, struct rcti *rect, struct rcti *slider, int state);
234 typedef void (*uiMenuCreateFunc)(struct bContext *C, struct uiLayout *layout, void *arg1);
235 typedef void (*uiMenuHandleFunc)(struct bContext *C, void *arg, int event);
239 * Functions used to create popup menus. For more extended menus the
240 * uiPupMenuBegin/End functions can be used to define own items with
241 * the uiItem functions inbetween. If it is a simple confirmation menu
242 * or similar, popups can be created with a single function call. */
244 typedef struct uiPopupMenu uiPopupMenu;
246 uiPopupMenu *uiPupMenuBegin(struct bContext *C, const char *title, int icon);
247 void uiPupMenuEnd(struct bContext *C, struct uiPopupMenu *head);
248 struct uiLayout *uiPupMenuLayout(uiPopupMenu *head);
250 void uiPupMenuOkee(struct bContext *C, char *opname, char *str, ...);
251 void uiPupMenuSaveOver(struct bContext *C, struct wmOperator *op, char *filename);
252 void uiPupMenuNotice(struct bContext *C, char *str, ...);
253 void uiPupMenuError(struct bContext *C, char *str, ...);
254 void uiPupMenuReports(struct bContext *C, struct ReportList *reports);
256 void uiPupMenuSetActive(int val);
260 * Functions used to create popup blocks. These are like popup menus
261 * but allow using all button types and creating an own layout. */
263 typedef uiBlock* (*uiBlockCreateFunc)(struct bContext *C, struct ARegion *ar, void *arg1);
265 void uiPupBlock(struct bContext *C, uiBlockCreateFunc func, void *arg);
266 void uiPupBlockO(struct bContext *C, uiBlockCreateFunc func, void *arg, char *opname, int opcontext);
267 void uiPupBlockOperator(struct bContext *C, uiBlockCreateFunc func, struct wmOperator *op, int opcontext);
271 * Functions for creating, drawing and freeing blocks. A Block is a
272 * container of buttons and used for various purposes.
274 * Begin/Define Buttons/End/Draw is the typical order in which these
275 * function should be called, though for popup blocks Draw is left out.
276 * Freeing blocks is done by the screen/ module automatically.
280 uiBlock *uiBeginBlock(const struct bContext *C, struct ARegion *region, const char *name, short dt);
281 void uiEndBlock(const struct bContext *C, uiBlock *block);
282 void uiDrawBlock(const struct bContext *C, struct uiBlock *block);
284 uiBlock *uiGetBlock(char *name, struct ARegion *ar);
286 void uiBlockSetEmboss(uiBlock *block, short dt);
288 void uiFreeBlock(const struct bContext *C, uiBlock *block);
289 void uiFreeBlocks(const struct bContext *C, struct ListBase *lb);
290 void uiFreeInactiveBlocks(const struct bContext *C, struct ListBase *lb);
292 void uiBlockSetRegion(uiBlock *block, struct ARegion *region);
294 void uiBlockSetButLock(uiBlock *block, int val, char *lockstr);
295 void uiBlockClearButLock(uiBlock *block);
297 /* automatic aligning, horiz or verical */
298 void uiBlockBeginAlign(uiBlock *block);
299 void uiBlockEndAlign(uiBlock *block);
301 void uiBoundsBlock(struct uiBlock *block, int addval);
302 void uiTextBoundsBlock(uiBlock *block, int addval);
303 void uiPopupBoundsBlock(uiBlock *block, int addval, int mx, int my);
304 void uiMenuPopupBoundsBlock(uiBlock *block, int addvall, int mx, int my);
306 int uiBlocksGetYMin (struct ListBase *lb);
308 void uiBlockSetDirection (uiBlock *block, int direction);
309 void uiBlockFlipOrder (uiBlock *block);
310 void uiBlockSetFlag (uiBlock *block, int flag);
311 void uiBlockClearFlag (uiBlock *block, int flag);
312 void uiBlockSetXOfs (uiBlock *block, int xofs);
314 int uiButGetRetVal (uiBut *but);
316 void uiButSetFlag (uiBut *but, int flag);
317 void uiButClearFlag (uiBut *but, int flag);
319 /* special button case, only draw it when used actively, for outliner etc */
320 int uiButActiveOnly (const struct bContext *C, uiBlock *block, uiBut *but);
325 * Functions to define various types of buttons in a block. Postfixes:
333 uiBut *uiDefBut(uiBlock *block,
334 int type, int retval, char *str,
338 float min, float max,
339 float a1, float a2, char *tip);
340 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);
341 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);
342 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);
343 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);
344 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);
345 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);
346 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);
347 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);
348 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);
349 uiBut *uiDefButO(uiBlock *block, int type, char *opname, int opcontext, char *str, short x1, short y1, short x2, short y2, char *tip);
351 uiBut *uiDefIconBut(uiBlock *block,
352 int type, int retval, int icon,
356 float min, float max,
357 float a1, float a2, char *tip);
358 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);
359 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);
360 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);
361 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);
362 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);
363 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);
364 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);
365 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);
366 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);
367 uiBut *uiDefIconButO(uiBlock *block, int type, char *opname, int opcontext, int icon, short x1, short y1, short x2, short y2, char *tip);
369 uiBut *uiDefIconTextBut(uiBlock *block,
370 int type, int retval, int icon, char *str,
374 float min, float max,
375 float a1, float a2, char *tip);
376 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);
377 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);
378 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);
379 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);
380 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);
381 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);
382 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);
383 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);
384 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);
385 uiBut *uiDefIconTextButO(uiBlock *block, int type, char *opname, int opcontext, int icon, char *str, short x1, short y1, short x2, short y2, char *tip);
387 /* for passing inputs to ButO buttons */
388 struct PointerRNA *uiButGetOperatorPtrRNA(uiBut *but);
392 * Butons with a more specific purpose:
393 * - IDPoinBut: for creating buttons that work on a pointer to an ID block.
394 * - MenuBut: buttons that popup a menu (in headers usually).
395 * - PulldownBut: like MenuBut, but creating a uiBlock (for compatibility).
396 * - BlockBut: buttons that popup a block with more buttons.
397 * - KeyevtBut: buttons that can be used to turn key events into values.
398 * - PickerButtons: buttons like the color picker (for code sharing).
399 * - AutoButR: RNA property button with type automatically defined. */
401 #define UI_ID_RENAME 1
402 #define UI_ID_BROWSE 2
403 #define UI_ID_ADD_NEW 4
405 #define UI_ID_ALONE 16
406 #define UI_ID_DELETE 32
407 #define UI_ID_LOCAL 64
408 #define UI_ID_AUTO_NAME 128
409 #define UI_ID_FAKE_USER 256
410 #define UI_ID_PIN 512
411 #define UI_ID_BROWSE_RENDER 1024
412 #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)
414 typedef void (*uiIDPoinFuncFP)(struct bContext *C, char *str, struct ID **idpp);
415 typedef void (*uiIDPoinFunc)(struct bContext *C, struct ID *id, int event);
417 uiBut *uiDefIDPoinBut(uiBlock *block, uiIDPoinFuncFP func, short blocktype, int retval, char *str,
418 short x1, short y1, short x2, short y2, void *idpp, char *tip);
419 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);
421 uiBut *uiDefPulldownBut(uiBlock *block, uiBlockCreateFunc func, void *arg, char *str, short x1, short y1, short x2, short y2, char *tip);
422 uiBut *uiDefMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, char *str, short x1, short y1, short x2, short y2, char *tip);
423 uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, char *str, short x1, short y1, short x2, short y2, char *tip);
425 uiBut *uiDefBlockBut(uiBlock *block, uiBlockCreateFunc func, void *func_arg1, char *str, short x1, short y1, short x2, short y2, char *tip);
426 uiBut *uiDefBlockButN(uiBlock *block, uiBlockCreateFunc func, void *argN, char *str, short x1, short y1, short x2, short y2, char *tip);
428 uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int retval, int icon, short x1, short y1, short x2, short y2, char *tip);
429 uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int icon, char *str, short x1, short y1, short x2, short y2, char *tip);
431 void uiDefKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1, short x2, short y2, short *spoin, char *tip);
432 uiBut *uiDefHotKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1, short x2, short y2, short *keypoin, short *modkeypoin, char *tip);
434 uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, short x1, short y1, short x2, short y2, char *tip);
436 void uiBlockPickerButtons(struct uiBlock *block, float *col, float *hsv, float *old, char *hexcol, char mode, short retval);
437 void uiBlockColorbandButtons(struct uiBlock *block, struct ColorBand *coba, struct rctf *butr, int event);
439 uiBut *uiDefAutoButR(uiBlock *block, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, char *name, int icon, int x1, int y1, int x2, int y2);
440 void uiDefAutoButsRNA(const struct bContext *C, uiLayout *layout, struct PointerRNA *ptr, int columns);
444 * Game engine logic brick links. Non-functional currently in 2.5,
445 * code to handle and draw these is disabled internally. */
447 void uiSetButLink(struct uiBut *but, void **poin, void ***ppoin, short *tot, int from, int to);
449 void uiComposeLinks(uiBlock *block);
450 uiBut *uiFindInlink(uiBlock *block, void *poin);
454 * uiBlockSetHandleFunc/ButmFunc are for handling events through a callback.
455 * HandleFunc gets the retval passed on, and ButmFunc gets a2. The latter is
456 * mostly for compatibility with older code.
458 * uiButSetCompleteFunc is for tab completion.
460 * uiButSearchFunc is for name buttons, showing a popup with matches
462 * uiBlockSetFunc and uiButSetFunc are callbacks run when a button is used,
463 * in case events, operators or RNA are not sufficient to handle the button.
465 * uiButSetNFunc will free the argument with MEM_freeN. */
467 typedef struct uiSearchItems uiSearchItems;
469 typedef void (*uiButHandleFunc)(struct bContext *C, void *arg1, void *arg2);
470 typedef void (*uiButHandleRenameFunc)(struct bContext *C, void *arg, char *origstr);
471 typedef void (*uiButHandleNFunc)(struct bContext *C, void *argN, void *arg2);
472 typedef void (*uiButCompleteFunc)(struct bContext *C, char *str, void *arg);
473 typedef void (*uiButSearchFunc)(const struct bContext *C, void *arg, char *str, uiSearchItems *items);
474 typedef void (*uiBlockHandleFunc)(struct bContext *C, void *arg, int event);
476 /* use inside searchfunc to add items */
477 int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin, int iconid);
478 /* bfunc gets search item *poin as arg2, or if NULL the old string */
479 void uiButSetSearchFunc (uiBut *but, uiButSearchFunc sfunc, void *arg1, uiButHandleFunc bfunc, void *active);
480 /* height in pixels, it's using hardcoded values still */
481 int uiSearchBoxhHeight(void);
483 void uiBlockSetHandleFunc(uiBlock *block, uiBlockHandleFunc func, void *arg);
484 void uiBlockSetButmFunc (uiBlock *block, uiMenuHandleFunc func, void *arg);
485 void uiBlockSetFunc (uiBlock *block, uiButHandleFunc func, void *arg1, void *arg2);
487 void uiButSetRenameFunc (uiBut *but, uiButHandleRenameFunc func, void *arg1);
488 void uiButSetFunc (uiBut *but, uiButHandleFunc func, void *arg1, void *arg2);
489 void uiButSetNFunc (uiBut *but, uiButHandleNFunc func, void *argN, void *arg2);
491 void uiButSetCompleteFunc(uiBut *but, uiButCompleteFunc func, void *arg);
493 void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)(const struct bContext *C, void *, void *, struct rcti *rect), void *arg);
497 * Tab complete helper functions, for use in uiButCompleteFunc callbacks.
498 * Call begin once, then multiple times do_name with all possibilities,
499 * and finally end to finish and get the completed name. */
501 typedef struct AutoComplete AutoComplete;
503 AutoComplete *autocomplete_begin(char *startname, int maxlen);
504 void autocomplete_do_name(AutoComplete *autocpl, const char *name);
505 void autocomplete_end(AutoComplete *autocpl, char *autoname);
509 * Functions for creating, freeing and drawing panels. The API here
510 * could use a good cleanup, though how they will function in 2.5 is
511 * not clear yet so we postpone that. */
513 void uiBeginPanels(const struct bContext *C, struct ARegion *ar);
514 void uiEndPanels(const struct bContext *C, struct ARegion *ar);
516 struct Panel *uiBeginPanel(struct ScrArea *sa, struct ARegion *ar, uiBlock *block, struct PanelType *pt, int *open);
517 void uiEndPanel(uiBlock *block, int width, int height);
521 * Handlers that can be registered in regions, areas and windows for
522 * handling WM events. Mostly this is done automatic by modules such
523 * as screen/ if ED_KEYMAP_UI is set, or internally in popup functions. */
525 void UI_add_region_handlers(struct ListBase *handlers);
526 void UI_add_area_handlers(struct ListBase *handlers);
527 void UI_add_popup_handlers(struct bContext *C, struct ListBase *handlers, uiPopupBlockHandle *menu);
530 * Callbacks and utils to get 2.48 work */
532 void test_idbutton_cb(struct bContext *C, void *namev, void *arg2);
533 void test_scriptpoin_but(struct bContext *C, char *name, struct ID **idpp);
534 void test_actionpoin_but(struct bContext *C, char *name, struct ID **idpp);
535 void test_obpoin_but(struct bContext *C, char *name, struct ID **idpp);
536 void test_meshobpoin_but(struct bContext *C, char *name, struct ID **idpp);
537 void test_meshpoin_but(struct bContext *C, char *name, struct ID **idpp);
538 void test_matpoin_but(struct bContext *C, char *name, struct ID **idpp);
539 void test_scenepoin_but(struct bContext *C, char *name, struct ID **idpp);
540 void test_grouppoin_but(struct bContext *C, char *name, struct ID **idpp);
541 void test_texpoin_but(struct bContext *C, char *name, struct ID **idpp);
542 void test_imapoin_but(struct bContext *C, char *name, struct ID **idpp);
543 void autocomplete_bone(struct bContext *C, char *str, void *arg_v);
544 void autocomplete_vgroup(struct bContext *C, char *str, void *arg_v);
547 void curvemap_buttons(uiBlock *block, struct CurveMapping *cumap, char labeltype, short event, short redraw, struct rctf *rect);
548 void curvemap_layout(uiLayout *layout, struct CurveMapping *cumap, char labeltype, short event, short redraw, struct rctf *rect);
549 void colorband_buttons(uiBlock *block, struct ColorBand *coba, struct rctf *rect, int small);
554 * init and exit should be called before using this module. init_userdef must
555 * be used to reinitialize some internal state if user preferences change. */
558 void UI_init_userdef(void);
563 * More automated layout of buttons. Has three levels:
564 * - Layout: contains a number templates, within a bounded width or height.
565 * - Template: predefined layouts for buttons with a number of slots, each
566 * slot can contain multiple items.
567 * - Item: item to put in a template slot, being either an RNA property,
568 * operator, label or menu. Also regular buttons can be used when setting
569 * uiBlockCurLayout. */
572 #define UI_LAYOUT_HORIZONTAL 0
573 #define UI_LAYOUT_VERTICAL 1
575 #define UI_LAYOUT_PANEL 0
576 #define UI_LAYOUT_HEADER 1
577 #define UI_LAYOUT_MENU 2
582 #define UI_LAYOUT_ALIGN_EXPAND 0
583 #define UI_LAYOUT_ALIGN_LEFT 1
584 #define UI_LAYOUT_ALIGN_CENTER 2
585 #define UI_LAYOUT_ALIGN_RIGHT 3
587 uiLayout *uiBlockLayout(uiBlock *block, int dir, int type, int x, int y, int size, int em, struct uiStyle *style);
588 void uiBlockSetCurLayout(uiBlock *block, uiLayout *layout);
589 void uiBlockLayoutResolve(const struct bContext *C, uiBlock *block, int *x, int *y);
591 uiBlock *uiLayoutGetBlock(uiLayout *layout);
593 void uiLayoutSetOperatorContext(uiLayout *layout, int opcontext);
594 void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv);
595 void uiLayoutSetContextPointer(uiLayout *layout, char *name, struct PointerRNA *ptr);
597 void uiLayoutSetActive(uiLayout *layout, int active);
598 void uiLayoutSetEnabled(uiLayout *layout, int enabled);
599 void uiLayoutSetRedAlert(uiLayout *layout, int redalert);
600 void uiLayoutSetAlignment(uiLayout *layout, int alignment);
601 void uiLayoutSetKeepAspect(uiLayout *layout, int keepaspect);
602 void uiLayoutSetScaleX(uiLayout *layout, float scale);
603 void uiLayoutSetScaleY(uiLayout *layout, float scale);
605 int uiLayoutGetOperatorContext(uiLayout *layout);
606 int uiLayoutGetActive(uiLayout *layout);
607 int uiLayoutGetEnabled(uiLayout *layout);
608 int uiLayoutGetRedAlert(uiLayout *layout);
609 int uiLayoutGetAlignment(uiLayout *layout);
610 int uiLayoutGetKeepAspect(uiLayout *layout);
611 float uiLayoutGetScaleX(uiLayout *layout);
612 float uiLayoutGetScaleY(uiLayout *layout);
613 ListBase *uiLayoutBoxGetList(uiLayout *layout);
615 /* layout specifiers */
616 uiLayout *uiLayoutRow(uiLayout *layout, int align);
617 uiLayout *uiLayoutColumn(uiLayout *layout, int align);
618 uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, int align);
619 uiLayout *uiLayoutBox(uiLayout *layout);
620 uiLayout *uiLayoutListBox(uiLayout *layout);
621 uiLayout *uiLayoutFree(uiLayout *layout, int align);
622 uiLayout *uiLayoutSplit(uiLayout *layout, float percentage);
624 uiBlock *uiLayoutFreeBlock(uiLayout *layout);
627 void uiTemplateHeader(uiLayout *layout, struct bContext *C);
628 void uiTemplateID(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname,
629 char *newop, char *unlinkop);
630 uiLayout *uiTemplateModifier(uiLayout *layout, struct PointerRNA *ptr);
631 uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr);
632 void uiTemplatePreview(uiLayout *layout, struct ID *id, struct ID *parent);
633 void uiTemplateColorRamp(uiLayout *layout, struct ColorBand *coba, int expand);
634 void uiTemplateCurveMapping(uiLayout *layout, struct CurveMapping *cumap, int type, int compact);
635 void uiTemplateTriColorSet(uiLayout *layout, struct PointerRNA *ptr, char *propname);
636 void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, char *propname);
637 void uiTemplateImageLayers(uiLayout *layout, struct bContext *C, struct Image *ima, struct ImageUser *iuser);
638 void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C);
639 void uiTemplateOperatorSearch(uiLayout *layout);
640 void uiTemplateHeader3D(uiLayout *layout, struct bContext *C);
641 void uiTemplateTextureImage(uiLayout *layout, struct bContext *C, struct Tex *tex);
643 typedef struct uiListItem {
644 struct uiListItem *next, *prev;
646 struct PointerRNA data;
650 ListBase uiTemplateList(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, struct PointerRNA *activeptr, char *activeprop, int rows, int type);
653 void uiItemO(uiLayout *layout, char *name, int icon, char *opname);
654 void uiItemEnumO(uiLayout *layout, char *name, int icon, char *opname, char *propname, int value);
655 void uiItemEnumO_string(uiLayout *layout, char *name, int icon, char *opname, char *propname, char *value);
656 void uiItemsEnumO(uiLayout *layout, char *opname, char *propname);
657 void uiItemBooleanO(uiLayout *layout, char *name, int icon, char *opname, char *propname, int value);
658 void uiItemIntO(uiLayout *layout, char *name, int icon, char *opname, char *propname, int value);
659 void uiItemFloatO(uiLayout *layout, char *name, int icon, char *opname, char *propname, float value);
660 void uiItemStringO(uiLayout *layout, char *name, int icon, char *opname, char *propname, char *value);
661 void uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, struct IDProperty *properties, int context);
663 void uiItemR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, int expand, int slider, int toggle);
664 void uiItemFullR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, int value, int expand, int slider, int toggle);
665 void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, int value);
666 void uiItemEnumR_string(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, char *value);
667 void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname);
668 void uiItemPointerR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, struct PointerRNA *searchptr, char *searchpropname);
670 void uiItemL(uiLayout *layout, char *name, int icon); /* label */
671 void uiItemM(uiLayout *layout, struct bContext *C, char *name, int icon, char *menuname); /* menu */
672 void uiItemV(uiLayout *layout, char *name, int icon, int argval); /* value */
673 void uiItemS(uiLayout *layout); /* separator */
675 void uiItemMenuF(uiLayout *layout, char *name, int icon, uiMenuCreateFunc func);
676 void uiItemMenuEnumO(uiLayout *layout, char *name, int icon, char *opname, char *propname);
677 void uiItemMenuEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname);
679 /* Helpers for Operators */
680 void uiAnimContextProperty(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index);
681 void uiFileBrowseContextProperty(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop);
683 /* Styled text draw */
684 void uiStyleFontSet(struct uiFontStyle *fs);
685 void uiStyleFontDraw(struct uiFontStyle *fs, struct rcti *rect, char *str);
687 int UI_GetStringWidth(char *str); // XXX temp
688 void UI_DrawString(float x, float y, char *str); // XXX temp
690 #endif /* UI_INTERFACE_H */