Reimplement the missing methods in MMGraphNode. Had to rename the cure and gradient editor classes as they were confliction with engine stuff.

This commit is contained in:
Relintai 2022-06-14 17:55:23 +02:00
parent f180658682
commit 43db64cc7f
11 changed files with 149 additions and 154 deletions

View File

@ -35,7 +35,7 @@ sources = [
"editor/widgets/file_dialog/left_panel.cpp",
"editor/widgets/file_dialog/mat_maker_file_dialog.cpp",
"editor/widgets/float_edit/float_edit.cpp",
#"editor/widgets/float_edit/float_edit.cpp",
"editor/widgets/gradient_editor/gradient_cursor.cpp",
"editor/widgets/gradient_editor/gradient_editor.cpp",

View File

@ -1,6 +1,9 @@
#include "mm_graph_node.h"
#include "../nodes/bases/curve_base.h"
#include "../nodes/bases/gradient_base.h"
#include "../nodes/bases/polygon_base.h"
#include "../nodes/mm_material.h"
#include "../nodes/mm_node.h"
#include "../nodes/mm_node_universal_property.h"
@ -15,6 +18,11 @@
#include "scene/gui/spin_box.h"
#include "scene/gui/texture_rect.h"
#include "widgets/curve_edit/curve_editor.h"
#include "widgets/gradient_editor/gradient_editor.h"
#include "widgets/image_picker_button/image_picker_button.h"
#include "widgets/polygon_edit/polygon_editor.h"
Ref<PackedScene> MMGraphNode::get_gradient_editor_scene() {
return gradient_editor_scene;
}
@ -133,72 +141,59 @@ int MMGraphNode::add_slot_texture_universal(const Ref<MMNodeUniversalProperty> &
}
int MMGraphNode::add_slot_image_path_universal(const Ref<MMNodeUniversalProperty> &property, const String &getter, const String &setter) {
/*
TextureButton *t = load("res://addons/mat_maker_gd/widgets/image_picker_button/image_picker_button.tscn").instance();
int slot_idx = add_slot(property.input_slot_type, property.output_slot_type, "", "", t);
properties[slot_idx].append(property);
properties[slot_idx].append(getter);
properties[slot_idx].append(setter);
property.connect("changed", self, "on_universal_texture_changed_image_picker", [slot_idx]);
t.connect("on_file_selected", self, "on_universal_image_path_changed", [slot_idx]);
t.call_deferred("do_set_image_path", _node.call(getter));
return slot_idx;
*/
ImagePickerButton *t = memnew(ImagePickerButton);
int slot_idx = add_slot(property->get_input_slot_type(), property->get_output_slot_type(), "", "", t);
return 0;
properties.write[slot_idx].universal_property = property;
properties.write[slot_idx].alt_getter = getter;
properties.write[slot_idx].alt_setter = setter;
Vector<Variant> bindings;
bindings.push_back(slot_idx);
Ref<MMNodeUniversalProperty> prop = property;
prop->connect("changed", this, "on_universal_texture_changed_image_picker", bindings);
t->connect("on_file_selected", this, "on_universal_image_path_changed", bindings);
t->call_deferred("do_set_image_path", _node->call(getter));
return slot_idx;
}
int MMGraphNode::add_slot_gradient() {
/*
Control *ge = gradient_editor_scene.instance();
ge.graph_node = self;
ge.set_undo_redo(_undo_redo);
int slot_idx = add_slot(MMNodeUniversalProperty::SLOT_TYPE_NONE, MMNodeUniversalProperty::SLOT_TYPE_NONE, "", "", ge);
ge.set_value(_node);
//ge.texture = _node.call(getter, _material, slot_idx);
//properties[slot_idx].append(ge.texture);
return slot_idx;
*/
return 0;
MMGradientEditor *ge = memnew(MMGradientEditor);
ge->set_graph_node(this);
ge->set_undo_redo(_undo_redo);
int slot_idx = add_slot(MMNodeUniversalProperty::SLOT_TYPE_NONE, MMNodeUniversalProperty::SLOT_TYPE_NONE, "", "", ge);
ge->set_value(_node);
//ge.texture = _node.call(getter, _material, slot_idx);
//properties[slot_idx].append(ge.texture);
return slot_idx;
}
int MMGraphNode::add_slot_polygon() {
/*
Control *ge = polygon_edit_scene.instance();
int slot_idx = add_slot(MMNodeUniversalProperty::SLOT_TYPE_NONE, MMNodeUniversalProperty::SLOT_TYPE_NONE, "", "", ge);
ge.set_value(_node);
//ge.texture = _node.call(getter, _material, slot_idx);
//properties[slot_idx].append(ge.texture);
return slot_idx;
*/
return 0;
PolygonEditor *pe = memnew(PolygonEditor);
int slot_idx = add_slot(MMNodeUniversalProperty::SLOT_TYPE_NONE, MMNodeUniversalProperty::SLOT_TYPE_NONE, "", "", pe);
pe->set_polygon(_node);
//ge.texture = _node.call(getter, _material, slot_idx);
//properties[slot_idx].append(ge.texture);
return slot_idx;
}
int MMGraphNode::add_slot_curve() {
/*
Control *ge = curve_edit_scene.instance();
int slot_idx = add_slot(MMNodeUniversalProperty::SLOT_TYPE_NONE, MMNodeUniversalProperty::SLOT_TYPE_NONE, "", "", ge);
ge.set_value(_node);
//ge.texture = _node.call(getter, _material, slot_idx);
//properties[slot_idx].append(ge.texture);
return slot_idx;
*/
return 0;
MMCurveEditor *ce = memnew(MMCurveEditor);
int slot_idx = add_slot(MMNodeUniversalProperty::SLOT_TYPE_NONE, MMNodeUniversalProperty::SLOT_TYPE_NONE, "", "", ce);
ce->set_curve(_node);
//ge.texture = _node.call(getter, _material, slot_idx);
//properties[slot_idx].append(ge.texture);
return slot_idx;
}
int MMGraphNode::add_slot_color(const String &getter, const String &setter) {
/*
ColorPickerButton *cp = ColorPickerButton.new();
int slot_idx = add_slot(MMNodeUniversalProperty::SLOT_TYPE_NONE, MMNodeUniversalProperty::SLOT_TYPE_NONE, getter, setter, cp);
cp.color = _node.call(getter);
cp.connect("color_changed", _node, setter);
return slot_idx;
*/
return 0;
ColorPickerButton *cp = memnew(ColorPickerButton);
int slot_idx = add_slot(MMNodeUniversalProperty::SLOT_TYPE_NONE, MMNodeUniversalProperty::SLOT_TYPE_NONE, getter, setter, cp);
cp->set_pick_color(_node->call(getter));
cp->connect("color_changed", _node.ptr(), setter);
return slot_idx;
}
int MMGraphNode::add_slot_color_universal(const Ref<MMNodeUniversalProperty> &property) {

View File

@ -47,7 +47,7 @@ void CurveDialog::_on_Cancel_pressed() {
queue_delete();
}
void CurveDialog::_on_CurveEditor_value_changed(const Ref<CurveBase> &value) {
void CurveDialog::_on_MMCurveEditor_value_changed(const Ref<CurveBase> &value) {
emit_signal("curve_changed", value);
}
@ -70,7 +70,7 @@ CurveDialog::CurveDialog() {
mvbc->add_child(mc);
_curve_editor = memnew(CurveEditor);
_curve_editor = memnew(MMCurveEditor);
_curve_editor->set_filename("res://addons/mat_maker_gd/widgets/curve_edit/curve_editor.tscn");
_curve_editor->set_v_size_flags(SIZE_EXPAND_FILL);
mc->add_child(_curve_editor);
@ -100,7 +100,7 @@ CurveDialog::~CurveDialog() {
void CurveDialog::_notification(int p_what) {
if (p_what == NOTIFICATION_POSTINITIALIZE) {
connect("popup_hide", this, "_on_CurveDialog_popup_hide");
_curve_editor->connect("value_changed", this, "_on_CurveEditor_value_changed");
_curve_editor->connect("value_changed", this, "_on_MMCurveEditor_value_changed");
_ok_button->connect("pressed", this, "_on_OK_pressed");
_cancel_button->connect("pressed", this, "_on_Cancel_pressed");
}
@ -122,5 +122,5 @@ void CurveDialog::_bind_methods() {
ClassDB::bind_method(D_METHOD("_on_CurveDialog_popup_hide"), &CurveDialog::_on_CurveDialog_popup_hide);
ClassDB::bind_method(D_METHOD("_on_OK_pressed"), &CurveDialog::_on_OK_pressed);
ClassDB::bind_method(D_METHOD("_on_Cancel_pressed"), &CurveDialog::_on_Cancel_pressed);
ClassDB::bind_method(D_METHOD("_on_CurveEditor_value_changed", "value"), &CurveDialog::_on_CurveEditor_value_changed);
ClassDB::bind_method(D_METHOD("_on_MMCurveEditor_value_changed", "value"), &CurveDialog::_on_MMCurveEditor_value_changed);
}

View File

@ -8,7 +8,7 @@
#include "../../../nodes/bases/curve_base.h"
class Button;
class CurveEditor;
class MMCurveEditor;
class CurveDialog : public WindowDialog {
GDCLASS(CurveDialog, WindowDialog);
@ -25,7 +25,7 @@ public:
void _on_CurveDialog_popup_hide();
void _on_OK_pressed();
void _on_Cancel_pressed();
void _on_CurveEditor_value_changed(const Ref<CurveBase> &value);
void _on_MMCurveEditor_value_changed(const Ref<CurveBase> &value);
CurveDialog();
~CurveDialog();
@ -38,7 +38,7 @@ protected:
Vector<CurveBase::Point> previous_points;
Ref<CurveBase> curve;
CurveEditor *_curve_editor;
MMCurveEditor *_curve_editor;
Button *_ok_button;
Button *_cancel_button;
};

View File

@ -6,13 +6,13 @@
#include "core/object.h"
#include "slope_point.h"
void CurveEditor::set_curve(const Variant &c) {
void MMCurveEditor::set_curve(const Variant &c) {
curve = c;
update();
update_controls();
}
void CurveEditor::update_controls() {
void MMCurveEditor::update_controls() {
if (!curve.is_valid()) {
return;
}
@ -52,7 +52,7 @@ void CurveEditor::update_controls() {
emit_signal("value_changed", curve);
}
void CurveEditor::_on_ControlPoint_moved(const Variant &index) {
void MMCurveEditor::_on_ControlPoint_moved(const Variant &index) {
Vector<CurveBase::Point> points = curve->get_points();
ControlPoint *control_point = Object::cast_to<ControlPoint>(get_child(index));
points.write[index].p = reverse_transform_point(control_point->get_position() + control_point->OFFSET);
@ -78,14 +78,14 @@ void CurveEditor::_on_ControlPoint_moved(const Variant &index) {
emit_signal("value_changed", curve);
}
void CurveEditor::_on_ControlPoint_removed(const Variant &index) {
void MMCurveEditor::_on_ControlPoint_removed(const Variant &index) {
if (curve->remove_point(index)) {
update();
update_controls();
}
}
void CurveEditor::_on_CurveEditor_gui_input(const Variant &event) {
void MMCurveEditor::_on_MMCurveEditor_gui_input(const Variant &event) {
Ref<InputEventMouseButton> iemb = event;
if (iemb.is_valid()) {
@ -97,36 +97,36 @@ void CurveEditor::_on_CurveEditor_gui_input(const Variant &event) {
}
}
void CurveEditor::_on_resize() {
void MMCurveEditor::_on_resize() {
CurveView::_on_resize();
update_controls();
}
CurveEditor::CurveEditor() {
MMCurveEditor::MMCurveEditor() {
set_mouse_filter(MOUSE_FILTER_STOP);
}
CurveEditor::~CurveEditor() {
MMCurveEditor::~MMCurveEditor() {
}
void CurveEditor::_notification(int p_what) {
void MMCurveEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_POSTINITIALIZE: {
connect("gui_input", this, "_on_CurveEditor_gui_input");
connect("gui_input", this, "_on_MMCurveEditor_gui_input");
update_controls();
} break;
default: {
} break;
}
}
void CurveEditor::_bind_methods() {
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"), &CurveEditor::set_curve);
ClassDB::bind_method(D_METHOD("update_controls"), &CurveEditor::update_controls);
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"), &CurveEditor::_on_ControlPoint_moved);
ClassDB::bind_method(D_METHOD("_on_ControlPoint_removed", "index"), &CurveEditor::_on_ControlPoint_removed);
ClassDB::bind_method(D_METHOD("_on_CurveEditor_gui_input", "event"), &CurveEditor::_on_CurveEditor_gui_input);
ClassDB::bind_method(D_METHOD("_on_resize"), &CurveEditor::_on_resize);
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);
}

View File

@ -1,10 +1,10 @@
#ifndef CURVE_EDITOR_H
#define CURVE_EDITOR_H
#ifndef MM_CURVE_EDITOR_H
#define MM_CURVE_EDITOR_H
#include "curve_view.h"
class CurveEditor : public CurveView {
GDCLASS(CurveEditor, CurveView);
class MMCurveEditor : public CurveView {
GDCLASS(MMCurveEditor, CurveView);
public:
void set_curve(const Variant &c);
@ -12,11 +12,11 @@ public:
void _on_ControlPoint_moved(const Variant &index);
void _on_ControlPoint_removed(const Variant &index);
void _on_CurveEditor_gui_input(const Variant &event);
void _on_MMCurveEditor_gui_input(const Variant &event);
void _on_resize();
CurveEditor();
~CurveEditor();
MMCurveEditor();
~MMCurveEditor();
protected:
void _notification(int p_what);

View File

@ -9,7 +9,7 @@ Color GradientCursor::get_color() {
void GradientCursor::set_color(const Color &val) {
color = val;
GradientEditor *ged = Object::cast_to<GradientEditor>(get_parent());
MMGradientEditor *ged = Object::cast_to<MMGradientEditor>(get_parent());
ERR_FAIL_COND(!ged);
ged->update_value();
update();
@ -46,7 +46,7 @@ void GradientCursor::_gui_input(const Ref<InputEvent> &ev) {
Ref<InputEventMouseButton> iemb = ev;
Ref<InputEventMouseMotion> iemm = ev;
GradientEditor *ged = Object::cast_to<GradientEditor>(get_parent());
MMGradientEditor *ged = Object::cast_to<MMGradientEditor>(get_parent());
ERR_FAIL_COND(!ged);
if (iemb.is_valid()) {

View File

@ -17,65 +17,65 @@
#include "scene/gui/texture_rect.h"
#include "scene/resources/material.h"
MMGraphNode *GradientEditor::get_graph_node() {
MMGraphNode *MMGradientEditor::get_graph_node() {
return graph_node;
}
void GradientEditor::set_graph_node(MMGraphNode *val) {
void MMGradientEditor::set_graph_node(MMGraphNode *val) {
graph_node = val;
}
Ref<GradientBase> GradientEditor::get_value() {
Ref<GradientBase> MMGradientEditor::get_value() {
return value;
}
void GradientEditor::set_value(const Ref<GradientBase> &val) {
void MMGradientEditor::set_value(const Ref<GradientBase> &val) {
value = val;
update_preview();
call_deferred("update_cursors");
}
bool GradientEditor::get_embedded() const {
bool MMGradientEditor::get_embedded() const {
return embedded;
}
void GradientEditor::set_embedded(const bool val) {
void MMGradientEditor::set_embedded(const bool val) {
embedded = val;
}
UndoRedo *GradientEditor::get_undo_redo() {
UndoRedo *MMGradientEditor::get_undo_redo() {
return _undo_redo;
}
void GradientEditor::set_undo_redo(UndoRedo *val) {
void MMGradientEditor::set_undo_redo(UndoRedo *val) {
_undo_redo = val;
}
PoolRealArray GradientEditor::get_saved_points() {
PoolRealArray MMGradientEditor::get_saved_points() {
return _saved_points;
}
void GradientEditor::set_saved_points(const PoolRealArray &val) {
void MMGradientEditor::set_saved_points(const PoolRealArray &val) {
_saved_points = val;
}
GradientCursor *GradientEditor::get_active_cursor() {
GradientCursor *MMGradientEditor::get_active_cursor() {
return active_cursor;
}
void GradientEditor::set_active_cursor(GradientCursor *val) {
void MMGradientEditor::set_active_cursor(GradientCursor *val) {
active_cursor = val;
}
void GradientEditor::_init() {
void MMGradientEditor::_init() {
connect("resized", this, "on_resized");
}
void GradientEditor::ignore_changes(const bool val) {
void MMGradientEditor::ignore_changes(const bool val) {
graph_node->ignore_changes(val);
}
void GradientEditor::save_color_state() {
void MMGradientEditor::save_color_state() {
PoolRealArray p = value->get_points();
_saved_points.resize(0);
@ -86,7 +86,7 @@ void GradientEditor::save_color_state() {
ignore_changes(true);
}
void GradientEditor::undo_redo_save_color_state() {
void MMGradientEditor::undo_redo_save_color_state() {
PoolRealArray op;
PoolRealArray np;
@ -107,7 +107,7 @@ void GradientEditor::undo_redo_save_color_state() {
ignore_changes(false);
}
void GradientEditor::update_cursors() {
void MMGradientEditor::update_cursors() {
for (int i = 0; i < get_child_count(); ++i) {
GradientCursor *c = Object::cast_to<GradientCursor>(get_child(i));
@ -126,7 +126,7 @@ void GradientEditor::update_cursors() {
interpolation->select(value->get_interpolation_type());
}
void GradientEditor::update_value() {
void MMGradientEditor::update_value() {
value->clear();
Vector<GradientCursor *> sc = get_sorted_cursors();
PoolRealArray points;
@ -146,7 +146,7 @@ void GradientEditor::update_value() {
update_preview();
}
void GradientEditor::add_cursor(const float x, const Color &color) {
void MMGradientEditor::add_cursor(const float x, const Color &color) {
GradientCursor *cursor = memnew(GradientCursor);
add_child(cursor);
@ -157,7 +157,7 @@ void GradientEditor::add_cursor(const float x, const Color &color) {
cursor->set_color(color);
}
void GradientEditor::_gui_input(const Ref<InputEvent> &ev) {
void MMGradientEditor::_gui_input(const Ref<InputEvent> &ev) {
Ref<InputEventMouseButton> iemb = ev;
if (iemb.is_valid() && iemb->get_button_index() == 1 && iemb->is_doubleclick()) {
@ -182,7 +182,7 @@ void GradientEditor::_gui_input(const Ref<InputEvent> &ev) {
}
}
void GradientEditor::select_color(GradientCursor *cursor, const Vector2 &position) {
void MMGradientEditor::select_color(GradientCursor *cursor, const Vector2 &position) {
active_cursor = cursor;
ColorPickerPopup *color_picker_popup = memnew(ColorPickerPopup);
@ -200,7 +200,7 @@ void GradientEditor::select_color(GradientCursor *cursor, const Vector2 &positio
// Calculating a color from the gradient and generating the shader;
Vector<GradientCursor *> GradientEditor::get_sorted_cursors() {
Vector<GradientCursor *> MMGradientEditor::get_sorted_cursors() {
Vector<GradientCursor *> array;
for (int i = 0; i < get_child_count(); ++i) {
@ -216,7 +216,7 @@ Vector<GradientCursor *> GradientEditor::get_sorted_cursors() {
return array;
}
void GradientEditor::generate_preview_image() {
void MMGradientEditor::generate_preview_image() {
Ref<ImageTexture> tex = gradient->get_texture();
if (!tex.is_valid()) {
@ -251,15 +251,15 @@ void GradientEditor::generate_preview_image() {
tex->create_from_image(img, 0);
}
Color GradientEditor::get_gradient_color(const float x) {
Color MMGradientEditor::get_gradient_color(const float x) {
return value->get_gradient_color(x / (get_size().x - GradientCursor::WIDTH));
}
void GradientEditor::update_preview() {
void MMGradientEditor::update_preview() {
call_deferred("generate_preview_image");
}
void GradientEditor::_on_Interpolation_item_selected(const int ID) {
void MMGradientEditor::_on_Interpolation_item_selected(const int ID) {
ignore_changes(true);
_undo_redo->create_action("MMGD: gradient interpolation_type changed");
_undo_redo->add_do_method(value.ptr(), "set_interpolation_type", ID);
@ -269,14 +269,14 @@ void GradientEditor::_on_Interpolation_item_selected(const int ID) {
update_preview();
}
void GradientEditor::on_resized() {
void MMGradientEditor::on_resized() {
if (value.is_valid()) {
update_preview();
call_deferred("update_cursors");
}
}
GradientEditor::GradientEditor() {
MMGradientEditor::MMGradientEditor() {
graph_node = nullptr;
embedded = false;
_undo_redo = nullptr;
@ -344,61 +344,61 @@ GradientEditor::GradientEditor() {
add_child(value_control);
}
GradientEditor::~GradientEditor() {
MMGradientEditor::~MMGradientEditor() {
}
void GradientEditor::_bind_methods() {
void MMGradientEditor::_bind_methods() {
ADD_SIGNAL(MethodInfo("updated", PropertyInfo(Variant::OBJECT, "value", PROPERTY_HINT_RESOURCE_TYPE, "GradientBase")));
//ClassDB::bind_method(D_METHOD("get_graph_node"), &GradientEditor::get_graph_node);
//ClassDB::bind_method(D_METHOD("set_graph_node", "value"), &GradientEditor::set_graph_node);
//ClassDB::bind_method(D_METHOD("get_graph_node"), &MMGradientEditor::get_graph_node);
//ClassDB::bind_method(D_METHOD("set_graph_node", "value"), &MMGradientEditor::set_graph_node);
//ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "graph_node", PROPERTY_HINT_RESOURCE_TYPE, "MMGraphNode "), "set_graph_node", "get_graph_node");
ClassDB::bind_method(D_METHOD("get_value"), &GradientEditor::get_value);
ClassDB::bind_method(D_METHOD("set_value", "value"), &GradientEditor::set_value);
ClassDB::bind_method(D_METHOD("get_value"), &MMGradientEditor::get_value);
ClassDB::bind_method(D_METHOD("set_value", "value"), &MMGradientEditor::set_value);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "value", PROPERTY_HINT_RESOURCE_TYPE, "GradientBase"), "set_value", "get_value");
ClassDB::bind_method(D_METHOD("get_embedded"), &GradientEditor::get_embedded);
ClassDB::bind_method(D_METHOD("set_embedded", "value"), &GradientEditor::set_embedded);
ClassDB::bind_method(D_METHOD("get_embedded"), &MMGradientEditor::get_embedded);
ClassDB::bind_method(D_METHOD("set_embedded", "value"), &MMGradientEditor::set_embedded);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "embedded"), "set_embedded", "get_embedded");
ClassDB::bind_method(D_METHOD("get_undo_redo"), &GradientEditor::get_undo_redo);
//ClassDB::bind_method(D_METHOD("set_undo_redo", "value"), &GradientEditor::set_undo_redo);
ClassDB::bind_method(D_METHOD("get_undo_redo"), &MMGradientEditor::get_undo_redo);
//ClassDB::bind_method(D_METHOD("set_undo_redo", "value"), &MMGradientEditor::set_undo_redo);
//ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "undo_redo", PROPERTY_HINT_RESOURCE_TYPE, "UndoRedo"), "set_undo_redo", "get_undo_redo");
ClassDB::bind_method(D_METHOD("get_saved_points"), &GradientEditor::get_saved_points);
ClassDB::bind_method(D_METHOD("set_saved_points", "value"), &GradientEditor::set_saved_points);
ClassDB::bind_method(D_METHOD("get_saved_points"), &MMGradientEditor::get_saved_points);
ClassDB::bind_method(D_METHOD("set_saved_points", "value"), &MMGradientEditor::set_saved_points);
ADD_PROPERTY(PropertyInfo(Variant::POOL_REAL_ARRAY, "saved_points"), "set_saved_points", "get_saved_points");
//ClassDB::bind_method(D_METHOD("get_active_cursor"), &GradientEditor::get_active_cursor);
//ClassDB::bind_method(D_METHOD("set_active_cursor", "value"), &GradientEditor::set_active_cursor);
//ClassDB::bind_method(D_METHOD("get_active_cursor"), &MMGradientEditor::get_active_cursor);
//ClassDB::bind_method(D_METHOD("set_active_cursor", "value"), &MMGradientEditor::set_active_cursor);
//ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "active_cursor", PROPERTY_HINT_RESOURCE_TYPE, "GradientCursor "), "set_active_cursor", "get_active_cursor");
ClassDB::bind_method(D_METHOD("ignore_changes", "val"), &GradientEditor::ignore_changes);
ClassDB::bind_method(D_METHOD("ignore_changes", "val"), &MMGradientEditor::ignore_changes);
ClassDB::bind_method(D_METHOD("save_color_state"), &GradientEditor::save_color_state);
ClassDB::bind_method(D_METHOD("save_color_state"), &MMGradientEditor::save_color_state);
ClassDB::bind_method(D_METHOD("undo_redo_save_color_state"), &GradientEditor::undo_redo_save_color_state);
ClassDB::bind_method(D_METHOD("undo_redo_save_color_state"), &MMGradientEditor::undo_redo_save_color_state);
//ClassDB::bind_method(D_METHOD("set_undo_redo", "ur"), &GradientEditor::set_undo_redo);
//ClassDB::bind_method(D_METHOD("set_undo_redo", "ur"), &MMGradientEditor::set_undo_redo);
ClassDB::bind_method(D_METHOD("set_value", "v"), &GradientEditor::set_value);
ClassDB::bind_method(D_METHOD("update_cursors"), &GradientEditor::update_cursors);
ClassDB::bind_method(D_METHOD("update_value"), &GradientEditor::update_value);
ClassDB::bind_method(D_METHOD("add_cursor", "x", " color"), &GradientEditor::add_cursor);
ClassDB::bind_method(D_METHOD("set_value", "v"), &MMGradientEditor::set_value);
ClassDB::bind_method(D_METHOD("update_cursors"), &MMGradientEditor::update_cursors);
ClassDB::bind_method(D_METHOD("update_value"), &MMGradientEditor::update_value);
ClassDB::bind_method(D_METHOD("add_cursor", "x", " color"), &MMGradientEditor::add_cursor);
ClassDB::bind_method(D_METHOD("_gui_input", "ev"), &GradientEditor::_gui_input);
ClassDB::bind_method(D_METHOD("_gui_input", "ev"), &MMGradientEditor::_gui_input);
//ClassDB::bind_method(D_METHOD("select_color", "cursor", " position"), &GradientEditor::select_color);
//ClassDB::bind_method(D_METHOD("select_color", "cursor", " position"), &MMGradientEditor::select_color);
//ClassDB::bind_method(D_METHOD("get_sorted_cursors"), &GradientEditor::get_sorted_cursors);
//ClassDB::bind_method(D_METHOD("get_sorted_cursors"), &MMGradientEditor::get_sorted_cursors);
ClassDB::bind_method(D_METHOD("generate_preview_image"), &GradientEditor::generate_preview_image);
ClassDB::bind_method(D_METHOD("generate_preview_image"), &MMGradientEditor::generate_preview_image);
ClassDB::bind_method(D_METHOD("get_gradient_color", "x"), &GradientEditor::get_gradient_color);
ClassDB::bind_method(D_METHOD("get_gradient_color", "x"), &MMGradientEditor::get_gradient_color);
ClassDB::bind_method(D_METHOD("update_preview"), &GradientEditor::update_preview);
ClassDB::bind_method(D_METHOD("update_preview"), &MMGradientEditor::update_preview);
ClassDB::bind_method(D_METHOD("_on_Interpolation_item_selected", "ID"), &GradientEditor::_on_Interpolation_item_selected);
ClassDB::bind_method(D_METHOD("on_resized"), &GradientEditor::on_resized);
ClassDB::bind_method(D_METHOD("_on_Interpolation_item_selected", "ID"), &MMGradientEditor::_on_Interpolation_item_selected);
ClassDB::bind_method(D_METHOD("on_resized"), &MMGradientEditor::on_resized);
}

View File

@ -1,5 +1,5 @@
#ifndef GRADIENT_EDITOR_H
#define GRADIENT_EDITOR_H
#ifndef MM_GRADIENT_EDITOR_H
#define MM_GRADIENT_EDITOR_H
#include "core/color.h"
#include "core/os/input_event.h"
@ -16,8 +16,8 @@ class GradientCursor;
class TextureRect;
class OptionButton;
class GradientEditor : public Control {
GDCLASS(GradientEditor, Control);
class MMGradientEditor : public Control {
GDCLASS(MMGradientEditor, Control);
public:
MMGraphNode *get_graph_node();
@ -62,8 +62,8 @@ public:
void _on_Interpolation_item_selected(const int ID);
void on_resized();
GradientEditor();
~GradientEditor();
MMGradientEditor();
~MMGradientEditor();
protected:
static void _bind_methods();

View File

@ -33,7 +33,7 @@ GradientPopup::GradientPopup() {
panel_gradientpopup_prop_custom_styles.instance();
panel_gradientpopup->set("custom_styles/panel", panel_gradientpopup_prop_custom_styles);
_gradient_editor = memnew(GradientEditor);
_gradient_editor = memnew(MMGradientEditor);
panel_gradientpopup->add_child(_gradient_editor);
}

View File

@ -8,7 +8,7 @@
class GradientBase;
class UndoRedo;
class MMGraphNode;
class GradientEditor;
class MMGradientEditor;
class GradientPopup : public Popup {
GDCLASS(GradientPopup, Popup);
@ -24,7 +24,7 @@ public:
protected:
static void _bind_methods();
GradientEditor *_gradient_editor;
MMGradientEditor *_gradient_editor;
};
#endif