33#include "RNA_prototypes.hh"
75 DATA_(
"Untitled Project");
84 BLI_path_join(path,
sizeof(path), base_path ? base_path :
"",
"Blender",
"Projects");
96 if (blendfile_path[0] ==
'\0') {
111 directories.
append(directory);
169 if (name && name[0]) {
181 "update_directory_from_name",
228 if (new_directories != directories) {
229 directories = std::move(new_directories);
238 item.
name = directories[i].c_str();
262 if (root_path.empty()) {
295 op->
reports,
RPT_ERROR,
"Failed to write project config in \"%s\"", root_path.c_str());
319 if (suggested_directories.
is_empty()) {
322 "Can not create project for a blend file in the home or root folder");
333 std::string name = base_name;
335 BLI_path_join(directory,
sizeof(directory), projects_dir.c_str(), name.c_str());
337 for (
int number = 2;
BLI_exists(directory); number++) {
338 name = fmt::format(
"{} {}", base_name, number);
339 BLI_path_join(directory,
sizeof(directory), projects_dir.c_str(), name.c_str());
356 RPT_(
"A Blender Project is a directory that provides a shared environment for related "
357 ".blend files, textures, and other files, with project-specific settings such as "
358 "Asset Libraries, custom variables, and other configuration options.\n"
360 "This is a structured way to organize files and settings across complex pipelines "
361 "and team projects."));
368 if (!parent_root.empty()) {
370 layout.
label(
IFACE_(
"Folder already contains a project."), ICON_STATUS_WARNING);
373 layout.
label(
IFACE_(
"Folder is inside another project."), ICON_STATUS_WARNING);
384 constexpr float label_factor = 0.25f;
389 col.
label(text, ICON_NONE);
390 return split.row(
true);
406 TIP_(
"The current file needs to be inside of the project's path.\n"
407 "To pick a different folder, move the current file there first, or create a new "
408 "project from a new unsaved file."));
424 if (!root_path.empty()) {
433 ot->
name =
"New Project";
434 ot->
idname =
"PROJECT_OT_new";
443 prop =
RNA_def_string(ot->
srna,
"name",
"Untitled Project", 0,
"Name",
"Name of the project");
451 "Project Root Folder",
452 "Project folder, created if missing");
457 ot->
srna,
"update_directory_from_name",
false,
"Update Directory From Name",
"");
463 "existing_directory",
466 "Project Root Folder",
467 "Folder of the current file or one of its parents, to turn into a project");
486 if (project_root_path ==
"") {
502 op->
reports,
RPT_ERROR,
"Failed to load project from path: %s", project_root_path.c_str());
550 ot->
name =
"Open Project...";
551 ot->
idname =
"PROJECT_OT_open";
552 ot->
description =
"Open a project, starting a new file in it";
568 "Skip check to prevent unsaved changes from being lost",
622 ot->
name =
"Close Project";
623 ot->
idname =
"PROJECT_OT_close";
624 ot->
description =
"Close the active project, starting a new file";
633 "Skip check to prevent unsaved changes from being lost",
653 ot->
name =
"Save Project Config";
654 ot->
idname =
"PROJECT_OT_config_save";
655 ot->
description =
"Save the current project config to disk";
675 switch (library_type) {
682 std::string(dirpath);
691 MEM_delete(remote_url);
696 U.runtime.is_dirty =
true;
717 C, op, event,
IFACE_(
"Add Asset Library"),
IFACE_(
"Create"));
729 switch (library_type) {
761 ot->
name =
"Add Asset Library";
762 ot->
idname =
"PROJECT_OT_asset_library_add";
763 ot->
description =
"Add a directory to be used by the Project as source of assets";
781 StructRNA *type_ref = RNA_UserAssetLibrary;
784 const char *prop_id =
"name";
796 const char *prop_id =
"remote_url";
812 "The kind of asset library to add");
831 if (num_assets == 0) {
845 if (num_assets ==
index) {
858 "Asset libraries defined by an extension are removed by uninstalling the extension");
869 CLAMP(
project->active_asset_library_index, 0, num_assets - 2);
872 U.runtime.is_dirty =
true;
883 ot->
name =
"Remove Asset Library";
884 ot->
idname =
"PROJECT_OT_asset_library_remove";
886 "Remove a path to a .blend file, so the Asset Browser will not attempt to show it anymore";
914 {0,
nullptr, 0,
nullptr,
nullptr},
922 std::string variable_name;
924 switch (variable_type) {
926 variable_name =
"string_variable";
930 variable_name =
"filepath_variable";
934 variable_name =
"integer_variable";
938 variable_name =
"float_variable";
959 ot->
name =
"Add Variable";
960 ot->
idname =
"PROJECT_OT_variable_add";
961 ot->
description =
"Add a new variable to the current project";
973 "The kind of variable type to add");
986 return project !=
nullptr &&
project->active_variable_index >= 0 &&
1004 ot->
name =
"Remove Variable";
1005 ot->
idname =
"PROJECT_OT_variable_remove";
1006 ot->
description =
"Remove the active variable from the current project";
1027 {0,
nullptr, 0,
nullptr,
nullptr},
1035 if (direction ==
UP &&
index > 0) {
1037 project->active_variable_index -= 1;
1041 project->active_variable_index += 1;
1051 ot->
name =
"Move Variable";
1052 ot->
idname =
"PROJECT_OT_variable_move";
1053 ot->
description =
"Move the active variable up or down in the list of variables";
1065 "Which direction to move the variable");
File and directory operations.
#define BLI_path_join(...)
#define USER_EXPERIMENTAL_TEST(userdef, member)
#define ND_PROJECT_CHANGED
#define BLI_assert_unreachable()
constexpr const char * c_str() const
void append(const T &value)
IndexRange index_range() const
void string_subtype_set(ProjectVariableStringSubtype type)
constexpr bool contains(int64_t value) const
static constexpr int64_t not_found
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)
void WM_main_add_notifier(uint type, void *reference)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
static constexpr EnumPropertyItem project_variable_type_items[]
void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc)
const EnumPropertyItem custom_library_type_items[]
static Vector< std::string > new_project_suggested_directories(const Main *bmain)
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
static wmOperatorStatus project_asset_library_add_exec(bContext *C, wmOperator *op)
char * STRNCPY(char(&dst)[N], const char *src)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
static bool project_new_poll(bContext *C)
const char * RNA_property_ui_name_raw(const PropertyRNA *prop, const PointerRNA *ptr)
bool BLI_path_abs(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1
void BKE_blender_project_config_autosave(Main *bmain)
bool wm_operator_close_file_dialog_if_needed(bContext *C, wmOperator *op, wmGenericCallbackFn post_action_fn)
static std::string new_project_find_root(const StringRefNull directory)
@ ASSET_LIBRARY_PROJECT_DEFINED
void PROJECT_OT_open(wmOperatorType *ot)
bool BLI_dir_create_recursive(const char *dirname) ATTR_NONNULL()
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
bke::BlenderProject * BKE_blender_project_get(const Main *bmain)
bool BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void PROJECT_OT_variable_remove(wmOperatorType *ot)
static wmOperatorStatus project_new_exec(bContext *C, wmOperator *op)
void PROJECT_OT_close(wmOperatorType *ot)
static void project_close_after_dialog_callback(bContext *C, void *user_data)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
static void project_new_ui(bContext *C, wmOperator *op)
std::string RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop)
static void new_project_name_update(Main *, Scene *, PointerRNA *ptr)
PropertyRNA * RNA_def_string_dir_path(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
int RNA_int_get(PointerRNA *ptr, const char *name)
static wmOperatorStatus project_open_exec(bContext *C, wmOperator *op)
static const EnumPropertyItem * new_project_existing_directory_itemf(bContext *C, PointerRNA *, PropertyRNA *, bool *r_free)
size_t BLI_path_append(char *__restrict dst, size_t dst_maxncpy, const char *__restrict file) ATTR_NONNULL(1
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
auto BKE_blender_project_read_callback(const Main *bmain, Fn lambda)
static void new_project_name_from_directory(PointerRNA *ptr, const StringRefNull directory)
void PROJECT_OT_config_save(wmOperatorType *ot)
static wmOperatorStatus project_open_invoke(bContext *C, wmOperator *op, const wmEvent *)
static bool project_variable_remove_poll(bContext *C)
static wmOperatorStatus project_variable_move_exec(bContext *C, wmOperator *op)
static bool has_vaild_project_poll(bContext *C)
static std::string new_project_name_get(PointerRNA *ptr)
void WM_operator_properties_filesel(wmOperatorType *ot, const int filter, const short type, const eFileSel_Action action, const eFileSel_Flag flag, const short display, const short sort)
char * RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen, int *r_len)
void WM_init_splash(bContext *C)
void BKE_blender_project_clear()
const char * BLI_dir_home()
const char * BKE_main_blendfile_path(const Main *bmain) ATTR_NONNULL()
static void project_mark_dirty(Main *bmain)
static const EnumPropertyItem * custom_library_type_itemf(bContext *, PointerRNA *, PropertyRNA *, bool *r_free)
static void new_project_directory_update(Main *, Scene *, PointerRNA *ptr)
void void void const char * BLI_path_basename(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
static void new_project_draw_folder_info(ui::Layout &layout, const std::string &root_path)
void BLI_path_slash_rstrip(char *path) ATTR_NONNULL(1)
void void BLI_path_split_dir_part(const char *filepath, char *dir, size_t dir_maxncpy) ATTR_NONNULL(1
static bool project_asset_library_remove_poll(bContext *C)
void BKE_blender_project_recent_update(const Main *bmain)
void BKE_report(ReportList *reports, eReportType type, const char *message)
int BLI_path_cmp_normalized(const char *p1, const char *p2) ATTR_NONNULL(1
void ED_userpref_asset_library_remove(bContext *C, struct bUserAssetLibrary *asset_library)
bool BLI_path_is_abs_from_cwd(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
struct bUserAssetLibrary * ED_userpref_asset_library_new(const struct bContext *C, const char *name, const char *dirpath, bUserAssetLibraryAddType library_type, bool is_project_defined, std::optional< UUID > uuid, std::optional< char * > auth_token)
void PROJECT_OT_asset_library_add(wmOperatorType *ot)
static constexpr EnumPropertyItem project_variable_move_items[]
const char * RNA_property_ui_description_raw(const PropertyRNA *prop, const PointerRNA *ptr)
bool BKE_blender_project_config_file_write(Main *bmain)
static wmOperatorStatus project_close_exec(bContext *C, wmOperator *op)
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
PropertyRNA * RNA_struct_type_find_property(StructRNA *srna, const char *identifier)
bool BKE_appdir_folder_documents(char *dir) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
int BLI_path_normalize(char *path) ATTR_NONNULL(1)
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
wmOperatorStatus WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width, std::optional< std::string > title, std::optional< std::string > confirm_text, const bool cancel_default, std::optional< std::string > message, const bool show_icon)
wmOperatorStatus WM_operator_name_call(bContext *C, const char *opstring, wm::OpCallContext context, PointerRNA *properties, const wmEvent *event)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void PROJECT_OT_new(wmOperatorType *ot)
const EnumPropertyItem rna_enum_dummy_NULL_items[]
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
static wmOperatorStatus project_new_invoke(bContext *C, wmOperator *op, const wmEvent *)
int RNA_string_length(PointerRNA *ptr, const char *name)
bool BLI_is_dir(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
static void new_project_existing_directory_update(Main *bmain, Scene *, PointerRNA *ptr)
std::string BKE_is_path_inside_blender_project(const char *path)
bool BKE_blender_project_init(blender::StringRef name, blender::StringRef root_path)
wmOperatorStatus WM_operator_props_popup_confirm_ex(bContext *C, wmOperator *op, const wmEvent *, std::optional< std::string > title, std::optional< std::string > confirm_text, const bool cancel_default, std::optional< std::string > message)
wmOperatorStatus WM_operator_name_call_with_properties(bContext *C, const char *opstring, wm::OpCallContext context, IDProperty *properties, const wmEvent *event)
bool BLI_path_parent_dir(char *path) ATTR_NONNULL(1)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void PROJECT_OT_variable_move(wmOperatorType *ot)
Main * CTX_data_main(const bContext *C)
static wmOperatorStatus project_variable_add_exec(bContext *C, wmOperator *op)
static void new_project_update_directory_from_name_set(PointerRNA *ptr)
bool BLI_path_contains(const char *container_path, const char *containee_path) ATTR_NONNULL(1
void PROJECT_OT_asset_library_remove(wmOperatorType *ot)
static void project_open_after_dialog_callback(bContext *C, void *user_data)
static wmOperatorStatus project_asset_library_add_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void RNA_def_property_update_runtime(PropertyRNA *prop, RNAPropertyUpdateFunc func)
static wmOperatorStatus project_asset_library_remove_exec(bContext *C, wmOperator *op)
static wmOperatorStatus project_config_save_exec(bContext *C, wmOperator *)
std::string RNA_string_get(PointerRNA *ptr, const char *name)
static std::string new_project_default_parent()
static std::string new_project_root_path(const Main *bmain, PointerRNA *ptr)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
static wmOperatorStatus project_close_invoke(bContext *C, wmOperator *op, const wmEvent *)
void PROJECT_OT_variable_add(wmOperatorType *ot)
static bool new_project_use_existing_directory(const Main *bmain, PointerRNA *ptr)
bool BKE_blender_project_init_from_root_path(Main *bmain, std::string project_root_path)
static wmOperatorStatus project_variable_remove_exec(bContext *C, wmOperator *)
static void project_asset_library_add_ui(bContext *, wmOperator *op)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
void WM_event_add_fileselect(bContext *C, wmOperator *op)
auto BKE_blender_project_write_callback(const Main *bmain, Fn lambda)
std::string BKE_blender_project_path_make_relative(StringRef path, bool path_is_template, const bke::BlenderProject &project)
void enabled_set(bool enabled)
void alignment_set(LayoutAlign alignment)
void use_property_decorate_set(bool is_decorate)
void use_property_split_set(bool is_sep)
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 & split(float percentage, bool align)
Button * button(StringRef name, int icon, std::function< void(bContext &)> func, std::optional< StringRef > tooltip=std::nullopt)
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
void(*) ui(bContext *C, wmOperator *op)
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports