16#include "RNA_prototypes.hh"
63 const size_t path_len = strlen(path);
64 const bool has_trailing_slash = path_len > 0 &&
78 return has_trailing_slash;
83 PathSplitEdit *edit =
static_cast<PathSplitEdit *
>(argN);
86 if (edit->part == PathSplitEdit::Part::Name &&
94 const bool has_trailing_slash =
path_split_get(edit->ptr, edit->prop, dir, name);
97 if (edit->part == PathSplitEdit::Part::Name) {
105 if (has_trailing_slash) {
115 MEM_delete(
static_cast<PathSplitEdit *
>(argN));
120 return MEM_new<PathSplitEdit>(__func__, *
static_cast<const PathSplitEdit *
>(argN));
125 const PathSplitEdit *edit_a =
static_cast<const PathSplitEdit *
>(a->
func_argN);
126 const PathSplitEdit *edit_b =
static_cast<const PathSplitEdit *
>(
b->func_argN);
127 return edit_a->ptr.
data == edit_b->ptr.
data && edit_a->prop == edit_b->prop &&
128 edit_a->part == edit_b->part;
135 const PathSplitEdit::Part part)
137 PathSplitEdit *edit = MEM_new<PathSplitEdit>(__func__);
145 if (part == PathSplitEdit::Part::Name) {
152 if (edit->text[0] ==
'\0') {
192 const std::optional<StringRef> text,
193 const std::optional<StringRef> placeholder)
197 row.
label(label, ICON_NONE);
204 parts_row, path_data.
ptr, path_data.
path_prop, PathSplitEdit::Part::Directory);
220 name_row, path_data.
ptr, path_data.
path_prop, PathSplitEdit::Part::Name);
240 const char *pathselect_op,
241 std::optional<StringRef> text,
242 const std::optional<StringRef> placeholder,
243 const bool split_name)
246 const bool align = !split_name;
249 Layout *decorate_column =
nullptr;
253 decorate_column =
split.decorate_column;
273 ICON_FOLDER_REDIRECT;
280 if (filter_glob_prop) {
287 row.
op(
"BUTTONS_OT_directory_browse",
305 if (decorate_column) {
314 const char *pathselect_op,
315 const char *filter_glob,
316 const std::optional<StringRef> text,
317 const std::optional<StringRef> placeholder,
318 const bool split_name)
321 template_path_data.
ptr = *ptr;
333 RNA_warning(
"String property is not a dirpath or filepath: %s.%s",
344 C, *layout, template_path_data, pathselect_op, text, placeholder, split_name);
#define BLI_path_join(...)
#define ID_CHECK_UNDO(id)
Read Blender memory allocation and freeing.
#define RNA_warning(format,...)
constexpr const char * c_str() const
constexpr bool is_empty() const
void split(const std::string &s, const char delim, std::vector< std::string > &tokens)
void template_filepath(Layout *layout, const bContext *C, PointerRNA *ptr, const StringRefNull propname, const char *pathselect_op, const char *filter_glob, const std::optional< StringRef > name, const std::optional< StringRef > placeholder, bool split_name=false)
static void template_filepath_split_name_buttons(Layout &row, TemplatePathData &path_data, const std::optional< StringRef > text, const std::optional< StringRef > placeholder)
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)
static void * path_split_edit_copy(const void *argN)
static bool path_split_edit_identity_cmp(const Button *a, const Button *b)
static void path_split_edit_free(void *argN)
@ ITEM_R_PATH_NO_OPEN_BUTTON
void button_func_identity_compare_set(Button *but, ButtonIdentityCompareFunc cmp_fn)
static void template_filepath_buttons(const bContext *, Layout &layout, TemplatePathData &path_data, const char *pathselect_op, std::optional< StringRef > text, const std::optional< StringRef > placeholder, const bool split_name)
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)
void button_placeholder_set(Button *but, StringRef placeholder_text)
void button_funcN_set(Button *but, ButtonHandleNFunc funcN, void *argN, void *arg2, ButtonArgNFree func_argN_free_fn=MEM_delete_void, ButtonArgNCopy func_argN_copy_fn=MEM_dupalloc_void)
void button_flag_disable(Button *but, int64_t flag)
static bool path_split_get(PointerRNA &ptr, PropertyRNA *prop, char(&r_dir)[FILE_MAX], char(&r_name)[FILE_MAXFILE])
static void path_split_edit_apply(bContext *C, void *argN, void *)
void block_layout_set_current(Block *block, Layout *layout)
PropertySplitWrapper uiItemPropertySplitWrapperCreate(Layout *parent_layout)
static Button * template_filepath_split_button(Layout &layout, const PointerRNA &ptr, PropertyRNA *prop, const PathSplitEdit::Part part)
char * STRNCPY(char(&dst)[N], const char *src)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
int RNA_property_string_length(PointerRNA *ptr, PropertyRNA *prop)
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
BLI_INLINE bool BLI_path_slash_is_native_compat(const char ch)
std::string RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_property_string_is_utf8(PropertyRNA *prop)
PropertyType RNA_property_type(PropertyRNA *prop)
bool RNA_property_undo_check(const PropertyRNA *prop, const StructRNA *type)
void BLI_path_slash_rstrip(char *path) ATTR_NONNULL(1)
void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *value)
bool BLI_path_is_win32_drive_only(const char *path)
int BLI_path_slash_ensure(char *path, size_t path_maxncpy) ATTR_NONNULL(1)
const char * RNA_struct_identifier(const StructRNA *type)
PropertySubType RNA_property_subtype(PropertyRNA *prop)
const char * RNA_property_ui_description(const PropertyRNA *prop, const PointerRNA *ptr)
void BLI_path_split_dir_file(const char *filepath, char *dir, size_t dir_maxncpy, char *file, size_t file_maxncpy) ATTR_NONNULL(1
bool RNA_property_editable(const PointerRNA *ptr, PropertyRNA *prop)
const char * BLI_path_slash_find(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
const char * RNA_property_ui_name(const PropertyRNA *prop, const PointerRNA *ptr)
void fixed_size_set(bool fixed_size)
bool use_property_split() const
void label_multiline(StringRefNull label, int icon, FontStyleAlign align=UI_STYLE_TEXT_LEFT, int max_lines=0)
void label(StringRef name, int icon)
void decorator(PointerRNA *ptr, PropertyRNA *prop, int index)
void ui_units_x_set(float width)
PointerRNA op(wmOperatorType *ot, std::optional< StringRef > name, int icon, wm::OpCallContext context, eUI_Item_Flag flag)
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)
PropertySubType path_prop_subtype
std::optional< std::string > filter_glob