mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-03-28 14:56:21 +01:00
Cleaned up mat maker's color picker button.
This commit is contained in:
parent
4c2ec0ffd9
commit
4f27367a1f
@ -1,44 +1,35 @@
|
|||||||
|
|
||||||
#include "color_picker_button.h"
|
#include "color_picker_button.h"
|
||||||
|
|
||||||
|
#include "scene/gui/color_rect.h"
|
||||||
|
|
||||||
|
Variant MMDNDColorPickerButton::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
|
||||||
//tool;
|
ColorRect *preview = memnew(ColorRect);
|
||||||
|
preview->set_frame_color(get_pick_color());
|
||||||
void ColorPickerButton::get_drag_data(const Variant &_position) {
|
preview->set_custom_minimum_size(Vector2(32, 32));
|
||||||
Variant = ColorRect.new();
|
set_drag_preview(preview);
|
||||||
preview.color = color;
|
return get_pick_color();
|
||||||
preview.rect_min_size = Vector2(32, 32);
|
|
||||||
set_drag_preview(preview);
|
|
||||||
return color;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MMDNDColorPickerButton::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
|
||||||
bool ColorPickerButton::can_drop_data(const Variant &_position, const Variant & data) {
|
return p_data.get_type() == Variant::COLOR;
|
||||||
return typeof(data) == TYPE_COLOR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMDNDColorPickerButton::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
|
||||||
void ColorPickerButton::drop_data(const Variant &_position, const Variant & data) {
|
set_pick_color(p_data);
|
||||||
color = data;
|
emit_signal("color_changed", get_pick_color());
|
||||||
emit_signal("color_changed", color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MMDNDColorPickerButton::MMDNDColorPickerButton() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ColorPickerButton::ColorPickerButton() {
|
MMDNDColorPickerButton::~MMDNDColorPickerButton() {
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
@ -1,24 +1,21 @@
|
|||||||
#ifndef COLOR_PICKER_BUTTON_H
|
#ifndef MM_DND_COLOR_PICKER_BUTTON_H
|
||||||
#define COLOR_PICKER_BUTTON_H
|
#define MM_DND_COLOR_PICKER_BUTTON_H
|
||||||
|
|
||||||
|
#include "scene/gui/color_picker.h"
|
||||||
|
|
||||||
class ColorPickerButton : public ColorPickerButton {
|
class MMDNDColorPickerButton : public ColorPickerButton {
|
||||||
GDCLASS(ColorPickerButton, 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);
|
MMDNDColorPickerButton();
|
||||||
bool can_drop_data(const Variant &_position, const Variant & data);
|
~MMDNDColorPickerButton();
|
||||||
void drop_data(const Variant &_position, const Variant & data);
|
|
||||||
|
|
||||||
ColorPickerButton();
|
protected:
|
||||||
~ColorPickerButton();
|
static void _bind_methods();
|
||||||
|
|
||||||
protected:
|
|
||||||
static void _bind_methods();
|
|
||||||
|
|
||||||
//tool
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user