14#include <fmt/format.h>
36#include "RNA_prototypes.hh"
60 const std::optional<StringRef>
name,
75 if (icon &&
name &&
name->is_empty()) {
190 if (icon &&
name &&
name->is_empty()) {
241 if (icon &&
name &&
name->is_empty()) {
302 if (icon == ICON_DOT) {
328 block,
ButType::Label, 0, text,
x,
y, width, height,
nullptr, 0, 0, std::nullopt);
354 const int item_width = tot_width /
len;
357 for (
int i = 0;
i <
len;
i++) {
375 std::optional<StringRefNull>
name;
383 if (check_prop && check_prop(
ptr, prop, user_data) == 0) {
389 switch (label_align) {
407 col->use_property_split_set(
true);
420 const bool use_activate_init = ((prop == prop_activate_init) &&
423 if (use_activate_init) {
424 col->activate_init_set(
true);
430 if (use_activate_init) {
431 col->activate_init_set(
false);
457 const bool requires_exact_data_name,
458 const bool has_id_icon,
465 if (!has_id_icon && cis.
is_id && !requires_exact_data_name) {
469 name_buf,
static_cast<const ID *
>(cis.
data),
false,
UI_SEP_CHAR, &name_prefix_offset);
491 const bool requires_exact_data_name = !is_ptr_target;
492 const bool skip_filter = is_first;
494 bool has_id_icon =
false;
499 if (
data->search_prop !=
nullptr) {
503 if (itemptr.data ==
data->target_ptr.owner_id) {
515 int name_prefix_offset = 0;
516 int iconid = ICON_NONE;
517 bool has_sep_char =
false;
523 if (!
ELEM(iconid, 0, ICON_BLANK1)) {
527 if (requires_exact_data_name) {
531 const ID *
id =
static_cast<ID *
>(itemptr.data);
534 "Name string buffer should be big enough to hold full UI ID name");
539 else if (
data->item_search_prop) {
541 &itemptr,
data->item_search_prop, name_buf,
sizeof(name_buf),
nullptr);
543 else if (itemptr.type == &RNA_ActionSlot) {
558 if (iconid == ICON_NONE) {
559 iconid = ICON_BLANK1;
567 auto cis = std::make_unique<CollItemSearch>();
568 cis->data = itemptr.data;
570 cis->index = items_list.
size();
571 cis->iconid = iconid;
573 cis->name_prefix_offset = name_prefix_offset;
574 cis->has_sep_char = has_sep_char;
575 items_list.
append(std::move(cis));
576 if (
name != name_buf) {
589 const bool show_extra_info = (
G.debug_value == 102);
596 auto cis = std::make_unique<CollItemSearch>();
599 if (visit_params.info && show_extra_info) {
600 cis->name = fmt::format(
"{}" UI_SEP_CHAR_S
"{}",
605 cis->name = std::move(visit_params.text);
608 cis->index = items_list.
size();
609 cis->iconid = visit_params.
icon_id.value_or(ICON_NONE);
611 cis->name_prefix_offset = 0;
612 cis->has_sep_char = visit_params.
info.has_value();
613 items_list.
append(std::move(cis));
620 [](
const std::unique_ptr<CollItemSearch> &a,
const std::unique_ptr<CollItemSearch> &
b) {
621 return BLI_strcasecmp_natural(a->name.c_str(), b->name.c_str()) < 0;
624 items_list[
i]->index =
i;
630 for (std::unique_ptr<CollItemSearch> &cis : items_list) {
638 for (std::unique_ptr<CollItemSearch> &cis : items_list) {
639 search.
add(cis->name, cis.get());
662 return ICON_EMPTY_DATA;
692 return ICON_CHECKMARK;
748 1e0, 1
e-1, 1
e-2, 1
e-3, 1
e-4, 1
e-5, 1
e-6};
749 static const double max_pow = 10000000.0;
759 if ((value < pow10_neg[prec]) && (value > (1.0 / max_pow))) {
760 int value_i = int(lround(value * max_pow));
762 const int prec_span = 3;
767 while (
i && value_i) {
777 test_prec = prec_min;
779 dec_flag = (dec_flag >> (prec_min + 1)) & ((1 << prec_span) - 1);
783 dec_flag = dec_flag >> 1;
786 prec = std::max(test_prec, prec);
804 return std::string(idname, idname_len);
847 bool changed =
false;
927 bs_handle->
block = block;
943 if (block != bs_handle->
block && bs_handle->
block !=
nullptr) {
944 block = bs_handle->
block;
956 return (bs_handle->
block !=
nullptr);
963 if (*bs_elem->but_p == but) {
976 bs_elem->
but_p = but_p;
984 if (bs_elem->but_p == but_p) {
999 if (*bs_elem->but_p == but_src) {
1000 *bs_elem->but_p = but_dst;
1012 bs_handle->block =
nullptr;
1014 *bs_elem->but_p =
nullptr;
1038 if (bs_handle->block == block->
oldblock) {
1039 bs_handle->block = block;
1042 if (*bs_elem->but_p) {
1048 *bs_elem->but_p = but_new;
Functions and classes to work with Actions.
#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_UTF8(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
#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)
uiBut * uiDefButR_prop(uiBlock *block, ButType 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)
uiBut * uiDefIconTextButR_prop(uiBlock *block, ButType 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)
bool UI_search_item_add(uiSearchItems *items, blender::StringRef name, void *poin, int iconid, int but_flag, uint8_t name_prefix_offset)
uiBut * uiDefIconButR_prop(uiBlock *block, ButType 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_block_align_begin(uiBlock *block)
uiBut * uiDefBut(uiBlock *block, uiButTypeWithPointerType but_and_ptr_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)
void UI_but_flag_enable(uiBut *but, int flag)
void UI_block_align_end(uiBlock *block)
int UI_icon_from_idcode(int idcode)
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()
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
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)
uiBut * ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *searchptr, PropertyRNA *searchprop, PropertyRNA *item_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)
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)
void * MEM_callocN(size_t len, const char *str)
void MEM_freeN(void *vmemh)
ccl_device_inline float2 fabs(const float2 a)
float wrap(float value, float max, float min)
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)
const char * RNA_property_ui_name(const PropertyRNA *prop, const PointerRNA *ptr)
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)
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
uiLayout & column(bool align)
size_t WM_operator_py_idname(char *dst, const char *src)