diff --git a/modules/material_maker/editor/widgets/color_picker_button/color_picker_button.cpp b/modules/material_maker/editor/widgets/color_picker_button/color_picker_button.cpp index dd3508bd1..7572f15f3 100644 --- a/modules/material_maker/editor/widgets/color_picker_button/color_picker_button.cpp +++ b/modules/material_maker/editor/widgets/color_picker_button/color_picker_button.cpp @@ -1,44 +1,35 @@ #include "color_picker_button.h" +#include "scene/gui/color_rect.h" - - //tool; - - void ColorPickerButton::get_drag_data(const Variant &_position) { - Variant = ColorRect.new(); - preview.color = color; - preview.rect_min_size = Vector2(32, 32); - set_drag_preview(preview); - return color; +Variant MMDNDColorPickerButton::get_drag_data_fw(const Point2 &p_point, Control *p_from) { + ColorRect *preview = memnew(ColorRect); + preview->set_frame_color(get_pick_color()); + preview->set_custom_minimum_size(Vector2(32, 32)); + set_drag_preview(preview); + return get_pick_color(); } - - bool ColorPickerButton::can_drop_data(const Variant &_position, const Variant & data) { - return typeof(data) == TYPE_COLOR; +bool MMDNDColorPickerButton::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { + return p_data.get_type() == Variant::COLOR; } - - void ColorPickerButton::drop_data(const Variant &_position, const Variant & data) { - color = data; - emit_signal("color_changed", color); +void MMDNDColorPickerButton::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) { + set_pick_color(p_data); + emit_signal("color_changed", get_pick_color()); } +MMDNDColorPickerButton::MMDNDColorPickerButton() { } - ColorPickerButton::ColorPickerButton() { - } - - ColorPickerButton::~ColorPickerButton() { - } - - - static void ColorPickerButton::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_drag_data", "_position"), &ColorPickerButton::get_drag_data); - ClassDB::bind_method(D_METHOD("can_drop_data", "_position", " data"), &ColorPickerButton::can_drop_data); - ClassDB::bind_method(D_METHOD("drop_data", "_position", " data"), &ColorPickerButton::drop_data); - - } - +MMDNDColorPickerButton::~MMDNDColorPickerButton() { +} +void MMDNDColorPickerButton::_bind_methods() { + ADD_SIGNAL(MethodInfo("color_changed", PropertyInfo(Variant::COLOR, "color"))); + ClassDB::bind_method(D_METHOD("get_drag_data_fw", "point", "from"), &MMDNDColorPickerButton::get_drag_data_fw); + ClassDB::bind_method(D_METHOD("can_drop_data_fw", "point", "data", "from"), &MMDNDColorPickerButton::can_drop_data_fw); + ClassDB::bind_method(D_METHOD("drop_data_fw", "point", "data", "from"), &MMDNDColorPickerButton::drop_data_fw); +} diff --git a/modules/material_maker/editor/widgets/color_picker_button/color_picker_button.h b/modules/material_maker/editor/widgets/color_picker_button/color_picker_button.h index 4077867ae..b109ea635 100644 --- a/modules/material_maker/editor/widgets/color_picker_button/color_picker_button.h +++ b/modules/material_maker/editor/widgets/color_picker_button/color_picker_button.h @@ -1,24 +1,21 @@ -#ifndef COLOR_PICKER_BUTTON_H -#define COLOR_PICKER_BUTTON_H +#ifndef MM_DND_COLOR_PICKER_BUTTON_H +#define MM_DND_COLOR_PICKER_BUTTON_H +#include "scene/gui/color_picker.h" -class ColorPickerButton : public ColorPickerButton { - GDCLASS(ColorPickerButton, ColorPickerButton); +class MMDNDColorPickerButton : public ColorPickerButton { + GDCLASS(MMDNDColorPickerButton, ColorPickerButton); - public: +public: + Variant get_drag_data_fw(const Point2 &p_point, Control *p_from); + bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; + void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from); - void get_drag_data(const Variant &_position); - bool can_drop_data(const Variant &_position, const Variant & data); - void drop_data(const Variant &_position, const Variant & data); + MMDNDColorPickerButton(); + ~MMDNDColorPickerButton(); - ColorPickerButton(); - ~ColorPickerButton(); - - protected: - static void _bind_methods(); - - //tool +protected: + static void _bind_methods(); }; - #endif