2 * $Id: interface.h 14444 2008-04-16 22:40:48Z hos $
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 *****
33 #include "UI_resources.h"
34 #include "RNA_types.h"
36 struct uiHandleButtonData;
43 #define UI_MAX_DRAW_STR 400
44 #define UI_MAX_NAME_STR 64
48 #define UI_PANEL_MINX 100
49 #define UI_PANEL_MINY 70
53 #define UI_MOUSE_OVER 2
56 /* warn: rest of uiBut->flag in BIF_interface.c */
58 /* internal panel drawing defines */
70 #define PNL_OVERLAP 16
72 /* Button text selection:
73 * extension direction, selextend, inside ui_do_but_TEX */
75 #define EXTEND_RIGHT 2
90 void *xl, *large, *medium, *small;
93 typedef struct uiLinkLine { /* only for draw/edit */
94 struct uiLinkLine *next, *prev;
98 struct uiBut *from, *to;
102 void **poin; /* pointer to original pointer */
103 void ***ppoin; /* pointer to original pointer-array */
104 short *totlink; /* if pointer-array, here is the total */
107 short fromcode, tocode;
113 struct uiBut *next, *prev;
114 short type, pointype, bit, bitnr, retval, strwidth, ofs, pos, selsta, selend;
118 char strdata[UI_MAX_NAME_STR];
119 char drawstr[UI_MAX_DRAW_STR];
121 float x1, y1, x2, y2;
125 float a1, a2, hsv[3]; // hsv is temp memory for hsv buttons
128 void (*func)(struct bContext*, void *, void *);
132 void (*handle_func)(struct bContext*, void *arg, int event);
133 void *handle_func_arg;
135 void (*embossfunc)(int , int , float, float, float, float, float, int);
136 void (*sliderfunc)(int , float, float, float, float, float, float, int);
138 void (*autocomplete_func)(struct bContext*, char *, void *);
145 int themecol; /* themecolor id */
149 short but_align; /* aligning buttons, horiz/vertical */
154 uiIDPoinFuncFP idpoin_func;
158 uiBlockFuncFP block_func;
161 struct PointerRNA rnapoin;
162 struct PropertyRNA *rnaprop;
165 /* activation button data */
166 struct uiHandleButtonData *active;
179 uiBlock *next, *prev;
185 char name[UI_MAX_NAME_STR];
189 float minx, miny, maxx, maxy;
192 void (*func)(struct bContext*, void *arg1, void *arg2);
196 void (*butm_func)(struct bContext*, void *arg, int but_a2);
199 void (*handle_func)(struct bContext*, void *arg, int event);
200 void *handle_func_arg;
202 /* extra draw function for custom blocks */
205 int themecol; /* themecolor id */
207 short font; /* indices */
211 short autofill, win, winq, direction, dt;
212 short auto_open, in_use, pad;
213 double auto_open_last;
218 float xofs, yofs; // offset to parent button
220 rctf safety; // pulldowns, to detect outside, can differ per case how it is created
221 ListBase saferct; // uiSafetyRct list
223 uiMenuBlockHandle *handle; // handle
224 int tooltipdisabled; // to avoid tooltip after click
227 typedef struct uiSafetyRct {
228 struct uiSafetyRct *next, *prev;
235 extern int ui_translate_buttons(void);
236 extern int ui_translate_menus(void);
237 extern int ui_translate_tooltips(void);
239 extern void ui_block_to_window_fl(const struct ARegion *ar, uiBlock *block, float *x, float *y);
240 extern void ui_block_to_window(const struct ARegion *ar, uiBlock *block, int *x, int *y);
241 extern void ui_block_to_window_rct(const struct ARegion *ar, uiBlock *block, rctf *graph, rcti *winr);
242 extern void ui_window_to_block_fl(const struct ARegion *ar, uiBlock *block, float *x, float *y);
243 extern void ui_window_to_block(const struct ARegion *ar, uiBlock *block, int *x, int *y);
244 extern void ui_window_to_region(const ARegion *ar, int *x, int *y);
246 extern double ui_get_but_val(uiBut *but);
247 extern void ui_set_but_val(uiBut *but, double value);
248 extern void ui_set_but_hsv(uiBut *but);
249 extern void ui_get_but_vectorf(uiBut *but, float *vec);
250 extern void ui_set_but_vectorf(uiBut *but, float *vec);
251 extern void ui_get_but_string(uiBut *but, char *str, int maxlen);
252 extern void ui_set_but_string(uiBut *but, const char *str);
254 extern void ui_check_but(uiBut *but);
255 extern void ui_autofill(uiBlock *block);
256 extern int ui_is_but_float(uiBut *but);
257 extern void ui_update_block_buts_hsv(uiBlock *block, float *hsv);
259 /* interface_regions.c */
260 uiBlock *ui_block_func_MENU(struct bContext *C, uiMenuBlockHandle *handle, void *arg_but);
261 uiBlock *ui_block_func_ICONROW(struct bContext *C, uiMenuBlockHandle *handle, void *arg_but);
262 uiBlock *ui_block_func_ICONTEXTROW(struct bContext *C, uiMenuBlockHandle *handle, void *arg_but);
263 uiBlock *ui_block_func_COL(struct bContext *C, uiMenuBlockHandle *handle, void *arg_but);
265 struct ARegion *ui_tooltip_create(struct bContext *C, struct ARegion *butregion, uiBut *but);
266 void ui_tooltip_free(struct bContext *C, struct ARegion *ar);
268 uiMenuBlockHandle *ui_menu_block_create(struct bContext *C, struct ARegion *butregion, uiBut *but,
269 uiBlockFuncFP block_func, void *arg);
270 void ui_menu_block_free(struct bContext *C, uiMenuBlockHandle *handle);
272 void ui_set_name_menu(uiBut *but, int value);
274 /* interface_panel.c */
275 extern void ui_draw_panel(uiBlock *block);
276 extern void ui_do_panel(uiBlock *block, uiEvent *uevent);
277 extern void ui_scale_panel(uiBlock *block);
278 extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad);
279 extern void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown);
281 /* interface_draw.c */
282 extern void ui_set_embossfunc(uiBut *but, int drawtype);
283 extern void ui_draw_but(uiBut *but);
284 extern void ui_rasterpos_safe(float x, float y, float aspect);
285 extern void ui_draw_tria_icon(float x, float y, float aspect, char dir);
286 extern void ui_draw_anti_x(float x1, float y1, float x2, float y2);
287 extern void ui_dropshadow(rctf *rct, float radius, float aspect, int select);
289 /* interface_handlers.c */
290 extern void ui_button_active_cancel(const struct bContext *C, uiBut *but);