Browse Source

Merge pull request #46643 from YeldhamDev/hide_all_the_things

Hide more options of disabled properties
Rémi Verschelde 4 years ago
parent
commit
c487f1e854

+ 7 - 0
scene/2d/camera_2d.cpp

@@ -569,6 +569,7 @@ void Camera2D::_set_old_smoothing(float p_enable) {
 
 void Camera2D::set_enable_follow_smoothing(bool p_enabled) {
 	smoothing_enabled = p_enabled;
+	notify_property_list_changed();
 }
 
 bool Camera2D::is_follow_smoothing_enabled() const {
@@ -642,6 +643,12 @@ bool Camera2D::is_margin_drawing_enabled() const {
 	return margin_drawing_enabled;
 }
 
+void Camera2D::_validate_property(PropertyInfo &property) const {
+	if (!smoothing_enabled && property.name == "smoothing_speed") {
+		property.usage = PROPERTY_USAGE_NOEDITOR;
+	}
+}
+
 void Camera2D::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("set_offset", "offset"), &Camera2D::set_offset);
 	ClassDB::bind_method(D_METHOD("get_offset"), &Camera2D::get_offset);

+ 2 - 0
scene/2d/camera_2d.h

@@ -97,8 +97,10 @@ protected:
 
 protected:
 	virtual Transform2D get_camera_transform();
+
 	void _notification(int p_what);
 	static void _bind_methods();
+	void _validate_property(PropertyInfo &property) const override;
 
 public:
 	void set_offset(const Vector2 &p_offset);

+ 7 - 0
scene/2d/light_2d.cpp

@@ -159,6 +159,7 @@ int Light2D::get_item_shadow_cull_mask() const {
 void Light2D::set_shadow_enabled(bool p_enabled) {
 	shadow = p_enabled;
 	RS::get_singleton()->canvas_light_set_shadow_enabled(canvas_light, shadow);
+	notify_property_list_changed();
 }
 
 bool Light2D::is_shadow_enabled() const {
@@ -221,6 +222,12 @@ float Light2D::get_shadow_smooth() const {
 	return shadow_smooth;
 }
 
+void Light2D::_validate_property(PropertyInfo &property) const {
+	if (!shadow && (property.name == "shadow_color" || property.name == "shadow_filter" || property.name == "shadow_filter_smooth" || property.name == "shadow_item_cull_mask")) {
+		property.usage = PROPERTY_USAGE_NOEDITOR;
+	}
+}
+
 void Light2D::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &Light2D::set_enabled);
 	ClassDB::bind_method(D_METHOD("is_enabled"), &Light2D::is_enabled);

+ 1 - 0
scene/2d/light_2d.h

@@ -77,6 +77,7 @@ protected:
 	_FORCE_INLINE_ RID _get_light() const { return canvas_light; }
 	void _notification(int p_what);
 	static void _bind_methods();
+	void _validate_property(PropertyInfo &property) const override;
 
 public:
 	void set_enabled(bool p_enabled);

+ 1 - 1
scene/2d/polygon_2d.cpp

@@ -88,13 +88,13 @@ bool Polygon2D::_edit_is_selected_on_click(const Point2 &p_point, double p_toler
 	}
 	return Geometry2D::is_point_in_polygon(p_point - get_offset(), polygon2d);
 }
+#endif
 
 void Polygon2D::_validate_property(PropertyInfo &property) const {
 	if (!invert && property.name == "invert_border") {
 		property.usage = PROPERTY_USAGE_NOEDITOR;
 	}
 }
-#endif
 
 void Polygon2D::_skeleton_bone_setup_changed() {
 	update();

+ 1 - 4
scene/2d/polygon_2d.h

@@ -72,13 +72,10 @@ class Polygon2D : public Node2D {
 
 	void _skeleton_bone_setup_changed();
 
-#ifdef TOOLS_ENABLED
-	void _validate_property(PropertyInfo &property) const override;
-#endif
-
 protected:
 	void _notification(int p_what);
 	static void _bind_methods();
+	void _validate_property(PropertyInfo &property) const override;
 
 public:
 #ifdef TOOLS_ENABLED

+ 0 - 2
scene/3d/decal.cpp

@@ -154,13 +154,11 @@ Vector<Face3> Decal::get_faces(uint32_t p_usage_flags) const {
 	return Vector<Face3>();
 }
 
-#ifdef TOOLS_ENABLED
 void Decal::_validate_property(PropertyInfo &property) const {
 	if (!distance_fade_enabled && (property.name == "distance_fade_begin" || property.name == "distance_fade_length")) {
 		property.usage = PROPERTY_USAGE_NOEDITOR;
 	}
 }
-#endif
 
 void Decal::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("set_extents", "extents"), &Decal::set_extents);

+ 1 - 4
scene/3d/decal.h

@@ -62,12 +62,9 @@ private:
 	float distance_fade_begin = 10.0;
 	float distance_fade_length = 1.0;
 
-#ifdef TOOLS_ENABLED
-	void _validate_property(PropertyInfo &property) const override;
-#endif
-
 protected:
 	static void _bind_methods();
+	void _validate_property(PropertyInfo &property) const override;
 
 public:
 	void set_extents(const Vector3 &p_extents);

+ 1 - 1
scene/3d/light_3d.cpp

@@ -204,7 +204,7 @@ bool Light3D::is_editor_only() const {
 }
 
 void Light3D::_validate_property(PropertyInfo &property) const {
-	if (!shadow && (property.name == "shadow_color" || property.name == "shadow_color" || property.name == "shadow_bias" || property.name == "shadow_normal_bias" || property.name == "shadow_reverse_cull_face" || property.name == "shadow_transmittance_bias" || property.name == "shadow_blur")) {
+	if (!shadow && (property.name == "shadow_color" || property.name == "shadow_bias" || property.name == "shadow_normal_bias" || property.name == "shadow_reverse_cull_face" || property.name == "shadow_transmittance_bias" || property.name == "shadow_fog_fade" || property.name == "shadow_blur")) {
 		property.usage = PROPERTY_USAGE_NOEDITOR;
 	}
 

+ 0 - 2
scene/3d/sprite_3d.cpp

@@ -625,11 +625,9 @@ void Sprite3D::_validate_property(PropertyInfo &property) const {
 		property.usage |= PROPERTY_USAGE_KEYING_INCREMENTS;
 	}
 
-#ifdef TOOLS_ENABLED
 	if (!region && property.name == "region_rect") {
 		property.usage = PROPERTY_USAGE_NOEDITOR;
 	}
-#endif
 }
 
 void Sprite3D::_bind_methods() {

+ 8 - 0
scene/gui/line_edit.cpp

@@ -1154,6 +1154,8 @@ void LineEdit::cursor_set_blink_enabled(const bool p_enabled) {
 	}
 
 	draw_caret = true;
+
+	notify_property_list_changed();
 }
 
 bool LineEdit::cursor_get_force_displayed() const {
@@ -2075,6 +2077,12 @@ void LineEdit::_get_property_list(List<PropertyInfo> *p_list) const {
 	p_list->push_back(PropertyInfo(Variant::NIL, "opentype_features/_new", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR));
 }
 
+void LineEdit::_validate_property(PropertyInfo &property) const {
+	if (!caret_blink_enabled && property.name == "caret_blink_speed") {
+		property.usage = PROPERTY_USAGE_NOEDITOR;
+	}
+}
+
 void LineEdit::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("_text_changed"), &LineEdit::_text_changed);
 

+ 3 - 3
scene/gui/line_edit.h

@@ -198,15 +198,15 @@ private:
 	void _backspace(bool p_word = false, bool p_all_to_left = false);
 	void _delete(bool p_word = false, bool p_all_to_right = false);
 
-	void _gui_input(Ref<InputEvent> p_event);
-	void _notification(int p_what);
-
 protected:
+	void _notification(int p_what);
 	static void _bind_methods();
+	void _gui_input(Ref<InputEvent> p_event);
 
 	bool _set(const StringName &p_name, const Variant &p_value);
 	bool _get(const StringName &p_name, Variant &r_ret) const;
 	void _get_property_list(List<PropertyInfo> *p_list) const;
+	void _validate_property(PropertyInfo &property) const override;
 
 public:
 	void set_align(Align p_align);

+ 7 - 0
scene/gui/rich_text_label.cpp

@@ -3634,6 +3634,7 @@ void RichTextLabel::set_use_bbcode(bool p_enable) {
 	}
 	use_bbcode = p_enable;
 	set_bbcode(bbcode);
+	notify_property_list_changed();
 }
 
 bool RichTextLabel::is_using_bbcode() const {
@@ -3771,6 +3772,12 @@ int RichTextLabel::get_content_height() const {
 	return total_height;
 }
 
+void RichTextLabel::_validate_property(PropertyInfo &property) const {
+	if (!use_bbcode && property.name == "bbcode_text") {
+		property.usage = PROPERTY_USAGE_NOEDITOR;
+	}
+}
+
 void RichTextLabel::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("_gui_input"), &RichTextLabel::_gui_input);
 	ClassDB::bind_method(D_METHOD("get_text"), &RichTextLabel::get_text);

+ 2 - 3
scene/gui/rich_text_label.h

@@ -81,7 +81,9 @@ public:
 	};
 
 protected:
+	void _notification(int p_what);
 	static void _bind_methods();
+	void _validate_property(PropertyInfo &property) const override;
 
 private:
 	struct Item;
@@ -441,9 +443,6 @@ private:
 
 	bool fit_content_height = false;
 
-protected:
-	void _notification(int p_what);
-
 public:
 	String get_text();
 	void add_text(const String &p_text);

+ 0 - 2
scene/main/canvas_layer.cpp

@@ -258,13 +258,11 @@ void CanvasLayer::_update_follow_viewport(bool p_force_exit) {
 	}
 }
 
-#ifdef TOOLS_ENABLED
 void CanvasLayer::_validate_property(PropertyInfo &property) const {
 	if (!follow_viewport && property.name == "follow_viewport_scale") {
 		property.usage = PROPERTY_USAGE_NOEDITOR;
 	}
 }
-#endif
 
 void CanvasLayer::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("set_layer", "layer"), &CanvasLayer::set_layer);

+ 1 - 4
scene/main/canvas_layer.h

@@ -61,13 +61,10 @@ class CanvasLayer : public Node {
 	void _update_locrotscale();
 	void _update_follow_viewport(bool p_force_exit = false);
 
-#ifdef TOOLS_ENABLED
-	void _validate_property(PropertyInfo &property) const override;
-#endif
-
 protected:
 	void _notification(int p_what);
 	static void _bind_methods();
+	void _validate_property(PropertyInfo &property) const override;
 
 public:
 	void set_layer(int p_xform);

+ 0 - 2
scene/resources/camera_effects.cpp

@@ -145,7 +145,6 @@ void CameraEffects::_update_override_exposure() {
 
 // Private methods, constructor and destructor
 
-#ifdef TOOLS_ENABLED
 void CameraEffects::_validate_property(PropertyInfo &property) const {
 	if ((!dof_blur_far_enabled && (property.name == "dof_blur_far_distance" || property.name == "dof_blur_far_transition")) ||
 			(!dof_blur_near_enabled && (property.name == "dof_blur_near_distance" || property.name == "dof_blur_near_transition")) ||
@@ -153,7 +152,6 @@ void CameraEffects::_validate_property(PropertyInfo &property) const {
 		property.usage = PROPERTY_USAGE_NOEDITOR;
 	}
 }
-#endif
 
 void CameraEffects::_bind_methods() {
 	// DOF blur

+ 1 - 4
scene/resources/camera_effects.h

@@ -57,12 +57,9 @@ private:
 	float override_exposure = 1.0;
 	void _update_override_exposure();
 
-#ifdef TOOLS_ENABLED
-	void _validate_property(PropertyInfo &property) const override;
-#endif
-
 protected:
 	static void _bind_methods();
+	void _validate_property(PropertyInfo &property) const override;
 
 public:
 	virtual RID get_rid() const override;

+ 7 - 0
scene/resources/style_box.cpp

@@ -460,6 +460,7 @@ Point2 StyleBoxFlat::get_shadow_offset() const {
 void StyleBoxFlat::set_anti_aliased(const bool &p_anti_aliased) {
 	anti_aliased = p_anti_aliased;
 	emit_changed();
+	notify_property_list_changed();
 }
 
 bool StyleBoxFlat::is_anti_aliased() const {
@@ -781,6 +782,12 @@ float StyleBoxFlat::get_style_margin(Side p_side) const {
 	return border_width[p_side];
 }
 
+void StyleBoxFlat::_validate_property(PropertyInfo &property) const {
+	if (!anti_aliased && property.name == "anti_aliasing_size") {
+		property.usage = PROPERTY_USAGE_NOEDITOR;
+	}
+}
+
 void StyleBoxFlat::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("set_bg_color", "color"), &StyleBoxFlat::set_bg_color);
 	ClassDB::bind_method(D_METHOD("get_bg_color"), &StyleBoxFlat::get_bg_color);

+ 1 - 0
scene/resources/style_box.h

@@ -159,6 +159,7 @@ class StyleBoxFlat : public StyleBox {
 protected:
 	virtual float get_style_margin(Side p_side) const override;
 	static void _bind_methods();
+	void _validate_property(PropertyInfo &property) const override;
 
 public:
 	//Color