1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
20 /** \file
21  * \ingroup editorui
22  */
23 
24 #pragma once
25 
26 #include "BLI_compiler_attrs.h"
27 #include "BLI_sys_types.h" /* size_t */
28 #include "RNA_types.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /* Struct Declarations */
35 
36 struct ARegion;
37 struct AutoComplete;
38 struct FileSelectParams;
39 struct ID;
40 struct IDProperty;
41 struct ImBuf;
42 struct Image;
43 struct ImageUser;
44 struct ListBase;
45 struct MTex;
46 struct Panel;
47 struct PanelType;
48 struct PointerRNA;
49 struct PropertyRNA;
50 struct ReportList;
51 struct ResultBLF;
52 struct ScrArea;
53 struct bContext;
54 struct bContextStore;
55 struct bNode;
56 struct bNodeSocket;
57 struct bNodeTree;
58 struct bScreen;
59 struct rcti;
60 struct uiButSearch;
61 struct uiFontStyle;
62 struct uiList;
63 struct uiStyle;
64 struct uiWidgetColors;
65 struct wmDrag;
66 struct wmDropBox;
67 struct wmEvent;
68 struct wmGizmo;
69 struct wmKeyConfig;
70 struct wmKeyMap;
71 struct wmKeyMapItem;
72 struct wmMsgBus;
73 struct wmOperator;
74 struct wmOperatorType;
75 struct wmWindow;
76 
77 typedef struct uiBlock uiBlock;
78 typedef struct uiBut uiBut;
79 typedef struct uiLayout uiLayout;
80 typedef struct uiPopupBlockHandle uiPopupBlockHandle;
81 
82 /* Defines */
83 
84 /* char for splitting strings, aligning shortcuts in menus, users never see */
85 #define UI_SEP_CHAR '|'
86 #define UI_SEP_CHAR_S "|"
87 
88 /* names */
89 #define UI_MAX_DRAW_STR 400
90 #define UI_MAX_NAME_STR 128
91 #define UI_MAX_SHORTCUT_STR 64
92 
93 /**
94  * For #ARegion.overlap regions, pass events though if they don't overlap
95  * the regions contents (the usable part of the #View2D and buttons).
96  *
97  * The margin is needed so it's not possible to accidentally click in between buttons.
98  */
99 #define UI_REGION_OVERLAP_MARGIN (U.widget_unit / 3)
100 
101 /* use for clamping popups within the screen */
102 #define UI_SCREEN_MARGIN 10
103 
104 /** #uiBlock.emboss and #uiBut.emboss */
105 enum {
106   UI_EMBOSS = 0,          /* use widget style for drawing */
107   UI_EMBOSS_NONE = 1,     /* Nothing, only icon and/or text */
108   UI_EMBOSS_PULLDOWN = 2, /* Pulldown menu style */
109   UI_EMBOSS_RADIAL = 3,   /* Pie Menu */
110 
111   UI_EMBOSS_UNDEFINED = 255, /* For layout engine, use emboss from block. */
112 };
113 
114 /* uiBlock->direction */
115 enum {
116   UI_DIR_UP = 1 << 0,
117   UI_DIR_DOWN = 1 << 1,
118   UI_DIR_LEFT = 1 << 2,
119   UI_DIR_RIGHT = 1 << 3,
120   UI_DIR_CENTER_X = 1 << 4,
121   UI_DIR_CENTER_Y = 1 << 5,
122 
123   UI_DIR_ALL = UI_DIR_UP | UI_DIR_DOWN | UI_DIR_LEFT | UI_DIR_RIGHT,
124 };
125 
126 #if 0
127 /* uiBlock->autofill (not yet used) */
128 #  define UI_BLOCK_COLLUMNS 1
129 #  define UI_BLOCK_ROWS 2
130 #endif
131 
132 /** #uiBlock.flag (controls) */
133 enum {
134   UI_BLOCK_LOOP = 1 << 0,
135   UI_BLOCK_IS_FLIP = 1 << 1,
136   UI_BLOCK_NO_FLIP = 1 << 2,
137   UI_BLOCK_NUMSELECT = 1 << 3,
138   /** Don't apply window clipping. */
139   UI_BLOCK_NO_WIN_CLIP = 1 << 4,
140   UI_BLOCK_CLIPBOTTOM = 1 << 5,
141   UI_BLOCK_CLIPTOP = 1 << 6,
142   UI_BLOCK_MOVEMOUSE_QUIT = 1 << 7,
143   UI_BLOCK_KEEP_OPEN = 1 << 8,
144   UI_BLOCK_POPUP = 1 << 9,
145   UI_BLOCK_OUT_1 = 1 << 10,
146   UI_BLOCK_SEARCH_MENU = 1 << 11,
147   UI_BLOCK_POPUP_MEMORY = 1 << 12,
148   /* Stop handling mouse events. */
149   UI_BLOCK_CLIP_EVENTS = 1 << 13,
150 
151   /* block->flag bits 14-17 are identical to but->drawflag bits */
152 
153   UI_BLOCK_POPUP_HOLD = 1 << 18,
154   UI_BLOCK_LIST_ITEM = 1 << 19,
155   UI_BLOCK_RADIAL = 1 << 20,
156   UI_BLOCK_POPOVER = 1 << 21,
157   UI_BLOCK_POPOVER_ONCE = 1 << 22,
158   /** Always show key-maps, even for non-menus. */
159   UI_BLOCK_SHOW_SHORTCUT_ALWAYS = 1 << 23,
160   /** The block is only used during the search process and will not be drawn.
161    * Currently just for the case of a closed panel's sub-panel (and its sub-panels). */
162   UI_BLOCK_SEARCH_ONLY = 1 << 25,
163 };
164 
165 /** #uiPopupBlockHandle.menuretval */
166 enum {
167   /** Cancel all menus cascading. */
168   UI_RETURN_CANCEL = 1 << 0,
169   /** Choice made. */
170   UI_RETURN_OK = 1 << 1,
171   /** Left the menu. */
172   UI_RETURN_OUT = 1 << 2,
173   /** Let the parent handle this event. */
174   UI_RETURN_OUT_PARENT = 1 << 3,
175   /** Update the button that opened. */
176   UI_RETURN_UPDATE = 1 << 4,
177   /** Popup is ok to be handled. */
178   UI_RETURN_POPUP_OK = 1 << 5,
179 };
180 
181 /* but->flag - general state flags. */
182 enum {
183   /** Warning, the first 6 flags are internal. */
184   UI_BUT_ICON_SUBMENU = 1 << 6,
185   UI_BUT_ICON_PREVIEW = 1 << 7,
186 
187   UI_BUT_NODE_LINK = 1 << 8,
188   UI_BUT_NODE_ACTIVE = 1 << 9,
189   UI_BUT_DRAG_LOCK = 1 << 10,
190   /** Grayed out and un-editable. */
191   UI_BUT_DISABLED = 1 << 11,
192 
193   UI_BUT_ANIMATED = 1 << 13,
194   UI_BUT_ANIMATED_KEY = 1 << 14,
195   UI_BUT_DRIVEN = 1 << 15,
196   UI_BUT_REDALERT = 1 << 16,
197   /** Grayed out but still editable. */
198   UI_BUT_INACTIVE = 1 << 17,
199   UI_BUT_LAST_ACTIVE = 1 << 18,
200   UI_BUT_UNDO = 1 << 19,
201   UI_BUT_IMMEDIATE = 1 << 20,
202   UI_BUT_NO_UTF8 = 1 << 21,
203 
204   /** For popups, pressing return activates this button, overriding the highlighted button.
205    * For non-popups this is just used as a display hint for the user to let them
206    * know the action which is activated when pressing return (file selector for eg). */
207   UI_BUT_ACTIVE_DEFAULT = 1 << 23,
208 
209   /** This but is "inside" a list item (currently used to change theme colors). */
210   UI_BUT_LIST_ITEM = 1 << 24,
211   /** edit this button as well as the active button (not just dragging) */
212   UI_BUT_DRAG_MULTI = 1 << 25,
213   /** Use for popups to start editing the button on initialization. */
214   UI_BUT_ACTIVATE_ON_INIT = 1 << 26,
215 
216   /** #uiBut.str contains #UI_SEP_CHAR, used for key shortcuts */
217   UI_BUT_HAS_SEP_CHAR = 1 << 27,
218   /** Don't run updates while dragging (needed in rare cases). */
219   UI_BUT_UPDATE_DELAY = 1 << 28,
220   /** When widget is in textedit mode, update value on each char stroke */
221   UI_BUT_TEXTEDIT_UPDATE = 1 << 29,
222   /** Show 'x' icon to clear/unlink value of text or search button. */
223   UI_BUT_VALUE_CLEAR = 1 << 30,
224 
225   /** RNA property of the button is overridden from linked reference data. */
226   UI_BUT_OVERRIDEN = 1u << 31u,
227 };
228 
229 /* Default font size for normal text. */
230 #define UI_DEFAULT_TEXT_POINTS 11
231 
232 /* Larger size used for title text. */
233 #define UI_DEFAULT_TITLE_POINTS 12
234 
235 #define UI_PANEL_WIDTH 340
236 #define UI_COMPACT_PANEL_WIDTH 160
237 #define UI_SIDEBAR_PANEL_WIDTH 220
238 #define UI_NAVIGATION_REGION_WIDTH UI_COMPACT_PANEL_WIDTH
239 #define UI_NARROW_NAVIGATION_REGION_WIDTH 100
240 
241 #define UI_PANEL_CATEGORY_MARGIN_WIDTH (U.widget_unit * 1.0f)
242 
243 #define UI_PANEL_BOX_STYLE_MARGIN (U.widget_unit * 0.2f)
244 
245 /* but->drawflag - these flags should only affect how the button is drawn. */
246 /* Note: currently, these flags _are not passed_ to the widget's state() or draw() functions
247  *       (except for the 'align' ones)!
248  */
249 enum {
250   /** Text and icon alignment (by default, they are centered). */
251   UI_BUT_TEXT_LEFT = 1 << 1,
252   UI_BUT_ICON_LEFT = 1 << 2,
253   UI_BUT_TEXT_RIGHT = 1 << 3,
254   /** Prevent the button to show any tooltip. */
255   UI_BUT_NO_TOOLTIP = 1 << 4,
256   /** Do not add the usual horizontal padding for text drawing. */
257   UI_BUT_NO_TEXT_PADDING = 1 << 5,
258 
259   /* Button align flag, for drawing groups together.
260    * Used in 'uiBlock.flag', take care! */
261   UI_BUT_ALIGN_TOP = 1 << 14,
262   UI_BUT_ALIGN_LEFT = 1 << 15,
263   UI_BUT_ALIGN_RIGHT = 1 << 16,
264   UI_BUT_ALIGN_DOWN = 1 << 17,
265   UI_BUT_ALIGN = UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_LEFT | UI_BUT_ALIGN_RIGHT | UI_BUT_ALIGN_DOWN,
266   /* end bits shared with 'uiBlock.flag' */
267 
268   /**
269    * Warning - HACK!
270    * Needed for buttons which are not TOP/LEFT aligned,
271    * but have some top/left corner stitched to some other TOP/LEFT-aligned button,
272    * because of 'corrective' hack in widget_roundbox_set()... */
273   UI_BUT_ALIGN_STITCH_TOP = 1 << 18,
274   UI_BUT_ALIGN_STITCH_LEFT = 1 << 19,
275   UI_BUT_ALIGN_ALL = UI_BUT_ALIGN | UI_BUT_ALIGN_STITCH_TOP | UI_BUT_ALIGN_STITCH_LEFT,
276 
277   /** This but is "inside" a box item (currently used to change theme colors). */
278   UI_BUT_BOX_ITEM = 1 << 20,
279 
280   /** Active left part of number button */
281   UI_BUT_ACTIVE_LEFT = 1 << 21,
282   /** Active right part of number button */
283   UI_BUT_ACTIVE_RIGHT = 1 << 22,
284 
285   /* (also used by search buttons to enforce shortcut display for their items). */
286   /** Button has shortcut text. */
287   UI_BUT_HAS_SHORTCUT = 1 << 23,
288 
289   /** Reverse order of consecutive off/on icons */
290   UI_BUT_ICON_REVERSE = 1 << 24,
291 
292   /** Value is animated, but the current value differs from the animated one. */
293   UI_BUT_ANIMATED_CHANGED = 1 << 25,
294 
295   /* Draw the checkbox buttons inverted. */
296   UI_BUT_CHECKBOX_INVERT = 1 << 26,
297 };
298 
299 /* scale fixed button widths by this to account for DPI */
300 
301 #define UI_DPI_FAC (U.dpi_fac)
302 /* 16 to copy ICON_DEFAULT_HEIGHT */
303 #define UI_DPI_ICON_SIZE ((float)16 * UI_DPI_FAC)
304 
305 /**
306  * Button types, bits stored in 1 value... and a short even!
307  * - bits 0-4:  #uiBut.bitnr (0-31)
308  * - bits 5-7:  pointer type
309  * - bit  8:    for 'bit'
310  * - bit  9-15: button type (now 6 bits, 64 types)
311  */
312 typedef enum {
313   UI_BUT_POIN_CHAR = 32,
314   UI_BUT_POIN_SHORT = 64,
315   UI_BUT_POIN_INT = 96,
316   UI_BUT_POIN_FLOAT = 128,
317   /*  UI_BUT_POIN_FUNCTION = 192, */ /*UNUSED*/
318   UI_BUT_POIN_BIT = 256,             /* OR'd with a bit index*/
319 } eButPointerType;
320 
321 /* requires (but->poin != NULL) */
322 #define UI_BUT_POIN_TYPES (UI_BUT_POIN_FLOAT | UI_BUT_POIN_SHORT | UI_BUT_POIN_CHAR)
323 
324 /* assigned to but->type, OR'd with the flags above when passing args */
325 typedef enum {
326   UI_BTYPE_BUT = 1 << 9,
327   UI_BTYPE_ROW = 2 << 9,
328   UI_BTYPE_TEXT = 3 << 9,
329   /** Drop-down list. */
330   UI_BTYPE_MENU = 4 << 9,
331   UI_BTYPE_BUT_MENU = 5 << 9,
332   /** number button */
333   UI_BTYPE_NUM = 6 << 9,
334   /** number slider */
335   UI_BTYPE_NUM_SLIDER = 7 << 9,
336   UI_BTYPE_TOGGLE = 8 << 9,
337   UI_BTYPE_TOGGLE_N = 9 << 9,
338   UI_BTYPE_ICON_TOGGLE = 10 << 9,
339   UI_BTYPE_ICON_TOGGLE_N = 11 << 9,
340   /** same as regular toggle, but no on/off state displayed */
341   UI_BTYPE_BUT_TOGGLE = 12 << 9,
342   /** similar to toggle, display a 'tick' */
343   UI_BTYPE_CHECKBOX = 13 << 9,
344   UI_BTYPE_CHECKBOX_N = 14 << 9,
345   UI_BTYPE_COLOR = 15 << 9,
346   UI_BTYPE_TAB = 16 << 9,
347   UI_BTYPE_POPOVER = 17 << 9,
348   UI_BTYPE_SCROLL = 18 << 9,
349   UI_BTYPE_BLOCK = 19 << 9,
350   UI_BTYPE_LABEL = 20 << 9,
351   UI_BTYPE_KEY_EVENT = 24 << 9,
352   UI_BTYPE_HSVCUBE = 26 << 9,
353   /** menu (often used in headers), **_MENU /w different draw-type */
354   UI_BTYPE_PULLDOWN = 27 << 9,
355   UI_BTYPE_ROUNDBOX = 28 << 9,
356   UI_BTYPE_COLORBAND = 30 << 9,
357   /** sphere widget (used to input a unit-vector, aka normal) */
358   UI_BTYPE_UNITVEC = 31 << 9,
359   UI_BTYPE_CURVE = 32 << 9,
360   /** Profile editing widget */
361   UI_BTYPE_CURVEPROFILE = 33 << 9,
362   UI_BTYPE_LISTBOX = 36 << 9,
363   UI_BTYPE_LISTROW = 37 << 9,
364   UI_BTYPE_HSVCIRCLE = 38 << 9,
365   UI_BTYPE_TRACK_PREVIEW = 40 << 9,
366 
367   /** Buttons with value >= #UI_BTYPE_SEARCH_MENU don't get undo pushes. */
368   UI_BTYPE_SEARCH_MENU = 41 << 9,
369   UI_BTYPE_EXTRA = 42 << 9,
370   UI_BTYPE_HOTKEY_EVENT = 46 << 9,
371   /** Non-interactive image, used for splash screen */
372   UI_BTYPE_IMAGE = 47 << 9,
373   UI_BTYPE_HISTOGRAM = 48 << 9,
374   UI_BTYPE_WAVEFORM = 49 << 9,
375   UI_BTYPE_VECTORSCOPE = 50 << 9,
376   UI_BTYPE_PROGRESS_BAR = 51 << 9,
377   UI_BTYPE_NODE_SOCKET = 53 << 9,
378   UI_BTYPE_SEPR = 54 << 9,
379   UI_BTYPE_SEPR_LINE = 55 << 9,
380   /** Dynamically fill available space. */
381   UI_BTYPE_SEPR_SPACER = 56 << 9,
382   /** Resize handle (resize uilist). */
383   UI_BTYPE_GRIP = 57 << 9,
384   UI_BTYPE_DECORATOR = 58 << 9,
385 } eButType;
386 
387 #define BUTTYPE (63 << 9)
388 
389 /** Gradient types, for color picker #UI_BTYPE_HSVCUBE etc. */
390 typedef enum eButGradientType {
391   UI_GRAD_SV = 0,
392   UI_GRAD_HV = 1,
393   UI_GRAD_HS = 2,
394   UI_GRAD_H = 3,
395   UI_GRAD_S = 4,
396   UI_GRAD_V = 5,
397 
398   UI_GRAD_V_ALT = 9,
399   UI_GRAD_L_ALT = 10,
400 } eButGradientType;
401 
402 /* Drawing
403  *
404  * Functions to draw various shapes, taking theme settings into account.
405  * Used for code that draws its own UI style elements. */
406 
407 void UI_draw_anti_tria(
408     float x1, float y1, float x2, float y2, float x3, float y3, const float color[4]);
409 void UI_draw_anti_fan(float tri_array[][2], unsigned int length, const float color[4]);
410 
411 void UI_draw_roundbox_corner_set(int type);
412 void UI_draw_roundbox_aa(
413     bool filled, float minx, float miny, float maxx, float maxy, float rad, const float color[4]);
414 void UI_draw_roundbox_4fv(
415     bool filled, float minx, float miny, float maxx, float maxy, float rad, const float col[4]);
416 void UI_draw_roundbox_3ub_alpha(bool filled,
417                                 float minx,
418                                 float miny,
419                                 float maxx,
420                                 float maxy,
421                                 float rad,
422                                 const unsigned char col[3],
423                                 unsigned char alpha);
424 void UI_draw_roundbox_3fv_alpha(bool filled,
425                                 float minx,
426                                 float miny,
427                                 float maxx,
428                                 float maxy,
429                                 float rad,
430                                 const float col[3],
431                                 float alpha);
432 void UI_draw_roundbox_shade_x(bool filled,
433                               float minx,
434                               float miny,
435                               float maxx,
436                               float maxy,
437                               float rad,
438                               float shadetop,
439                               float shadedown,
440                               const float col[4]);
441 
442 #if 0 /* unused */
443 int UI_draw_roundbox_corner_get(void);
444 void UI_draw_roundbox_shade_y(bool filled,
445                               float minx,
446                               float miny,
447                               float maxx,
448                               float maxy,
449                               float rad,
450                               float shadeleft,
451                               float shaderight,
452                               const float col[4]);
453 #endif
454 
455 void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx, float maxy);
456 void UI_draw_text_underline(int pos_x, int pos_y, int len, int height, const float color[4]);
457 
458 void UI_draw_safe_areas(uint pos,
459                         float x1,
460                         float x2,
461                         float y1,
462                         float y2,
463                         const float title_aspect[2],
464                         const float action_aspect[2]);
465 
466 /** State for scrolldrawing. */
467 enum {
468   UI_SCROLL_PRESSED = 1 << 0,
469   UI_SCROLL_ARROWS = 1 << 1,
470   UI_SCROLL_NO_OUTLINE = 1 << 2,
471 };
472 void UI_draw_widget_scroll(struct uiWidgetColors *wcol,
473                            const struct rcti *rect,
474                            const struct rcti *slider,
475                            int state);
476 
477 /* Shortening string helper. */
478 float UI_text_clip_middle_ex(const struct uiFontStyle *fstyle,
479                              char *str,
480                              float okwidth,
481                              const float minwidth,
482                              const size_t max_len,
483                              const char rpart_sep);
484 
485 /**
486  * Callbacks
487  *
488  * UI_block_func_handle_set/ButmFunc are for handling events through a callback.
489  * HandleFunc gets the retval passed on, and ButmFunc gets a2. The latter is
490  * mostly for compatibility with older code.
491  *
492  * - #UI_but_func_complete_set is for tab completion.
493  *
494  * - #uiButSearchFunc is for name buttons, showing a popup with matches
495  *
496  * - #UI_block_func_set and UI_but_func_set are callbacks run when a button is used,
497  *   in case events, operators or RNA are not sufficient to handle the button.
498  *
499  * - #UI_but_funcN_set will free the argument with MEM_freeN. */
500 
501 typedef struct uiSearchItems uiSearchItems;
502 
503 typedef void (*uiButHandleFunc)(struct bContext *C, void *arg1, void *arg2);
504 typedef void (*uiButHandleRenameFunc)(struct bContext *C, void *arg, char *origstr);
505 typedef void (*uiButHandleNFunc)(struct bContext *C, void *argN, void *arg2);
506 typedef void (*uiButHandleHoldFunc)(struct bContext *C, struct ARegion *butregion, uiBut *but);
507 typedef int (*uiButCompleteFunc)(struct bContext *C, char *str, void *arg);
508 
509 /* Search types. */
510 typedef struct ARegion *(*uiButSearchCreateFn)(struct bContext *C,
511                                                struct ARegion *butregion,
512                                                struct uiButSearch *search_but);
513 typedef void (*uiButSearchUpdateFn)(const struct bContext *C,
514                                     void *arg,
515                                     const char *str,
516                                     uiSearchItems *items);
517 typedef void (*uiButSearchArgFreeFn)(void *arg);
518 typedef bool (*uiButSearchContextMenuFn)(struct bContext *C,
519                                          void *arg,
520                                          void *active,
521                                          const struct wmEvent *event);
522 typedef struct ARegion *(*uiButSearchTooltipFn)(struct bContext *C,
523                                                 struct ARegion *region,
524                                                 void *arg,
525                                                 void *active);
526 
527 /* Must return allocated string. */
528 typedef char *(*uiButToolTipFunc)(struct bContext *C, void *argN, const char *tip);
529 typedef int (*uiButPushedStateFunc)(struct bContext *C, void *arg);
530 
531 typedef void (*uiBlockHandleFunc)(struct bContext *C, void *arg, int event);
532 
533 /* Menu Callbacks */
534 
535 typedef void (*uiMenuCreateFunc)(struct bContext *C, struct uiLayout *layout, void *arg1);
536 typedef void (*uiMenuHandleFunc)(struct bContext *C, void *arg, int event);
537 /**
538  * Used for cycling menu values without opening the menu (Ctrl-Wheel).
539  * \param direction: forward or backwards [1 / -1].
540  * \param arg1: uiBut.poin (as with #uiMenuCreateFunc).
541  * \return true when the button was changed.
542  */
543 typedef bool (*uiMenuStepFunc)(struct bContext *C, int direction, void *arg1);
544 
545 /* interface_query.c */
546 bool UI_but_has_tooltip_label(const uiBut *but);
547 bool UI_but_is_tool(const uiBut *but);
548 bool UI_but_is_utf8(const uiBut *but);
549 #define UI_but_is_decorator(but) ((but)->type == UI_BTYPE_DECORATOR)
550 
551 bool UI_block_is_empty_ex(const uiBlock *block, const bool skip_title);
552 bool UI_block_is_empty(const uiBlock *block);
553 bool UI_block_can_add_separator(const uiBlock *block);
554 
555 /* interface_region_menu_popup.c */
556 /**
557  * Popup Menus
558  *
559  * Functions used to create popup menus. For more extended menus the
560  * UI_popup_menu_begin/End functions can be used to define own items with
561  * the uiItem functions in between. If it is a simple confirmation menu
562  * or similar, popups can be created with a single function call.
563  */
564 typedef struct uiPopupMenu uiPopupMenu;
565 
566 uiPopupMenu *UI_popup_menu_begin(struct bContext *C, const char *title, int icon) ATTR_NONNULL();
567 uiPopupMenu *UI_popup_menu_begin_ex(struct bContext *C,
568                                     const char *title,
569                                     const char *block_name,
570                                     int icon) ATTR_NONNULL();
571 void UI_popup_menu_end(struct bContext *C, struct uiPopupMenu *pup);
572 bool UI_popup_menu_end_or_cancel(struct bContext *C, struct uiPopupMenu *head);
573 struct uiLayout *UI_popup_menu_layout(uiPopupMenu *pup);
574 
575 void UI_popup_menu_reports(struct bContext *C, struct ReportList *reports) ATTR_NONNULL();
576 int UI_popup_menu_invoke(struct bContext *C, const char *idname, struct ReportList *reports)
577     ATTR_NONNULL(1, 2);
578 
579 void UI_popup_menu_retval_set(const uiBlock *block, const int retval, const bool enable);
580 void UI_popup_menu_but_set(uiPopupMenu *pup, struct ARegion *butregion, uiBut *but);
581 
582 /* interface_region_popover.c */
583 
584 typedef struct uiPopover uiPopover;
585 
586 int UI_popover_panel_invoke(struct bContext *C,
587                             const char *idname,
588                             bool keep_open,
589                             struct ReportList *reports);
590 
591 uiPopover *UI_popover_begin(struct bContext *C, int menu_width, bool from_active_button)
592     ATTR_NONNULL(1);
593 void UI_popover_end(struct bContext *C, struct uiPopover *pup, struct wmKeyMap *keymap);
594 struct uiLayout *UI_popover_layout(uiPopover *pup);
595 void UI_popover_once_clear(uiPopover *pup);
596 
597 /* interface_region_menu_pie.c */
598 /* Pie menus */
599 typedef struct uiPieMenu uiPieMenu;
600 
601 int UI_pie_menu_invoke(struct bContext *C, const char *idname, const struct wmEvent *event);
602 int UI_pie_menu_invoke_from_operator_enum(struct bContext *C,
603                                           const char *title,
604                                           const char *opname,
605                                           const char *propname,
606                                           const struct wmEvent *event);
607 int UI_pie_menu_invoke_from_rna_enum(struct bContext *C,
608                                      const char *title,
609                                      const char *path,
610                                      const struct wmEvent *event);
611 
612 struct uiPieMenu *UI_pie_menu_begin(struct bContext *C,
613                                     const char *title,
614                                     int icon,
615                                     const struct wmEvent *event) ATTR_NONNULL();
616 void UI_pie_menu_end(struct bContext *C, uiPieMenu *pie);
617 struct uiLayout *UI_pie_menu_layout(struct uiPieMenu *pie);
618 
619 /* interface_region_menu_popup.c */
620 
621 /* Popup Blocks
622  *
623  * Functions used to create popup blocks. These are like popup menus
624  * but allow using all button types and creating an own layout. */
625 typedef uiBlock *(*uiBlockCreateFunc)(struct bContext *C, struct ARegion *region, void *arg1);
626 typedef void (*uiBlockCancelFunc)(struct bContext *C, void *arg1);
627 
628 void UI_popup_block_invoke(struct bContext *C,
629                            uiBlockCreateFunc func,
630                            void *arg,
631                            void (*arg_free)(void *arg));
632 void UI_popup_block_invoke_ex(struct bContext *C,
633                               uiBlockCreateFunc func,
634                               void *arg,
635                               void (*arg_free)(void *arg),
636                               bool can_refresh);
637 void UI_popup_block_ex(struct bContext *C,
638                        uiBlockCreateFunc func,
639                        uiBlockHandleFunc popup_func,
640                        uiBlockCancelFunc cancel_func,
641                        void *arg,
642                        struct wmOperator *op);
643 #if 0 /* UNUSED */
644 void uiPupBlockOperator(struct bContext *C,
645                         uiBlockCreateFunc func,
646                         struct wmOperator *op,
647                         int opcontext);
648 #endif
649 
650 void UI_popup_block_close(struct bContext *C, struct wmWindow *win, uiBlock *block);
651 
652 bool UI_popup_block_name_exists(const struct bScreen *screen, const char *name);
653 
654 /* Blocks
655  *
656  * Functions for creating, drawing and freeing blocks. A Block is a
657  * container of buttons and used for various purposes.
658  *
659  * Begin/Define Buttons/End/Draw is the typical order in which these
660  * function should be called, though for popup blocks Draw is left out.
661  * Freeing blocks is done by the screen/ module automatically.
662  *
663  * */
664 
665 uiBlock *UI_block_begin(const struct bContext *C,
666                         struct ARegion *region,
667                         const char *name,
668                         char emboss);
669 void UI_block_end_ex(const struct bContext *C, uiBlock *block, const int xy[2], int r_xy[2]);
670 void UI_block_end(const struct bContext *C, uiBlock *block);
671 void UI_block_draw(const struct bContext *C, struct uiBlock *block);
672 void UI_blocklist_update_window_matrix(const struct bContext *C, const struct ListBase *lb);
673 void UI_blocklist_draw(const struct bContext *C, const struct ListBase *lb);
674 void UI_block_update_from_old(const struct bContext *C, struct uiBlock *block);
675 
676 enum {
677   UI_BLOCK_THEME_STYLE_REGULAR = 0,
678   UI_BLOCK_THEME_STYLE_POPUP = 1,
679 };
680 void UI_block_theme_style_set(uiBlock *block, char theme_style);
681 char UI_block_emboss_get(uiBlock *block);
682 void UI_block_emboss_set(uiBlock *block, char emboss);
683 bool UI_block_is_search_only(const uiBlock *block);
684 void UI_block_set_search_only(uiBlock *block, bool search_only);
685 
686 void UI_block_free(const struct bContext *C, uiBlock *block);
687 void UI_blocklist_free(const struct bContext *C, struct ListBase *lb);
688 void UI_blocklist_free_inactive(const struct bContext *C, struct ListBase *lb);
689 void UI_screen_free_active_but(const struct bContext *C, struct bScreen *screen);
690 
691 void UI_block_region_set(uiBlock *block, struct ARegion *region);
692 
693 void UI_block_lock_set(uiBlock *block, bool val, const char *lockstr);
694 void UI_block_lock_clear(uiBlock *block);
695 
696 /* automatic aligning, horiz or verical */
697 void UI_block_align_begin(uiBlock *block);
698 void UI_block_align_end(uiBlock *block);
699 
700 /* block bounds/position calculation */
701 typedef enum {
702   UI_BLOCK_BOUNDS_NONE = 0,
703   UI_BLOCK_BOUNDS = 1,
704   UI_BLOCK_BOUNDS_TEXT,
705   UI_BLOCK_BOUNDS_POPUP_MOUSE,
706   UI_BLOCK_BOUNDS_POPUP_MENU,
707   UI_BLOCK_BOUNDS_POPUP_CENTER,
708   UI_BLOCK_BOUNDS_PIE_CENTER,
709 } eBlockBoundsCalc;
710 
711 void UI_block_bounds_set_normal(struct uiBlock *block, int addval);
712 void UI_block_bounds_set_text(uiBlock *block, int addval);
713 void UI_block_bounds_set_popup(uiBlock *block, int addval, const int bounds_offset[2]);
714 void UI_block_bounds_set_menu(uiBlock *block, int addval, const int bounds_offset[2]);
715 void UI_block_bounds_set_centered(uiBlock *block, int addval);
716 void UI_block_bounds_set_explicit(uiBlock *block, int minx, int miny, int maxx, int maxy);
717 
718 int UI_blocklist_min_y_get(struct ListBase *lb);
719 
720 void UI_block_direction_set(uiBlock *block, char direction);
721 void UI_block_order_flip(uiBlock *block);
722 void UI_block_flag_enable(uiBlock *block, int flag);
723 void UI_block_flag_disable(uiBlock *block, int flag);
724 void UI_block_translate(uiBlock *block, int x, int y);
725 
726 int UI_but_return_value_get(uiBut *but);
727 
728 void UI_but_drag_set_id(uiBut *but, struct ID *id);
729 void UI_but_drag_set_rna(uiBut *but, struct PointerRNA *ptr);
730 void UI_but_drag_set_path(uiBut *but, const char *path, const bool use_free);
731 void UI_but_drag_set_name(uiBut *but, const char *name);
732 void UI_but_drag_set_value(uiBut *but);
733 void UI_but_drag_set_image(
734     uiBut *but, const char *path, int icon, struct ImBuf *imb, float scale, const bool use_free);
735 
736 bool UI_but_active_drop_name(struct bContext *C);
737 bool UI_but_active_drop_color(struct bContext *C);
738 
739 void UI_but_flag_enable(uiBut *but, int flag);
740 void UI_but_flag_disable(uiBut *but, int flag);
741 bool UI_but_flag_is_set(uiBut *but, int flag);
742 
743 void UI_but_drawflag_enable(uiBut *but, int flag);
744 void UI_but_drawflag_disable(uiBut *but, int flag);
745 
746 void UI_but_disable(uiBut *but, const char *disabled_hint);
747 
748 void UI_but_type_set_menu_from_pulldown(uiBut *but);
749 
750 /* special button case, only draw it when used actively, for outliner etc */
751 bool UI_but_active_only_ex(const struct bContext *C,
752                            struct ARegion *region,
753                            uiBlock *block,
754                            uiBut *but,
755                            const bool remove_on_failure);
756 bool UI_but_active_only(const struct bContext *C,
757                         struct ARegion *region,
758                         uiBlock *block,
759                         uiBut *but);
760 bool UI_block_active_only_flagged_buttons(const struct bContext *C,
761                                           struct ARegion *region,
762                                           struct uiBlock *block);
763 
764 void UI_but_execute(const struct bContext *C, struct ARegion *region, uiBut *but);
765 
766 bool UI_but_online_manual_id(const uiBut *but,
767                              char *r_str,
768                              size_t maxlength) ATTR_WARN_UNUSED_RESULT;
769 bool UI_but_online_manual_id_from_active(const struct bContext *C,
770                                          char *r_str,
771                                          size_t maxlength) ATTR_WARN_UNUSED_RESULT;
772 bool UI_but_is_userdef(const uiBut *but);
773 
774 /* Buttons
775  *
776  * Functions to define various types of buttons in a block. Postfixes:
777  * - F: float
778  * - I: int
779  * - S: short
780  * - C: char
781  * - R: RNA
782  * - O: operator */
783 
784 uiBut *uiDefBut(uiBlock *block,
785                 int type,
786                 int retval,
787                 const char *str,
788                 int x,
789                 int y,
790                 short width,
791                 short height,
792                 void *poin,
793                 float min,
794                 float max,
795                 float a1,
796                 float a2,
797                 const char *tip);
798 uiBut *uiDefButF(uiBlock *block,
799                  int type,
800                  int retval,
801                  const char *str,
802                  int x,
803                  int y,
804                  short width,
805                  short height,
806                  float *poin,
807                  float min,
808                  float max,
809                  float a1,
810                  float a2,
811                  const char *tip);
812 uiBut *uiDefButBitF(uiBlock *block,
813                     int type,
814                     int bit,
815                     int retval,
816                     const char *str,
817                     int x,
818                     int y,
819                     short width,
820                     short height,
821                     float *poin,
822                     float min,
823                     float max,
824                     float a1,
825                     float a2,
826                     const char *tip);
827 uiBut *uiDefButI(uiBlock *block,
828                  int type,
829                  int retval,
830                  const char *str,
831                  int x,
832                  int y,
833                  short width,
834                  short height,
835                  int *poin,
836                  float min,
837                  float max,
838                  float a1,
839                  float a2,
840                  const char *tip);
841 uiBut *uiDefButBitI(uiBlock *block,
842                     int type,
843                     int bit,
844                     int retval,
845                     const char *str,
846                     int x,
847                     int y,
848                     short width,
849                     short height,
850                     int *poin,
851                     float min,
852                     float max,
853                     float a1,
854                     float a2,
855                     const char *tip);
856 uiBut *uiDefButS(uiBlock *block,
857                  int type,
858                  int retval,
859                  const char *str,
860                  int x,
861                  int y,
862                  short width,
863                  short height,
864                  short *poin,
865                  float min,
866                  float max,
867                  float a1,
868                  float a2,
869                  const char *tip);
870 uiBut *uiDefButBitS(uiBlock *block,
871                     int type,
872                     int bit,
873                     int retval,
874                     const char *str,
875                     int x,
876                     int y,
877                     short width,
878                     short height,
879                     short *poin,
880                     float min,
881                     float max,
882                     float a1,
883                     float a2,
884                     const char *tip);
885 uiBut *uiDefButC(uiBlock *block,
886                  int type,
887                  int retval,
888                  const char *str,
889                  int x,
890                  int y,
891                  short width,
892                  short height,
893                  char *poin,
894                  float min,
895                  float max,
896                  float a1,
897                  float a2,
898                  const char *tip);
899 uiBut *uiDefButBitC(uiBlock *block,
900                     int type,
901                     int bit,
902                     int retval,
903                     const char *str,
904                     int x,
905                     int y,
906                     short width,
907                     short height,
908                     char *poin,
909                     float min,
910                     float max,
911                     float a1,
912                     float a2,
913                     const char *tip);
914 uiBut *uiDefButR(uiBlock *block,
915                  int type,
916                  int retval,
917                  const char *str,
918                  int x,
919                  int y,
920                  short width,
921                  short height,
922                  struct PointerRNA *ptr,
923                  const char *propname,
924                  int index,
925                  float min,
926                  float max,
927                  float a1,
928                  float a2,
929                  const char *tip);
930 uiBut *uiDefButR_prop(uiBlock *block,
931                       int type,
932                       int retval,
933                       const char *str,
934                       int x,
935                       int y,
936                       short width,
937                       short height,
938                       struct PointerRNA *ptr,
939                       struct PropertyRNA *prop,
940                       int index,
941                       float min,
942                       float max,
943                       float a1,
944                       float a2,
945                       const char *tip);
946 uiBut *uiDefButO(uiBlock *block,
947                  int type,
948                  const char *opname,
949                  int opcontext,
950                  const char *str,
951                  int x,
952                  int y,
953                  short width,
954                  short height,
955                  const char *tip);
956 uiBut *uiDefButO_ptr(uiBlock *block,
957                      int type,
958                      struct wmOperatorType *ot,
959                      int opcontext,
960                      const char *str,
961                      int x,
962                      int y,
963                      short width,
964                      short height,
965                      const char *tip);
966 
967 uiBut *uiDefIconBut(uiBlock *block,
968                     int type,
969                     int retval,
970                     int icon,
971                     int x,
972                     int y,
973                     short width,
974                     short height,
975                     void *poin,
976                     float min,
977                     float max,
978                     float a1,
979                     float a2,
980                     const char *tip);
981 uiBut *uiDefIconButF(uiBlock *block,
982                      int type,
983                      int retval,
984                      int icon,
985                      int x,
986                      int y,
987                      short width,
988                      short height,
989                      float *poin,
990                      float min,
991                      float max,
992                      float a1,
993                      float a2,
994                      const char *tip);
995 uiBut *uiDefIconButBitF(uiBlock *block,
996                         int type,
997                         int bit,
998                         int retval,
999                         int icon,
1000                         int x,
1001                         int y,
1002                         short width,
1003                         short height,
1004                         float *poin,
1005                         float min,
1006                         float max,
1007                         float a1,
1008                         float a2,
1009                         const char *tip);
1010 uiBut *uiDefIconButI(uiBlock *block,
1011                      int type,
1012                      int retval,
1013                      int icon,
1014                      int x,
1015                      int y,
1016                      short width,
1017                      short height,
1018                      int *poin,
1019                      float min,
1020                      float max,
1021                      float a1,
1022                      float a2,
1023                      const char *tip);
1024 uiBut *uiDefIconButBitI(uiBlock *block,
1025                         int type,
1026                         int bit,
1027                         int retval,
1028                         int icon,
1029                         int x,
1030                         int y,
1031                         short width,
1032                         short height,
1033                         int *poin,
1034                         float min,
1035                         float max,
1036                         float a1,
1037                         float a2,
1038                         const char *tip);
1039 uiBut *uiDefIconButS(uiBlock *block,
1040                      int type,
1041                      int retval,
1042                      int icon,
1043                      int x,
1044                      int y,
1045                      short width,
1046                      short height,
1047                      short *poin,
1048                      float min,
1049                      float max,
1050                      float a1,
1051                      float a2,
1052                      const char *tip);
1053 uiBut *uiDefIconButBitS(uiBlock *block,
1054                         int type,
1055                         int bit,
1056                         int retval,
1057                         int icon,
1058                         int x,
1059                         int y,
1060                         short width,
1061                         short height,
1062                         short *poin,
1063                         float min,
1064                         float max,
1065                         float a1,
1066                         float a2,
1067                         const char *tip);
1068 uiBut *uiDefIconButC(uiBlock *block,
1069                      int type,
1070                      int retval,
1071                      int icon,
1072                      int x,
1073                      int y,
1074                      short width,
1075                      short height,
1076                      char *poin,
1077                      float min,
1078                      float max,
1079                      float a1,
1080                      float a2,
1081                      const char *tip);
1082 uiBut *uiDefIconButBitC(uiBlock *block,
1083                         int type,
1084                         int bit,
1085                         int retval,
1086                         int icon,
1087                         int x,
1088                         int y,
1089                         short width,
1090                         short height,
1091                         char *poin,
1092                         float min,
1093                         float max,
1094                         float a1,
1095                         float a2,
1096                         const char *tip);
1097 uiBut *uiDefIconButR(uiBlock *block,
1098                      int type,
1099                      int retval,
1100                      int icon,
1101                      int x,
1102                      int y,
1103                      short width,
1104                      short height,
1105                      struct PointerRNA *ptr,
1106                      const char *propname,
1107                      int index,
1108                      float min,
1109                      float max,
1110                      float a1,
1111                      float a2,
1112                      const char *tip);
1113 uiBut *uiDefIconButR_prop(uiBlock *block,
1114                           int type,
1115                           int retval,
1116                           int icon,
1117                           int x,
1118                           int y,
1119                           short width,
1120                           short height,
1121                           struct PointerRNA *ptr,
1122                           PropertyRNA *prop,
1123                           int index,
1124                           float min,
1125                           float max,
1126                           float a1,
1127                           float a2,
1128                           const char *tip);
1129 uiBut *uiDefIconButO(uiBlock *block,
1130                      int type,
1131                      const char *opname,
1132                      int opcontext,
1133                      int icon,
1134                      int x,
1135                      int y,
1136                      short width,
1137                      short height,
1138                      const char *tip);
1139 uiBut *uiDefIconButO_ptr(uiBlock *block,
1140                          int type,
1141                          struct wmOperatorType *ot,
1142                          int opcontext,
1143                          int icon,
1144                          int x,
1145                          int y,
1146                          short width,
1147                          short height,
1148                          const char *tip);
1149 uiBut *uiDefButImage(
1150     uiBlock *block, void *imbuf, int x, int y, short width, short height, const uchar color[4]);
1151 uiBut *uiDefButAlert(uiBlock *block, int icon, int x, int y, short width, short height);
1152 uiBut *uiDefIconTextBut(uiBlock *block,
1153                         int type,
1154                         int retval,
1155                         int icon,
1156                         const char *str,
1157                         int x,
1158                         int y,
1159                         short width,
1160                         short height,
1161                         void *poin,
1162                         float min,
1163                         float max,
1164                         float a1,
1165                         float a2,
1166                         const char *tip);
1167 uiBut *uiDefIconTextButF(uiBlock *block,
1168                          int type,
1169                          int retval,
1170                          int icon,
1171                          const char *str,
1172                          int x,
1173                          int y,
1174                          short width,
1175                          short height,
1176                          float *poin,
1177                          float min,
1178                          float max,
1179                          float a1,
1180                          float a2,
1181                          const char *tip);
1182 uiBut *uiDefIconTextButBitF(uiBlock *block,
1183                             int type,
1184                             int bit,
1185                             int retval,
1186                             int icon,
1187                             const char *str,
1188                             int x,
1189                             int y,
1190                             short width,
1191                             short height,
1192                             float *poin,
1193                             float min,
1194                             float max,
1195                             float a1,
1196                             float a2,
1197                             const char *tip);
1198 uiBut *uiDefIconTextButI(uiBlock *block,
1199                          int type,
1200                          int retval,
1201                          int icon,
1202                          const char *str,
1203                          int x,
1204                          int y,
1205                          short width,
1206                          short height,
1207                          int *poin,
1208                          float min,
1209                          float max,
1210                          float a1,
1211                          float a2,
1212                          const char *tip);
1213 uiBut *uiDefIconTextButBitI(uiBlock *block,
1214                             int type,
1215                             int bit,
1216                             int retval,
1217                             int icon,
1218                             const char *str,
1219                             int x,
1220                             int y,
1221                             short width,
1222                             short height,
1223                             int *poin,
1224                             float min,
1225                             float max,
1226                             float a1,
1227                             float a2,
1228                             const char *tip);
1229 uiBut *uiDefIconTextButS(uiBlock *block,
1230                          int type,
1231                          int retval,
1232                          int icon,
1233                          const char *str,
1234                          int x,
1235                          int y,
1236                          short width,
1237                          short height,
1238                          short *poin,
1239                          float min,
1240                          float max,
1241                          float a1,
1242                          float a2,
1243                          const char *tip);
1244 uiBut *uiDefIconTextButBitS(uiBlock *block,
1245                             int type,
1246                             int bit,
1247                             int retval,
1248                             int icon,
1249                             const char *str,
1250                             int x,
1251                             int y,
1252                             short width,
1253                             short height,
1254                             short *poin,
1255                             float min,
1256                             float max,
1257                             float a1,
1258                             float a2,
1259                             const char *tip);
1260 uiBut *uiDefIconTextButC(uiBlock *block,
1261                          int type,
1262                          int retval,
1263                          int icon,
1264                          const char *str,
1265                          int x,
1266                          int y,
1267                          short width,
1268                          short height,
1269                          char *poin,
1270                          float min,
1271                          float max,
1272                          float a1,
1273                          float a2,
1274                          const char *tip);
1275 uiBut *uiDefIconTextButBitC(uiBlock *block,
1276                             int type,
1277                             int bit,
1278                             int retval,
1279                             int icon,
1280                             const char *str,
1281                             int x,
1282                             int y,
1283                             short width,
1284                             short height,
1285                             char *poin,
1286                             float min,
1287                             float max,
1288                             float a1,
1289                             float a2,
1290                             const char *tip);
1291 uiBut *uiDefIconTextButR(uiBlock *block,
1292                          int type,
1293                          int retval,
1294                          int icon,
1295                          const char *str,
1296                          int x,
1297                          int y,
1298                          short width,
1299                          short height,
1300                          struct PointerRNA *ptr,
1301                          const char *propname,
1302                          int index,
1303                          float min,
1304                          float max,
1305                          float a1,
1306                          float a2,
1307                          const char *tip);
1308 uiBut *uiDefIconTextButR_prop(uiBlock *block,
1309                               int type,
1310                               int retval,
1311                               int icon,
1312                               const char *str,
1313                               int x,
1314                               int y,
1315                               short width,
1316                               short height,
1317                               struct PointerRNA *ptr,
1318                               struct PropertyRNA *prop,
1319                               int index,
1320                               float min,
1321                               float max,
1322                               float a1,
1323                               float a2,
1324                               const char *tip);
1325 uiBut *uiDefIconTextButO(uiBlock *block,
1326                          int type,
1327                          const char *opname,
1328                          int opcontext,
1329                          int icon,
1330                          const char *str,
1331                          int x,
1332                          int y,
1333                          short width,
1334                          short height,
1335                          const char *tip);
1336 uiBut *uiDefIconTextButO_ptr(uiBlock *block,
1337                              int type,
1338                              struct wmOperatorType *ot,
1339                              int opcontext,
1340                              int icon,
1341                              const char *str,
1342                              int x,
1343                              int y,
1344                              short width,
1345                              short height,
1346                              const char *tip);
1347 
1348 /* for passing inputs to ButO buttons */
1349 struct PointerRNA *UI_but_operator_ptr_get(uiBut *but);
1350 
1351 void UI_but_unit_type_set(uiBut *but, const int unit_type);
1352 int UI_but_unit_type_get(const uiBut *but);
1353 
1354 enum {
1355   BUT_GET_RNAPROP_IDENTIFIER = 1,
1356   BUT_GET_RNASTRUCT_IDENTIFIER,
1357   BUT_GET_RNAENUM_IDENTIFIER,
1358   BUT_GET_LABEL,
1359   BUT_GET_RNA_LABEL,
1360   BUT_GET_RNAENUM_LABEL,
1361   BUT_GET_RNA_LABEL_CONTEXT, /* Context specified in CTX_XXX_ macros are just unreachable! */
1362   BUT_GET_TIP,
1363   BUT_GET_RNA_TIP,
1364   BUT_GET_RNAENUM_TIP,
1365   BUT_GET_OP_KEYMAP,
1366   BUT_GET_PROP_KEYMAP,
1367 };
1368 
1369 typedef struct uiStringInfo {
1370   int type;
1371   char *strinfo;
1372 } uiStringInfo;
1373 
1374 /* Note: Expects pointers to uiStringInfo structs as parameters.
1375  *       Will fill them with translated strings, when possible.
1376  *       Strings in uiStringInfo must be MEM_freeN'ed by caller. */
1377 void UI_but_string_info_get(struct bContext *C, uiBut *but, ...) ATTR_SENTINEL(0);
1378 
1379 /* Edit i18n stuff. */
1380 /* Name of the main py op from i18n addon. */
1381 #define EDTSRC_I18N_OP_NAME "UI_OT_edittranslation"
1382 
1383 /**
1384  * Special Buttons
1385  *
1386  * Buttons with a more specific purpose:
1387  * - MenuBut: buttons that popup a menu (in headers usually).
1388  * - PulldownBut: like MenuBut, but creating a uiBlock (for compatibility).
1389  * - BlockBut: buttons that popup a block with more buttons.
1390  * - KeyevtBut: buttons that can be used to turn key events into values.
1391  * - PickerButtons: buttons like the color picker (for code sharing).
1392  * - AutoButR: RNA property button with type automatically defined.
1393  */
1394 enum {
1395   UI_ID_RENAME = 1 << 0,
1396   UI_ID_BROWSE = 1 << 1,
1397   UI_ID_ADD_NEW = 1 << 2,
1398   UI_ID_ALONE = 1 << 4,
1399   UI_ID_OPEN = 1 << 3,
1400   UI_ID_DELETE = 1 << 5,
1401   UI_ID_LOCAL = 1 << 6,
1402   UI_ID_AUTO_NAME = 1 << 7,
1403   UI_ID_FAKE_USER = 1 << 8,
1404   UI_ID_PIN = 1 << 9,
1405   UI_ID_PREVIEWS = 1 << 10,
1406   UI_ID_OVERRIDE = 1 << 11,
1407   UI_ID_FULL = UI_ID_RENAME | UI_ID_BROWSE | UI_ID_ADD_NEW | UI_ID_OPEN | UI_ID_ALONE |
1408                UI_ID_DELETE | UI_ID_LOCAL,
1409 };
1410 
1411 /**
1412  * Ways to limit what is displayed in ID-search popup.
1413  * \note We may want to add LOCAL, LIBRARY ... as needed.
1414  */
1415 enum {
1416   UI_TEMPLATE_ID_FILTER_ALL = 0,
1417   UI_TEMPLATE_ID_FILTER_AVAILABLE = 1,
1418 };
1419 
1420 int UI_icon_from_id(struct ID *id);
1421 int UI_icon_from_report_type(int type);
1422 
1423 int UI_icon_from_event_type(short event_type, short event_value);
1424 int UI_icon_from_keymap_item(const struct wmKeyMapItem *kmi, int r_icon_mod[4]);
1425 
1426 uiBut *uiDefPulldownBut(uiBlock *block,
1427                         uiBlockCreateFunc func,
1428                         void *arg,
1429                         const char *str,
1430                         int x,
1431                         int y,
1432                         short width,
1433                         short height,
1434                         const char *tip);
1435 uiBut *uiDefMenuBut(uiBlock *block,
1436                     uiMenuCreateFunc func,
1437                     void *arg,
1438                     const char *str,
1439                     int x,
1440                     int y,
1441                     short width,
1442                     short height,
1443                     const char *tip);
1444 uiBut *uiDefIconTextMenuBut(uiBlock *block,
1445                             uiMenuCreateFunc func,
1446                             void *arg,
1447                             int icon,
1448                             const char *str,
1449                             int x,
1450                             int y,
1451                             short width,
1452                             short height,
1453                             const char *tip);
1454 uiBut *uiDefIconMenuBut(uiBlock *block,
1455                         uiMenuCreateFunc func,
1456                         void *arg,
1457                         int icon,
1458                         int x,
1459                         int y,
1460                         short width,
1461                         short height,
1462                         const char *tip);
1463 
1464 uiBut *uiDefBlockBut(uiBlock *block,
1465                      uiBlockCreateFunc func,
1466                      void *arg,
1467                      const char *str,
1468                      int x,
1469                      int y,
1470                      short width,
1471                      short height,
1472                      const char *tip);
1473 uiBut *uiDefBlockButN(uiBlock *block,
1474                       uiBlockCreateFunc func,
1475                       void *argN,
1476                       const char *str,
1477                       int x,
1478                       int y,
1479                       short width,
1480                       short height,
1481                       const char *tip);
1482 
1483 uiBut *uiDefIconBlockBut(uiBlock *block,
1484                          uiBlockCreateFunc func,
1485                          void *arg,
1486                          int retval,
1487                          int icon,
1488                          int x,
1489                          int y,
1490                          short width,
1491                          short height,
1492                          const char *tip);
1493 uiBut *uiDefIconTextBlockBut(uiBlock *block,
1494                              uiBlockCreateFunc func,
1495                              void *arg,
1496                              int icon,
1497                              const char *str,
1498                              int x,
1499                              int y,
1500                              short width,
1501                              short height,
1502                              const char *tip);
1503 
1504 uiBut *uiDefKeyevtButS(uiBlock *block,
1505                        int retval,
1506                        const char *str,
1507                        int x,
1508                        int y,
1509                        short width,
1510                        short height,
1511                        short *spoin,
1512                        const char *tip);
1513 uiBut *uiDefHotKeyevtButS(uiBlock *block,
1514                           int retval,
1515                           const char *str,
1516                           int x,
1517                           int y,
1518                           short width,
1519                           short height,
1520                           short *keypoin,
1521                           const short *modkeypoin,
1522                           const char *tip);
1523 
1524 uiBut *uiDefSearchBut(uiBlock *block,
1525                       void *arg,
1526                       int retval,
1527                       int icon,
1528                       int maxlen,
1529                       int x,
1530                       int y,
1531                       short width,
1532                       short height,
1533                       float a1,
1534                       float a2,
1535                       const char *tip);
1536 uiBut *uiDefSearchButO_ptr(uiBlock *block,
1537                            struct wmOperatorType *ot,
1538                            struct IDProperty *properties,
1539                            void *arg,
1540                            int retval,
1541                            int icon,
1542                            int maxlen,
1543                            int x,
1544                            int y,
1545                            short width,
1546                            short height,
1547                            float a1,
1548                            float a2,
1549                            const char *tip);
1550 
1551 /* For uiDefAutoButsRNA */
1552 typedef enum {
1553   /* Keep current layout for aligning label with property button. */
1554   UI_BUT_LABEL_ALIGN_NONE,
1555   /* Align label and property button vertically. */
1556   UI_BUT_LABEL_ALIGN_COLUMN,
1557   /* Split layout into a column for the label and one for property button. */
1558   UI_BUT_LABEL_ALIGN_SPLIT_COLUMN,
1559 } eButLabelAlign;
1560 
1561 /* Return info for uiDefAutoButsRNA */
1562 typedef enum {
1563   /* Returns when no buttons were added */
1564   UI_PROP_BUTS_NONE_ADDED = 1 << 0,
1565   /* Returned when any property failed the custom check callback (check_prop) */
1566   UI_PROP_BUTS_ANY_FAILED_CHECK = 1 << 1,
1567 } eAutoPropButsReturn;
1568 
1569 uiBut *uiDefAutoButR(uiBlock *block,
1570                      struct PointerRNA *ptr,
1571                      struct PropertyRNA *prop,
1572                      int index,
1573                      const char *name,
1574                      int icon,
1575                      int x1,
1576                      int y1,
1577                      int x2,
1578                      int y2);
1579 eAutoPropButsReturn uiDefAutoButsRNA(uiLayout *layout,
1580                                      struct PointerRNA *ptr,
1581                                      bool (*check_prop)(struct PointerRNA *ptr,
1582                                                         struct PropertyRNA *prop,
1583                                                         void *user_data),
1584                                      void *user_data,
1585                                      struct PropertyRNA *prop_activate_init,
1586                                      eButLabelAlign label_align,
1587                                      const bool compact);
1588 
1589 /* use inside searchfunc to add items */
1590 bool UI_search_item_add(uiSearchItems *items,
1591                         const char *name,
1592                         void *poin,
1593                         int iconid,
1594                         int state,
1595                         const uint8_t name_prefix_offset);
1596 
1597 void UI_but_func_search_set(uiBut *but,
1598                             uiButSearchCreateFn search_create_fn,
1599                             uiButSearchUpdateFn search_update_fn,
1600                             void *arg,
1601                             uiButSearchArgFreeFn search_arg_free_fn,
1602                             uiButHandleFunc search_exec_fn,
1603                             void *active);
1604 void UI_but_func_search_set_context_menu(uiBut *but, uiButSearchContextMenuFn context_menu_fn);
1605 void UI_but_func_search_set_tooltip(uiBut *but, uiButSearchTooltipFn tooltip_fn);
1606 void UI_but_func_search_set_sep_string(uiBut *but, const char *search_sep_string);
1607 
1608 /* height in pixels, it's using hardcoded values still */
1609 int UI_searchbox_size_y(void);
1610 int UI_searchbox_size_x(void);
1611 /* check if a string is in an existing search box */
1612 int UI_search_items_find_index(uiSearchItems *items, const char *name);
1613 
1614 void UI_but_node_link_set(uiBut *but, struct bNodeSocket *socket, const float draw_color[4]);
1615 
1616 void UI_but_number_step_size_set(uiBut *but, float step_size);
1617 void UI_but_number_precision_set(uiBut *but, float precision);
1618 
1619 void UI_block_func_handle_set(uiBlock *block, uiBlockHandleFunc func, void *arg);
1620 void UI_block_func_butmenu_set(uiBlock *block, uiMenuHandleFunc func, void *arg);
1621 void UI_block_func_set(uiBlock *block, uiButHandleFunc func, void *arg1, void *arg2);
1622 void UI_block_funcN_set(uiBlock *block, uiButHandleNFunc funcN, void *argN, void *arg2);
1623 
1624 void UI_but_func_rename_set(uiBut *but, uiButHandleRenameFunc func, void *arg1);
1625 void UI_but_func_set(uiBut *but, uiButHandleFunc func, void *arg1, void *arg2);
1626 void UI_but_funcN_set(uiBut *but, uiButHandleNFunc funcN, void *argN, void *arg2);
1627 
1628 void UI_but_func_complete_set(uiBut *but, uiButCompleteFunc func, void *arg);
1629 
1630 void UI_but_func_drawextra_set(
1631     uiBlock *block,
1632     void (*func)(const struct bContext *C, void *, void *, void *, struct rcti *rect),
1633     void *arg1,
1634     void *arg2);
1635 
1636 void UI_but_func_menu_step_set(uiBut *but, uiMenuStepFunc func);
1637 
1638 void UI_but_func_tooltip_set(uiBut *but, uiButToolTipFunc func, void *argN);
1639 void UI_but_tooltip_refresh(struct bContext *C, uiBut *but);
1640 void UI_but_tooltip_timer_remove(struct bContext *C, uiBut *but);
1641 
1642 bool UI_textbutton_activate_rna(const struct bContext *C,
1643                                 struct ARegion *region,
1644                                 const void *rna_poin_data,
1645                                 const char *rna_prop_id);
1646 bool UI_textbutton_activate_but(const struct bContext *C, uiBut *but);
1647 
1648 void UI_but_focus_on_enter_event(struct wmWindow *win, uiBut *but);
1649 
1650 void UI_but_func_hold_set(uiBut *but, uiButHandleHoldFunc func, void *argN);
1651 
1652 void UI_but_func_pushed_state_set(uiBut *but, uiButPushedStateFunc func, void *arg);
1653 
1654 PointerRNA *UI_but_extra_operator_icon_add(uiBut *but,
1655                                            const char *opname,
1656                                            short opcontext,
1657                                            int icon);
1658 
1659 /* Autocomplete
1660  *
1661  * Tab complete helper functions, for use in uiButCompleteFunc callbacks.
1662  * Call begin once, then multiple times do_name with all possibilities,
1663  * and finally end to finish and get the completed name. */
1664 
1665 typedef struct AutoComplete AutoComplete;
1666 
1667 #define AUTOCOMPLETE_NO_MATCH 0
1668 #define AUTOCOMPLETE_FULL_MATCH 1
1669 #define AUTOCOMPLETE_PARTIAL_MATCH 2
1670 
1671 AutoComplete *UI_autocomplete_begin(const char *startname, size_t maxlen);
1672 void UI_autocomplete_update_name(AutoComplete *autocpl, const char *name);
1673 int UI_autocomplete_end(AutoComplete *autocpl, char *autoname);
1674 
1675 /* Panels
1676  *
1677  * Functions for creating, freeing and drawing panels. The API here
1678  * could use a good cleanup, though how they will function in 2.5 is
1679  * not clear yet so we postpone that. */
1680 
1681 void UI_panels_begin(const struct bContext *C, struct ARegion *region);
1682 void UI_panels_end(const struct bContext *C, struct ARegion *region, int *r_x, int *r_y);
1683 void UI_panels_draw(const struct bContext *C, struct ARegion *region);
1684 
1685 struct Panel *UI_panel_find_by_type(struct ListBase *lb, struct PanelType *pt);
1686 struct Panel *UI_panel_begin(struct ARegion *region,
1687                              struct ListBase *lb,
1688                              uiBlock *block,
1689                              struct PanelType *pt,
1690                              struct Panel *panel,
1691                              bool *r_open);
1692 void UI_panel_header_buttons_begin(struct Panel *panel);
1693 void UI_panel_header_buttons_end(struct Panel *panel);
1694 void UI_panel_end(struct Panel *panel, int width, int height);
1695 
1696 bool UI_panel_is_closed(const struct Panel *panel);
1697 bool UI_panel_is_active(const struct Panel *panel);
1698 void UI_panel_label_offset(struct uiBlock *block, int *r_x, int *r_y);
1699 int UI_panel_size_y(const struct Panel *panel);
1700 bool UI_panel_is_dragging(const struct Panel *panel);
1701 bool UI_panel_matches_search_filter(const struct Panel *panel);
1702 
1703 bool UI_panel_category_is_visible(const struct ARegion *region);
1704 void UI_panel_category_add(struct ARegion *region, const char *name);
1705 struct PanelCategoryDyn *UI_panel_category_find(struct ARegion *region, const char *idname);
1706 struct PanelCategoryStack *UI_panel_category_active_find(struct ARegion *region,
1707                                                          const char *idname);
1708 const char *UI_panel_category_active_get(struct ARegion *region, bool set_fallback);
1709 void UI_panel_category_active_set(struct ARegion *region, const char *idname);
1710 void UI_panel_category_active_set_default(struct ARegion *region, const char *idname);
1711 struct PanelCategoryDyn *UI_panel_category_find_mouse_over_ex(struct ARegion *region,
1712                                                               const int x,
1713                                                               const int y);
1714 struct PanelCategoryDyn *UI_panel_category_find_mouse_over(struct ARegion *region,
1715                                                            const struct wmEvent *event);
1716 void UI_panel_category_clear_all(struct ARegion *region);
1717 void UI_panel_category_draw_all(struct ARegion *region, const char *category_id_active);
1718 
1719 struct PanelType *UI_paneltype_find(int space_id, int region_id, const char *idname);
1720 
1721 /* Panel custom data. */
1722 struct PointerRNA *UI_panel_custom_data_get(const struct Panel *panel);
1723 struct PointerRNA *UI_region_panel_custom_data_under_cursor(const struct bContext *C,
1724                                                             const struct wmEvent *event);
1725 void UI_panel_custom_data_set(struct Panel *panel, struct PointerRNA *custom_data);
1726 
1727 /* Polyinstantiated panels for representing a list of data. */
1728 struct Panel *UI_panel_add_instanced(const struct bContext *C,
1729                                      struct ARegion *region,
1730                                      struct ListBase *panels,
1731                                      char *panel_idname,
1732                                      struct PointerRNA *custom_data);
1733 void UI_panels_free_instanced(const struct bContext *C, struct ARegion *region);
1734 
1735 #define INSTANCED_PANEL_UNIQUE_STR_LEN 4
1736 void UI_list_panel_unique_str(struct Panel *panel, char *r_name);
1737 
1738 typedef void (*uiListPanelIDFromDataFunc)(void *data_link, char *r_idname);
1739 bool UI_panel_list_matches_data(struct ARegion *region,
1740                                 struct ListBase *data,
1741                                 uiListPanelIDFromDataFunc panel_idname_func);
1742 
1743 /* Handlers
1744  *
1745  * Handlers that can be registered in regions, areas and windows for
1746  * handling WM events. Mostly this is done automatic by modules such
1747  * as screen/ if ED_KEYMAP_UI is set, or internally in popup functions. */
1748 
1749 void UI_region_handlers_add(struct ListBase *handlers);
1750 void UI_popup_handlers_add(struct bContext *C,
1751                            struct ListBase *handlers,
1752                            uiPopupBlockHandle *popup,
1753                            const char flag);
1754 void UI_popup_handlers_remove(struct ListBase *handlers, uiPopupBlockHandle *popup);
1755 void UI_popup_handlers_remove_all(struct bContext *C, struct ListBase *handlers);
1756 
1757 /* Module
1758  *
1759  * init and exit should be called before using this module. init_userdef must
1760  * be used to reinitialize some internal state if user preferences change. */
1761 
1762 void UI_init(void);
1763 void UI_init_userdef(void);
1764 void UI_reinit_font(void);
1765 void UI_exit(void);
1766 
1767 /* Layout
1768  *
1769  * More automated layout of buttons. Has three levels:
1770  * - Layout: contains a number templates, within a bounded width or height.
1771  * - Template: predefined layouts for buttons with a number of slots, each
1772  *   slot can contain multiple items.
1773  * - Item: item to put in a template slot, being either an RNA property,
1774  *   operator, label or menu. Also regular buttons can be used when setting
1775  *   uiBlockCurLayout. */
1776 
1777 /* layout */
1778 enum {
1779   UI_LAYOUT_HORIZONTAL = 0,
1780   UI_LAYOUT_VERTICAL = 1,
1781 };
1782 
1783 enum {
1784   UI_LAYOUT_PANEL = 0,
1785   UI_LAYOUT_HEADER = 1,
1786   UI_LAYOUT_MENU = 2,
1787   UI_LAYOUT_TOOLBAR = 3,
1788   UI_LAYOUT_PIEMENU = 4,
1789   UI_LAYOUT_VERT_BAR = 5,
1790 };
1791 
1792 #define UI_UNIT_X ((void)0, U.widget_unit)
1793 #define UI_UNIT_Y ((void)0, U.widget_unit)
1794 
1795 enum {
1796   UI_LAYOUT_ALIGN_EXPAND = 0,
1797   UI_LAYOUT_ALIGN_LEFT = 1,
1798   UI_LAYOUT_ALIGN_CENTER = 2,
1799   UI_LAYOUT_ALIGN_RIGHT = 3,
1800 };
1801 
1802 enum {
1803   /* UI_ITEM_O_RETURN_PROPS = 1 << 0, */ /* UNUSED */
1804   UI_ITEM_R_EXPAND = 1 << 1,
1805   UI_ITEM_R_SLIDER = 1 << 2,
1806   /**
1807    * Use for booleans, causes the button to draw with an outline (emboss),
1808    * instead of text with a checkbox.
1809    * This is implied when toggle buttons have an icon
1810    * unless #UI_ITEM_R_ICON_NEVER flag is set.
1811    */
1812   UI_ITEM_R_TOGGLE = 1 << 3,
1813   /**
1814    * Don't attempt to use an icon when the icon is set to #ICON_NONE.
1815    *
1816    * Use for boolean's, causes the buttons to always show as a checkbox
1817    * even when there is an icon (which would normally show the button as a toggle).
1818    */
1819   UI_ITEM_R_ICON_NEVER = 1 << 4,
1820   UI_ITEM_R_ICON_ONLY = 1 << 5,
1821   UI_ITEM_R_EVENT = 1 << 6,
1822   UI_ITEM_R_FULL_EVENT = 1 << 7,
1823   UI_ITEM_R_NO_BG = 1 << 8,
1824   UI_ITEM_R_IMMEDIATE = 1 << 9,
1825   UI_ITEM_O_DEPRESS = 1 << 10,
1826   UI_ITEM_R_COMPACT = 1 << 11,
1827   UI_ITEM_R_CHECKBOX_INVERT = 1 << 12,
1828   /** Don't add a real decorator item, just blank space. */
1829   UI_ITEM_R_FORCE_BLANK_DECORATE = 1 << 13,
1830   /* Even create the property split layout if there's no name to show there. */
1831   UI_ITEM_R_SPLIT_EMPTY_NAME = 1 << 14,
1832 };
1833 
1834 #define UI_HEADER_OFFSET ((void)0, 0.4f * UI_UNIT_X)
1835 
1836 /* uiLayoutOperatorButs flags */
1837 enum {
1838   UI_TEMPLATE_OP_PROPS_SHOW_TITLE = 1 << 0,
1839   UI_TEMPLATE_OP_PROPS_SHOW_EMPTY = 1 << 1,
1840   UI_TEMPLATE_OP_PROPS_COMPACT = 1 << 2,
1841   UI_TEMPLATE_OP_PROPS_HIDE_ADVANCED = 1 << 3,
1842   /* Disable property split for the default layout (custom ui callbacks still have full control
1843    * over the layout and can enable it). */
1844   UI_TEMPLATE_OP_PROPS_NO_SPLIT_LAYOUT = 1 << 4,
1845 };
1846 
1847 /* used for transp checkers */
1848 #define UI_ALPHA_CHECKER_DARK 100
1849 #define UI_ALPHA_CHECKER_LIGHT 160
1850 
1851 /* flags to set which corners will become rounded:
1852  *
1853  * 1------2
1854  * |      |
1855  * 8------4 */
1856 
1857 enum {
1858   UI_CNR_TOP_LEFT = 1 << 0,
1859   UI_CNR_TOP_RIGHT = 1 << 1,
1860   UI_CNR_BOTTOM_RIGHT = 1 << 2,
1861   UI_CNR_BOTTOM_LEFT = 1 << 3,
1862   /* just for convenience */
1863   UI_CNR_NONE = 0,
1864   UI_CNR_ALL = (UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT),
1865 };
1866 
1867 uiLayout *UI_block_layout(uiBlock *block,
1868                           int dir,
1869                           int type,
1870                           int x,
1871                           int y,
1872                           int size,
1873                           int em,
1874                           int padding,
1875                           const struct uiStyle *style);
1876 void UI_block_layout_set_current(uiBlock *block, uiLayout *layout);
1877 void UI_block_layout_resolve(uiBlock *block, int *r_x, int *r_y);
1878 void UI_block_layout_free(uiBlock *block);
1879 
1880 bool UI_block_apply_search_filter(uiBlock *block, const char *search_filter);
1881 
1882 void UI_region_message_subscribe(struct ARegion *region, struct wmMsgBus *mbus);
1883 
1884 uiBlock *uiLayoutGetBlock(uiLayout *layout);
1885 
1886 void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv);
1887 void uiLayoutSetContextPointer(uiLayout *layout, const char *name, struct PointerRNA *ptr);
1888 void uiLayoutContextCopy(uiLayout *layout, struct bContextStore *context);
1889 struct wmOperatorType *UI_but_operatortype_get_from_enum_menu(struct uiBut *but,
1890                                                               PropertyRNA **r_prop);
1891 struct MenuType *UI_but_menutype_get(uiBut *but);
1892 struct PanelType *UI_but_paneltype_get(uiBut *but);
1893 void UI_menutype_draw(struct bContext *C, struct MenuType *mt, struct uiLayout *layout);
1894 void UI_paneltype_draw(struct bContext *C, struct PanelType *pt, struct uiLayout *layout);
1895 
1896 /* Only for convenience. */
1897 void uiLayoutSetContextFromBut(uiLayout *layout, uiBut *but);
1898 
1899 void uiLayoutSetOperatorContext(uiLayout *layout, int opcontext);
1900 void uiLayoutSetActive(uiLayout *layout, bool active);
1901 void uiLayoutSetActiveDefault(uiLayout *layout, bool active_default);
1902 void uiLayoutSetActivateInit(uiLayout *layout, bool activate_init);
1903 void uiLayoutSetEnabled(uiLayout *layout, bool enabled);
1904 void uiLayoutSetRedAlert(uiLayout *layout, bool redalert);
1905 void uiLayoutSetAlignment(uiLayout *layout, char alignment);
1906 void uiLayoutSetFixedSize(uiLayout *layout, bool fixed_size);
1907 void uiLayoutSetKeepAspect(uiLayout *layout, bool keepaspect);
1908 void uiLayoutSetScaleX(uiLayout *layout, float scale);
1909 void uiLayoutSetScaleY(uiLayout *layout, float scale);
1910 void uiLayoutSetUnitsX(uiLayout *layout, float unit);
1911 void uiLayoutSetUnitsY(uiLayout *layout, float unit);
1912 void uiLayoutSetEmboss(uiLayout *layout, char emboss);
1913 void uiLayoutSetPropSep(uiLayout *layout, bool is_sep);
1914 void uiLayoutSetPropDecorate(uiLayout *layout, bool is_sep);
1915 int uiLayoutGetLocalDir(const uiLayout *layout);
1916 
1917 int uiLayoutGetOperatorContext(uiLayout *layout);
1918 bool uiLayoutGetActive(uiLayout *layout);
1919 bool uiLayoutGetActiveDefault(uiLayout *layout);
1920 bool uiLayoutGetActivateInit(uiLayout *layout);
1921 bool uiLayoutGetEnabled(uiLayout *layout);
1922 bool uiLayoutGetRedAlert(uiLayout *layout);
1923 int uiLayoutGetAlignment(uiLayout *layout);
1924 bool uiLayoutGetFixedSize(uiLayout *layout);
1925 bool uiLayoutGetKeepAspect(uiLayout *layout);
1926 int uiLayoutGetWidth(uiLayout *layout);
1927 float uiLayoutGetScaleX(uiLayout *layout);
1928 float uiLayoutGetScaleY(uiLayout *layout);
1929 float uiLayoutGetUnitsX(uiLayout *layout);
1930 float uiLayoutGetUnitsY(uiLayout *layout);
1931 int uiLayoutGetEmboss(uiLayout *layout);
1932 bool uiLayoutGetPropSep(uiLayout *layout);
1933 bool uiLayoutGetPropDecorate(uiLayout *layout);
1934 
1935 /* layout specifiers */
1936 uiLayout *uiLayoutRow(uiLayout *layout, bool align);
1937 uiLayout *uiLayoutRowWithHeading(uiLayout *layout, bool align, const char *heading);
1938 uiLayout *uiLayoutColumn(uiLayout *layout, bool align);
1939 uiLayout *uiLayoutColumnWithHeading(uiLayout *layout, bool align, const char *heading);
1940 uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, bool align);
1941 uiLayout *uiLayoutGridFlow(uiLayout *layout,
1942                            bool row_major,
1943                            int columns_len,
1944                            bool even_columns,
1945                            bool even_rows,
1946                            bool align);
1947 uiLayout *uiLayoutBox(uiLayout *layout);
1948 uiLayout *uiLayoutListBox(uiLayout *layout,
1949                           struct uiList *ui_list,
1950                           struct PointerRNA *actptr,
1951                           struct PropertyRNA *actprop);
1952 uiLayout *uiLayoutAbsolute(uiLayout *layout, bool align);
1953 uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, bool align);
1954 uiLayout *uiLayoutOverlap(uiLayout *layout);
1955 uiBlock *uiLayoutAbsoluteBlock(uiLayout *layout);
1956 uiLayout *uiLayoutRadial(uiLayout *layout);
1957 
1958 /* templates */
1959 void uiTemplateHeader(uiLayout *layout, struct bContext *C);
1960 void uiTemplateID(uiLayout *layout,
1961                   const struct bContext *C,
1962                   struct PointerRNA *ptr,
1963                   const char *propname,
1964                   const char *newop,
1965                   const char *openop,
1966                   const char *unlinkop,
1967                   int filter,
1968                   const bool live_icon,
1969                   const char *text);
1970 void uiTemplateIDBrowse(uiLayout *layout,
1971                         struct bContext *C,
1972                         struct PointerRNA *ptr,
1973                         const char *propname,
1974                         const char *newop,
1975                         const char *openop,
1976                         const char *unlinkop,
1977                         int filter,
1978                         const char *text);
1979 void uiTemplateIDPreview(uiLayout *layout,
1980                          struct bContext *C,
1981                          struct PointerRNA *ptr,
1982                          const char *propname,
1983                          const char *newop,
1984                          const char *openop,
1985                          const char *unlinkop,
1986                          int rows,
1987                          int cols,
1988                          int filter,
1989                          const bool hide_buttons);
1990 void uiTemplateIDTabs(uiLayout *layout,
1991                       struct bContext *C,
1992                       PointerRNA *ptr,
1993                       const char *propname,
1994                       const char *newop,
1995                       const char *menu,
1996                       int filter);
1997 void uiTemplateAnyID(uiLayout *layout,
1998                      struct PointerRNA *ptr,
1999                      const char *propname,
2000                      const char *proptypename,
2001                      const char *text);
2002 void uiTemplateSearch(uiLayout *layout,
2003                       struct bContext *C,
2004                       struct PointerRNA *ptr,
2005                       const char *propname,
2006                       struct PointerRNA *searchptr,
2007                       const char *searchpropname,
2008                       const char *newop,
2009                       const char *unlinkop);
2010 void uiTemplateSearchPreview(uiLayout *layout,
2011                              struct bContext *C,
2012                              struct PointerRNA *ptr,
2013                              const char *propname,
2014                              struct PointerRNA *searchptr,
2015                              const char *searchpropname,
2016                              const char *newop,
2017                              const char *unlinkop,
2018                              const int rows,
2019                              const int cols);
2020 void uiTemplatePathBuilder(uiLayout *layout,
2021                            struct PointerRNA *ptr,
2022                            const char *propname,
2023                            struct PointerRNA *root_ptr,
2024                            const char *text);
2025 void uiTemplateModifiers(uiLayout *layout, struct bContext *C);
2026 void uiTemplateGpencilModifiers(uiLayout *layout, struct bContext *C);
2027 void uiTemplateShaderFx(uiLayout *layout, struct bContext *C);
2028 void uiTemplateConstraints(uiLayout *layout, struct bContext *C, bool use_bone_constraints);
2029 
2030 uiLayout *uiTemplateGpencilModifier(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr);
2031 void uiTemplateGpencilColorPreview(uiLayout *layout,
2032                                    struct bContext *C,
2033                                    struct PointerRNA *ptr,
2034                                    const char *propname,
2035                                    int rows,
2036                                    int cols,
2037                                    float scale,
2038                                    int filter);
2039 
2040 void uiTemplateOperatorRedoProperties(uiLayout *layout, const struct bContext *C);
2041 
2042 void uiTemplateConstraintHeader(uiLayout *layout, struct PointerRNA *ptr);
2043 void uiTemplatePreview(uiLayout *layout,
2044                        struct bContext *C,
2045                        struct ID *id,
2046                        bool show_buttons,
2047                        struct ID *parent,
2048                        struct MTex *slot,
2049                        const char *preview_id);
2050 void uiTemplateColorRamp(uiLayout *layout,
2051                          struct PointerRNA *ptr,
2052                          const char *propname,
2053                          bool expand);
2054 void uiTemplateIcon(uiLayout *layout, int icon_value, float icon_scale);
2055 void uiTemplateIconView(uiLayout *layout,
2056                         struct PointerRNA *ptr,
2057                         const char *propname,
2058                         bool show_labels,
2059                         float icon_scale,
2060                         float icon_scale_popup);
2061 void uiTemplateHistogram(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
2062 void uiTemplateWaveform(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
2063 void uiTemplateVectorscope(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
2064 void uiTemplateCurveMapping(uiLayout *layout,
2065                             struct PointerRNA *ptr,
2066                             const char *propname,
2067                             int type,
2068                             bool levels,
2069                             bool brush,
2070                             bool neg_slope,
2071                             bool tone);
2072 void uiTemplateCurveProfile(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
2073 void uiTemplateColorPicker(uiLayout *layout,
2074                            struct PointerRNA *ptr,
2075                            const char *propname,
2076                            bool value_slider,
2077                            bool lock,
2078                            bool lock_luminosity,
2079                            bool cubic);
2080 void uiTemplatePalette(uiLayout *layout,
2081                        struct PointerRNA *ptr,
2082                        const char *propname,
2083                        bool colors);
2084 void uiTemplateCryptoPicker(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
2085 void uiTemplateLayers(uiLayout *layout,
2086                       struct PointerRNA *ptr,
2087                       const char *propname,
2088                       PointerRNA *used_ptr,
2089                       const char *used_propname,
2090                       int active_layer);
2091 void uiTemplateImage(uiLayout *layout,
2092                      struct bContext *C,
2093                      struct PointerRNA *ptr,
2094                      const char *propname,
2095                      struct PointerRNA *userptr,
2096                      bool compact,
2097                      bool multiview);
2098 void uiTemplateImageSettings(uiLayout *layout, struct PointerRNA *imfptr, bool color_management);
2099 void uiTemplateImageStereo3d(uiLayout *layout, struct PointerRNA *stereo3d_format_ptr);
2100 void uiTemplateImageViews(uiLayout *layout, struct PointerRNA *imaptr);
2101 void uiTemplateImageFormatViews(uiLayout *layout, PointerRNA *imfptr, PointerRNA *ptr);
2102 void uiTemplateImageLayers(uiLayout *layout,
2103                            struct bContext *C,
2104                            struct Image *ima,
2105                            struct ImageUser *iuser);
2106 void uiTemplateImageInfo(uiLayout *layout,
2107                          struct bContext *C,
2108                          struct Image *ima,
2109                          struct ImageUser *iuser);
2110 void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C);
2111 void UI_but_func_operator_search(uiBut *but);
2112 void uiTemplateOperatorSearch(uiLayout *layout);
2113 
2114 void UI_but_func_menu_search(uiBut *but);
2115 void uiTemplateMenuSearch(uiLayout *layout);
2116 
2117 void uiTemplateOperatorPropertyButs(const struct bContext *C,
2118                                     uiLayout *layout,
2119                                     struct wmOperator *op,
2120                                     eButLabelAlign label_align,
2121                                     short flag);
2122 void uiTemplateHeader3D_mode(uiLayout *layout, struct bContext *C);
2123 void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C);
2124 void uiTemplateReportsBanner(uiLayout *layout, struct bContext *C);
2125 void uiTemplateInputStatus(uiLayout *layout, struct bContext *C);
2126 void uiTemplateKeymapItemProperties(uiLayout *layout, struct PointerRNA *ptr);
2127 
2128 bool uiTemplateEventFromKeymapItem(struct uiLayout *layout,
2129                                    const char *text,
2130                                    const struct wmKeyMapItem *kmi,
2131                                    bool text_fallback);
2132 
2133 void uiTemplateComponentMenu(uiLayout *layout,
2134                              struct PointerRNA *ptr,
2135                              const char *propname,
2136                              const char *name);
2137 void uiTemplateNodeSocket(uiLayout *layout, struct bContext *C, float *color);
2138 void uiTemplateCacheFile(uiLayout *layout,
2139                          const struct bContext *C,
2140                          struct PointerRNA *ptr,
2141                          const char *propname);
2142 
2143 /* Default UIList class name, keep in sync with its declaration in bl_ui/__init__.py */
2144 #define UI_UL_DEFAULT_CLASS_NAME "UI_UL_list"
2145 void uiTemplateList(uiLayout *layout,
2146                     struct bContext *C,
2147                     const char *listtype_name,
2148                     const char *list_id,
2149                     struct PointerRNA *dataptr,
2150                     const char *propname,
2151                     struct PointerRNA *active_dataptr,
2152                     const char *active_propname,
2153                     const char *item_dyntip_propname,
2154                     int rows,
2155                     int maxrows,
2156                     int layout_type,
2157                     int columns,
2158                     bool sort_reverse,
2159                     bool sort_lock);
2160 void uiTemplateNodeLink(uiLayout *layout,
2161                         struct bContext *C,
2162                         struct bNodeTree *ntree,
2163                         struct bNode *node,
2164                         struct bNodeSocket *input);
2165 void uiTemplateNodeView(uiLayout *layout,
2166                         struct bContext *C,
2167                         struct bNodeTree *ntree,
2168                         struct bNode *node,
2169                         struct bNodeSocket *input);
2170 void uiTemplateTextureUser(uiLayout *layout, struct bContext *C);
2171 void uiTemplateTextureShow(uiLayout *layout,
2172                            const struct bContext *C,
2173                            struct PointerRNA *ptr,
2174                            struct PropertyRNA *prop);
2175 
2176 void uiTemplateMovieClip(struct uiLayout *layout,
2177                          struct bContext *C,
2178                          struct PointerRNA *ptr,
2179                          const char *propname,
2180                          bool compact);
2181 void uiTemplateTrack(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname);
2182 void uiTemplateMarker(struct uiLayout *layout,
2183                       struct PointerRNA *ptr,
2184                       const char *propname,
2185                       PointerRNA *userptr,
2186                       PointerRNA *trackptr,
2187                       bool compact);
2188 void uiTemplateMovieclipInformation(struct uiLayout *layout,
2189                                     struct PointerRNA *ptr,
2190                                     const char *propname,
2191                                     struct PointerRNA *userptr);
2192 
2193 void uiTemplateColorspaceSettings(struct uiLayout *layout,
2194                                   struct PointerRNA *ptr,
2195                                   const char *propname);
2196 void uiTemplateColormanagedViewSettings(struct uiLayout *layout,
2197                                         struct bContext *C,
2198                                         struct PointerRNA *ptr,
2199                                         const char *propname);
2200 
2201 int uiTemplateRecentFiles(struct uiLayout *layout, int rows);
2202 void uiTemplateFileSelectPath(uiLayout *layout,
2203                               struct bContext *C,
2204                               struct FileSelectParams *params);
2205 
2206 /* items */
2207 void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname);
2208 void uiItemEnumO_ptr(uiLayout *layout,
2209                      struct wmOperatorType *ot,
2210                      const char *name,
2211                      int icon,
2212                      const char *propname,
2213                      int value);
2214 void uiItemEnumO(uiLayout *layout,
2215                  const char *opname,
2216                  const char *name,
2217                  int icon,
2218                  const char *propname,
2219                  int value);
2220 void uiItemEnumO_value(uiLayout *layout,
2221                        const char *name,
2222                        int icon,
2223                        const char *opname,
2224                        const char *propname,
2225                        int value);
2226 void uiItemEnumO_string(uiLayout *layout,
2227                         const char *name,
2228                         int icon,
2229                         const char *opname,
2230                         const char *propname,
2231                         const char *value);
2232 void uiItemsEnumO(uiLayout *layout, const char *opname, const char *propname);
2233 void uiItemBooleanO(uiLayout *layout,
2234                     const char *name,
2235                     int icon,
2236                     const char *opname,
2237                     const char *propname,
2238                     int value);
2239 void uiItemIntO(uiLayout *layout,
2240                 const char *name,
2241                 int icon,
2242                 const char *opname,
2243                 const char *propname,
2244                 int value);
2245 void uiItemFloatO(uiLayout *layout,
2246                   const char *name,
2247                   int icon,
2248                   const char *opname,
2249                   const char *propname,
2250                   float value);
2251 void uiItemStringO(uiLayout *layout,
2252                    const char *name,
2253                    int icon,
2254                    const char *opname,
2255                    const char *propname,
2256                    const char *value);
2257 
2258 void uiItemFullO_ptr(uiLayout *layout,
2259                      struct wmOperatorType *ot,
2260                      const char *name,
2261                      int icon,
2262                      struct IDProperty *properties,
2263                      int context,
2264                      int flag,
2265                      PointerRNA *r_opptr);
2266 void uiItemFullO(uiLayout *layout,
2267                  const char *opname,
2268                  const char *name,
2269                  int icon,
2270                  struct IDProperty *properties,
2271                  int context,
2272                  int flag,
2273                  PointerRNA *r_opptr);
2274 void uiItemFullOMenuHold_ptr(uiLayout *layout,
2275                              struct wmOperatorType *ot,
2276                              const char *name,
2277                              int icon,
2278                              struct IDProperty *properties,
2279                              int context,
2280                              int flag,
2281                              const char *menu_id, /* extra menu arg. */
2282                              PointerRNA *r_opptr);
2283 
2284 void uiItemR(uiLayout *layout,
2285              struct PointerRNA *ptr,
2286              const char *propname,
2287              int flag,
2288              const char *name,
2289              int icon);
2290 void uiItemFullR(uiLayout *layout,
2291                  struct PointerRNA *ptr,
2292                  struct PropertyRNA *prop,
2293                  int index,
2294                  int value,
2295                  int flag,
2296                  const char *name,
2297                  int icon);
2298 void uiItemFullR_with_popover(uiLayout *layout,
2299                               struct PointerRNA *ptr,
2300                               struct PropertyRNA *prop,
2301                               int index,
2302                               int value,
2303                               int flag,
2304                               const char *name,
2305                               int icon,
2306                               const char *panel_type);
2307 void uiItemFullR_with_menu(uiLayout *layout,
2308                            struct PointerRNA *ptr,
2309                            struct PropertyRNA *prop,
2310                            int index,
2311                            int value,
2312                            int flag,
2313                            const char *name,
2314                            int icon,
2315                            const char *menu_type);
2316 void uiItemEnumR_prop(uiLayout *layout,
2317                       const char *name,
2318                       int icon,
2319                       struct PointerRNA *ptr,
2320                       PropertyRNA *prop,
2321                       int value);
2322 void uiItemEnumR(uiLayout *layout,
2323                  const char *name,
2324                  int icon,
2325                  struct PointerRNA *ptr,
2326                  const char *propname,
2327                  int value);
2328 void uiItemEnumR_string_prop(uiLayout *layout,
2329                              struct PointerRNA *ptr,
2330                              PropertyRNA *prop,
2331                              const char *value,
2332                              const char *name,
2333                              int icon);
2334 void uiItemEnumR_string(uiLayout *layout,
2335                         struct PointerRNA *ptr,
2336                         const char *propname,
2337                         const char *value,
2338                         const char *name,
2339                         int icon);
2340 void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
2341 void uiItemPointerR_prop(uiLayout *layout,
2342                          struct PointerRNA *ptr,
2343                          PropertyRNA *prop,
2344                          struct PointerRNA *searchptr,
2345                          PropertyRNA *searchprop,
2346                          const char *name,
2347                          int icon);
2348 void uiItemPointerR(uiLayout *layout,
2349                     struct PointerRNA *ptr,
2350                     const char *propname,
2351                     struct PointerRNA *searchptr,
2352                     const char *searchpropname,
2353                     const char *name,
2354                     int icon);
2355 void uiItemsFullEnumO(uiLayout *layout,
2356                       const char *opname,
2357                       const char *propname,
2358                       struct IDProperty *properties,
2359                       int context,
2360                       int flag);
2361 void uiItemsFullEnumO_items(uiLayout *layout,
2362                             struct wmOperatorType *ot,
2363                             PointerRNA ptr,
2364                             PropertyRNA *prop,
2365                             struct IDProperty *properties,
2366                             int context,
2367                             int flag,
2368                             const EnumPropertyItem *item_array,
2369                             int totitem);
2370 
2371 typedef struct uiPropertySplitWrapper {
2372   uiLayout *label_column;
2373   uiLayout *property_row;
2374   uiLayout *decorate_column;
2375 } uiPropertySplitWrapper;
2376 
2377 uiPropertySplitWrapper uiItemPropertySplitWrapperCreate(uiLayout *parent_layout);
2378 
2379 void uiItemL(uiLayout *layout, const char *name, int icon); /* label */
2380 void uiItemL_ex(
2381     uiLayout *layout, const char *name, int icon, const bool highlight, const bool redalert);
2382 uiLayout *uiItemL_respect_property_split(uiLayout *layout, const char *text, int icon);
2383 /* label icon for dragging */
2384 void uiItemLDrag(uiLayout *layout, struct PointerRNA *ptr, const char *name, int icon);
2385 /* menu */
2386 void uiItemM_ptr(uiLayout *layout, struct MenuType *mt, const char *name, int icon);
2387 void uiItemM(uiLayout *layout, const char *menuname, const char *name, int icon);
2388 /* menu contents */
2389 void uiItemMContents(uiLayout *layout, const char *menuname);
2390 /* Decorators */
2391 void uiItemDecoratorR_prop(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index);
2392 void uiItemDecoratorR(uiLayout *layout, PointerRNA *ptr, const char *propname, int index);
2393 /* value */
2394 void uiItemV(uiLayout *layout, const char *name, int icon, int argval);
2395 /* separator */
2396 void uiItemS(uiLayout *layout);
2397 void uiItemS_ex(uiLayout *layout, float factor);
2398 /* Special separator. */
2399 void uiItemSpacer(uiLayout *layout);
2400 
2401 void uiItemPopoverPanel_ptr(
2402     uiLayout *layout, struct bContext *C, struct PanelType *pt, const char *name, int icon);
2403 void uiItemPopoverPanel(
2404     uiLayout *layout, struct bContext *C, const char *panel_type, const char *name, int icon);
2405 void uiItemPopoverPanelFromGroup(uiLayout *layout,
2406                                  struct bContext *C,
2407                                  int space_id,
2408                                  int region_id,
2409                                  const char *context,
2410                                  const char *category);
2411 
2412 void uiItemMenuF(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *arg);
2413 void uiItemMenuFN(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *argN);
2414 void uiItemMenuEnumO_ptr(uiLayout *layout,
2415                          struct bContext *C,
2416                          struct wmOperatorType *ot,
2417                          const char *propname,
2418                          const char *name,
2419                          int icon);
2420 void uiItemMenuEnumO(uiLayout *layout,
2421                      struct bContext *C,
2422                      const char *opname,
2423                      const char *propname,
2424                      const char *name,
2425                      int icon);
2426 void uiItemMenuEnumR_prop(
2427     uiLayout *layout, struct PointerRNA *ptr, PropertyRNA *prop, const char *name, int icon);
2428 void uiItemMenuEnumR(
2429     uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name, int icon);
2430 void uiItemTabsEnumR_prop(uiLayout *layout,
2431                           struct bContext *C,
2432                           struct PointerRNA *ptr,
2433                           PropertyRNA *prop,
2434                           struct PointerRNA *ptr_highlight,
2435                           PropertyRNA *prop_highlight,
2436                           bool icon_only);
2437 
2438 /* Only for testing, inspecting layouts. */
2439 const char *UI_layout_introspect(uiLayout *layout);
2440 
2441 /* UI Operators */
2442 typedef struct uiDragColorHandle {
2443   float color[3];
2444   bool gamma_corrected;
2445 } uiDragColorHandle;
2446 
2447 void ED_operatortypes_ui(void);
2448 void ED_keymap_ui(struct wmKeyConfig *keyconf);
2449 
2450 void UI_drop_color_copy(struct wmDrag *drag, struct wmDropBox *drop);
2451 bool UI_drop_color_poll(struct bContext *C,
2452                         struct wmDrag *drag,
2453                         const struct wmEvent *event,
2454                         const char **r_tooltip);
2455 
2456 bool UI_context_copy_to_selected_list(struct bContext *C,
2457                                       struct PointerRNA *ptr,
2458                                       struct PropertyRNA *prop,
2459                                       struct ListBase *r_lb,
2460                                       bool *r_use_path_from_id,
2461                                       char **r_path);
2462 
2463 /* Helpers for Operators */
2464 uiBut *UI_context_active_but_get(const struct bContext *C);
2465 uiBut *UI_context_active_but_get_respect_menu(const struct bContext *C);
2466 uiBut *UI_context_active_but_prop_get(const struct bContext *C,
2467                                       struct PointerRNA *r_ptr,
2468                                       struct PropertyRNA **r_prop,
2469                                       int *r_index);
2470 void UI_context_active_but_prop_handle(struct bContext *C);
2471 void UI_context_active_but_clear(struct bContext *C, struct wmWindow *win, struct ARegion *region);
2472 
2473 struct wmOperator *UI_context_active_operator_get(const struct bContext *C);
2474 void UI_context_update_anim_flag(const struct bContext *C);
2475 void UI_context_active_but_prop_get_filebrowser(const struct bContext *C,
2476                                                 struct PointerRNA *r_ptr,
2477                                                 struct PropertyRNA **r_prop,
2478                                                 bool *r_is_undo,
2479                                                 bool *r_is_userdef);
2480 void UI_context_active_but_prop_get_templateID(struct bContext *C,
2481                                                struct PointerRNA *r_ptr,
2482                                                struct PropertyRNA **r_prop);
2483 struct ID *UI_context_active_but_get_tab_ID(struct bContext *C);
2484 
2485 uiBut *UI_region_active_but_get(struct ARegion *region);
2486 uiBut *UI_region_but_find_rect_over(const struct ARegion *region, const struct rcti *rect_px);
2487 uiBlock *UI_region_block_find_mouse_over(const struct ARegion *region,
2488                                          const int xy[2],
2489                                          bool only_clip);
2490 
2491 /* uiFontStyle.align */
2492 typedef enum eFontStyle_Align {
2493   UI_STYLE_TEXT_LEFT = 0,
2494   UI_STYLE_TEXT_CENTER = 1,
2495   UI_STYLE_TEXT_RIGHT = 2,
2496 } eFontStyle_Align;
2497 
2498 struct uiFontStyleDraw_Params {
2499   eFontStyle_Align align;
2500   uint word_wrap : 1;
2501 };
2502 
2503 /* Styled text draw */
2504 void UI_fontstyle_set(const struct uiFontStyle *fs);
2505 void UI_fontstyle_draw_ex(const struct uiFontStyle *fs,
2506                           const struct rcti *rect,
2507                           const char *str,
2508                           const uchar col[4],
2509                           const struct uiFontStyleDraw_Params *fs_params,
2510                           size_t len,
2511                           int *r_xofs,
2512                           int *r_yofs,
2513                           struct ResultBLF *r_info);
2514 void UI_fontstyle_draw(const struct uiFontStyle *fs,
2515                        const struct rcti *rect,
2516                        const char *str,
2517                        const uchar col[4],
2518                        const struct uiFontStyleDraw_Params *fs_params);
2519 void UI_fontstyle_draw_rotated(const struct uiFontStyle *fs,
2520                                const struct rcti *rect,
2521                                const char *str,
2522                                const uchar col[4]);
2523 void UI_fontstyle_draw_simple(
2524     const struct uiFontStyle *fs, float x, float y, const char *str, const uchar col[4]);
2525 void UI_fontstyle_draw_simple_backdrop(const struct uiFontStyle *fs,
2526                                        float x,
2527                                        float y,
2528                                        const char *str,
2529                                        const float col_fg[4],
2530                                        const float col_bg[4]);
2531 
2532 int UI_fontstyle_string_width(const struct uiFontStyle *fs, const char *str);
2533 int UI_fontstyle_height_max(const struct uiFontStyle *fs);
2534 
2535 void UI_draw_icon_tri(float x, float y, char dir, const float[4]);
2536 
2537 const struct uiStyle *UI_style_get(void);     /* use for fonts etc */
2538 const struct uiStyle *UI_style_get_dpi(void); /* DPI scaled settings for drawing */
2539 
2540 /* linker workaround ack! */
2541 void UI_template_fix_linking(void);
2542 
2543 /* UI_OT_editsource helpers */
2544 bool UI_editsource_enable_check(void);
2545 void UI_editsource_active_but_test(uiBut *but);
2546 
2547 /* UI_butstore_ helpers */
2548 typedef struct uiButStore uiButStore;
2549 typedef struct uiButStoreElem uiButStoreElem;
2550 
2551 uiButStore *UI_butstore_create(uiBlock *block);
2552 void UI_butstore_clear(uiBlock *block);
2553 void UI_butstore_update(uiBlock *block);
2554 void UI_butstore_free(uiBlock *block, uiButStore *bs);
2555 bool UI_butstore_is_valid(uiButStore *bs);
2556 bool UI_butstore_is_registered(uiBlock *block, uiBut *but);
2557 void UI_butstore_register(uiButStore *bs_handle, uiBut **but_p);
2558 bool UI_butstore_register_update(uiBlock *block, uiBut *but_dst, const uiBut *but_src);
2559 void UI_butstore_unregister(uiButStore *bs_handle, uiBut **but_p);
2560 
2561 /* ui_interface_region_tooltip.c */
2562 struct ARegion *UI_tooltip_create_from_button(struct bContext *C,
2563                                               struct ARegion *butregion,
2564                                               uiBut *but,
2565                                               bool is_label);
2566 struct ARegion *UI_tooltip_create_from_gizmo(struct bContext *C, struct wmGizmo *gz);
2567 void UI_tooltip_free(struct bContext *C, struct bScreen *screen, struct ARegion *region);
2568 
2569 /* How long before a tool-tip shows. */
2570 #define UI_TOOLTIP_DELAY 0.5
2571 #define UI_TOOLTIP_DELAY_LABEL 0.2
2572 
2573 /* Float precision helpers */
2574 #define UI_PRECISION_FLOAT_MAX 6
2575 /* For float buttons the 'step' (or a1), is scaled */
2576 #define UI_PRECISION_FLOAT_SCALE 0.01f
2577 
2578 /* Typical UI text */
2579 #define UI_FSTYLE_WIDGET (const uiFontStyle *)&(UI_style_get()->widget)
2580 
2581 int UI_calc_float_precision(int prec, double value);
2582 
2583 /* widget batched drawing */
2584 void UI_widgetbase_draw_cache_begin(void);
2585 void UI_widgetbase_draw_cache_flush(void);
2586 void UI_widgetbase_draw_cache_end(void);
2587 
2588 /* Use for resetting the theme. */
2589 void UI_theme_init_default(void);
2590 void UI_style_init_default(void);
2591 
2592 void UI_interface_tag_script_reload(void);
2593 
2594 /* Special drawing for toolbar, mainly workarounds for inflexible icon sizing. */
2595 #define USE_UI_TOOLBAR_HACK
2596 
2597 /* Support click-drag motion which presses the button and closes a popover (like a menu). */
2598 #define USE_UI_POPOVER_ONCE
2599 
2600 #ifdef __cplusplus
2601 }
2602 #endif
2603