From 034aed2b7387595c88170eb41b050807e9788e9c Mon Sep 17 00:00:00 2001 From: Relintai Date: Thu, 16 Jun 2022 12:15:10 +0200 Subject: [PATCH] Fix duplicate methods and binds in CurveEditor. --- .../editor/widgets/curve_edit/curve_editor.cpp | 10 ++++------ .../editor/widgets/curve_edit/curve_editor.h | 8 ++++---- .../editor/widgets/curve_edit/curve_view.h | 4 ++-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/modules/material_maker/editor/widgets/curve_edit/curve_editor.cpp b/modules/material_maker/editor/widgets/curve_edit/curve_editor.cpp index 71b065f42..83eba3607 100644 --- a/modules/material_maker/editor/widgets/curve_edit/curve_editor.cpp +++ b/modules/material_maker/editor/widgets/curve_edit/curve_editor.cpp @@ -6,7 +6,7 @@ #include "core/object.h" #include "slope_point.h" -void MMCurveEditor::set_curve(const Variant &c) { +void MMCurveEditor::set_curve(const Ref &c) { curve = c; update(); update_controls(); @@ -52,7 +52,7 @@ void MMCurveEditor::update_controls() { emit_signal("value_changed", curve); } -void MMCurveEditor::_on_ControlPoint_moved(const Variant &index) { +void MMCurveEditor::_on_ControlPoint_moved(const int index) { Vector points = curve->get_points(); ControlPoint *control_point = Object::cast_to(get_child(index)); points.write[index].p = reverse_transform_point(control_point->get_position() + control_point->OFFSET); @@ -78,14 +78,14 @@ void MMCurveEditor::_on_ControlPoint_moved(const Variant &index) { emit_signal("value_changed", curve); } -void MMCurveEditor::_on_ControlPoint_removed(const Variant &index) { +void MMCurveEditor::_on_ControlPoint_removed(const int index) { if (curve->remove_point(index)) { update(); update_controls(); } } -void MMCurveEditor::_on_MMCurveEditor_gui_input(const Variant &event) { +void MMCurveEditor::_on_MMCurveEditor_gui_input(const Ref &event) { Ref iemb = event; if (iemb.is_valid()) { @@ -122,11 +122,9 @@ void MMCurveEditor::_notification(int p_what) { void MMCurveEditor::_bind_methods() { ADD_SIGNAL(MethodInfo("value_changed", PropertyInfo(Variant::OBJECT, "value", PROPERTY_HINT_RESOURCE_TYPE, "CurveBase"))); - ClassDB::bind_method(D_METHOD("set_curve", "c"), &MMCurveEditor::set_curve); ClassDB::bind_method(D_METHOD("update_controls"), &MMCurveEditor::update_controls); ClassDB::bind_method(D_METHOD("_on_ControlPoint_moved", "index"), &MMCurveEditor::_on_ControlPoint_moved); ClassDB::bind_method(D_METHOD("_on_ControlPoint_removed", "index"), &MMCurveEditor::_on_ControlPoint_removed); ClassDB::bind_method(D_METHOD("_on_MMCurveEditor_gui_input", "event"), &MMCurveEditor::_on_MMCurveEditor_gui_input); - ClassDB::bind_method(D_METHOD("_on_resize"), &MMCurveEditor::_on_resize); } diff --git a/modules/material_maker/editor/widgets/curve_edit/curve_editor.h b/modules/material_maker/editor/widgets/curve_edit/curve_editor.h index afe0eff46..bd7180b6d 100644 --- a/modules/material_maker/editor/widgets/curve_edit/curve_editor.h +++ b/modules/material_maker/editor/widgets/curve_edit/curve_editor.h @@ -7,12 +7,12 @@ class MMCurveEditor : public CurveView { GDCLASS(MMCurveEditor, CurveView); public: - void set_curve(const Variant &c); + void set_curve(const Ref &c); void update_controls(); - void _on_ControlPoint_moved(const Variant &index); - void _on_ControlPoint_removed(const Variant &index); - void _on_MMCurveEditor_gui_input(const Variant &event); + void _on_ControlPoint_moved(const int index); + void _on_ControlPoint_removed(const int index); + void _on_MMCurveEditor_gui_input(const Ref &event); void _on_resize(); MMCurveEditor(); diff --git a/modules/material_maker/editor/widgets/curve_edit/curve_view.h b/modules/material_maker/editor/widgets/curve_edit/curve_view.h index 40335a536..f3d6b410b 100644 --- a/modules/material_maker/editor/widgets/curve_edit/curve_view.h +++ b/modules/material_maker/editor/widgets/curve_edit/curve_view.h @@ -15,13 +15,13 @@ public: void set_show_axes(const bool val); Ref get_curve(); - void set_curve(const Ref &val); + virtual void set_curve(const Ref &val); Vector2 transform_point(const Vector2 &p); Vector2 reverse_transform_point(const Vector2 &p); void _draw(); - void _on_resize(); + virtual void _on_resize(); CurveView(); ~CurveView();