Skip to content

Commit

Permalink
Merge pull request #46643 from YeldhamDev/hide_all_the_things
Browse files Browse the repository at this point in the history
Hide more options of disabled properties
  • Loading branch information
akien-mga authored Mar 7, 2021
2 parents afd0df7 + 4be282a commit c487f1e
Show file tree
Hide file tree
Showing 20 changed files with 51 additions and 32 deletions.
7 changes: 7 additions & 0 deletions scene/2d/camera_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions scene/2d/camera_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@ class Camera2D : public Node2D {

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);
Expand Down
7 changes: 7 additions & 0 deletions scene/2d/light_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions scene/2d/light_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class Light2D : public Node2D {
_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);
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/polygon_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 1 addition & 4 deletions scene/2d/polygon_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions scene/3d/decal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 1 addition & 4 deletions scene/3d/decal.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,9 @@ class Decal : public VisualInstance3D {
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);
Expand Down
2 changes: 1 addition & 1 deletion scene/3d/light_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 0 additions & 2 deletions scene/3d/sprite_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
8 changes: 8 additions & 0 deletions scene/gui/line_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions scene/gui/line_edit.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,15 @@ class LineEdit : public Control {
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);
Expand Down
7 changes: 7 additions & 0 deletions scene/gui/rich_text_label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions scene/gui/rich_text_label.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ class RichTextLabel : public Control {
};

protected:
void _notification(int p_what);
static void _bind_methods();
void _validate_property(PropertyInfo &property) const override;

private:
struct Item;
Expand Down Expand Up @@ -441,9 +443,6 @@ class RichTextLabel : public Control {

bool fit_content_height = false;

protected:
void _notification(int p_what);

public:
String get_text();
void add_text(const String &p_text);
Expand Down
2 changes: 0 additions & 2 deletions scene/main/canvas_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 1 addition & 4 deletions scene/main/canvas_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions scene/resources/camera_effects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,13 @@ 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")) ||
(!override_exposure_enabled && property.name == "override_exposure")) {
property.usage = PROPERTY_USAGE_NOEDITOR;
}
}
#endif

void CameraEffects::_bind_methods() {
// DOF blur
Expand Down
5 changes: 1 addition & 4 deletions scene/resources/camera_effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,9 @@ class CameraEffects : public Resource {
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;
Expand Down
7 changes: 7 additions & 0 deletions scene/resources/style_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions scene/resources/style_box.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c487f1e

Please sign in to comment.