Fix loading cursors for the gradient editor.

This commit is contained in:
Relintai 2022-06-15 16:45:58 +02:00
parent 275d0604f8
commit 1ec5e8a756
3 changed files with 11 additions and 2 deletions

View File

@ -8,6 +8,11 @@ Color GradientCursor::get_cursor_color() {
}
void GradientCursor::set_cursor_color(const Color &val) {
color = val;
update();
}
void GradientCursor::set_cursor_color_notify(const Color &val) {
color = val;
MMGradientEditor *ged = Object::cast_to<MMGradientEditor>(get_parent());
ERR_FAIL_COND(!ged);
@ -104,7 +109,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_cursor_color(p_data);
set_cursor_color_notify(p_data);
}
GradientCursor::GradientCursor() {
@ -132,6 +137,8 @@ void GradientCursor::_bind_methods() {
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("set_cursor_color_notify", "value"), &GradientCursor::set_cursor_color_notify);
ClassDB::bind_method(D_METHOD("get_sliding"), &GradientCursor::get_sliding);
ClassDB::bind_method(D_METHOD("set_sliding", "value"), &GradientCursor::set_sliding);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sliding"), "set_sliding", "get_sliding");

View File

@ -17,6 +17,8 @@ public:
Color get_cursor_color();
void set_cursor_color(const Color &val);
void set_cursor_color_notify(const Color &val);
bool get_sliding() const;
void set_sliding(const bool val);

View File

@ -191,7 +191,7 @@ void MMGradientEditor::select_color(GradientCursor *cursor, const Vector2 &posit
ColorPicker *color_picker = color_picker_popup->color_picker;
color_picker->set_pick_color(cursor->get_cursor_color());
color_picker->connect("color_changed", cursor, "set_cursor_color");
color_picker->connect("color_changed", cursor, "set_cursor_color_notify");
color_picker_popup->set_position(position);
color_picker_popup->connect("popup_hide", this, "undo_redo_save_color_state");