Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00019 * All rights reserved. 00020 * 00021 * The Original Code is: all of this file. 00022 * 00023 * Contributor(s): none yet. 00024 * 00025 * ***** END GPL LICENSE BLOCK ***** 00026 */ 00027 00033 #ifndef INTERFACE_H 00034 #define INTERFACE_H 00035 00036 #include "UI_resources.h" 00037 #include "RNA_types.h" 00038 00039 struct ARegion; 00040 struct bContext; 00041 struct IDProperty; 00042 struct uiHandleButtonData; 00043 struct wmEvent; 00044 struct wmOperatorType; 00045 struct wmWindow; 00046 struct wmTimer; 00047 struct uiStyle; 00048 struct uiWidgetColors; 00049 struct uiLayout; 00050 struct bContextStore; 00051 struct Scene; 00052 struct ID; 00053 struct ImBuf; 00054 00055 /* ****************** general defines ************** */ 00056 00057 /* visual types for drawing */ 00058 /* for time being separated from functional types */ 00059 typedef enum { 00060 /* default */ 00061 UI_WTYPE_REGULAR, 00062 00063 /* standard set */ 00064 UI_WTYPE_LABEL, 00065 UI_WTYPE_TOGGLE, 00066 UI_WTYPE_OPTION, 00067 UI_WTYPE_RADIO, 00068 UI_WTYPE_NUMBER, 00069 UI_WTYPE_SLIDER, 00070 UI_WTYPE_EXEC, 00071 00072 /* strings */ 00073 UI_WTYPE_NAME, 00074 UI_WTYPE_NAME_LINK, 00075 UI_WTYPE_POINTER_LINK, 00076 UI_WTYPE_FILENAME, 00077 00078 /* menus */ 00079 UI_WTYPE_MENU_RADIO, 00080 UI_WTYPE_MENU_ICON_RADIO, 00081 UI_WTYPE_MENU_POINTER_LINK, 00082 UI_WTYPE_MENU_NODE_LINK, 00083 00084 UI_WTYPE_PULLDOWN, 00085 UI_WTYPE_MENU_ITEM, 00086 UI_WTYPE_MENU_BACK, 00087 00088 /* specials */ 00089 UI_WTYPE_ICON, 00090 UI_WTYPE_SWATCH, 00091 UI_WTYPE_RGB_PICKER, 00092 UI_WTYPE_NORMAL, 00093 UI_WTYPE_BOX, 00094 UI_WTYPE_SCROLL, 00095 UI_WTYPE_LISTITEM, 00096 UI_WTYPE_PROGRESSBAR, 00097 00098 } uiWidgetTypeEnum; 00099 00100 /* panel limits */ 00101 #define UI_PANEL_MINX 100 00102 #define UI_PANEL_MINY 70 00103 00104 /* uiBut->flag */ 00105 #define UI_SELECT 1 /* use when the button is pressed */ 00106 #define UI_SCROLLED 2 /* temp hidden, scrolled away */ 00107 #define UI_ACTIVE 4 00108 #define UI_HAS_ICON 8 00109 #define UI_TEXTINPUT 16 00110 #define UI_HIDDEN 32 00111 /* warn: rest of uiBut->flag in UI_interface.h */ 00112 00113 /* internal panel drawing defines */ 00114 #define PNL_GRID (UI_UNIT_Y / 5) /* 4 default */ 00115 #define PNL_HEADER (UI_UNIT_Y + 4) /* 24 default */ 00116 00117 /* panel->flag */ 00118 #define PNL_SELECT 1 00119 #define PNL_CLOSEDX 2 00120 #define PNL_CLOSEDY 4 00121 #define PNL_CLOSED 6 00122 /*#define PNL_TABBED 8*/ /*UNUSED*/ 00123 #define PNL_OVERLAP 16 00124 00125 /* Button text selection: 00126 * extension direction, selextend, inside ui_do_but_TEX */ 00127 #define EXTEND_LEFT 1 00128 #define EXTEND_RIGHT 2 00129 00130 /* for scope resize zone */ 00131 #define SCOPE_RESIZE_PAD 9 00132 00133 typedef struct uiLinkLine { /* only for draw/edit */ 00134 struct uiLinkLine *next, *prev; 00135 struct uiBut *from, *to; 00136 short flag, pad; 00137 } uiLinkLine; 00138 00139 typedef struct { 00140 void **poin; /* pointer to original pointer */ 00141 void ***ppoin; /* pointer to original pointer-array */ 00142 short *totlink; /* if pointer-array, here is the total */ 00143 00144 short maxlink, pad; 00145 short fromcode, tocode; 00146 00147 ListBase lines; 00148 } uiLink; 00149 00150 struct uiBut { 00151 struct uiBut *next, *prev; 00152 int flag; 00153 short type, pointype, bit, bitnr, retval, strwidth, ofs, pos, selsta, selend, alignnr; 00154 short pad1; 00155 00156 char *str; 00157 char strdata[UI_MAX_NAME_STR]; 00158 char drawstr[UI_MAX_DRAW_STR]; 00159 00160 float x1, y1, x2, y2; 00161 00162 char *poin; 00163 float hardmin, hardmax, softmin, softmax; 00164 float a1, a2; 00165 float aspect; 00166 char col[4]; 00167 00168 uiButHandleFunc func; 00169 void *func_arg1; 00170 void *func_arg2; 00171 void *func_arg3; 00172 00173 uiButHandleNFunc funcN; 00174 void *func_argN; 00175 00176 struct bContextStore *context; 00177 00178 /* not ysed yet, was used in 2.4x for ui_draw_pulldown_round & friends */ 00179 /* 00180 void (*embossfunc)(int , int , float, float, float, float, float, int); 00181 void (*sliderfunc)(int , float, float, float, float, float, float, int); 00182 */ 00183 00184 uiButCompleteFunc autocomplete_func; 00185 void *autofunc_arg; 00186 00187 uiButSearchFunc search_func; 00188 void *search_arg; 00189 00190 uiButHandleRenameFunc rename_func; 00191 void *rename_arg1; 00192 void *rename_orig; 00193 00194 uiLink *link; 00195 short linkto[2]; 00196 00197 const char *tip, *lockstr; 00198 00199 BIFIconID icon; 00200 char lock; 00201 char dt; /* drawtype: UI_EMBOSS, UI_EMBOSSN ... etc, copied from the block */ 00202 char changed; /* could be made into a single flag */ 00203 unsigned char unit_type; /* so buttons can support unit systems which are not RNA */ 00204 short modifier_key; 00205 short iconadd; 00206 00207 /* IDPOIN data */ 00208 uiIDPoinFuncFP idpoin_func; 00209 ID **idpoin_idpp; 00210 00211 /* BLOCK data */ 00212 uiBlockCreateFunc block_create_func; 00213 00214 /* PULLDOWN/MENU data */ 00215 uiMenuCreateFunc menu_create_func; 00216 00217 /* RNA data */ 00218 struct PointerRNA rnapoin; 00219 struct PropertyRNA *rnaprop; 00220 int rnaindex; 00221 00222 struct PointerRNA rnasearchpoin; 00223 struct PropertyRNA *rnasearchprop; 00224 00225 /* Operator data */ 00226 struct wmOperatorType *optype; 00227 struct IDProperty *opproperties; 00228 struct PointerRNA *opptr; 00229 short opcontext; 00230 unsigned char menu_key; /* 'a'-'z', always lower case */ 00231 00232 /* Draggable data, type is WM_DRAG_... */ 00233 char dragtype; 00234 void *dragpoin; 00235 struct ImBuf *imb; 00236 float imb_scale; 00237 00238 /* active button data */ 00239 struct uiHandleButtonData *active; 00240 00241 char *editstr; 00242 double *editval; 00243 float *editvec; 00244 void *editcoba; 00245 void *editcumap; 00246 00247 /* pointer back */ 00248 uiBlock *block; 00249 }; 00250 00251 struct uiBlock { 00252 uiBlock *next, *prev; 00253 00254 ListBase buttons; 00255 Panel *panel; 00256 uiBlock *oldblock; 00257 00258 ListBase layouts; 00259 struct uiLayout *curlayout; 00260 00261 ListBase contexts; 00262 00263 char name[UI_MAX_NAME_STR]; 00264 00265 float winmat[4][4]; 00266 00267 float minx, miny, maxx, maxy; 00268 float aspect; 00269 00270 int puphash; // popup menu hash for memory 00271 00272 uiButHandleFunc func; 00273 void *func_arg1; 00274 void *func_arg2; 00275 00276 uiButHandleNFunc funcN; 00277 void *func_argN; 00278 00279 uiMenuHandleFunc butm_func; 00280 void *butm_func_arg; 00281 00282 uiBlockHandleFunc handle_func; 00283 void *handle_func_arg; 00284 00285 /* custom extra handling */ 00286 int (*block_event_func)(const struct bContext *C, struct uiBlock *, struct wmEvent *); 00287 00288 /* extra draw function for custom blocks */ 00289 void (*drawextra)(const struct bContext *C, void *idv, void *arg1, void *arg2, rcti *rect); 00290 void *drawextra_arg1; 00291 void *drawextra_arg2; 00292 00293 int flag; 00294 short alignnr; 00295 00296 char direction; 00297 char dt; /* drawtype: UI_EMBOSS, UI_EMBOSSN ... etc, copied to buttons */ 00298 char auto_open; 00299 char _pad[7]; 00300 double auto_open_last; 00301 00302 const char *lockstr; 00303 00304 char lock; 00305 char active; // to keep blocks while drawing and free them afterwards 00306 char tooltipdisabled; // to avoid tooltip after click 00307 char endblock; // uiEndBlock done? 00308 00309 float xofs, yofs; // offset to parent button 00310 int dobounds, mx, my; // for doing delayed 00311 int bounds, minbounds; // for doing delayed 00312 00313 rctf safety; // pulldowns, to detect outside, can differ per case how it is created 00314 ListBase saferct; // uiSafetyRct list 00315 00316 uiPopupBlockHandle *handle; // handle 00317 00318 struct wmOperator *ui_operator;// use so presets can find the operator, 00319 // across menus and from nested popups which fail for operator context. 00320 00321 void *evil_C; // XXX hack for dynamic operator enums 00322 00323 struct UnitSettings *unit; // unit system, used a lot for numeric buttons so include here rather then fetching through the scene every time. 00324 float _hsv[3]; // XXX, only access via ui_block_hsv_get() 00325 char color_profile; // color profile for correcting linear colors for display 00326 }; 00327 00328 typedef struct uiSafetyRct { 00329 struct uiSafetyRct *next, *prev; 00330 rctf parent; 00331 rctf safety; 00332 } uiSafetyRct; 00333 00334 /* interface.c */ 00335 00336 extern void ui_delete_linkline(uiLinkLine *line, uiBut *but); 00337 00338 void ui_fontscale(short *points, float aspect); 00339 00340 extern void ui_block_to_window_fl(const struct ARegion *ar, uiBlock *block, float *x, float *y); 00341 extern void ui_block_to_window(const struct ARegion *ar, uiBlock *block, int *x, int *y); 00342 extern void ui_block_to_window_rct(const struct ARegion *ar, uiBlock *block, rctf *graph, rcti *winr); 00343 extern void ui_window_to_block_fl(const struct ARegion *ar, uiBlock *block, float *x, float *y); 00344 extern void ui_window_to_block(const struct ARegion *ar, uiBlock *block, int *x, int *y); 00345 extern void ui_window_to_region(const ARegion *ar, int *x, int *y); 00346 00347 extern double ui_get_but_val(uiBut *but); 00348 extern void ui_set_but_val(uiBut *but, double value); 00349 extern void ui_set_but_hsv(uiBut *but); 00350 extern void ui_get_but_vectorf(uiBut *but, float vec[3]); 00351 extern void ui_set_but_vectorf(uiBut *but, const float vec[3]); 00352 00353 extern void ui_hsvcircle_vals_from_pos(float *valrad, float *valdist, rcti *rect, float mx, float my); 00354 00355 extern void ui_get_but_string(uiBut *but, char *str, size_t maxlen); 00356 extern void ui_convert_to_unit_alt_name(uiBut *but, char *str, size_t maxlen); 00357 extern int ui_set_but_string(struct bContext *C, uiBut *but, const char *str); 00358 extern int ui_get_but_string_max_length(uiBut *but); 00359 00360 extern void ui_set_but_default(struct bContext *C, short all); 00361 00362 extern void ui_set_but_soft_range(uiBut *but, double value); 00363 00364 extern void ui_check_but(uiBut *but); 00365 extern int ui_is_but_float(uiBut *but); 00366 extern int ui_is_but_unit(uiBut *but); 00367 extern int ui_is_but_rna_valid(uiBut *but); 00368 extern int ui_is_but_utf8(uiBut *but); 00369 00370 extern void ui_bounds_block(uiBlock *block); 00371 extern void ui_block_translate(uiBlock *block, int x, int y); 00372 extern void ui_block_do_align(uiBlock *block); 00373 00374 /* interface_regions.c */ 00375 00376 struct uiPopupBlockHandle { 00377 /* internal */ 00378 struct ARegion *region; 00379 int towardsx, towardsy; 00380 double towardstime; 00381 int dotowards; 00382 00383 int popup; 00384 void (*popup_func)(struct bContext *C, void *arg, int event); 00385 void (*cancel_func)(void *arg); 00386 void *popup_arg; 00387 00388 struct wmTimer *scrolltimer; 00389 00390 /* for operator popups */ 00391 struct wmOperatorType *optype; 00392 ScrArea *ctx_area; 00393 ARegion *ctx_region; 00394 int opcontext; 00395 00396 /* return values */ 00397 int butretval; 00398 int menuretval; 00399 float retvalue; 00400 float retvec[4]; 00401 }; 00402 00403 uiBlock *ui_block_func_COL(struct bContext *C, uiPopupBlockHandle *handle, void *arg_but); 00404 void ui_block_func_ICONROW(struct bContext *C, uiLayout *layout, void *arg_but); 00405 void ui_block_func_ICONTEXTROW(struct bContext *C, uiLayout *layout, void *arg_but); 00406 00407 struct ARegion *ui_tooltip_create(struct bContext *C, struct ARegion *butregion, uiBut *but); 00408 void ui_tooltip_free(struct bContext *C, struct ARegion *ar); 00409 00410 uiBut *ui_popup_menu_memory(struct uiBlock *block, struct uiBut *but); 00411 00412 float *ui_block_hsv_get(struct uiBlock *block); 00413 void ui_popup_block_scrolltest(struct uiBlock *block); 00414 00415 00416 /* searchbox for string button */ 00417 ARegion *ui_searchbox_create(struct bContext *C, struct ARegion *butregion, uiBut *but); 00418 int ui_searchbox_inside(struct ARegion *ar, int x, int y); 00419 void ui_searchbox_update(struct bContext *C, struct ARegion *ar, uiBut *but, int reset); 00420 void ui_searchbox_autocomplete(struct bContext *C, struct ARegion *ar, uiBut *but, char *str); 00421 void ui_searchbox_event(struct bContext *C, struct ARegion *ar, uiBut *but, struct wmEvent *event); 00422 void ui_searchbox_apply(uiBut *but, struct ARegion *ar); 00423 void ui_searchbox_free(struct bContext *C, struct ARegion *ar); 00424 void ui_but_search_test(uiBut *but); 00425 00426 typedef uiBlock* (*uiBlockHandleCreateFunc)(struct bContext *C, struct uiPopupBlockHandle *handle, void *arg1); 00427 00428 uiPopupBlockHandle *ui_popup_block_create(struct bContext *C, struct ARegion *butregion, uiBut *but, 00429 uiBlockCreateFunc create_func, uiBlockHandleCreateFunc handle_create_func, void *arg); 00430 uiPopupBlockHandle *ui_popup_menu_create(struct bContext *C, struct ARegion *butregion, uiBut *but, 00431 uiMenuCreateFunc create_func, void *arg, char *str); 00432 00433 void ui_popup_block_free(struct bContext *C, uiPopupBlockHandle *handle); 00434 00435 void ui_set_name_menu(uiBut *but, int value); 00436 int ui_step_name_menu(uiBut *but, int step); 00437 00438 struct AutoComplete; 00439 00440 /* interface_panel.c */ 00441 extern int ui_handler_panel_region(struct bContext *C, struct wmEvent *event); 00442 extern void ui_draw_aligned_panel(struct uiStyle *style, uiBlock *block, rcti *rect); 00443 00444 /* interface_draw.c */ 00445 extern void ui_dropshadow(rctf *rct, float radius, float aspect, int select); 00446 00447 void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha); 00448 00449 void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect); 00450 void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect); 00451 void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect); 00452 void ui_draw_but_COLORBAND(uiBut *but, struct uiWidgetColors *wcol, rcti *rect); 00453 void ui_draw_but_NORMAL(uiBut *but, struct uiWidgetColors *wcol, rcti *rect); 00454 void ui_draw_but_CURVE(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect); 00455 void ui_draw_but_IMAGE(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect); 00456 void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect); 00457 00458 /* interface_handlers.c */ 00459 extern void ui_button_activate_do(struct bContext *C, struct ARegion *ar, uiBut *but); 00460 extern void ui_button_active_free(const struct bContext *C, uiBut *but); 00461 extern int ui_button_is_active(struct ARegion *ar); 00462 00463 /* interface_widgets.c */ 00464 void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3); 00465 void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float maxy, float rad); 00466 void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect); 00467 void ui_draw_search_back(struct uiStyle *style, uiBlock *block, rcti *rect); 00468 int ui_link_bezier_points(rcti *rect, float coord_array[][2], int resol); 00469 void ui_draw_link_bezier(rcti *rect); 00470 00471 extern void ui_draw_but(const struct bContext *C, ARegion *ar, struct uiStyle *style, uiBut *but, rcti *rect); 00472 /* theme color init */ 00473 struct ThemeUI; 00474 void ui_widget_color_init(struct ThemeUI *tui); 00475 00476 void ui_draw_menu_item(struct uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state); 00477 void ui_draw_preview_item(struct uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state); 00478 00479 extern unsigned char checker_stipple_sml[]; 00480 /* used for transp checkers */ 00481 #define UI_TRANSP_DARK 100 00482 #define UI_TRANSP_LIGHT 160 00483 00484 /* interface_style.c */ 00485 void uiStyleInit(void); 00486 00487 /* interface_icons.c */ 00488 int ui_id_icon_get(struct bContext *C, struct ID *id, int preview); 00489 00490 /* resources.c */ 00491 void init_userdef_do_versions(void); 00492 void ui_theme_init_default(void); 00493 void ui_resources_init(void); 00494 void ui_resources_free(void); 00495 00496 /* interface_layout.c */ 00497 void ui_layout_add_but(uiLayout *layout, uiBut *but); 00498 int ui_but_can_align(uiBut *but); 00499 void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *searchptr, PropertyRNA *searchprop); 00500 00501 /* interface_anim.c */ 00502 void ui_but_anim_flag(uiBut *but, float cfra); 00503 void ui_but_anim_insert_keyframe(struct bContext *C); 00504 void ui_but_anim_delete_keyframe(struct bContext *C); 00505 void ui_but_anim_add_driver(struct bContext *C); 00506 void ui_but_anim_remove_driver(struct bContext *C); 00507 void ui_but_anim_copy_driver(struct bContext *C); 00508 void ui_but_anim_paste_driver(struct bContext *C); 00509 void ui_but_anim_add_keyingset(struct bContext *C); 00510 void ui_but_anim_remove_keyingset(struct bContext *C); 00511 int ui_but_anim_expression_get(uiBut *but, char *str, size_t maxlen); 00512 int ui_but_anim_expression_set(uiBut *but, const char *str); 00513 int ui_but_anim_expression_create(uiBut *but, const char *str); 00514 void ui_but_anim_autokey(struct bContext *C, uiBut *but, struct Scene *scene, float cfra); 00515 00516 #endif 00517