14#include <fmt/format.h>
36#include "RNA_prototypes.hh"
61 const std::optional<StringRef> name,
67 std::optional<ButtonType> button_type_override)
77 if (icon && name && name->is_empty()) {
169 block, button_type, name,
x,
y, width, height, ptr, prop,
index, 0, 0, std::nullopt);
180 if (icon && name && name->is_empty()) {
182 block, button_type, icon,
x,
y, width, height, ptr, prop,
index, 0, 0, std::nullopt);
202 block, button_type, name,
x,
y, width, height, ptr, prop,
index, 0, 0, std::nullopt);
208 const ButtonType button_type = bool(search_flag) ?
212 if (icon && name && name->is_empty()) {
214 block, button_type, icon,
x,
y, width, height, ptr, prop,
index, 0, 0, std::nullopt);
234 block, button_type, name,
x,
y, width, height, ptr, prop,
index, 0, 0, std::nullopt);
258 if (icon == ICON_DOT) {
283 block,
ButtonType::Label, text,
x,
y, width, height,
nullptr, 0, 0, std::nullopt);
309 const int item_width = tot_width /
len;
312 for (
int i = 0; i <
len; i++) {
313 uiDefAutoButR(block, ptr, prop, i,
"", icon,
x + i * item_width,
y, item_width, height);
330 std::optional<StringRefNull> name;
338 if (check_prop && check_prop(ptr, prop, user_data) == 0) {
344 switch (label_align) {
352 col = &layout->
column(
true);
355 col->
label(*name, ICON_NONE);
360 col = &layout->
column(
true);
375 const bool use_activate_init = ((prop == prop_activate_init) &&
378 if (use_activate_init) {
385 if (use_activate_init) {
416 const bool requires_exact_data_name,
417 const bool has_id_icon,
424 if (!has_id_icon && cis.
is_id && !requires_exact_data_name) {
428 name_buf,
static_cast<const ID *
>(cis.
data),
false,
UI_SEP_CHAR, &name_prefix_offset);
449 const bool requires_exact_data_name = !is_ptr_target;
450 const bool skip_filter = is_first;
452 bool has_id_icon =
false;
457 if (
data->search_prop !=
nullptr) {
461 if (itemptr.data ==
data->target_ptr.owner_id) {
473 int name_prefix_offset = 0;
474 int iconid = ICON_NONE;
475 bool has_sep_char =
false;
480 const ID *
id =
static_cast<ID *
>(itemptr.data);
484 if ((
id->name[2] ==
'.') && (
str[0] !=
'.')) {
490 if (!
ELEM(iconid, 0, ICON_BLANK1)) {
494 if (requires_exact_data_name) {
500 "Name string buffer should be big enough to hold full UI ID name");
505 else if (
data->item_search_prop) {
507 &itemptr,
data->item_search_prop, name_buf,
sizeof(name_buf),
nullptr);
509 else if (itemptr.type == RNA_ActionSlot) {
524 if (iconid == ICON_NONE) {
525 iconid = ICON_BLANK1;
533 auto cis = std::make_unique<CollItemSearch>();
534 cis->data = itemptr.data;
536 cis->index = items_list.
size();
537 cis->iconid = iconid;
539 cis->name_prefix_offset = name_prefix_offset;
540 cis->has_sep_char = has_sep_char;
541 items_list.
append(std::move(cis));
542 if (name != name_buf) {
552 [](
const std::unique_ptr<CollItemSearch> &a,
const std::unique_ptr<CollItemSearch> &
b) {
556 items_list[i]->index = i;
565 const bool show_extra_info = (
G.debug_value == 102);
572 auto cis = std::make_unique<CollItemSearch>();
575 if (visit_params.info && show_extra_info) {
576 cis->name = fmt::format(
"{}" UI_SEP_CHAR_S
"{}",
581 cis->name = std::move(visit_params.text);
584 cis->index = items_list.
size();
585 cis->iconid = visit_params.
icon_id.value_or(ICON_NONE);
587 cis->name_prefix_offset = 0;
588 cis->has_sep_char = visit_params.
info.has_value();
589 items_list.
append(std::move(cis));
595 [](
const std::unique_ptr<CollItemSearch> &a,
const std::unique_ptr<CollItemSearch> &
b) {
599 items_list[i]->index = i;
605 for (std::unique_ptr<CollItemSearch> &cis : items_list) {
613 for (std::unique_ptr<CollItemSearch> &cis : items_list) {
614 search.add(cis->name, cis.get());
640 Object *ob = id_cast<Object *>(
const_cast<ID *
>(
id));
643 return ICON_EMPTY_DATA;
658 return ICON_STATUS_ERROR_FILLED;
661 return ICON_STATUS_WARNING_FILLED;
664 return ICON_STATUS_INFO_FILLED;
673 return ICON_CHECKMARK;
675 return ICON_STATUS_INFO_FILLED;
733 1e0, 1
e-1, 1
e-2, 1
e-3, 1
e-4, 1
e-5, 1
e-6};
734 static const double max_pow = 10000000.0;
744 if ((value < pow10_neg[prec]) && (value > (1.0 / max_pow))) {
745 int value_i = int(lround(value * max_pow));
747 const int prec_span = 3;
752 while (i && value_i) {
762 test_prec = prec_min;
764 dec_flag = (dec_flag >> (prec_min + 1)) & ((1 << prec_span) - 1);
768 dec_flag = dec_flag >> 1;
771 prec = std::max(test_prec, prec);
789 return std::string(idname, idname_len);
835 bool changed =
false;
838 if ((cur->
ymin > rect->
ymin) || (rect_height > cur_height)) {
850 else if ((cur->
xmin > rect->
xmin) || (rect_width > cur_width)) {
919 bs_handle->
block = block;
935 if (block != bs_handle->
block && bs_handle->
block !=
nullptr) {
936 block = bs_handle->
block;
939 bs_handle->
items.free_no_destruct();
943 MEM_delete(bs_handle);
948 return (bs_handle->
block !=
nullptr);
955 if (*bs_elem.
but_p == but) {
968 bs_elem->
but_p = but_p;
976 if (bs_elem.but_p == but_p) {
978 MEM_delete(&bs_elem);
991 if (*bs_elem.
but_p == but_src) {
992 *bs_elem.
but_p = but_dst;
1004 bs_handle.
block =
nullptr;
1006 *bs_elem.
but_p =
nullptr;
1020 if (block->
butstore.first_ ==
nullptr) [[likely]] {
1031 bs_handle.
block = block;
1034 if (*bs_elem.
but_p) {
Functions and classes to work with Actions.
#define MAX_ID_FULL_NAME_UI
#define SNPRINTF_UTF8(dst, format,...)
#define ID_IS_LINKED(_id)
Object is a sort of wrapper for general info.
Read Blender memory allocation and freeing.
#define RNA_STRUCT_BEGIN(sptr, prop)
#define RNA_PROP_BEGIN(sptr, itemptr, prop)
#define UI_PRECISION_FLOAT_MAX
void append(const T &value)
IndexRange index_range() const
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
ccl_device_inline dual3 fabs(const ccl_private dual3 &a)
BLI_INLINE Texture * wrap(MTLTexture *texture)
void butstore_free(Block *block, ButStore *bs_handle)
void butstore_clear(Block *block)
int icon_from_report_type(int type)
void butstore_update(Block *block)
@ PROP_BUTS_ANY_FAILED_CHECK
BLI_STATIC_ASSERT(int(TIP_LC_MAX)==int(TIP_LC_ALERT)+1, "invalid lc-max")
int icon_colorid_from_report_type(int type)
std::optional< std::string > button_online_manual_id_from_active(const bContext *C) ATTR_WARN_UNUSED_RESULT
void button_configure_search(Button *but, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *searchptr, PropertyRNA *searchprop, PropertyRNA *item_searchprop, bool results_are_suggestions)
void block_to_region_rctf(const ARegion *region, const Block *block, rctf *rct_dst, const rctf *rct_src)
std::optional< std::string > button_online_manual_id(const Button *but) ATTR_WARN_UNUSED_RESULT
Button * uiDefAutoButR(Block *block, PointerRNA *ptr, PropertyRNA *prop, int index, std::optional< StringRef > name, int icon, int x, int y, int width, int height, std::optional< ButtonType > button_type_override=std::nullopt)
void butstore_register(ButStore *bs_handle, Button **but_p)
void butstore_unregister(ButStore *bs_handle, Button **but_p)
Button * context_active_but_get_respect_popup(const bContext *C)
int calc_float_precision(int prec, double value)
bool(*)(const Button *a, const Button *b) ButtonIdentityCompareFunc
void block_align_begin(Block *block)
void button_func_identity_compare_set(Button *but, ButtonIdentityCompareFunc cmp_fn)
int icon_from_idcode(int idcode)
bool butstore_register_update(Block *block, Button *but_dst, const Button *but_src)
int icon_from_id(const ID *id)
int id_icon_get(const bContext *C, ID *id, const bool big)
@ BUT_LABEL_ALIGN_SPLIT_COLUMN
AutoPropButsReturn uiDefAutoButsRNA(Layout *layout, PointerRNA *ptr, bool(*check_prop)(PointerRNA *ptr, PropertyRNA *prop, void *user_data), void *user_data, PropertyRNA *prop_activate_init, eButLabelAlign label_align, bool compact)
Button * uiDefIconButR_prop(Block *block, ButtonType type, int icon, int x, int y, short width, short height, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, std::optional< StringRef > tip)
void uiDefAutoButsArrayR(Block *block, PointerRNA *ptr, PropertyRNA *prop, const int icon, const int x, const int y, const int tot_width, const int height)
bool butstore_is_registered(Block *block, Button *but)
void button_flag_enable(Button *but, int64_t flag)
static std::unique_ptr< Button > but_new(const ButtonType type)
static bool add_collection_search_item(CollItemSearch &cis, const bool requires_exact_data_name, const bool has_id_icon, SearchItems *items)
Button * uiDefBut(Block *block, ButtonTypeWithPointerType but_and_ptr_type, StringRef str, int x, int y, short width, short height, void *poin, float min, float max, std::optional< StringRef > tip)
bool butstore_is_valid(ButStore *bs_handle)
Button * uiDefButR_prop(Block *block, ButtonType type, std::optional< StringRef > str, int x, int y, short width, short height, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, std::optional< StringRef > tip)
void block_align_end(Block *block)
void but_ensure_in_view(const bContext *C, ARegion *region, const Button *but)
Button * button_find_new(Block *block_new, const Button *but_old)
bool search_item_add(SearchItems *items, StringRef name, void *poin, int iconid, int64_t but_flag, uint8_t name_prefix_offset)
Button * uiDefIconTextButR_prop(Block *block, ButtonType type, int icon, std::optional< StringRef > str, int x, int y, short width, short height, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, std::optional< StringRef > tip)
void rna_collection_search_update_fn(const bContext *C, void *arg, const char *str, SearchItems *items, bool is_first)
void view2d_curRect_changed(const bContext *C, View2D *v2d)
void view2d_region_to_view_rctf(const View2D *v2d, const rctf *rect_src, rctf *rect_dst) ATTR_NONNULL()
int icon_from_library(const ID *id)
static bool view2d_cur_ensure_rect_in_view(View2D *v2d, const rctf *rect)
int UI_text_colorid_from_report_type(int type)
ButStore * butstore_create(Block *block)
static rctf but_rect_to_view(const Button *but, const ARegion *region, const View2D *v2d)
char * RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fixedbuf, int fixedlen, int *r_len)
int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
int char char int int int BLI_strcasecmp_natural(const char *s1, const char *s2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
PointerRNA RNA_id_pointer_create(ID *id)
const char * RNA_property_identifier(const PropertyRNA *prop)
void void void BLI_movelisttolist(ListBase *dst, ListBase *src) ATTR_NONNULL(1
char * RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen, int *r_len)
void RNA_property_string_search(const bContext *C, PointerRNA *ptr, PropertyRNA *prop, const char *edit_text, FunctionRef< void(StringPropertySearchVisitParams)> visit_fn)
int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_property_array_check(PropertyRNA *prop)
PropertyType RNA_property_type(PropertyRNA *prop)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
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)
StructRNA * RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
eStringPropertySearchFlag
@ PROP_STRING_SEARCH_SUPPORTED
@ PROP_STRING_SEARCH_SORT
@ PROP_STRING_SEARCH_SUGGESTION
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
BMesh const char void * data
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
int RNA_property_flag(PropertyRNA *prop)
bool BLI_rctf_inside_rctf(const rctf *rct_a, const rctf *rct_b)
int RNA_struct_ui_icon(const StructRNA *type)
bool RNA_struct_is_ID(const StructRNA *type)
const char * RNA_struct_identifier(const StructRNA *type)
PropertySubType RNA_property_subtype(PropertyRNA *prop)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
@ USER_HIDE_DOT_DATABLOCK
ID_Type GS(const char *name)
eStringPropertySearchFlag RNA_property_string_search_flag(PropertyRNA *prop)
size_t WM_operator_py_idname(char *dst, const char *src)
void ED_region_tag_redraw_no_rebuild(ARegion *region)
bool RNA_property_pointer_poll(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *value)
void BLI_rctf_pad(struct rctf *rect, float pad_x, float pad_y)
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
const char * RNA_property_ui_name(const PropertyRNA *prop, const PointerRNA *ptr)
std::optional< std::string > info
std::optional< int > icon_id
ListBaseT< ButStore > butstore
ListBaseT< ButStoreElem > items
void use_property_split_set(bool is_sep)
void label(StringRef name, int icon)
void activate_init_set(bool activate_init)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)
Layout & column(bool align)