46 #define MENU_BORDER (int)(0.3f * U.widget_unit)
91 #define SEARCH_ITEMS 10
98 const uint8_t name_prefix_offset)
112 if (poin == items->
active) {
140 if (name_prefix_offset != 0) {
175 for (
int i = 0; i < items->
totitem; i++) {
182 for (
int i = 0; i < items->
totitem; i++) {
197 data->active += step;
199 if (
data->items.totitem == 0) {
202 else if (
data->active >=
data->items.totitem) {
203 if (
data->items.more) {
204 data->items.offset++;
205 data->active =
data->items.totitem - 1;
209 data->active =
data->items.totitem - 1;
212 else if (
data->active < 0) {
213 if (
data->items.offset) {
214 data->items.offset--;
235 *r_rect =
data->bbox;
238 row = itemnr /
data->prv_cols;
250 *r_rect =
data->bbox;
251 r_rect->
xmin =
data->bbox.xmin + 3.0f;
252 r_rect->
xmax =
data->bbox.xmax - 3.0f;
281 if (
data->active != -1) {
282 const char *name =
data->items.names[
data->active] +
284 (
data->items.name_prefix_offsets ?
285 data->items.name_prefix_offsets[
data->active] :
288 const char *name_sep =
data->use_shortcut_sep ? strrchr(name,
UI_SEP_CHAR) :
nullptr;
306 double *
UNUSED(pass_delay),
307 bool *r_exit_on_event)
309 *r_exit_on_event =
true;
342 int type =
event->type, val =
event->val;
343 bool handled =
false;
344 bool tooltip_timer_started =
false;
366 if (
data->active != -1) {
391 for (
a = 0;
a <
data->items.totitem;
a++) {
396 if (
data->active !=
a) {
408 if (
data->active != -1) {
412 tooltip_timer_started =
true;
421 if (handled && (tooltip_timer_started ==
false)) {
440 const bool is_first_search = !search_but->
but.
changed;
452 data->items.totitem = 0;
453 data->items.more = 0;
455 data->items.offset_i =
data->items.offset;
458 data->items.offset_i =
data->items.offset = 0;
462 const bool is_first_search = !search_but->
but.
changed;
466 data->items.active =
nullptr;
469 if (
data->items.totitem) {
471 if (
data->items.offset_i <
data->items.maxitem) {
472 data->active =
data->items.offset_i;
473 data->items.offset_i = 0;
477 if (
data->items.totitem -
data->items.offset_i <=
data->items.maxitem) {
478 data->active =
data->items.offset_i -
data->items.totitem +
data->items.maxitem;
479 data->items.offset_i =
data->items.totitem -
data->items.maxitem;
483 data->items.offset_i -=
data->items.maxitem / 2;
484 data->active =
data->items.maxitem / 2;
488 data->items.offset =
data->items.offset_i;
489 data->items.totitem = 0;
500 for (
int a = 0;
a <
data->items.totitem;
a++) {
501 const char *name =
data->items.names[
a] +
503 (
data->items.name_prefix_offsets ?
data->items.name_prefix_offsets[
a] :
505 const char *name_sep =
data->use_shortcut_sep ? strrchr(name,
UI_SEP_CHAR) :
nullptr;
536 data->items.autocpl =
nullptr;
549 if (
data->noback ==
false) {
554 if (
data->items.totitem) {
559 for (
int a = 0;
a <
data->items.totitem;
a++) {
570 data->items.names[
a],
571 data->items.icons[
a],
577 if (
data->items.more) {
583 if (
data->items.offset) {
591 const int search_sep_len =
data->sep_string ? strlen(
data->sep_string) : 0;
593 for (
int a = 0;
a <
data->items.totitem;
a++) {
595 char *name =
data->items.names[
a];
596 int icon =
data->items.icons[
a];
597 char *name_sep_test =
nullptr;
600 if (
data->use_shortcut_sep) {
611 if ((search_sep_len == 0) ||
612 !(name_sep_test = strstr(
data->items.names[
a],
data->sep_string))) {
613 if (!icon &&
data->items.has_icon) {
623 char *name_sep =
nullptr;
625 name_sep = name_sep_test;
626 name_sep_test = strstr(name_sep + search_sep_len,
data->sep_string);
627 }
while (name_sep_test !=
nullptr);
629 name_sep += search_sep_len;
630 const char name_sep_prev = *name_sep;
640 *name_sep = name_sep_prev;
641 rect.
xmin += name_width;
644 if (icon == ICON_BLANK1) {
651 &
data->fstyle, &rect, name_sep, icon, but_flag, separator_type,
nullptr);
655 if (
data->items.more) {
661 if (
data->items.offset) {
676 for (
int a = 0;
a <
data->items.maxitem;
a++) {
684 if (
data->items.name_prefix_offsets !=
nullptr) {
695 const bool use_shortcut_sep)
729 if (but->
a1 > 0 && but->
a2 > 0) {
730 data->preview =
true;
735 if (but->
optype !=
nullptr || use_shortcut_sep) {
736 data->use_shortcut_sep =
true;
749 data->bbox.xmin = margin;
751 data->bbox.ymin = margin;
756 data->bbox.ymin += search_but_h;
759 data->bbox.ymax -= search_but_h;
778 rect_fl.
xmax = rect_fl.
xmin + searchbox_width;
807 if (rect_i.
ymin < 0) {
821 data->bbox.xmin = margin;
823 data->bbox.ymin = margin;
848 data->items.totitem = 0;
850 data->items.pointers = (
void **)
MEM_callocN(
data->items.maxitem *
sizeof(
void *), __func__);
853 data->items.name_prefix_offsets =
nullptr;
854 for (
int i = 0; i <
data->items.maxitem; i++) {
874 bool prev_delim =
true;
876 for (
size_t i = 0; (i <
len) &&
str[i]; i++) {
877 if (
str[i] >=
'A' &&
str[i] <=
'Z') {
878 if (prev_delim ==
false) {
882 else if (
str[i] ==
'_') {
886 prev_delim =
ELEM(
str[i],
' ') || (
str[i] >=
'0' &&
str[i] <=
'9');
897 if (
data->noback ==
false) {
902 if (
data->items.totitem) {
906 for (
int a = 0;
a <
data->items.totitem;
a++) {
907 rcti rect_pre, rect_post;
922 const char *text_pre_p = strstr(
ot->
idname,
"_OT_");
923 if (text_pre_p ==
nullptr) {
931 text_pre[text_pre_len] =
':';
932 text_pre[text_pre_len + 1] =
'\0';
940 data->items.icons[
a],
946 data->items.names[
a],
955 if (
data->items.more) {
961 if (
data->items.offset) {
1016 for (
int i = 0; i < items->
maxitem; i++) {
1027 else if (items->
more == 0) {
1034 for (
int i = 0; i < items->
maxitem; i++) {
struct ScrArea * CTX_wm_area(const bContext *C)
struct bScreen * CTX_wm_screen(const bContext *C)
struct wmWindow * CTX_wm_window(const bContext *C)
#define LISTBASE_FOREACH(type, var, list)
MINLINE int min_ii(int a, int b)
void BLI_rctf_translate(struct rctf *rect, float x, float y)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct)
void BLI_rcti_translate(struct rcti *rect, int x, int y)
bool BLI_rcti_isect_pt(const struct rcti *rect, int x, int y)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
void BLI_rcti_rctf_copy(struct rcti *dst, const struct rctf *src)
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
size_t BLI_strncpy_rlen(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
#define STREQLEN(a, b, n)
#define CTX_IFACE_(context, msgid)
#define BLT_I18NCONTEXT_OPERATOR_DEFAULT
ID and Library types, which are fundamental for sdna.
void ED_region_floating_init(struct ARegion *region)
void ED_region_tag_redraw(struct ARegion *region)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
void GPU_blend(eGPUBlend blend)
Read Guarded memory(de)allocation.
void UI_fontstyle_set(const struct uiFontStyle *fs)
const struct uiStyle * UI_style_get(void)
#define AUTOCOMPLETE_NO_MATCH
AutoComplete * UI_autocomplete_begin(const char *startname, size_t maxlen)
int UI_autocomplete_end(AutoComplete *autocpl, char *autoname)
struct ARegion * UI_region_searchbox_region_get(const struct ARegion *button_region)
void UI_autocomplete_update_name(AutoComplete *autocpl, const char *name)
void UI_but_flag_enable(uiBut *but, int flag)
void UI_icon_draw(float x, float y, int icon_id)
void UI_view2d_view_to_region_rcti(const struct View2D *v2d, const struct rctf *rect_src, struct rcti *rect_dst) ATTR_NONNULL()
float UI_view2d_view_to_region_y(const struct View2D *v2d, float y)
static bool is_inside(int x, int y, int cols, int rows)
void ui_fontscale(float *points, float aspect)
int ui_but_string_get_max_length(uiBut *but)
void ui_pan_to_scroll(const wmEvent *event, int *type, int *val)
void ui_icon_ensure_deferred(const bContext *C, const int icon_id, const bool big)
#define UI_POPUP_MENU_TOP
void ui_draw_widget_menu_back(const rcti *rect, bool use_shadow)
void ui_draw_menu_item(const struct uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int but_flag, uiMenuItemSeparatorType separator_type, int *r_xmax)
void ui_draw_preview_item(const struct uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int but_flag, eFontStyle_Align text_align)
@ UI_MENU_ITEM_SEPARATOR_NONE
@ UI_MENU_ITEM_SEPARATOR_HINT
@ UI_MENU_ITEM_SEPARATOR_SHORTCUT
bool UI_search_item_add(uiSearchItems *items, const char *name, void *poin, int iconid, const int but_flag, const uint8_t name_prefix_offset)
int ui_searchbox_find_index(ARegion *region, const char *name)
void ui_searchbox_update(bContext *C, ARegion *region, uiBut *but, const bool reset)
ARegion * ui_searchbox_create_operator(bContext *C, ARegion *butregion, uiButSearch *search_but)
static void str_tolower_titlecaps_ascii(char *str, const size_t len)
void ui_but_search_refresh(uiButSearch *search_but)
static void ui_searchbox_butrect(rcti *r_rect, uiSearchboxData *data, int itemnr)
static void ui_searchbox_select(bContext *C, ARegion *region, uiBut *but, int step)
static struct ARegion * wm_searchbox_tooltip_init(struct bContext *C, struct ARegion *region, int *UNUSED(r_pass), double *UNUSED(pass_delay), bool *r_exit_on_event)
void ui_searchbox_free(bContext *C, ARegion *region)
int UI_searchbox_size_x()
ARegion * ui_searchbox_create_generic(bContext *C, ARegion *butregion, uiButSearch *search_but)
bool ui_searchbox_apply(uiBut *but, ARegion *region)
static void ui_searchbox_update_fn(bContext *C, uiButSearch *search_but, const char *str, uiSearchItems *items)
static void ui_searchbox_region_draw_fn(const bContext *C, ARegion *region)
int UI_searchbox_size_y()
static ARegion * ui_searchbox_create_generic_ex(bContext *C, ARegion *butregion, uiButSearch *search_but, const bool use_shortcut_sep)
static void ui_searchbox_region_draw_cb__menu(const bContext *UNUSED(C), ARegion *UNUSED(region))
bool ui_searchbox_event(bContext *C, ARegion *region, uiBut *but, ARegion *butregion, const wmEvent *event)
static void ui_searchbox_region_draw_cb__operator(const bContext *UNUSED(C), ARegion *region)
ARegion * ui_searchbox_create_menu(bContext *C, ARegion *butregion, uiButSearch *search_but)
int UI_search_items_find_index(uiSearchItems *items, const char *name)
static void ui_searchbox_region_free_fn(ARegion *region)
bool ui_searchbox_inside(ARegion *region, const int xy[2])
int ui_searchbox_autocomplete(bContext *C, ARegion *region, uiBut *but, char *str)
void ui_region_temp_remove(bContext *C, bScreen *screen, ARegion *region)
ARegion * ui_region_temp_add(bScreen *screen)
ccl_gpu_kernel_postfix ccl_global float int int int int float bool reset
clear internal cached data and reset random seed
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
static void area(int d1, int d2, int e1, int e2, float weights[2])
bool active
all scheduled work for the GPU.
PropertyType RNA_property_type(PropertyRNA *prop)
void(* draw)(const struct bContext *C, struct ARegion *region)
struct ARegionType * type
uiButSearchUpdateFn items_update_fn
bool results_are_suggestions
const char * item_sep_string
uiButSearchTooltipFn item_tooltip_fn
uiButSearchContextMenuFn item_context_menu_fn
struct wmOperatorType * optype
char drawstr[UI_MAX_DRAW_STR]
struct PropertyRNA * rnaprop
uint8_t * name_prefix_offsets
void wmOrtho2_region_pixelspace(const ARegion *region)
int WM_window_pixels_x(const wmWindow *win)