31#include "RNA_prototypes.hh"
112 layout.
label(
"", icon);
125 subrow->
prop(&listptr,
137 subrow = &row.
row(
true);
140 subrow->
prop(&listptr,
141 "use_filter_sort_reverse",
151 const char *filter_raw =
list.filter_byname;
154 const size_t slen = strlen(filter_raw);
157 if (slen + 3 <=
sizeof(storage_.filter_buff)) {
158 filter_ = storage_.filter_buff;
169 MEM_SAFE_DELETE(storage_.filter_dyn);
185 const int fn_flag = FNM_CASEFOLD | FNM_NOESCAPE;
186 if (fnmatch(filter_, name.
c_str(), fn_flag) == 0) {
201 static_cast<const StringCmp *
>(p2)->name);
208 const char *propname,
221 if (
len && (order_by_name || item_filter_fn)) {
223 int order_idx = 0, i = 0;
229 if (item_filter_fn) {
235 bool do_order =
false;
239 namebuf =
BLI_strdup(get_name_fn(itemptr, i).c_str());
245 const char *name = namebuf ? namebuf :
"";
247 if (item_filter_fn) {
254 if (!filter_exclude) {
257 do_order = order_by_name;
261 else if (filter_exclude) {
264 do_order = order_by_name;
268 do_order = order_by_name;
272 names[order_idx].
org_idx = order_idx;
273 STRNCPY(names[order_idx++].name, name);
294 "items_filter_neworder");
295 for (new_idx = 0; new_idx < order_idx; new_idx++) {
328 const char *propname)
363 const char *item_dyntip_propname,
371 RNA_warning(
"template_list using default '%s' UIList class must provide a custom list_id",
376 if (!*active_dataptr) {
381 r_input_data->
dataptr = *dataptr;
384 if (!r_input_data->
prop) {
396 active_propname.
c_str());
400 if (r_input_data->
prop) {
403 RNA_warning(
"Expected a collection data property");
410 RNA_warning(
"Expected an integer active data property");
416 RNA_warning(
"List type %s not found", std::string(listtype_name).c_str());
437 bool activei_mapping_pending =
true;
444 new_order_idx = order_reverse ? dyn_data->
items_shown - new_order_idx - 1 : new_order_idx;
447 new_order_idx = order_reverse ? dyn_data->
items_shown - ++reorder_i : reorder_i++;
450 r_items->
item_vec[new_order_idx].item = itemptr;
451 r_items->
item_vec[new_order_idx].org_idx = i;
456 if (activei_mapping_pending && activei == i) {
457 activei = new_order_idx;
459 activei_mapping_pending =
false;
462 else if (activei < i) {
466 if (prev_order_idx >= 0) {
467 activei = prev_order_idx;
471 activei = new_order_idx;
476 prev_ii = new_order_idx;
502 int prev_ii = -1, prev_i;
516 if (items_shown >= 0) {
517 r_items->
item_vec.resize(items_shown);
532 const bool use_auto_size = (ui_list->
list_grip <
535 int actual_rows = layout_data->
rows;
536 int actual_maxrows = layout_data->
maxrows;
539 if (actual_rows <= 0) {
543 if (actual_maxrows < actual_rows) {
544 actual_maxrows =
max_ii(actual_rows, 5);
551 if (!use_auto_size) {
555 else if ((actual_rows != actual_maxrows) && (dyn_data->
height > actual_rows)) {
565 if (activei_row < ui_list->list_scroll) {
568 else if (activei_row >= ui_list->
list_scroll + actual_rows) {
569 ui_list->
list_scroll = activei_row - actual_rows + 1;
574 const int max_scroll =
max_ii(0, dyn_data->
height - actual_rows);
603 if (propname && propname[0] && itemptr && *itemptr) {
615 char *dyn_tooltip =
static_cast<char *
>(argN);
616 std::string tooltip_string = dyn_tooltip;
618 tooltip_string +=
'\n';
619 tooltip_string += tip;
621 return tooltip_string;
636 if (region ==
nullptr) {
649 ui_list = MEM_new<uiList>(
"uiList");
662 ui_list->
dyn_data = MEM_new<uiListDyn>(
"uiList.dyn_data");
670 ui_list->
type = ui_list_type;
692 Layout *glob =
nullptr, *box, *row, *col, *sub, *overlap;
694 int rnaicon = ICON_NONE, icon = ICON_NONE;
710 glob = &box->
column(
true);
711 row = &glob->
row(
false);
716 uilist_prepare(ui_list, items, &adjusted_layout_data, &visual_info);
727 const int org_i = items->
item_vec[i].org_idx;
728 const int flt_flag = items->
item_vec[i].flt_flag;
729 Block *subblock = col->block();
731 overlap = &col->overlap();
750 editable ?
TIP_(
"Select List Item "
751 "(Double click to rename)") :
752 TIP_(
"Select List Item"));
764 sub = &item_row.
row(
false);
766 if (icon == ICON_DOT) {
782 but->
context = sub->context_store();
796 col->label(
"", ICON_NONE);
819 row = &layout.
row(
true);
828 if (icon == ICON_DOT) {
844 row->label(
"", ICON_NONE);
888 row = &glob->
row(
true);
889 Block *subblock = row->block();
896 ICON_DISCLOSURE_TRI_DOWN,
904 TIP_(
"Hide filtering options"));
924 col = &glob->
column(
false);
925 subblock = col->block();
944 ICON_DISCLOSURE_TRI_RIGHT,
952 TIP_(
"Show filtering options"));
977 const char *listtype_name,
983 const char *item_dyntip_propname,
997 item_dyntip_propname,
1030 layout_data.
rows = rows;
1031 layout_data.
maxrows = maxrows;
#define SNPRINTF_UTF8(dst, format,...)
#define STRNCPY_UTF8(dst, src)
#define UI_LIST_AUTO_SIZE_THRESHOLD
Read Blender memory allocation and freeing.
#define RNA_PROP_BEGIN(sptr, itemptr, prop)
#define RNA_warning(format,...)
#define UI_UL_DEFAULT_CLASS_NAME
constexpr const char * c_str() const
constexpr bool is_empty() const
eUIListFilterResult operator()(const PointerRNA &itemptr, StringRefNull name, int index)
uiListNameFilter(uiList &list)
IMETHOD Vector diff(const Vector &a, const Vector &b, double dt)
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
static void template_uilist_layout_draw(const bContext *C, uiList *ui_list, Layout &layout, TemplateListInputData *input_data, TemplateListItems *items, const TemplateListLayoutDrawData *layout_data, const TemplateListFlags flags)
static void uilist_filter_items_default(uiList *ui_list, const bContext *C, PointerRNA *dataptr, const char *propname)
static int cmpstringp(const void *p1, const void *p2)
void button_func_set(Button *but, std::function< void(bContext &)> func)
static uiList * uilist_ensure(const bContext *C, uiListType *ui_list_type, const char *list_id, euiList_LayoutType layout_type, bool sort_reverse, bool sort_lock)
@ TEMPLATE_LIST_SORT_REVERSE
@ TEMPLATE_LIST_SORT_LOCK
static void * uilist_item_use_dynamic_tooltip(PointerRNA *itemptr, const char *propname)
uiListType * UI_UL_cache_file_layers()
static void uilist_prepare(uiList *ui_list, const TemplateListItems *items, const TemplateListLayoutDrawData *layout_data, TemplateListVisualInfo *r_visual_info)
static void uilist_free_dyn_data(uiList *ui_list)
void block_flag_enable(Block *block, int flag)
void template_uilist(Layout *layout, const bContext *C, const char *listtype_name, const char *list_id, PointerRNA *dataptr, StringRefNull propname, PointerRNA *active_dataptr, StringRefNull active_propname, const char *item_dyntip_propname, int rows, int maxrows, int layout_type, enum TemplateListFlags flags)
Button * uiDefIconButV(Block *block, ButtonType type, int icon, int x, int y, short width, short height, T *poin, float min, float max, std::optional< StringRef > tip)
void button_func_tooltip_set(Button *but, ButtonToolTipFunc func, void *arg, FreeArgFunc free_arg)
void button_flag_enable(Button *but, int64_t flag)
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)
@ UI_LIST_ITEM_FILTER_MISMATCHES
@ UI_LIST_ITEM_NEVER_SHOW
@ UI_LIST_ITEM_FILTER_MATCHES
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)
static void uilist_draw_item_default(uiList *ui_list, const bContext *, Layout &layout, PointerRNA *, PointerRNA *itemptr, int icon, PointerRNA *, const char *, int, int)
static std::string uilist_item_tooltip_func(bContext *, void *argN, const StringRef tip)
void block_emboss_set(Block *block, EmbossType emboss)
int icon_from_rnaptr(const bContext *C, PointerRNA *ptr, int rnaicon, bool big)
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 block_flag_disable(Block *block, int flag)
void layout_list_set_labels_active(Layout *layout)
void button_flag_disable(Button *but, int64_t flag)
static bool template_uilist_data_retrieve(const StringRef listtype_name, const char *list_id, PointerRNA *dataptr, const StringRefNull propname, PointerRNA *active_dataptr, const StringRefNull active_propname, const char *item_dyntip_propname, TemplateListInputData *r_input_data, uiListType **r_list_type)
bool uilist_item_index_is_filtered_visible(const struct uiList *ui_list, int item_idx)
FunctionRef< eUIListFilterResult(const PointerRNA &itemptr, StringRefNull name, int index)> uiListItemFilterFn
static void uilist_draw_filter_default(uiList *ui_list, const bContext *, Layout &layout)
static void uilist_resize_update(bContext *C, uiList *ui_list)
Button * uiDefIconButBit(Block *block, ButtonType type, int bit, int icon, int x, int y, short width, short height, T *poin, float min, float max, std::optional< StringRef > tip)
Button * uiDefButV(Block *block, ButtonType type, StringRef str, int x, int y, short width, short height, T *poin, float min, float max, std::optional< StringRef > tip)
void uiLayoutListItemAddPadding(Layout *layout)
void uilist_filter_and_sort_items(uiList *ui_list, const bContext *C, uiListItemFilterFn item_filter_fn, PointerRNA *dataptr, const char *propname, uiListItemGetNameFn get_name_fn=nullptr)
static void template_uilist_collect_display_items(const bContext *C, uiList *ui_list, TemplateListInputData *input_data, const uiListFilterItemsFunc filter_items_fn, TemplateListItems *r_items)
FunctionRef< std::string(const PointerRNA &itemptr, int index)> uiListItemGetNameFn
static void template_uilist_collect_items(PointerRNA *list_ptr, PropertyRNA *list_prop, const uiList *ui_list, int activei, TemplateListItems *r_items)
char * RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fixedbuf, int fixedlen, int *r_len)
int char char int BLI_strcasecmp(const char *s1, const char *s2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
char * STRNCPY(char(&dst)[N], const char *src)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
@ UILST_SCROLL_TO_ACTIVE_ITEM
MINLINE int round_fl_to_int(float a)
const char * RNA_property_identifier(const PropertyRNA *prop)
void(*)(uiList *ui_list, const bContext *C, PointerRNA *, const char *propname) uiListFilterItemsFunc
void * BLI_findstring(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
char * RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen, int *r_len)
void(*)(uiList *ui_list, const bContext *C, ui::Layout &layout, PointerRNA *dataptr, PointerRNA *itemptr, int icon, PointerRNA *active_dataptr, const char *active_propname, int index, int flt_flag) uiListDrawItemFunc
MINLINE int max_ii(int a, int b)
int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop)
void MEM_delete_void(void *vmemh)
char char * BLI_strncpy_ensure_pad(char *__restrict dst, const char *__restrict src, char pad, size_t dst_maxncpy) ATTR_NONNULL(1
void RNA_property_int_set(PointerRNA *ptr, PropertyRNA *prop, int value)
PropertyType RNA_property_type(PropertyRNA *prop)
StructRNA * RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop)
void WM_uilisttype_to_full_list_id(const uiListType *ult, const char *list_id, char r_full_list_id[])
void ED_region_tag_refresh_ui(ARegion *region)
@ UILST_FLT_ITEM_NEVER_SHOW
int RNA_property_flag(PropertyRNA *prop)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
void(*)(uiList *ui_list, const bContext *C, ui::Layout &layout) uiListDrawFilterFunc
PropertyRNA * RNA_struct_name_property(const StructRNA *type)
int RNA_struct_ui_icon(const StructRNA *type)
const char * RNA_struct_identifier(const StructRNA *type)
bool WM_uilisttype_add(uiListType *ult)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
ARegion * CTX_wm_region_popup(const bContext *C)
uiListType * WM_uilisttype_find(const StringRef idname, bool quiet)
int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop)
MINLINE int min_ii(int a, int b)
ARegion * CTX_wm_region(const bContext *C)
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
ListBaseT< uiList > ui_lists
uiListFreeRuntimeDataFunc free_runtime_data_fn
int * items_filter_neworder
uiListFilterItemsFunc filter_items
uiListDrawFilterFunc draw_filter
uiListDrawItemFunc draw_item
euiList_FilterSortFlag filter_sort_flag
euiList_LayoutType layout_type
euiList_FilterFlag filter_flag
void label(StringRef name, int icon)
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)
Layout & list_box(uiList *ui_list, PointerRNA *actptr, PropertyRNA *actprop)
char name[MAX_IDPROP_NAME]
Vector< _uilist_item > item_vec
uiListDrawFilterFunc draw_filter
uiListDrawItemFunc draw_item