Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/interface/interface_templates.c')
-rw-r--r--source/blender/editors/interface/interface_templates.c173
1 files changed, 103 insertions, 70 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 5813f1d090c..0b72c358dc9 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -571,8 +571,11 @@ static uiBlock *id_search_menu(bContext *C, ARegion *region, void *arg_litem)
/** \name ID Template
* \{ */
-/* This is for browsing and editing the ID-blocks used */
+static void template_id_cb(bContext *C, void *arg_litem, void *arg_event);
+/**
+ * This is for browsing and editing the ID-blocks used.
+ */
void UI_context_active_but_prop_get_templateID(bContext *C,
PointerRNA *r_ptr,
PropertyRNA **r_prop)
@@ -582,7 +585,7 @@ void UI_context_active_but_prop_get_templateID(bContext *C,
memset(r_ptr, 0, sizeof(*r_ptr));
*r_prop = NULL;
- if (but && but->func_argN) {
+ if (but && (but->funcN == template_id_cb) && but->func_argN) {
TemplateID *template_ui = but->func_argN;
*r_ptr = template_ui->ptr;
*r_prop = template_ui->prop;
@@ -650,14 +653,13 @@ static void template_id_liboverride_hierarchy_collections_tag_recursive(
}
}
-static void template_id_liboverride_hierarchy_create(bContext *C,
- Main *bmain,
- TemplateID *template_ui,
- PointerRNA *idptr,
- const char **r_undo_push_label)
+ID *ui_template_id_liboverride_hierarchy_make(
+ bContext *C, Main *bmain, ID *owner_id, ID *id, const char **r_undo_push_label)
{
- ID *id = idptr->data;
- ID *owner_id = template_ui->ptr.owner_id;
+ const char *undo_push_label;
+ if (r_undo_push_label == NULL) {
+ r_undo_push_label = &undo_push_label;
+ }
/* If this is called on an already local override, 'toggle' between user-editable state, and
* system override with reset. */
@@ -677,14 +679,15 @@ static void template_id_liboverride_hierarchy_create(bContext *C,
WM_event_add_notifier(C, NC_WM | ND_DATACHANGED, NULL);
WM_event_add_notifier(C, NC_WM | ND_LIB_OVERRIDE_CHANGED, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL);
- return;
+ return id;
}
/* Attempt to perform a hierarchy override, based on contextual data available.
* NOTE: do not attempt to perform such hierarchy override at all cost, if there is not enough
* context, better to abort than create random overrides all over the place. */
if (!ID_IS_OVERRIDABLE_LIBRARY_HIERARCHY(id)) {
- return;
+ RNA_warning("The data-block %s is not overridable", id->name);
+ return NULL;
}
Object *object_active = CTX_data_active_object(C);
@@ -762,15 +765,8 @@ static void template_id_liboverride_hierarchy_create(bContext *C,
if (object_active != NULL) {
object_active->id.tag |= LIB_TAG_DOIT;
}
- BKE_lib_override_library_create(bmain,
- scene,
- view_layer,
- NULL,
- id,
- &collection_active->id,
- NULL,
- &id_override,
- U.experimental.use_override_new_fully_editable);
+ BKE_lib_override_library_create(
+ bmain, scene, view_layer, NULL, id, &collection_active->id, NULL, &id_override, false);
}
else if (object_active != NULL && !ID_IS_LINKED(object_active) &&
&object_active->instance_collection->id == id) {
@@ -783,7 +779,7 @@ static void template_id_liboverride_hierarchy_create(bContext *C,
&object_active->id,
&object_active->id,
&id_override,
- U.experimental.use_override_new_fully_editable);
+ false);
}
break;
case ID_OB:
@@ -793,15 +789,17 @@ static void template_id_liboverride_hierarchy_create(bContext *C,
if (object_active != NULL) {
object_active->id.tag |= LIB_TAG_DOIT;
}
- BKE_lib_override_library_create(bmain,
- scene,
- view_layer,
- NULL,
- id,
- &collection_active->id,
- NULL,
- &id_override,
- U.experimental.use_override_new_fully_editable);
+ BKE_lib_override_library_create(
+ bmain, scene, view_layer, NULL, id, &collection_active->id, NULL, &id_override, false);
+ }
+ else {
+ if (object_active != NULL) {
+ object_active->id.tag |= LIB_TAG_DOIT;
+ }
+ BKE_lib_override_library_create(
+ bmain, scene, view_layer, NULL, id, NULL, NULL, &id_override, false);
+ BKE_scene_collections_object_remove(bmain, scene, (Object *)id, true);
+ WM_event_add_notifier(C, NC_ID | NA_REMOVED, NULL);
}
break;
case ID_ME:
@@ -816,7 +814,8 @@ static void template_id_liboverride_hierarchy_create(bContext *C,
case ID_CV:
case ID_PT:
case ID_VO:
- if (object_active != NULL && object_active->data == id) {
+ case ID_NT: /* Essentially geometry nodes from modifier currently. */
+ if (object_active != NULL) {
if (collection_active != NULL &&
BKE_collection_has_object_recursive(collection_active, object_active)) {
template_id_liboverride_hierarchy_collections_tag_recursive(collection_active, id, true);
@@ -831,42 +830,74 @@ static void template_id_liboverride_hierarchy_create(bContext *C,
&collection_active->id,
NULL,
&id_override,
- U.experimental.use_override_new_fully_editable);
+ false);
}
else {
object_active->id.tag |= LIB_TAG_DOIT;
- BKE_lib_override_library_create(bmain,
- scene,
- view_layer,
- NULL,
- id,
- &object_active->id,
- NULL,
- &id_override,
- U.experimental.use_override_new_fully_editable);
+ BKE_lib_override_library_create(
+ bmain, scene, view_layer, NULL, id, &object_active->id, NULL, &id_override, false);
}
}
break;
case ID_MA:
case ID_TE:
case ID_IM:
+ RNA_warning("The type of data-block %s could not yet implemented", id->name);
break;
case ID_WO:
+ RNA_warning("The type of data-block %s could not yet implemented", id->name);
break;
case ID_PA:
+ RNA_warning("The type of data-block %s could not yet implemented", id->name);
break;
default:
+ RNA_warning("The type of data-block %s could not yet implemented", id->name);
break;
}
if (id_override != NULL) {
id_override->override_library->flag &= ~IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED;
*r_undo_push_label = "Make Library Override Hierarchy";
- /* Given `idptr` is re-assigned to owner property by caller to ensure proper updates etc. Here
- * we also use it to ensure remapping of the owner property from the linked data to the newly
- * created liboverride (note that in theory this remapping has already been done by code
- * above). */
- RNA_id_pointer_create(id_override, idptr);
+ /* In theory we could rely on setting/updating the RNA ID pointer property (as done by calling
+ * code) to be enough.
+ *
+ * However, some rare ID pointers properties (like the 'active object in viewlayer' one used
+ * for the Object templateID in the Object properties) use notifiers that do not enforce a
+ * rebuild of outliner trees, leading to crashes.
+ *
+ * So for now, add some extra notifiers here. */
+ WM_event_add_notifier(C, NC_ID | NA_ADDED, NULL);
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_OUTLINER, NULL);
+ }
+ return id_override;
+}
+
+static void template_id_liboverride_hierarchy_make(bContext *C,
+ Main *bmain,
+ TemplateID *template_ui,
+ PointerRNA *idptr,
+ const char **r_undo_push_label)
+{
+ ID *id = idptr->data;
+ ID *owner_id = template_ui->ptr.owner_id;
+
+ ID *id_override = ui_template_id_liboverride_hierarchy_make(
+ C, bmain, owner_id, id, r_undo_push_label);
+
+ if (id_override != NULL) {
+ /* `idptr` is re-assigned to owner property to ensure proper updates etc. Here we also use it
+ * to ensure remapping of the owner property from the linked data to the newly created
+ * liboverride (note that in theory this remapping has already been done by code above), but
+ * only in case owner ID was already local ID (override or pure local data).
+ *
+ * Otherwise, owner ID will also have been overridden, and remapped already to use it's
+ * override of the data too. */
+ if (!ID_IS_LINKED(owner_id)) {
+ RNA_id_pointer_create(id_override, idptr);
+ }
+ }
+ else {
+ RNA_warning("The data-block %s could not be overridden", id->name);
}
}
@@ -919,8 +950,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
if (id) {
Main *bmain = CTX_data_main(C);
if (CTX_wm_window(C)->eventstate->modifier & KM_SHIFT) {
- template_id_liboverride_hierarchy_create(
- C, bmain, template_ui, &idptr, &undo_push_label);
+ template_id_liboverride_hierarchy_make(C, bmain, template_ui, &idptr, &undo_push_label);
}
else {
if (BKE_lib_id_make_local(bmain, id, 0)) {
@@ -941,8 +971,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
if (id && ID_IS_OVERRIDE_LIBRARY(id)) {
Main *bmain = CTX_data_main(C);
if (CTX_wm_window(C)->eventstate->modifier & KM_SHIFT) {
- template_id_liboverride_hierarchy_create(
- C, bmain, template_ui, &idptr, &undo_push_label);
+ template_id_liboverride_hierarchy_make(C, bmain, template_ui, &idptr, &undo_push_label);
}
else {
BKE_lib_override_library_make_local(id);
@@ -1336,20 +1365,22 @@ static void template_ID(const bContext *C,
}
}
else if (ID_IS_OVERRIDE_LIBRARY(id)) {
- but = uiDefIconBut(block,
- UI_BTYPE_BUT,
- 0,
- ICON_LIBRARY_DATA_OVERRIDE,
- 0,
- 0,
- UI_UNIT_X,
- UI_UNIT_Y,
- NULL,
- 0,
- 0,
- 0,
- 0,
- TIP_("Library override of linked data-block, click to make fully local"));
+ but = uiDefIconBut(
+ block,
+ UI_BTYPE_BUT,
+ 0,
+ ICON_LIBRARY_DATA_OVERRIDE,
+ 0,
+ 0,
+ UI_UNIT_X,
+ UI_UNIT_Y,
+ NULL,
+ 0,
+ 0,
+ 0,
+ 0,
+ TIP_("Library override of linked data-block, click to make fully local, "
+ "Shift + Click to clear the library override and toggle if it can be edited"));
UI_but_funcN_set(
but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_OVERRIDE));
}
@@ -5175,7 +5206,7 @@ static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAUp
0.0,
0.0,
0.0,
- "Reapply and update the preset, removing changes");
+ TIP_("Reapply and update the preset, removing changes"));
UI_but_funcN_set(bt, CurveProfile_buttons_reset, MEM_dupallocN(cb), profile);
}
}
@@ -6300,7 +6331,7 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C)
0,
width + UI_UNIT_X,
UI_UNIT_Y,
- "Show in Info Log");
+ TIP_("Show in Info Log"));
UI_block_emboss_set(block, previous_emboss);
}
@@ -6327,8 +6358,10 @@ void uiTemplateInputStatus(uiLayout *layout, struct bContext *C)
uiLayout *row = uiLayoutRow(col, true);
uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_LEFT);
- const char *msg = TIP_(WM_window_cursor_keymap_status_get(win, i, 0));
- const char *msg_drag = TIP_(WM_window_cursor_keymap_status_get(win, i, 1));
+ const char *msg = CTX_TIP_(BLT_I18NCONTEXT_OPERATOR_DEFAULT,
+ WM_window_cursor_keymap_status_get(win, i, 0));
+ const char *msg_drag = CTX_TIP_(BLT_I18NCONTEXT_OPERATOR_DEFAULT,
+ WM_window_cursor_keymap_status_get(win, i, 1));
if (msg || (msg_drag == NULL)) {
uiItemL(row, msg ? msg : "", (ICON_MOUSE_LMB + i));
@@ -6458,13 +6491,13 @@ bool uiTemplateEventFromKeymapItem(struct uiLayout *layout,
for (int j = 0; j < ARRAY_SIZE(icon_mod) && icon_mod[j]; j++) {
uiItemL(layout, "", icon_mod[j]);
}
- uiItemL(layout, TIP_(text), icon);
+ uiItemL(layout, CTX_TIP_(BLT_I18NCONTEXT_ID_WINDOWMANAGER, text), icon);
ok = true;
}
else if (text_fallback) {
const char *event_text = WM_key_event_string(kmi->type, true);
uiItemL(layout, event_text, ICON_NONE);
- uiItemL(layout, TIP_(text), ICON_NONE);
+ uiItemL(layout, CTX_TIP_(BLT_I18NCONTEXT_ID_WINDOWMANAGER, text), ICON_NONE);
ok = true;
}
return ok;