13#include <fmt/format.h>
35#include "RNA_prototypes.hh"
69 if (icon && name && name[0] ==
'\0') {
125 block,
UI_BTYPE_COLOR, 0, name, x, y, width, height,
ptr, prop, -1, 0, 0,
nullptr);
151 block,
UI_BTYPE_NUM, 0, name, x, y, width, height,
ptr, prop, index, 0, 0,
nullptr);
160 if (icon && name && name[0] ==
'\0') {
162 block,
UI_BTYPE_MENU, 0, icon, x, y, width, height,
ptr, prop, index, 0, 0,
nullptr);
183 block,
UI_BTYPE_MENU, 0, name, x, y, width, height,
ptr, prop, index, 0, 0,
nullptr);
187 if (icon && name && name[0] ==
'\0') {
189 block,
UI_BTYPE_TEXT, 0, icon, x, y, width, height,
ptr, prop, index, 0, 0,
nullptr);
210 block,
UI_BTYPE_TEXT, 0, name, x, y, width, height,
ptr, prop, index, 0, 0,
nullptr);
224 if (icon == ICON_DOT) {
249 but =
uiDefBut(block,
UI_BTYPE_LABEL, 0, text, x, y, width, height,
nullptr, 0, 0,
nullptr);
275 const int item_width = tot_width /
len;
278 for (
int i = 0; i <
len; i++) {
279 uiDefAutoButR(block,
ptr, prop, i,
"", icon, x + i * item_width, y, item_width, height);
304 if (check_prop && check_prop(
ptr, prop, user_data) == 0) {
310 switch (label_align) {
341 const bool use_activate_init = ((prop == prop_activate_init) &&
344 if (use_activate_init) {
350 return_info &= ~UI_PROP_BUTS_NONE_ADDED;
352 if (use_activate_init) {
379 const bool requires_exact_data_name,
380 const bool has_id_icon,
387 if (!has_id_icon && cis.
is_id && !requires_exact_data_name) {
391 name_buf,
static_cast<const ID *
>(cis.
data),
false,
UI_SEP_CHAR, &name_prefix_offset);
413 const bool requires_exact_data_name = !is_ptr_target;
414 const bool skip_filter = is_first;
416 bool has_id_icon =
false;
419 Vector<std::unique_ptr<CollItemSearch>> items_list;
421 if (data->search_prop !=
nullptr) {
425 if (itemptr.data == data->target_ptr.owner_id) {
437 int name_prefix_offset = 0;
438 int iconid = ICON_NONE;
439 bool has_sep_char =
false;
445 if (!
ELEM(iconid, 0, ICON_BLANK1)) {
449 if (requires_exact_data_name) {
453 const ID *
id =
static_cast<ID *
>(itemptr.data);
456 "Name string buffer should be big enough to hold full UI ID name");
461#ifdef WITH_ANIM_BAKLAVA
462 else if (itemptr.type == &RNA_ActionSlot) {
472 auto cis = std::make_unique<CollItemSearch>();
473 cis->data = itemptr.data;
475 cis->index = items_list.size();
476 cis->iconid = iconid;
478 cis->name_prefix_offset = name_prefix_offset;
479 cis->has_sep_char = has_sep_char;
480 items_list.append(std::move(cis));
481 if (name != name_buf) {
494 const bool show_extra_info = (
G.debug_value == 102);
501 auto cis = std::make_unique<CollItemSearch>();
504 if (visit_params.info && show_extra_info) {
505 cis->name = fmt::format(
"{}" UI_SEP_CHAR_S
"{}",
510 cis->name = std::move(visit_params.text);
513 cis->index = items_list.size();
514 cis->iconid = visit_params.
icon_id.value_or(ICON_NONE);
516 cis->name_prefix_offset = 0;
517 cis->has_sep_char = visit_params.
info.has_value();
518 items_list.append(std::move(cis));
525 [](
const std::unique_ptr<CollItemSearch> &a,
const std::unique_ptr<CollItemSearch> &
b) {
526 return BLI_strcasecmp_natural(a->name.c_str(), b->name.c_str()) < 0;
528 for (
const int i : items_list.index_range()) {
529 items_list[i]->index = i;
535 for (std::unique_ptr<CollItemSearch> &cis : items_list) {
543 for (std::unique_ptr<CollItemSearch> &cis : items_list) {
544 search.
add(cis->name, cis.get());
547 const Vector<CollItemSearch *> filtered_items = search.
query(
str);
567 return ICON_EMPTY_DATA;
597 return ICON_CHECKMARK;
653 1e0, 1
e-1, 1
e-2, 1
e-3, 1
e-4, 1
e-5, 1
e-6};
654 static const double max_pow = 10000000.0;
664 if ((value < pow10_neg[prec]) && (value > (1.0 / max_pow))) {
665 int value_i =
int(lround(value * max_pow));
667 const int prec_span = 3;
672 while (i && value_i) {
682 test_prec = prec_min;
684 dec_flag = (dec_flag >> (prec_min + 1)) & ((1 << prec_span) - 1);
688 dec_flag = dec_flag >> 1;
691 if (test_prec > prec) {
711 return std::string(idname, idname_len);
754 bool changed =
false;
789 View2D *v2d = ®ion->v2d;
832 uiButStore *bs_handle = MEM_cnew<uiButStore>(__func__);
834 bs_handle->
block = block;
850 if (block != bs_handle->
block && bs_handle->
block !=
nullptr) {
851 block = bs_handle->
block;
863 return (bs_handle->
block !=
nullptr);
870 if (*bs_elem->but_p == but) {
883 bs_elem->
but_p = but_p;
891 if (bs_elem->but_p == but_p) {
906 if (*bs_elem->but_p == but_src) {
907 *bs_elem->but_p = but_dst;
919 bs_handle->
block =
nullptr;
921 *bs_elem->but_p =
nullptr;
945 if (bs_handle->block == block->
oldblock) {
946 bs_handle->block = block;
949 if (*bs_elem->but_p) {
955 *bs_elem->but_p = but_new;
973 const bool is_strict,
998 const bool is_strict)
1004 if (region ==
nullptr) {
1005 return std::nullopt;
1010 return std::nullopt;
1014 if (but ==
nullptr) {
1015 return std::nullopt;
1019 return std::nullopt;
1025 uiBut *listbox =
nullptr;
1060 false,
false,
false,
false, 0, event_val, event_type,
false);
1063 return std::nullopt;
ARegion * CTX_wm_region(const bContext *C)
bool IDP_EqualsProperties_ex(const IDProperty *prop1, const IDProperty *prop2, bool is_strict) ATTR_WARN_UNUSED_RESULT
#define MAX_ID_FULL_NAME_UI
void BKE_id_full_name_ui_prefix_get(char name[MAX_ID_FULL_NAME_UI], const ID *id, bool add_lib_hint, char separator_char, int *r_prefix_len)
#define BLI_STATIC_ASSERT(a, msg)
#define LISTBASE_FOREACH(type, var, list)
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
#define LISTBASE_FOREACH_BACKWARD(type, var, list)
void void void BLI_movelisttolist(struct ListBase *dst, struct ListBase *src) ATTR_NONNULL(1
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_rctf_pad(struct rctf *rect, float pad_x, float pad_y)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
bool BLI_rctf_inside_rctf(const rctf *rct_a, const rctf *rct_b)
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
#define SNPRINTF(dst, format,...)
int rect_width(int rect[2][2])
int rect_height(int rect[2][2])
#define ID_IS_LINKED(_id)
Object is a sort of wrapper for general info.
void ED_region_tag_redraw_no_rebuild(ARegion *region)
Read Guarded memory(de)allocation.
#define RNA_STRUCT_BEGIN(sptr, prop)
#define RNA_PROP_BEGIN(sptr, itemptr, prop)
eStringPropertySearchFlag
@ PROP_STRING_SEARCH_SORT
@ PROP_STRING_SEARCH_SUPPORTED
@ UI_PROP_BUTS_ANY_FAILED_CHECK
@ UI_PROP_BUTS_NONE_ADDED
bool(*)(const uiBut *a, const uiBut *b) uiButIdentityCompareFunc
uiBut * uiDefBut(uiBlock *block, int type, int retval, blender::StringRef str, int x, int y, short width, short height, void *poin, float min, float max, const char *tip)
void uiItemL(uiLayout *layout, const char *name, int icon)
uiBut * UI_region_active_but_get(const ARegion *region)
uiBut * uiDefIconButR_prop(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, const char *tip)
bool UI_search_item_add(uiSearchItems *items, const char *name, void *poin, int iconid, int but_flag, uint8_t name_prefix_offset)
void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, const char *name, int icon, const char *placeholder=nullptr)
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
#define UI_PRECISION_FLOAT_MAX
@ UI_BUT_LABEL_ALIGN_SPLIT_COLUMN
@ UI_BUT_LABEL_ALIGN_NONE
@ UI_BUT_LABEL_ALIGN_COLUMN
uiBut * UI_context_active_but_get(const bContext *C)
void UI_block_align_begin(uiBlock *block)
uiBut * uiDefIconTextButR_prop(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, const char *tip)
uiLayout * uiLayoutColumn(uiLayout *layout, bool align)
void uiLayoutSetActivateInit(uiLayout *layout, bool activate_init)
uiBut * uiDefButR_prop(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, const char *tip)
void UI_but_flag_enable(uiBut *but, int flag)
void UI_block_align_end(uiBlock *block)
int UI_icon_from_library(const ID *id)
void UI_view2d_curRect_changed(const bContext *C, View2D *v2d)
void UI_view2d_region_to_view_rctf(const View2D *v2d, const rctf *rect_src, rctf *rect_dst) ATTR_NONNULL()
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
void add(const StringRef str, T *user_data, const int weight=0)
Vector< T * > query(const StringRef query) const
local_group_size(16, 16) .push_constant(Type b
pow(value.r - subtrahend, 2.0)") .do_static_compilation(true)
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
uiBut * ui_but_find_new(uiBlock *block_new, const uiBut *but_old)
void ui_block_to_region_rctf(const ARegion *region, const uiBlock *block, rctf *rct_dst, const rctf *rct_src)
int ui_id_icon_get(const bContext *C, ID *id, const bool big)
bool ui_but_contains_rect(const uiBut *but, const rctf *rect)
uiBut * ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *searchptr, PropertyRNA *searchprop, bool results_are_suggestions)
int UI_text_colorid_from_report_type(int type)
int UI_icon_from_report_type(int type)
eAutoPropButsReturn uiDefAutoButsRNA(uiLayout *layout, PointerRNA *ptr, bool(*check_prop)(PointerRNA *ptr, PropertyRNA *prop, void *user_data), void *user_data, PropertyRNA *prop_activate_init, const eButLabelAlign label_align, const bool compact)
int UI_icon_from_id(const ID *id)
int UI_icon_colorid_from_report_type(int type)
void UI_butstore_update(uiBlock *block)
void uiDefAutoButsArrayR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, const int icon, const int x, const int y, const int tot_width, const int height)
static bool ui_view2d_cur_ensure_rect_in_view(View2D *v2d, const rctf *rect)
void UI_but_func_identity_compare_set(uiBut *but, uiButIdentityCompareFunc cmp_fn)
void UI_butstore_unregister(uiButStore *bs_handle, uiBut **but_p)
std::optional< std::string > UI_but_online_manual_id(const uiBut *but)
bool UI_butstore_register_update(uiBlock *block, uiBut *but_dst, const uiBut *but_src)
void ui_rna_collection_search_update_fn(const bContext *C, void *arg, const char *str, uiSearchItems *items, const bool is_first)
bool UI_butstore_is_registered(uiBlock *block, uiBut *but)
std::optional< std::string > UI_key_event_operator_string(const bContext *C, const char *opname, IDProperty *properties, const bool is_strict)
bool UI_butstore_is_valid(uiButStore *bs_handle)
void UI_butstore_register(uiButStore *bs_handle, uiBut **but_p)
std::optional< std::string > UI_but_online_manual_id_from_active(const bContext *C)
void UI_butstore_clear(uiBlock *block)
uiButStore * UI_butstore_create(uiBlock *block)
static rctf ui_but_rect_to_view(const uiBut *but, const ARegion *region, const View2D *v2d)
static bool add_collection_search_item(CollItemSearch &cis, const bool requires_exact_data_name, const bool has_id_icon, uiSearchItems *items)
void UI_butstore_free(uiBlock *block, uiButStore *bs_handle)
void UI_but_ensure_in_view(const bContext *C, ARegion *region, const uiBut *but)
int UI_calc_float_precision(int prec, double value)
static bool ui_key_event_property_match(const char *opname, IDProperty *properties, const bool is_strict, wmOperatorType *ui_optype, PointerRNA *ui_opptr)
uiBut * uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int index, const char *name, int icon, int x, int y, int width, int height)
void MEM_freeN(void *vmemh)
ccl_device_inline float2 fabs(const float2 a)
bool RNA_property_array_check(PropertyRNA *prop)
bool RNA_struct_is_ID(const StructRNA *type)
eStringPropertySearchFlag RNA_property_string_search_flag(PropertyRNA *prop)
StructRNA * RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
void RNA_property_string_search(const bContext *C, PointerRNA *ptr, PropertyRNA *prop, const char *edit_text, blender::FunctionRef< void(StringPropertySearchVisitParams)> visit_fn)
char * RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen, int *r_len)
PropertyType RNA_property_type(PropertyRNA *prop)
char * RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fixedbuf, int fixedlen, int *r_len)
PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
const char * RNA_struct_identifier(const StructRNA *type)
bool RNA_property_pointer_poll(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *value)
int RNA_property_flag(PropertyRNA *prop)
int RNA_struct_ui_icon(const StructRNA *type)
int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
const char * RNA_property_ui_name(const PropertyRNA *prop)
PropertySubType RNA_property_subtype(PropertyRNA *prop)
const char * RNA_property_identifier(const PropertyRNA *prop)
int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop)
PointerRNA RNA_id_pointer_create(ID *id)
std::optional< int > icon_id
std::optional< std::string > info
uiButIdentityCompareFunc identity_cmp_func
struct wmOperatorType * custom_activate_optype
struct PointerRNA * custom_drag_opptr
struct wmOperatorType * custom_drag_optype
struct PointerRNA * custom_activate_opptr
std::optional< std::string > WM_keymap_item_raw_to_string(const short shift, const short ctrl, const short alt, const short oskey, const short keymodifier, const short val, const short type, const bool compact)
size_t WM_operator_py_idname(char *dst, const char *src)