|
Blender
V2.59
|
00001 /* 00002 * $Id: UI_interface.h 39104 2011-08-06 16:00:00Z campbellbarton $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00021 * All rights reserved. 00022 * 00023 * The Original Code is: all of this file. 00024 * 00025 * Contributor(s): none yet. 00026 * 00027 * ***** END GPL LICENSE BLOCK ***** 00028 */ 00029 00034 #ifndef UI_INTERFACE_H 00035 #define UI_INTERFACE_H 00036 00037 #include "RNA_types.h" 00038 #include "DNA_userdef_types.h" 00039 00040 /* Struct Declarations */ 00041 00042 struct ID; 00043 struct Main; 00044 struct ListBase; 00045 struct ARegion; 00046 struct ScrArea; 00047 struct wmWindow; 00048 struct wmWindowManager; 00049 struct wmOperator; 00050 struct AutoComplete; 00051 struct bContext; 00052 struct Panel; 00053 struct PanelType; 00054 struct PointerRNA; 00055 struct PropertyRNA; 00056 struct ReportList; 00057 struct rcti; 00058 struct rctf; 00059 struct uiStyle; 00060 struct uiFontStyle; 00061 struct uiWidgetColors; 00062 struct ColorBand; 00063 struct CurveMapping; 00064 struct Image; 00065 struct ImageUser; 00066 struct uiWidgetColors; 00067 struct Tex; 00068 struct MTex; 00069 struct ImBuf; 00070 00071 typedef struct uiBut uiBut; 00072 typedef struct uiBlock uiBlock; 00073 typedef struct uiPopupBlockHandle uiPopupBlockHandle; 00074 typedef struct uiLayout uiLayout; 00075 00076 /* Defines */ 00077 00078 /* uiBlock->dt */ 00079 #define UI_EMBOSS 0 /* use widget style for drawing */ 00080 #define UI_EMBOSSN 1 /* Nothing, only icon and/or text */ 00081 #define UI_EMBOSSP 2 /* Pulldown menu style */ 00082 #define UI_EMBOSST 3 /* Table */ 00083 00084 /* uiBlock->direction */ 00085 #define UI_DIRECTION (UI_TOP|UI_DOWN|UI_LEFT|UI_RIGHT) 00086 #define UI_TOP 1 00087 #define UI_DOWN 2 00088 #define UI_LEFT 4 00089 #define UI_RIGHT 8 00090 00091 #define UI_CENTER 16 00092 #define UI_SHIFT_FLIPPED 32 00093 00094 /* uiBlock->autofill (not yet used) */ 00095 // #define UI_BLOCK_COLLUMNS 1 00096 // #define UI_BLOCK_ROWS 2 00097 00098 /* uiBlock->flag (controls) */ 00099 #define UI_BLOCK_LOOP 1 00100 #define UI_BLOCK_REDRAW 2 00101 #define UI_BLOCK_RET_1 4 /* XXX 2.5 not implemented */ 00102 #define UI_BLOCK_NUMSELECT 8 00103 /*#define UI_BLOCK_ENTER_OK 16*/ /*UNUSED*/ 00104 #define UI_BLOCK_CLIPBOTTOM 32 00105 #define UI_BLOCK_CLIPTOP 64 00106 #define UI_BLOCK_MOVEMOUSE_QUIT 128 00107 #define UI_BLOCK_KEEP_OPEN 256 00108 #define UI_BLOCK_POPUP 512 00109 #define UI_BLOCK_OUT_1 1024 00110 #define UI_BLOCK_NO_FLIP 2048 00111 #define UI_BLOCK_POPUP_MEMORY 4096 00112 00113 /* uiPopupBlockHandle->menuretval */ 00114 #define UI_RETURN_CANCEL 1 /* cancel all menus cascading */ 00115 #define UI_RETURN_OK 2 /* choice made */ 00116 #define UI_RETURN_OUT 4 /* left the menu */ 00117 #define UI_RETURN_UPDATE 8 /* update the button that opened */ 00118 00119 /* block->flag bits 12-15 are identical to but->flag bits */ 00120 00121 /* panel controls */ 00122 #define UI_PNL_SOLID 2 00123 #define UI_PNL_CLOSE 32 00124 #define UI_PNL_SCALE 512 00125 00126 /* warning the first 6 flags are internal */ 00127 /* but->flag */ 00128 #define UI_TEXT_LEFT 64 00129 #define UI_ICON_LEFT 128 00130 #define UI_ICON_SUBMENU 256 00131 #define UI_ICON_PREVIEW 512 00132 /* control for button type block */ 00133 #define UI_MAKE_TOP 1024 00134 #define UI_MAKE_DOWN 2048 00135 #define UI_MAKE_LEFT 4096 00136 #define UI_MAKE_RIGHT 8192 00137 00138 /* button align flag, for drawing groups together */ 00139 #define UI_BUT_ALIGN (UI_BUT_ALIGN_TOP|UI_BUT_ALIGN_LEFT|UI_BUT_ALIGN_RIGHT|UI_BUT_ALIGN_DOWN) 00140 #define UI_BUT_ALIGN_TOP (1<<14) 00141 #define UI_BUT_ALIGN_LEFT (1<<15) 00142 #define UI_BUT_ALIGN_RIGHT (1<<16) 00143 #define UI_BUT_ALIGN_DOWN (1<<17) 00144 00145 #define UI_BUT_DISABLED (1<<18) 00146 #define UI_BUT_COLOR_LOCK (1<<19) 00147 #define UI_BUT_ANIMATED (1<<20) 00148 #define UI_BUT_ANIMATED_KEY (1<<21) 00149 #define UI_BUT_DRIVEN (1<<22) 00150 #define UI_BUT_REDALERT (1<<23) 00151 #define UI_BUT_INACTIVE (1<<24) 00152 #define UI_BUT_LAST_ACTIVE (1<<25) 00153 #define UI_BUT_UNDO (1<<26) 00154 #define UI_BUT_IMMEDIATE (1<<27) 00155 #define UI_BUT_NO_TOOLTIP (1<<28) 00156 #define UI_BUT_NO_UTF8 (1<<29) 00157 00158 #define UI_BUT_VEC_SIZE_LOCK (1<<30) /* used to flag if color hsv-circle should keep luminance */ 00159 #define UI_BUT_COLOR_CUBIC (1<<31) /* cubic saturation for the color wheel */ 00160 00161 #define UI_PANEL_WIDTH 340 00162 #define UI_COMPACT_PANEL_WIDTH 160 00163 00164 /* scale fixed button widths by this to account for DPI 00165 * 8.4852 == sqrtf(72.0f)) */ 00166 #define UI_DPI_FAC (sqrtf((float)U.dpi) / 8.48528137423857f) 00167 #define UI_DPI_ICON_FAC (((float)U.dpi) / 72.0f) 00168 /* 16 to copy ICON_DEFAULT_HEIGHT */ 00169 #define UI_DPI_ICON_SIZE ((float)16 * UI_DPI_ICON_FAC) 00170 00171 /* Button types, bits stored in 1 value... and a short even! 00172 - bits 0-4: bitnr (0-31) 00173 - bits 5-7: pointer type 00174 - bit 8: for 'bit' 00175 - bit 9-15: button type (now 6 bits, 64 types) 00176 */ 00177 00178 #define CHA 32 00179 #define SHO 64 00180 #define INT 96 00181 #define FLO 128 00182 /*#define FUN 192*/ /*UNUSED*/ 00183 #define BIT 256 00184 00185 #define BUTPOIN (128+64+32) 00186 00187 #define BUT (1<<9) 00188 #define ROW (2<<9) 00189 #define TOG (3<<9) 00190 #define SLI (4<<9) 00191 #define NUM (5<<9) 00192 #define TEX (6<<9) 00193 #define TOG3 (7<<9) 00194 #define TOGR (8<<9) 00195 #define TOGN (9<<9) 00196 #define LABEL (10<<9) 00197 #define MENU (11<<9) 00198 #define ICONROW (12<<9) 00199 #define ICONTOG (13<<9) 00200 #define NUMSLI (14<<9) 00201 #define COL (15<<9) 00202 #define IDPOIN (16<<9) 00203 #define HSVSLI (17<<9) 00204 #define SCROLL (18<<9) 00205 #define BLOCK (19<<9) 00206 #define BUTM (20<<9) 00207 #define SEPR (21<<9) 00208 #define LINK (22<<9) 00209 #define INLINK (23<<9) 00210 #define KEYEVT (24<<9) 00211 #define ICONTEXTROW (25<<9) 00212 #define HSVCUBE (26<<9) 00213 #define PULLDOWN (27<<9) 00214 #define ROUNDBOX (28<<9) 00215 #define CHARTAB (29<<9) 00216 #define BUT_COLORBAND (30<<9) 00217 #define BUT_NORMAL (31<<9) 00218 #define BUT_CURVE (32<<9) 00219 #define BUT_TOGDUAL (33<<9) 00220 #define ICONTOGN (34<<9) 00221 #define FTPREVIEW (35<<9) 00222 #define NUMABS (36<<9) 00223 #define TOGBUT (37<<9) 00224 #define OPTION (38<<9) 00225 #define OPTIONN (39<<9) 00226 /* buttons with value >= SEARCH_MENU don't get undo pushes */ 00227 #define SEARCH_MENU (40<<9) 00228 #define BUT_EXTRA (41<<9) 00229 #define HSVCIRCLE (42<<9) 00230 #define LISTBOX (43<<9) 00231 #define LISTROW (44<<9) 00232 #define HOTKEYEVT (45<<9) 00233 #define BUT_IMAGE (46<<9) 00234 #define HISTOGRAM (47<<9) 00235 #define WAVEFORM (48<<9) 00236 #define VECTORSCOPE (49<<9) 00237 #define PROGRESSBAR (50<<9) 00238 00239 #define BUTTYPE (63<<9) 00240 00241 /* gradient types, for color picker HSVCUBE etc */ 00242 #define UI_GRAD_SV 0 00243 #define UI_GRAD_HV 1 00244 #define UI_GRAD_HS 2 00245 #define UI_GRAD_H 3 00246 #define UI_GRAD_S 4 00247 #define UI_GRAD_V 5 00248 00249 #define UI_GRAD_V_ALT 9 00250 00251 /* Drawing 00252 * 00253 * Functions to draw various shapes, taking theme settings into account. 00254 * Used for code that draws its own UI style elements. */ 00255 00256 void uiEmboss(float x1, float y1, float x2, float y2, int sel); 00257 void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad); 00258 void uiSetRoundBox(int type); 00259 int uiGetRoundBox(void); 00260 void uiRoundRect(float minx, float miny, float maxx, float maxy, float rad); 00261 void uiDrawMenuBox(float minx, float miny, float maxx, float maxy, short flag, short direction); 00262 void uiDrawBoxShadow(unsigned char alpha, float minx, float miny, float maxx, float maxy); 00263 void uiDrawBox(int mode, float minx, float miny, float maxx, float maxy, float rad); 00264 void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown); 00265 void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadeLeft, float shadeRight); 00266 00267 /* state for scrolldrawing */ 00268 #define UI_SCROLL_PRESSED 1 00269 #define UI_SCROLL_ARROWS 2 00270 #define UI_SCROLL_NO_OUTLINE 4 00271 void uiWidgetScrollDraw(struct uiWidgetColors *wcol, struct rcti *rect, struct rcti *slider, int state); 00272 00273 /* Menu Callbacks */ 00274 00275 typedef void (*uiMenuCreateFunc)(struct bContext *C, struct uiLayout *layout, void *arg1); 00276 typedef void (*uiMenuHandleFunc)(struct bContext *C, void *arg, int event); 00277 00278 /* Popup Menus 00279 * 00280 * Functions used to create popup menus. For more extended menus the 00281 * uiPupMenuBegin/End functions can be used to define own items with 00282 * the uiItem functions in between. If it is a simple confirmation menu 00283 * or similar, popups can be created with a single function call. */ 00284 00285 typedef struct uiPopupMenu uiPopupMenu; 00286 00287 uiPopupMenu *uiPupMenuBegin(struct bContext *C, const char *title, int icon); 00288 void uiPupMenuEnd(struct bContext *C, struct uiPopupMenu *head); 00289 struct uiLayout *uiPupMenuLayout(uiPopupMenu *head); 00290 00291 void uiPupMenuOkee(struct bContext *C, const char *opname, const char *str, ...); 00292 void uiPupMenuSaveOver(struct bContext *C, struct wmOperator *op, const char *filename); 00293 void uiPupMenuNotice(struct bContext *C, const char *str, ...); 00294 void uiPupMenuError(struct bContext *C, const char *str, ...); 00295 void uiPupMenuReports(struct bContext *C, struct ReportList *reports); 00296 void uiPupMenuInvoke(struct bContext *C, const char *idname); /* popup registered menu */ 00297 00298 /* Popup Blocks 00299 * 00300 * Functions used to create popup blocks. These are like popup menus 00301 * but allow using all button types and creating an own layout. */ 00302 00303 typedef uiBlock* (*uiBlockCreateFunc)(struct bContext *C, struct ARegion *ar, void *arg1); 00304 typedef void (*uiBlockCancelFunc)(void *arg1); 00305 00306 void uiPupBlock(struct bContext *C, uiBlockCreateFunc func, void *arg); 00307 void uiPupBlockO(struct bContext *C, uiBlockCreateFunc func, void *arg, const char *opname, int opcontext); 00308 void uiPupBlockEx(struct bContext *C, uiBlockCreateFunc func, uiBlockCancelFunc cancel_func, void *arg); 00309 /* void uiPupBlockOperator(struct bContext *C, uiBlockCreateFunc func, struct wmOperator *op, int opcontext); */ /* UNUSED */ 00310 00311 void uiPupBlockClose(struct bContext *C, uiBlock *block); 00312 00313 /* Blocks 00314 * 00315 * Functions for creating, drawing and freeing blocks. A Block is a 00316 * container of buttons and used for various purposes. 00317 * 00318 * Begin/Define Buttons/End/Draw is the typical order in which these 00319 * function should be called, though for popup blocks Draw is left out. 00320 * Freeing blocks is done by the screen/ module automatically. 00321 * 00322 * */ 00323 00324 uiBlock *uiBeginBlock(const struct bContext *C, struct ARegion *region, const char *name, short dt); 00325 void uiEndBlock(const struct bContext *C, uiBlock *block); 00326 void uiDrawBlock(const struct bContext *C, struct uiBlock *block); 00327 00328 uiBlock *uiGetBlock(const char *name, struct ARegion *ar); 00329 00330 void uiBlockSetEmboss(uiBlock *block, char dt); 00331 00332 void uiFreeBlock(const struct bContext *C, uiBlock *block); 00333 void uiFreeBlocks(const struct bContext *C, struct ListBase *lb); 00334 void uiFreeInactiveBlocks(const struct bContext *C, struct ListBase *lb); 00335 void uiFreeActiveButtons(const struct bContext *C, struct bScreen *screen); 00336 00337 void uiBlockSetRegion(uiBlock *block, struct ARegion *region); 00338 00339 void uiBlockSetButLock(uiBlock *block, int val, const char *lockstr); 00340 void uiBlockClearButLock(uiBlock *block); 00341 00342 /* automatic aligning, horiz or verical */ 00343 void uiBlockBeginAlign(uiBlock *block); 00344 void uiBlockEndAlign(uiBlock *block); 00345 00346 /* block bounds/position calculation */ 00347 enum { 00348 UI_BLOCK_BOUNDS=1, 00349 UI_BLOCK_BOUNDS_TEXT, 00350 UI_BLOCK_BOUNDS_POPUP_MOUSE, 00351 UI_BLOCK_BOUNDS_POPUP_MENU, 00352 UI_BLOCK_BOUNDS_POPUP_CENTER 00353 } eBlockBoundsCalc; 00354 00355 void uiBoundsBlock(struct uiBlock *block, int addval); 00356 void uiTextBoundsBlock(uiBlock *block, int addval); 00357 void uiPopupBoundsBlock(uiBlock *block, int addval, int mx, int my); 00358 void uiMenuPopupBoundsBlock(uiBlock *block, int addvall, int mx, int my); 00359 void uiCenteredBoundsBlock(uiBlock *block, int addval); 00360 00361 int uiBlocksGetYMin (struct ListBase *lb); 00362 00363 void uiBlockSetDirection (uiBlock *block, int direction); 00364 void uiBlockFlipOrder (uiBlock *block); 00365 void uiBlockSetFlag (uiBlock *block, int flag); 00366 void uiBlockClearFlag (uiBlock *block, int flag); 00367 void uiBlockSetXOfs (uiBlock *block, int xofs); 00368 00369 int uiButGetRetVal (uiBut *but); 00370 00371 void uiButSetDragID(uiBut *but, struct ID *id); 00372 void uiButSetDragRNA(uiBut *but, struct PointerRNA *ptr); 00373 void uiButSetDragPath(uiBut *but, const char *path); 00374 void uiButSetDragName(uiBut *but, const char *name); 00375 void uiButSetDragValue(uiBut *but); 00376 void uiButSetDragImage(uiBut *but, const char *path, int icon, struct ImBuf *ima, float scale); 00377 00378 int UI_but_active_drop_name(struct bContext *C); 00379 00380 void uiButSetFlag (uiBut *but, int flag); 00381 void uiButClearFlag (uiBut *but, int flag); 00382 00383 /* special button case, only draw it when used actively, for outliner etc */ 00384 int uiButActiveOnly (const struct bContext *C, uiBlock *block, uiBut *but); 00385 00386 00387 /* Buttons 00388 * 00389 * Functions to define various types of buttons in a block. Postfixes: 00390 * - F: float 00391 * - I: int 00392 * - S: short 00393 * - C: char 00394 * - R: RNA 00395 * - O: operator */ 00396 00397 uiBut *uiDefBut(uiBlock *block, 00398 int type, int retval, const char *str, 00399 int x1, int y1, 00400 short x2, short y2, 00401 void *poin, 00402 float min, float max, 00403 float a1, float a2, const char *tip); 00404 uiBut *uiDefButF(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip); 00405 uiBut *uiDefButBitF(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip); 00406 uiBut *uiDefButI(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip); 00407 uiBut *uiDefButBitI(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip); 00408 uiBut *uiDefButS(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip); 00409 uiBut *uiDefButBitS(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip); 00410 uiBut *uiDefButC(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip); 00411 uiBut *uiDefButBitC(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip); 00412 uiBut *uiDefButR(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip); 00413 uiBut *uiDefButR_prop(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip); 00414 uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip); 00415 uiBut *uiDefButTextO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip); 00416 00417 uiBut *uiDefIconBut(uiBlock *block, 00418 int type, int retval, int icon, 00419 int x1, int y1, 00420 short x2, short y2, 00421 void *poin, 00422 float min, float max, 00423 float a1, float a2, const char *tip); 00424 uiBut *uiDefIconButF(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip); 00425 uiBut *uiDefIconButBitF(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip); 00426 uiBut *uiDefIconButI(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip); 00427 uiBut *uiDefIconButBitI(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip); 00428 uiBut *uiDefIconButS(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip); 00429 uiBut *uiDefIconButBitS(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip); 00430 uiBut *uiDefIconButC(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip); 00431 uiBut *uiDefIconButBitC(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip); 00432 uiBut *uiDefIconButR(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip); 00433 uiBut *uiDefIconButR_prop(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip); 00434 uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip); 00435 00436 uiBut *uiDefIconTextBut(uiBlock *block, 00437 int type, int retval, int icon, const char *str, 00438 int x1, int y1, 00439 short x2, short y2, 00440 void *poin, 00441 float min, float max, 00442 float a1, float a2, const char *tip); 00443 uiBut *uiDefIconTextButF(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip); 00444 uiBut *uiDefIconTextButBitF(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip); 00445 uiBut *uiDefIconTextButI(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip); 00446 uiBut *uiDefIconTextButBitI(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip); 00447 uiBut *uiDefIconTextButS(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip); 00448 uiBut *uiDefIconTextButBitS(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip); 00449 uiBut *uiDefIconTextButC(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip); 00450 uiBut *uiDefIconTextButBitC(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip); 00451 uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip); 00452 uiBut *uiDefIconTextButR_prop(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip); 00453 uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip); 00454 00455 /* for passing inputs to ButO buttons */ 00456 struct PointerRNA *uiButGetOperatorPtrRNA(uiBut *but); 00457 00458 void uiButSetUnitType(uiBut *but, const int unit_type); 00459 int uiButGetUnitType(uiBut *but); 00460 00461 /* Special Buttons 00462 * 00463 * Butons with a more specific purpose: 00464 * - IDPoinBut: for creating buttons that work on a pointer to an ID block. 00465 * - MenuBut: buttons that popup a menu (in headers usually). 00466 * - PulldownBut: like MenuBut, but creating a uiBlock (for compatibility). 00467 * - BlockBut: buttons that popup a block with more buttons. 00468 * - KeyevtBut: buttons that can be used to turn key events into values. 00469 * - PickerButtons: buttons like the color picker (for code sharing). 00470 * - AutoButR: RNA property button with type automatically defined. */ 00471 00472 #define UI_ID_RENAME 1 00473 #define UI_ID_BROWSE 2 00474 #define UI_ID_ADD_NEW 4 00475 #define UI_ID_OPEN 8 00476 #define UI_ID_ALONE 16 00477 #define UI_ID_DELETE 32 00478 #define UI_ID_LOCAL 64 00479 #define UI_ID_AUTO_NAME 128 00480 #define UI_ID_FAKE_USER 256 00481 #define UI_ID_PIN 512 00482 #define UI_ID_BROWSE_RENDER 1024 00483 #define UI_ID_PREVIEWS 2048 00484 #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) 00485 00486 typedef void (*uiIDPoinFuncFP)(struct bContext *C, const char *str, struct ID **idpp); 00487 typedef void (*uiIDPoinFunc)(struct bContext *C, struct ID *id, int event); 00488 00489 uiBut *uiDefIDPoinBut(uiBlock *block, uiIDPoinFuncFP func, short blocktype, int retval, const char *str, 00490 int x1, int y1, short x2, short y2, void *idpp, const char *tip); 00491 00492 int uiIconFromID(struct ID *id); 00493 00494 uiBut *uiDefPulldownBut(uiBlock *block, uiBlockCreateFunc func, void *arg, const char *str, int x1, int y1, short x2, short y2, const char *tip); 00495 uiBut *uiDefMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, const char *str, int x1, int y1, short x2, short y2, const char *tip); 00496 uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip); 00497 uiBut *uiDefIconMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, int x1, int y1, short x2, short y2, const char *tip); 00498 00499 uiBut *uiDefBlockBut(uiBlock *block, uiBlockCreateFunc func, void *func_arg1, const char *str, int x1, int y1, short x2, short y2, const char *tip); 00500 uiBut *uiDefBlockButN(uiBlock *block, uiBlockCreateFunc func, void *argN, const char *str, int x1, int y1, short x2, short y2, const char *tip); 00501 00502 uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int retval, int icon, int x1, int y1, short x2, short y2, const char *tip); 00503 uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip); 00504 00505 uiBut *uiDefKeyevtButS(uiBlock *block, int retval, const char *str, int x1, int y1, short x2, short y2, short *spoin, const char *tip); 00506 uiBut *uiDefHotKeyevtButS(uiBlock *block, int retval, const char *str, int x1, int y1, short x2, short y2, short *keypoin, short *modkeypoin, const char *tip); 00507 00508 uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, int x1, int y1, short x2, short y2, float a1, float a2, const char *tip); 00509 00510 void uiBlockPickerButtons(struct uiBlock *block, float *col, float *hsv, float *old, char *hexcol, char mode, short retval); 00511 00512 uiBut *uiDefAutoButR(uiBlock *block, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, const char *name, int icon, int x1, int y1, int x2, int y2); 00513 int uiDefAutoButsRNA(uiLayout *layout, struct PointerRNA *ptr, int (*check_prop)(struct PropertyRNA *), const char label_align); 00514 00515 /* Links 00516 * 00517 * Game engine logic brick links. Non-functional currently in 2.5, 00518 * code to handle and draw these is disabled internally. */ 00519 00520 void uiSetButLink(struct uiBut *but, void **poin, void ***ppoin, short *tot, int from, int to); 00521 00522 void uiComposeLinks(uiBlock *block); 00523 uiBut *uiFindInlink(uiBlock *block, void *poin); 00524 00525 /* Callbacks 00526 * 00527 * uiBlockSetHandleFunc/ButmFunc are for handling events through a callback. 00528 * HandleFunc gets the retval passed on, and ButmFunc gets a2. The latter is 00529 * mostly for compatibility with older code. 00530 * 00531 * uiButSetCompleteFunc is for tab completion. 00532 * 00533 * uiButSearchFunc is for name buttons, showing a popup with matches 00534 * 00535 * uiBlockSetFunc and uiButSetFunc are callbacks run when a button is used, 00536 * in case events, operators or RNA are not sufficient to handle the button. 00537 * 00538 * uiButSetNFunc will free the argument with MEM_freeN. */ 00539 00540 typedef struct uiSearchItems uiSearchItems; 00541 00542 typedef void (*uiButHandleFunc)(struct bContext *C, void *arg1, void *arg2); 00543 typedef void (*uiButHandleRenameFunc)(struct bContext *C, void *arg, char *origstr); 00544 typedef void (*uiButHandleNFunc)(struct bContext *C, void *argN, void *arg2); 00545 typedef void (*uiButCompleteFunc)(struct bContext *C, char *str, void *arg); 00546 typedef void (*uiButSearchFunc)(const struct bContext *C, void *arg, const char *str, uiSearchItems *items); 00547 typedef void (*uiBlockHandleFunc)(struct bContext *C, void *arg, int event); 00548 00549 /* use inside searchfunc to add items */ 00550 int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin, int iconid); 00551 /* bfunc gets search item *poin as arg2, or if NULL the old string */ 00552 void uiButSetSearchFunc (uiBut *but, uiButSearchFunc sfunc, void *arg1, uiButHandleFunc bfunc, void *active); 00553 /* height in pixels, it's using hardcoded values still */ 00554 int uiSearchBoxhHeight(void); 00555 00556 void uiBlockSetHandleFunc(uiBlock *block, uiBlockHandleFunc func, void *arg); 00557 void uiBlockSetButmFunc (uiBlock *block, uiMenuHandleFunc func, void *arg); 00558 void uiBlockSetFunc (uiBlock *block, uiButHandleFunc func, void *arg1, void *arg2); 00559 void uiBlockSetNFunc (uiBlock *block, uiButHandleFunc func, void *argN, void *arg2); 00560 00561 void uiButSetRenameFunc (uiBut *but, uiButHandleRenameFunc func, void *arg1); 00562 void uiButSetFunc (uiBut *but, uiButHandleFunc func, void *arg1, void *arg2); 00563 void uiButSetNFunc (uiBut *but, uiButHandleNFunc func, void *argN, void *arg2); 00564 00565 void uiButSetCompleteFunc(uiBut *but, uiButCompleteFunc func, void *arg); 00566 00567 void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)(const struct bContext *C, void *, void *, void *, struct rcti *rect), void *arg1, void *arg2); 00568 00569 void uiButSetFocusOnEnter (struct wmWindow *win, uiBut *but); 00570 00571 /* Autocomplete 00572 * 00573 * Tab complete helper functions, for use in uiButCompleteFunc callbacks. 00574 * Call begin once, then multiple times do_name with all possibilities, 00575 * and finally end to finish and get the completed name. */ 00576 00577 typedef struct AutoComplete AutoComplete; 00578 00579 AutoComplete *autocomplete_begin(const char *startname, int maxlen); 00580 void autocomplete_do_name(AutoComplete *autocpl, const char *name); 00581 void autocomplete_end(AutoComplete *autocpl, char *autoname); 00582 00583 /* Panels 00584 * 00585 * Functions for creating, freeing and drawing panels. The API here 00586 * could use a good cleanup, though how they will function in 2.5 is 00587 * not clear yet so we postpone that. */ 00588 00589 void uiBeginPanels(const struct bContext *C, struct ARegion *ar); 00590 void uiEndPanels(const struct bContext *C, struct ARegion *ar); 00591 00592 struct Panel *uiBeginPanel(struct ScrArea *sa, struct ARegion *ar, uiBlock *block, struct PanelType *pt, int *open); 00593 void uiEndPanel(uiBlock *block, int width, int height); 00594 00595 /* Handlers 00596 * 00597 * Handlers that can be registered in regions, areas and windows for 00598 * handling WM events. Mostly this is done automatic by modules such 00599 * as screen/ if ED_KEYMAP_UI is set, or internally in popup functions. */ 00600 00601 void UI_add_region_handlers(struct ListBase *handlers); 00602 void UI_add_area_handlers(struct ListBase *handlers); 00603 void UI_add_popup_handlers(struct bContext *C, struct ListBase *handlers, uiPopupBlockHandle *popup); 00604 void UI_remove_popup_handlers(struct ListBase *handlers, uiPopupBlockHandle *popup); 00605 00606 /* Module 00607 * 00608 * init and exit should be called before using this module. init_userdef must 00609 * be used to reinitialize some internal state if user preferences change. */ 00610 00611 void UI_init(void); 00612 void UI_init_userdef(void); 00613 void UI_exit(void); 00614 00615 /* Layout 00616 * 00617 * More automated layout of buttons. Has three levels: 00618 * - Layout: contains a number templates, within a bounded width or height. 00619 * - Template: predefined layouts for buttons with a number of slots, each 00620 * slot can contain multiple items. 00621 * - Item: item to put in a template slot, being either an RNA property, 00622 * operator, label or menu. Also regular buttons can be used when setting 00623 * uiBlockCurLayout. */ 00624 00625 /* layout */ 00626 #define UI_LAYOUT_HORIZONTAL 0 00627 #define UI_LAYOUT_VERTICAL 1 00628 00629 #define UI_LAYOUT_PANEL 0 00630 #define UI_LAYOUT_HEADER 1 00631 #define UI_LAYOUT_MENU 2 00632 #define UI_LAYOUT_TOOLBAR 3 00633 00634 #define UI_UNIT_X U.widget_unit 00635 #define UI_UNIT_Y U.widget_unit 00636 00637 #define UI_LAYOUT_ALIGN_EXPAND 0 00638 #define UI_LAYOUT_ALIGN_LEFT 1 00639 #define UI_LAYOUT_ALIGN_CENTER 2 00640 #define UI_LAYOUT_ALIGN_RIGHT 3 00641 00642 #define UI_ITEM_O_RETURN_PROPS 1 00643 #define UI_ITEM_R_EXPAND 2 00644 #define UI_ITEM_R_SLIDER 4 00645 #define UI_ITEM_R_TOGGLE 8 00646 #define UI_ITEM_R_ICON_ONLY 16 00647 #define UI_ITEM_R_EVENT 32 00648 #define UI_ITEM_R_FULL_EVENT 64 00649 #define UI_ITEM_R_NO_BG 128 00650 #define UI_ITEM_R_IMMEDIATE 256 00651 00652 /* uiLayoutOperatorButs flags */ 00653 #define UI_LAYOUT_OP_SHOW_TITLE 1 00654 #define UI_LAYOUT_OP_SHOW_EMPTY 2 00655 00656 uiLayout *uiBlockLayout(uiBlock *block, int dir, int type, int x, int y, int size, int em, struct uiStyle *style); 00657 void uiBlockSetCurLayout(uiBlock *block, uiLayout *layout); 00658 void uiBlockLayoutResolve(uiBlock *block, int *x, int *y); 00659 00660 uiBlock *uiLayoutGetBlock(uiLayout *layout); 00661 00662 void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv); 00663 void uiLayoutSetContextPointer(uiLayout *layout, const char *name, struct PointerRNA *ptr); 00664 const char *uiLayoutIntrospect(uiLayout *layout); // XXX - testing 00665 void uiLayoutOperatorButs(const struct bContext *C, struct uiLayout *layout, struct wmOperator *op, int (*check_prop)(struct PropertyRNA *), const char label_align, const short flag); 00666 00667 void uiLayoutSetOperatorContext(uiLayout *layout, int opcontext); 00668 void uiLayoutSetActive(uiLayout *layout, int active); 00669 void uiLayoutSetEnabled(uiLayout *layout, int enabled); 00670 void uiLayoutSetRedAlert(uiLayout *layout, int redalert); 00671 void uiLayoutSetAlignment(uiLayout *layout, int alignment); 00672 void uiLayoutSetKeepAspect(uiLayout *layout, int keepaspect); 00673 void uiLayoutSetScaleX(uiLayout *layout, float scale); 00674 void uiLayoutSetScaleY(uiLayout *layout, float scale); 00675 00676 int uiLayoutGetOperatorContext(uiLayout *layout); 00677 int uiLayoutGetActive(uiLayout *layout); 00678 int uiLayoutGetEnabled(uiLayout *layout); 00679 int uiLayoutGetRedAlert(uiLayout *layout); 00680 int uiLayoutGetAlignment(uiLayout *layout); 00681 int uiLayoutGetKeepAspect(uiLayout *layout); 00682 int uiLayoutGetWidth(uiLayout *layout); 00683 float uiLayoutGetScaleX(uiLayout *layout); 00684 float uiLayoutGetScaleY(uiLayout *layout); 00685 00686 /* layout specifiers */ 00687 uiLayout *uiLayoutRow(uiLayout *layout, int align); 00688 uiLayout *uiLayoutColumn(uiLayout *layout, int align); 00689 uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, int align); 00690 uiLayout *uiLayoutBox(uiLayout *layout); 00691 uiLayout *uiLayoutListBox(uiLayout *layout, struct PointerRNA *ptr, struct PropertyRNA *prop, 00692 struct PointerRNA *actptr, struct PropertyRNA *actprop); 00693 uiLayout *uiLayoutAbsolute(uiLayout *layout, int align); 00694 uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, int align); 00695 uiLayout *uiLayoutOverlap(uiLayout *layout); 00696 00697 uiBlock *uiLayoutAbsoluteBlock(uiLayout *layout); 00698 00699 /* templates */ 00700 void uiTemplateHeader(uiLayout *layout, struct bContext *C, int menus); 00701 void uiTemplateDopeSheetFilter(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr); 00702 void uiTemplateID(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, 00703 const char *newop, const char *openop, const char *unlinkop); 00704 void uiTemplateIDBrowse(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, 00705 const char *newop, const char *openop, const char *unlinkop); 00706 void uiTemplateIDPreview(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, 00707 const char *newop, const char *openop, const char *unlinkop, int rows, int cols); 00708 void uiTemplateAnyID(uiLayout *layout, struct PointerRNA *ptr, const char *propname, 00709 const char *proptypename, const char *text); 00710 void uiTemplatePathBuilder(uiLayout *layout, struct PointerRNA *ptr, const char *propname, 00711 struct PointerRNA *root_ptr, const char *text); 00712 uiLayout *uiTemplateModifier(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr); 00713 uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr); 00714 void uiTemplatePreview(uiLayout *layout, struct ID *id, int show_buttons, struct ID *parent, struct MTex *slot); 00715 void uiTemplateColorRamp(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int expand); 00716 void uiTemplateHistogram(uiLayout *layout, struct PointerRNA *ptr, const char *propname); 00717 void uiTemplateWaveform(uiLayout *layout, struct PointerRNA *ptr, const char *propname); 00718 void uiTemplateVectorscope(uiLayout *layout, struct PointerRNA *ptr, const char *propname); 00719 void uiTemplateCurveMapping(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int type, int levels, int brush); 00720 void uiTemplateColorWheel(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int value_slider, int lock, int lock_luminosity, int cubic); 00721 void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, const char *propname, 00722 PointerRNA *used_ptr, const char *used_propname, int active_layer); 00723 void uiTemplateImage(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr, int compact); 00724 void uiTemplateImageLayers(uiLayout *layout, struct bContext *C, struct Image *ima, struct ImageUser *iuser); 00725 void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C); 00726 void uiTemplateOperatorSearch(uiLayout *layout); 00727 void uiTemplateHeader3D(uiLayout *layout, struct bContext *C); 00728 void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C); 00729 void uiTemplateTextureImage(uiLayout *layout, struct bContext *C, struct Tex *tex); 00730 void uiTemplateReportsBanner(uiLayout *layout, struct bContext *C); 00731 00732 void uiTemplateList(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *activeptr, const char *activeprop, int rows, int maxrows, int type); 00733 00734 /* items */ 00735 void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname); 00736 void uiItemEnumO(uiLayout *layout, const char *opname, const char *name, int icon, const char *propname, int value); 00737 void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value); 00738 void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value); 00739 void uiItemsEnumO(uiLayout *layout, const char *opname, const char *propname); 00740 void uiItemBooleanO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value); 00741 void uiItemIntO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value); 00742 void uiItemFloatO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, float value); 00743 void uiItemStringO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value); 00744 PointerRNA uiItemFullO(uiLayout *layout, const char *idname, const char *name, int icon, struct IDProperty *properties, int context, int flag); 00745 00746 void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon); 00747 void uiItemFullR(uiLayout *layout, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, int value, int flag, const char *name, int icon); 00748 void uiItemEnumR(uiLayout *layout, const char *name, int icon, struct PointerRNA *ptr, const char *propname, int value); 00749 void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *value, const char *name, int icon); 00750 void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname); 00751 void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *searchptr, const char *searchpropname, const char *name, int icon); 00752 void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname, struct IDProperty *properties, int context, int flag); 00753 00754 void uiItemL(uiLayout *layout, const char *name, int icon); /* label */ 00755 void uiItemLDrag(uiLayout *layout, struct PointerRNA *ptr, const char *name, int icon); /* label icon for dragging */ 00756 void uiItemM(uiLayout *layout, struct bContext *C, const char *menuname, const char *name, int icon); /* menu */ 00757 void uiItemV(uiLayout *layout, const char *name, int icon, int argval); /* value */ 00758 void uiItemS(uiLayout *layout); /* separator */ 00759 00760 void uiItemMenuF(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *arg); 00761 void uiItemMenuEnumO(uiLayout *layout, const char *opname, const char *propname, const char *name, int icon); 00762 void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name, int icon); 00763 00764 /* UI Operators */ 00765 void UI_buttons_operatortypes(void); 00766 00767 /* Helpers for Operators */ 00768 void uiContextActiveProperty(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index); 00769 void uiContextAnimUpdate(const struct bContext *C); 00770 void uiFileBrowseContextProperty(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop); 00771 void uiIDContextProperty(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop); 00772 00773 /* Styled text draw */ 00774 void uiStyleFontSet(struct uiFontStyle *fs); 00775 void uiStyleFontDrawExt(struct uiFontStyle *fs, struct rcti *rect, const char *str, 00776 float *r_xofs, float *r_yofs); 00777 void uiStyleFontDraw(struct uiFontStyle *fs, struct rcti *rect, const char *str); 00778 void uiStyleFontDrawRotated(struct uiFontStyle *fs, struct rcti *rect, const char *str); 00779 00780 int UI_GetStringWidth(const char *str); // XXX temp 00781 void UI_DrawString(float x, float y, const char *str); // XXX temp 00782 void UI_DrawTriIcon(float x, float y, char dir); 00783 00784 /* linker workaround ack! */ 00785 void UI_template_fix_linking(void); 00786 00787 #endif /* UI_INTERFACE_H */ 00788