diff --git a/modules/material_maker/editor/widgets/gradient_editor/gradient_cursor.cpp b/modules/material_maker/editor/widgets/gradient_editor/gradient_cursor.cpp index fd14d039d..3f86d6260 100644 --- a/modules/material_maker/editor/widgets/gradient_editor/gradient_cursor.cpp +++ b/modules/material_maker/editor/widgets/gradient_editor/gradient_cursor.cpp @@ -3,11 +3,11 @@ #include "gradient_editor.h" #include "scene/gui/label.h" -Color GradientCursor::get_color() { +Color GradientCursor::get_cursor_color() { return color; } -void GradientCursor::set_color(const Color &val) { +void GradientCursor::set_cursor_color(const Color &val) { color = val; MMGradientEditor *ged = Object::cast_to(get_parent()); ERR_FAIL_COND(!ged); @@ -104,7 +104,7 @@ bool GradientCursor::can_drop_data_fw(const Point2 &p_point, const Variant &p_da } void GradientCursor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) { - set_color(p_data); + set_cursor_color(p_data); } GradientCursor::GradientCursor() { @@ -128,9 +128,9 @@ void GradientCursor::_notification(int p_what) { } void GradientCursor::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_color"), &GradientCursor::get_color); - ClassDB::bind_method(D_METHOD("set_color", "value"), &GradientCursor::set_color); - ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color"); + ClassDB::bind_method(D_METHOD("get_cursor_color"), &GradientCursor::get_cursor_color); + ClassDB::bind_method(D_METHOD("set_cursor_color", "value"), &GradientCursor::set_cursor_color); + ADD_PROPERTY(PropertyInfo(Variant::COLOR, "cursor_color"), "set_cursor_color", "get_cursor_color"); ClassDB::bind_method(D_METHOD("get_sliding"), &GradientCursor::get_sliding); ClassDB::bind_method(D_METHOD("set_sliding", "value"), &GradientCursor::set_sliding); diff --git a/modules/material_maker/editor/widgets/gradient_editor/gradient_cursor.h b/modules/material_maker/editor/widgets/gradient_editor/gradient_cursor.h index 4703552e9..8629ce858 100644 --- a/modules/material_maker/editor/widgets/gradient_editor/gradient_cursor.h +++ b/modules/material_maker/editor/widgets/gradient_editor/gradient_cursor.h @@ -14,8 +14,8 @@ class GradientCursor : public Control { GDCLASS(GradientCursor, Control); public: - Color get_color(); - void set_color(const Color &val); + Color get_cursor_color(); + void set_cursor_color(const Color &val); bool get_sliding() const; void set_sliding(const bool val); diff --git a/modules/material_maker/editor/widgets/gradient_editor/gradient_editor.cpp b/modules/material_maker/editor/widgets/gradient_editor/gradient_editor.cpp index c1bddcb11..0683d954a 100644 --- a/modules/material_maker/editor/widgets/gradient_editor/gradient_editor.cpp +++ b/modules/material_maker/editor/widgets/gradient_editor/gradient_editor.cpp @@ -135,7 +135,7 @@ void MMGradientEditor::update_value() { GradientCursor *c = sc[i]; points.push_back(c->get_position().x / (get_size().x - GradientCursor::WIDTH)); - Color color = c->get_color(); + Color color = c->get_cursor_color(); points.push_back(color.r); points.push_back(color.g); points.push_back(color.b); @@ -148,13 +148,14 @@ void MMGradientEditor::update_value() { void MMGradientEditor::add_cursor(const float x, const Color &color) { GradientCursor *cursor = memnew(GradientCursor); + cursor->set_label(cursor_value_label); add_child(cursor); Vector2 rp = cursor->get_position(); rp.x = x; cursor->set_position(rp); - cursor->set_color(color); + cursor->set_cursor_color(color); } void MMGradientEditor::_gui_input(const Ref &ev) { @@ -189,8 +190,8 @@ void MMGradientEditor::select_color(GradientCursor *cursor, const Vector2 &posit add_child(color_picker_popup); ColorPicker *color_picker = color_picker_popup->color_picker; - color_picker->set_pick_color(cursor->get_color()); - color_picker->connect("color_changed", cursor, "set_color"); + color_picker->set_pick_color(cursor->get_cursor_color()); + color_picker->connect("color_changed", cursor, "set_cursor_color"); color_picker_popup->set_position(position); color_picker_popup->connect("popup_hide", this, "undo_redo_save_color_state"); @@ -332,16 +333,16 @@ MMGradientEditor::MMGradientEditor() { interpolation->connect("item_selected", this, "_on_Interpolation_item_selected"); add_child(interpolation); - Label *value_control = memnew(Label); - value_control->set_align(Label::ALIGN_CENTER); + cursor_value_label = memnew(Label); + cursor_value_label->set_align(Label::ALIGN_CENTER); - value_control->set("custom_colors/font_color", Color(1, 1, 1, 1)); - value_control->set("custom_colors/font_color_shadow", Color(0, 0, 0, 1)); - value_control->set("custom_constants/shadow_offset_x", 1); - value_control->set("custom_constants/shadow_offset_y", 1); - value_control->set("custom_constants/shadow_as_outline", 1); + cursor_value_label->set("custom_colors/font_color", Color(1, 1, 1, 1)); + cursor_value_label->set("custom_colors/font_color_shadow", Color(0, 0, 0, 1)); + cursor_value_label->set("custom_constants/shadow_offset_x", 1); + cursor_value_label->set("custom_constants/shadow_offset_y", 1); + cursor_value_label->set("custom_constants/shadow_as_outline", 1); - add_child(value_control); + add_child(cursor_value_label); } MMGradientEditor::~MMGradientEditor() { diff --git a/modules/material_maker/editor/widgets/gradient_editor/gradient_editor.h b/modules/material_maker/editor/widgets/gradient_editor/gradient_editor.h index a5415c898..60f9957bc 100644 --- a/modules/material_maker/editor/widgets/gradient_editor/gradient_editor.h +++ b/modules/material_maker/editor/widgets/gradient_editor/gradient_editor.h @@ -14,6 +14,7 @@ class MMGraphNode; class GradientBase; class GradientCursor; class TextureRect; +class Label; class OptionButton; class MMGradientEditor : public Control { @@ -76,6 +77,7 @@ protected: GradientCursor *active_cursor; TextureRect *gradient; OptionButton *interpolation; + Label *cursor_value_label; }; #endif