|
@@ -1245,6 +1245,38 @@ void CanvasItem::_validate_property(PropertyInfo &p_property) const {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+PackedStringArray CanvasItem::get_configuration_warnings() const {
|
|
|
|
+ PackedStringArray warnings = Node::get_configuration_warnings();
|
|
|
|
+
|
|
|
|
+ if (clip_children_mode != CLIP_CHILDREN_DISABLED && is_inside_tree()) {
|
|
|
|
+ bool warned_about_ancestor_clipping = false;
|
|
|
|
+ bool warned_about_canvasgroup_ancestor = false;
|
|
|
|
+ Node *n = get_parent();
|
|
|
|
+ while (n) {
|
|
|
|
+ CanvasItem *as_canvas_item = Object::cast_to<CanvasItem>(n);
|
|
|
|
+ if (!warned_about_ancestor_clipping && as_canvas_item && as_canvas_item->clip_children_mode != CLIP_CHILDREN_DISABLED) {
|
|
|
|
+ warnings.push_back(vformat(RTR("Ancestor \"%s\" clips its children, so this node will not be able to clip its children."), as_canvas_item->get_name()));
|
|
|
|
+ warned_about_ancestor_clipping = true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ CanvasGroup *as_canvas_group = Object::cast_to<CanvasGroup>(n);
|
|
|
|
+ if (!warned_about_canvasgroup_ancestor && as_canvas_group) {
|
|
|
|
+ warnings.push_back(vformat(RTR("Ancestor \"%s\" is a CanvasGroup, so this node will not be able to clip its children."), as_canvas_group->get_name()));
|
|
|
|
+ warned_about_canvasgroup_ancestor = true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Only break out early once both warnings have been triggered, so
|
|
|
|
+ // that the user is aware of both possible reasons for clipping not working.
|
|
|
|
+ if (warned_about_ancestor_clipping && warned_about_canvasgroup_ancestor) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ n = n->get_parent();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return warnings;
|
|
|
|
+}
|
|
|
|
+
|
|
void CanvasItem::_bind_methods() {
|
|
void CanvasItem::_bind_methods() {
|
|
ClassDB::bind_method(D_METHOD("_top_level_raise_self"), &CanvasItem::_top_level_raise_self);
|
|
ClassDB::bind_method(D_METHOD("_top_level_raise_self"), &CanvasItem::_top_level_raise_self);
|
|
|
|
|
|
@@ -1646,6 +1678,8 @@ void CanvasItem::set_clip_children_mode(ClipChildrenMode p_clip_mode) {
|
|
}
|
|
}
|
|
clip_children_mode = p_clip_mode;
|
|
clip_children_mode = p_clip_mode;
|
|
|
|
|
|
|
|
+ update_configuration_warnings();
|
|
|
|
+
|
|
if (Object::cast_to<CanvasGroup>(this) != nullptr) {
|
|
if (Object::cast_to<CanvasGroup>(this) != nullptr) {
|
|
//avoid accidental bugs, make this not work on CanvasGroup
|
|
//avoid accidental bugs, make this not work on CanvasGroup
|
|
return;
|
|
return;
|