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