mirror of
https://github.com/godotengine/godot.git
synced 2026-01-06 10:11:57 +03:00
Merge pull request #64339 from YuriSizov/core-multilevel-validate-property
This commit is contained in:
@@ -422,9 +422,9 @@ void Control::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
}
|
||||
}
|
||||
|
||||
void Control::_validate_property(PropertyInfo &property) const {
|
||||
void Control::_validate_property(PropertyInfo &p_property) const {
|
||||
// Update theme type variation options.
|
||||
if (property.name == "theme_type_variation") {
|
||||
if (p_property.name == "theme_type_variation") {
|
||||
List<StringName> names;
|
||||
|
||||
// Only the default theme and the project theme are used for the list of options.
|
||||
@@ -447,18 +447,18 @@ void Control::_validate_property(PropertyInfo &property) const {
|
||||
unique_names.append(E);
|
||||
}
|
||||
|
||||
property.hint_string = hint_string;
|
||||
p_property.hint_string = hint_string;
|
||||
}
|
||||
|
||||
if (property.name == "mouse_force_pass_scroll_events") {
|
||||
if (p_property.name == "mouse_force_pass_scroll_events") {
|
||||
// Disable force pass if the control is not stopping the event.
|
||||
if (data.mouse_filter != MOUSE_FILTER_STOP) {
|
||||
property.usage |= PROPERTY_USAGE_READ_ONLY;
|
||||
p_property.usage |= PROPERTY_USAGE_READ_ONLY;
|
||||
}
|
||||
}
|
||||
|
||||
if (property.name == "scale") {
|
||||
property.hint = PROPERTY_HINT_LINK;
|
||||
if (p_property.name == "scale") {
|
||||
p_property.hint = PROPERTY_HINT_LINK;
|
||||
}
|
||||
|
||||
// Validate which positioning properties should be displayed depending on the parent and the layout mode.
|
||||
@@ -467,33 +467,33 @@ void Control::_validate_property(PropertyInfo &property) const {
|
||||
// If there is no parent, display both anchor and container options.
|
||||
|
||||
// Set the layout mode to be disabled with the proper value.
|
||||
if (property.name == "layout_mode") {
|
||||
property.hint_string = "Position,Anchors,Container,Uncontrolled";
|
||||
property.usage |= PROPERTY_USAGE_READ_ONLY;
|
||||
if (p_property.name == "layout_mode") {
|
||||
p_property.hint_string = "Position,Anchors,Container,Uncontrolled";
|
||||
p_property.usage |= PROPERTY_USAGE_READ_ONLY;
|
||||
}
|
||||
|
||||
// Use the layout mode to display or hide advanced anchoring properties.
|
||||
bool use_custom_anchors = _get_anchors_layout_preset() == -1; // Custom "preset".
|
||||
if (!use_custom_anchors && (property.name.begins_with("anchor_") || property.name.begins_with("offset_") || property.name.begins_with("grow_"))) {
|
||||
property.usage ^= PROPERTY_USAGE_EDITOR;
|
||||
if (!use_custom_anchors && (p_property.name.begins_with("anchor_") || p_property.name.begins_with("offset_") || p_property.name.begins_with("grow_"))) {
|
||||
p_property.usage ^= PROPERTY_USAGE_EDITOR;
|
||||
}
|
||||
} else if (Object::cast_to<Container>(parent_node)) {
|
||||
// If the parent is a container, display only container-related properties.
|
||||
if (property.name.begins_with("anchor_") || property.name.begins_with("offset_") || property.name.begins_with("grow_") || property.name == "anchors_preset" ||
|
||||
property.name == "position" || property.name == "rotation" || property.name == "scale" || property.name == "size" || property.name == "pivot_offset") {
|
||||
property.usage ^= PROPERTY_USAGE_EDITOR;
|
||||
if (p_property.name.begins_with("anchor_") || p_property.name.begins_with("offset_") || p_property.name.begins_with("grow_") || p_property.name == "anchors_preset" ||
|
||||
p_property.name == "position" || p_property.name == "rotation" || p_property.name == "scale" || p_property.name == "size" || p_property.name == "pivot_offset") {
|
||||
p_property.usage ^= PROPERTY_USAGE_EDITOR;
|
||||
|
||||
} else if (property.name == "layout_mode") {
|
||||
} else if (p_property.name == "layout_mode") {
|
||||
// Set the layout mode to be disabled with the proper value.
|
||||
property.hint_string = "Position,Anchors,Container,Uncontrolled";
|
||||
property.usage |= PROPERTY_USAGE_READ_ONLY;
|
||||
} else if (property.name == "size_flags_horizontal" || property.name == "size_flags_vertical") {
|
||||
p_property.hint_string = "Position,Anchors,Container,Uncontrolled";
|
||||
p_property.usage |= PROPERTY_USAGE_READ_ONLY;
|
||||
} else if (p_property.name == "size_flags_horizontal" || p_property.name == "size_flags_vertical") {
|
||||
// Filter allowed size flags based on the parent container configuration.
|
||||
Container *parent_container = Object::cast_to<Container>(parent_node);
|
||||
Vector<int> size_flags;
|
||||
if (property.name == "size_flags_horizontal") {
|
||||
if (p_property.name == "size_flags_horizontal") {
|
||||
size_flags = parent_container->get_allowed_size_flags_horizontal();
|
||||
} else if (property.name == "size_flags_vertical") {
|
||||
} else if (p_property.name == "size_flags_vertical") {
|
||||
size_flags = parent_container->get_allowed_size_flags_vertical();
|
||||
}
|
||||
|
||||
@@ -522,30 +522,30 @@ void Control::_validate_property(PropertyInfo &property) const {
|
||||
}
|
||||
|
||||
if (hint_string.is_empty()) {
|
||||
property.hint_string = "";
|
||||
property.usage |= PROPERTY_USAGE_READ_ONLY;
|
||||
p_property.hint_string = "";
|
||||
p_property.usage |= PROPERTY_USAGE_READ_ONLY;
|
||||
} else {
|
||||
property.hint_string = hint_string;
|
||||
p_property.hint_string = hint_string;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If the parent is NOT a container or not a control at all, display only anchoring-related properties.
|
||||
if (property.name.begins_with("size_flags_")) {
|
||||
property.usage ^= PROPERTY_USAGE_EDITOR;
|
||||
if (p_property.name.begins_with("size_flags_")) {
|
||||
p_property.usage ^= PROPERTY_USAGE_EDITOR;
|
||||
|
||||
} else if (property.name == "layout_mode") {
|
||||
} else if (p_property.name == "layout_mode") {
|
||||
// Set the layout mode to be enabled with proper options.
|
||||
property.hint_string = "Position,Anchors";
|
||||
p_property.hint_string = "Position,Anchors";
|
||||
}
|
||||
|
||||
// Use the layout mode to display or hide advanced anchoring properties.
|
||||
bool use_anchors = _get_layout_mode() == LayoutMode::LAYOUT_MODE_ANCHORS;
|
||||
if (!use_anchors && property.name == "anchors_preset") {
|
||||
property.usage ^= PROPERTY_USAGE_EDITOR;
|
||||
if (!use_anchors && p_property.name == "anchors_preset") {
|
||||
p_property.usage ^= PROPERTY_USAGE_EDITOR;
|
||||
}
|
||||
bool use_custom_anchors = use_anchors && _get_anchors_layout_preset() == -1; // Custom "preset".
|
||||
if (!use_custom_anchors && (property.name.begins_with("anchor_") || property.name.begins_with("offset_") || property.name.begins_with("grow_"))) {
|
||||
property.usage ^= PROPERTY_USAGE_EDITOR;
|
||||
if (!use_custom_anchors && (p_property.name.begins_with("anchor_") || p_property.name.begins_with("offset_") || p_property.name.begins_with("grow_"))) {
|
||||
p_property.usage ^= PROPERTY_USAGE_EDITOR;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -555,13 +555,13 @@ void Control::_validate_property(PropertyInfo &property) const {
|
||||
}
|
||||
bool property_is_managed_by_container = false;
|
||||
for (unsigned i = 0; i < properties_managed_by_container_count; i++) {
|
||||
property_is_managed_by_container = properties_managed_by_container[i] == property.name;
|
||||
property_is_managed_by_container = properties_managed_by_container[i] == p_property.name;
|
||||
if (property_is_managed_by_container) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (property_is_managed_by_container) {
|
||||
property.usage |= PROPERTY_USAGE_READ_ONLY;
|
||||
p_property.usage |= PROPERTY_USAGE_READ_ONLY;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user