14#include <fmt/format.h>
36#include "RNA_prototypes.hh"
58 const std::optional<StringRef> name,
73 if (icon && name && name->is_empty()) {
188 if (icon && name && name->is_empty()) {
239 if (icon && name && name->is_empty()) {
300 if (icon == ICON_DOT) {
326 block,
UI_BTYPE_LABEL, 0, text,
x,
y, width, height,
nullptr, 0, 0, std::nullopt);
352 const int item_width = tot_width /
len;
355 for (
int i = 0;
i <
len;
i++) {
373 std::optional<StringRefNull> name;
381 if (check_prop && check_prop(
ptr, prop, user_data) == 0) {
387 switch (label_align) {
398 col->label(*name, ICON_NONE);
418 const bool use_activate_init = ((prop == prop_activate_init) &&
421 if (use_activate_init) {
428 if (use_activate_init) {
455 const bool requires_exact_data_name,
456 const bool has_id_icon,
463 if (!has_id_icon && cis.
is_id && !requires_exact_data_name) {
467 name_buf,
static_cast<const ID *
>(cis.
data),
false,
UI_SEP_CHAR, &name_prefix_offset);
489 const bool requires_exact_data_name = !is_ptr_target;
490 const bool skip_filter = is_first;
492 bool has_id_icon =
false;
497 if (
data->search_prop !=
nullptr) {
501 if (itemptr.data ==
data->target_ptr.owner_id) {
513 int name_prefix_offset = 0;
514 int iconid = ICON_NONE;
515 bool has_sep_char =
false;
521 if (!
ELEM(iconid, 0, ICON_BLANK1)) {
525 if (requires_exact_data_name) {
529 const ID *
id =
static_cast<ID *
>(itemptr.data);
532 "Name string buffer should be big enough to hold full UI ID name");
537 else if (itemptr.type == &RNA_ActionSlot) {
546 auto cis = std::make_unique<CollItemSearch>();
547 cis->data = itemptr.data;
549 cis->index = items_list.
size();
550 cis->iconid = iconid;
552 cis->name_prefix_offset = name_prefix_offset;
553 cis->has_sep_char = has_sep_char;
554 items_list.
append(std::move(cis));
555 if (name != name_buf) {
568 const bool show_extra_info = (
G.debug_value == 102);
575 auto cis = std::make_unique<CollItemSearch>();
578 if (visit_params.info && show_extra_info) {
579 cis->name = fmt::format(
"{}" UI_SEP_CHAR_S
"{}",
584 cis->name = std::move(visit_params.text);
587 cis->index = items_list.
size();
588 cis->iconid = visit_params.
icon_id.value_or(ICON_NONE);
590 cis->name_prefix_offset = 0;
591 cis->has_sep_char = visit_params.
info.has_value();
592 items_list.
append(std::move(cis));
599 [](
const std::unique_ptr<CollItemSearch> &a,
const std::unique_ptr<CollItemSearch> &
b) {
600 return BLI_strcasecmp_natural(a->name.c_str(), b->name.c_str()) < 0;
603 items_list[
i]->index =
i;
609 for (std::unique_ptr<CollItemSearch> &cis : items_list) {
617 for (std::unique_ptr<CollItemSearch> &cis : items_list) {
618 search.
add(cis->name, cis.get());
641 return ICON_EMPTY_DATA;
671 return ICON_CHECKMARK;
727 1e0, 1
e-1, 1
e-2, 1
e-3, 1
e-4, 1
e-5, 1
e-6};
728 static const double max_pow = 10000000.0;
738 if ((value < pow10_neg[prec]) && (value > (1.0 / max_pow))) {
739 int value_i = int(lround(value * max_pow));
741 const int prec_span = 3;
746 while (
i && value_i) {
756 test_prec = prec_min;
758 dec_flag = (dec_flag >> (prec_min + 1)) & ((1 << prec_span) - 1);
762 dec_flag = dec_flag >> 1;
765 prec = std::max(test_prec, prec);
783 return std::string(idname, idname_len);
826 bool changed =
false;
906 bs_handle->
block = block;
922 if (block != bs_handle->
block && bs_handle->
block !=
nullptr) {
923 block = bs_handle->
block;
935 return (bs_handle->
block !=
nullptr);
942 if (*bs_elem->but_p == but) {
955 bs_elem->
but_p = but_p;
963 if (bs_elem->but_p == but_p) {
978 if (*bs_elem->but_p == but_src) {
979 *bs_elem->but_p = but_dst;
991 bs_handle->block =
nullptr;
993 *bs_elem->but_p =
nullptr;
1017 if (bs_handle->block == block->
oldblock) {
1018 bs_handle->block = block;
1021 if (*bs_elem->but_p) {
1027 *bs_elem->but_p = but_new;
1045 const bool is_strict,
1049 if (ui_optype->
idname != opname) {
1070 const bool is_strict)
1076 if (region ==
nullptr) {
1077 return std::nullopt;
1082 return std::nullopt;
1086 if (but ==
nullptr) {
1087 return std::nullopt;
1091 return std::nullopt;
1097 uiBut *listbox =
nullptr;
1143 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)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void void void BLI_movelisttolist(ListBase *dst, ListBase *src) ATTR_NONNULL(1
#define LISTBASE_FOREACH(type, var, list)
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
void void BLI_freelistN(ListBase *listbase) ATTR_NONNULL(1)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(ListBase *listbase, void *vlink) 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])
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
uiBut * uiDefIconTextButR_prop(uiBlock *block, int type, int retval, int icon, std::optional< blender::StringRef > str, int x, int y, short width, short height, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, std::optional< blender::StringRef > tip)
uiBut * uiDefButR_prop(uiBlock *block, int type, int retval, std::optional< blender::StringRef > str, int x, int y, short width, short height, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, std::optional< blender::StringRef > tip)
bool(*)(const uiBut *a, const uiBut *b) uiButIdentityCompareFunc
uiBut * UI_region_active_but_get(const ARegion *region)
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, std::optional< blender::StringRef > tip)
#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)
bool UI_search_item_add(uiSearchItems *items, blender::StringRef name, void *poin, int iconid, int but_flag, uint8_t name_prefix_offset)
void UI_block_align_begin(uiBlock *block)
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, std::optional< blender::StringRef > 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 uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
void uiLayoutSetActivateInit(uiLayout *layout, bool activate_init)
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()
BMesh const char void * data
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
void append(const T &value)
IndexRange index_range() const
void add(const StringRef str, T *user_data, const int weight=0)
Vector< T * > query(const StringRef query) const
#define ID_IS_LINKED(_id)
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)
uiBut * uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int index, const std::optional< StringRef > name, int icon, int x, int y, int width, int height)
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)
std::optional< std::string > UI_key_event_operator_string(const bContext *C, const StringRefNull opname, IDProperty *properties, const bool is_strict)
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)
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 StringRefNull opname, IDProperty *properties, const bool is_strict, wmOperatorType *ui_optype, PointerRNA *ui_opptr)
void * MEM_callocN(size_t len, const char *str)
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)
ARegionRuntimeHandle * runtime
std::optional< int > icon_id
std::optional< std::string > info
blender::Vector< std::unique_ptr< uiBut > > buttons
uiButIdentityCompareFunc identity_cmp_func
uiLayout & column(bool align)
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 int8_t shift, const int8_t ctrl, const int8_t alt, const int8_t oskey, const int8_t hyper, const short keymodifier, const short val, const short type, const bool compact)
size_t WM_operator_py_idname(char *dst, const char *src)