From 943538fec95bddb4c8422e8b0532fdf316697c08 Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 10 Jun 2022 18:33:01 +0200 Subject: [PATCH] GradientCursor initial cleanup. --- .../gradient_editor/gradient_cursor.cpp | 146 +++ .../widgets/gradient_editor/gradient_cursor.h | 50 + .../gradient_editor/gradient_editor.cpp | 965 +++++++++--------- .../gradient_editor/gradient_editor.ctscn | 251 ----- .../widgets/gradient_editor/gradient_editor.h | 149 +-- .../gradient_editor/gradient_popup.cpp | 349 ++++++- .../gradient_editor/gradient_popup.ctscn | 325 ------ 7 files changed, 1057 insertions(+), 1178 deletions(-) create mode 100644 modules/material_maker/editor/widgets/gradient_editor/gradient_cursor.cpp create mode 100644 modules/material_maker/editor/widgets/gradient_editor/gradient_cursor.h delete mode 100644 modules/material_maker/editor/widgets/gradient_editor/gradient_editor.ctscn delete mode 100644 modules/material_maker/editor/widgets/gradient_editor/gradient_popup.ctscn diff --git a/modules/material_maker/editor/widgets/gradient_editor/gradient_cursor.cpp b/modules/material_maker/editor/widgets/gradient_editor/gradient_cursor.cpp new file mode 100644 index 000000000..2e5f20e8e --- /dev/null +++ b/modules/material_maker/editor/widgets/gradient_editor/gradient_cursor.cpp @@ -0,0 +1,146 @@ +#include "gradient_cursor.h" + +#include "gradient_editor.h" +#include "scene/gui/label.h" + +Color GradientCursor::get_color() { + return color; +} + +void GradientCursor::set_color(const Color &val) { + color = val; + GradientEditor *ged = Object::cast_to(get_parent()); + ERR_FAIL_COND(!ged); + ged->update_value(); + update(); +} + +bool GradientCursor::get_sliding() const { + return sliding; +} + +void GradientCursor::set_sliding(const bool val) { + sliding = val; +} + +void GradientCursor::set_label(Label *p_label) { + label = p_label; +} + +void GradientCursor::_draw() { + Vector polygon; + polygon.push_back(Vector2(0, 5)); + polygon.push_back(Vector2(WIDTH / 2, 0)); + polygon.push_back(Vector2(WIDTH, 5)); + polygon.push_back(Vector2(WIDTH, 15)); + polygon.push_back(Vector2(0, 15)); + polygon.push_back(Vector2(0, 5)); + + Color c = color; + c.a = 1.0; + draw_colored_polygon(polygon, c); + draw_polyline(polygon, color.get_v() > 0.5 ? Color(0.0, 0.0, 0.0) : Color(1.0, 1.0, 1.0)); +} + +void GradientCursor::_gui_input(const Ref &ev) { + Ref iemb = ev; + Ref iemm = ev; + + GradientEditor *ged = Object::cast_to(get_parent()); + ERR_FAIL_COND(!ged); + + if (iemb.is_valid()) { + if (iemb->get_button_index() == BUTTON_LEFT) { + if (iemb->is_doubleclick()) { + ged->save_color_state(); + ged->select_color(this, iemb->get_global_position()); + } else if (iemb->is_pressed()) { + ged->save_color_state(); + sliding = true; + label->set_visible(true); + label->set_text(String::num(get_cursor_position(), 3)); + } else { + if (sliding) { + ged->undo_redo_save_color_state(); + } + + sliding = false; + label->set_visible(false); + } + } else if (iemb->get_button_index() == BUTTON_RIGHT && ged->get_sorted_cursors().size() > 2) { + ged->save_color_state(); + ged->remove_child(this); + ged->update_value(); + ged->undo_redo_save_color_state(); + queue_delete(); + } + } else if (iemm.is_valid() && (iemm->get_button_mask() & BUTTON_MASK_LEFT) != 0 && sliding) { + Vector2 position = get_position(); + + position.x += get_local_mouse_position().x; + + if (iemm->get_control()) { + position.x = Math::round(get_cursor_position() * 20.0) * 0.05 * (ged->get_size().x - WIDTH); + } + + position.x = MIN(MAX(0, position.x), ged->get_size().x - get_size().x); + set_position(position); + + ged->update_value(); + label->set_text(String::num(get_cursor_position(), 3)); + } +} + +float GradientCursor::get_cursor_position() { + return get_position().x / (get_parent_control()->get_size().x - WIDTH); +} + +bool GradientCursor::sort(const Variant &a, const Variant &b) { + return a.get_position() < b.get_position(); +} + +bool GradientCursor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { + return p_data.get_type() == Variant::COLOR; +} + +void GradientCursor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) { + set_color(p_data); +} + +GradientCursor::GradientCursor() { + sliding = false; + label = nullptr; +} + +GradientCursor::~GradientCursor() { +} + +void GradientCursor::_notification(int p_what) { + switch (p_what) { + case NOTIFICATION_POSTINITIALIZE: { + set_position(Vector2(0, 15)); + set_size(Vector2(WIDTH, 15)); + } break; + case NOTIFICATION_DRAW: { + _draw(); + } break; + } +} + +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_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"); + + ClassDB::bind_method(D_METHOD("_gui_input", "ev"), &GradientCursor::_gui_input); + + ClassDB::bind_method(D_METHOD("get_cursor_position"), &GradientCursor::get_cursor_position); + ClassDB::bind_method(D_METHOD("set_color", "c"), &GradientCursor::set_color); + + ClassDB::bind_method(D_METHOD("can_drop_data_fw", "point", "data", "from"), &GradientCursor::can_drop_data_fw); + ClassDB::bind_method(D_METHOD("drop_data_fw", "point", "data", "from"), &GradientCursor::drop_data_fw); +} diff --git a/modules/material_maker/editor/widgets/gradient_editor/gradient_cursor.h b/modules/material_maker/editor/widgets/gradient_editor/gradient_cursor.h new file mode 100644 index 000000000..205f0ff56 --- /dev/null +++ b/modules/material_maker/editor/widgets/gradient_editor/gradient_cursor.h @@ -0,0 +1,50 @@ + +#ifndef GRADIENT_CURSOR_H +#define GRADIENT_CURSOR_H + +#include "core/color.h" +#include "core/os/input_event.h" +#include "core/variant.h" + +#include "scene/gui/control.h" + +class Label; + +class GradientCursor : public Control { + GDCLASS(GradientCursor, Control); + +public: + Color get_color(); + void set_color(const Color &val); + + bool get_sliding() const; + void set_sliding(const bool val); + + void set_label(Label *label); + + void _draw(); + void _gui_input(const Ref &ev); + + float get_cursor_position(); + + static bool sort(const Variant &a, const Variant &b); + + 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); + + GradientCursor(); + ~GradientCursor(); + +protected: + void _notification(int p_what); + + static void _bind_methods(); + + Color color; + bool sliding; + Label *label; + + const int WIDTH = 10; +}; + +#endif 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 48bee2297..9ad737440 100644 --- a/modules/material_maker/editor/widgets/gradient_editor/gradient_editor.cpp +++ b/modules/material_maker/editor/widgets/gradient_editor/gradient_editor.cpp @@ -1,555 +1,580 @@ #include "gradient_editor.h" - Variant GradientEditor::get_Variant() { - return Variant; + return Variant; } void GradientEditor::set_Variant(const Variant &val) { -Variant = val; + Variant = val; } - Variant GradientEditor::get_Variant() { - return Variant; + return Variant; } void GradientEditor::set_Variant(const Variant &val) { -Variant = val; + Variant = val; } - bool GradientEditor::get_embedded() const { - return embedded; + return embedded; } void GradientEditor::set_embedded(const bool val) { -embedded = val; + embedded = val; } - -UndoRedo GradientEditor::get_*_undo_redo() { - return *_undo_redo; +UndoRedo GradientEditor::get_ *_undo_redo() { + return *_undo_redo; } -void GradientEditor::set_*_undo_redo(const UndoRedo &val) { -*_undo_redo = val; +void GradientEditor::set_ *_undo_redo(const UndoRedo &val) { + *_undo_redo = val; } - PoolRealArray GradientEditor::get__saved_points() { - return _saved_points; + return _saved_points; } void GradientEditor::set__saved_points(const PoolRealArray &val) { -_saved_points = val; + _saved_points = val; } - Variant GradientEditor::get_Variant() { - return Variant; + return Variant; } void GradientEditor::set_Variant(const Variant &val) { -Variant = val; + Variant = val; } +//tool; +Variant = null; +// setget set_value; +Variant = null; +//export ; +bool embedded = true; +UndoRedo *_undo_redo = null; +signal updated(value); +PoolRealArray _saved_points = PoolRealArray(); - - //tool; - - Color GradientCursor::get_color() { - return color; - } - - void GradientCursor::set_color(const Color &val) { - color = val; - } - - - bool GradientCursor::get_sliding() const { - return sliding; - } - - void GradientCursor::set_sliding(const bool val) { - sliding = val; - } - - - - extends Control; - Color color = ; - bool sliding = false; - onready var label : Label = get_parent().get_node("Value"); - const WIDTH : int = 10; - - void GradientCursor::_ready() { - rect_position = Vector2(0, 15); - rect_size = Vector2(WIDTH, 15); +void GradientEditor::_init() { + connect("resized", self, "on_resized"); } - - void GradientCursor::_draw() { - // warning-ignore:integer_division; - PoolVector2Array polygon = PoolVector2Array([Vector2(0, 5), Vector2(WIDTH/2, 0), Vector2(WIDTH, 5), Vector2(WIDTH, 15), Vector2(0, 15), Vector2(0, 5)]); - Variant = color; - c.a = 1.0; - draw_colored_polygon(polygon, c); - draw_polyline(polygon, Color(0.0, 0.0, 0.0) if color.v > 0.5 else Color(1.0, 1.0, 1.0)); +void GradientEditor::ignore_changes(const Variant &val) { + graph_node.ignore_changes(val); } +void GradientEditor::save_color_state() { + PoolRealArray p = value.points; + _saved_points.resize(0); - void GradientCursor::_gui_input(const Variant &ev) { + for (v in p) { + _saved_points.push_back(v); + } - if (ev is InputEventMouseButton) { - - if (ev.button_index == BUTTON_LEFT) { - - if (ev.doubleclick) { - get_parent().save_color_state(); - get_parent().select_color(self, ev.global_position); + ignore_changes(true); } +void GradientEditor::undo_redo_save_color_state() { + PoolRealArray op = ; + PoolRealArray np = ; - else if (ev.pressed) { - get_parent().save_color_state(); - sliding = true; - label.visible = true; - label.text = "%.03f" % get_cursor_position(); + for (v in _saved_points) { + op.push_back(v); + } + + for (v in value.get_points()) { + np.push_back(v); + } + + _undo_redo.create_action("MMGD: gradient colors changed"); + _undo_redo.add_do_method(value, "set_points", np); + _undo_redo.add_undo_method(value, "set_points", op); + _undo_redo.commit_action(); + ignore_changes(false); } - - else { - - if (sliding) { - get_parent().undo_redo_save_color_state(); +void GradientEditor::set_undo_redo(const UndoRedo &ur) { + _undo_redo = ur; } - sliding = false; - label.visible = false; +//func get_gradient_from_data(data):; +// if typeof(data) == TYPE_ARRAY:; +// return data; +// elif typeof(data) == TYPE_DICTIONARY:; +// if data.has("parameters") and data.parameters.has("gradient"):; +// return data.parameters.gradient; +// if data.has("type") and data.type == "Gradient":; +// return data; +// return null; +//func get_drag_data(_position : Vector2):; +// var data = 0//MMType.serialize_value(value); +// var preview = ColorRect.new(); +// preview.rect_size = Vector2(64, 24); +// preview.material = $Gradient.material; +// set_drag_preview(preview); +// return data; +//; +//func can_drop_data(_position : Vector2, data) -> bool:; +// return get_gradient_from_data(data) != null; +//; +//func drop_data(_position : Vector2, data) -> void:; +// var gradient = get_gradient_from_data(data); +// //if gradient != null:; +// //set_value(MMType.deserialize_value(gradient)); + +void GradientEditor::set_value(const Variant &v) { + value = v; + update_preview(); + call_deferred("update_cursors"); } +void GradientEditor::update_cursors() { + for (c in get_children()) { + if (c is GradientCursor) { + remove_child(c); + c.free(); + } + } + + int vs = value.get_point_count(); + + for (int i = 0; i < vs; ++i) { //i in range(vs) + add_cursor(value.get_point_value(i) * (rect_size.x - GradientCursor.WIDTH), value.get_point_color(i)); + } + + $Interpolation.selected = value.interpolation_type; } +void GradientEditor::update_value() { + value.clear(); + Array sc = get_sorted_cursors(); + PoolRealArray points = PoolRealArray(); - else if (ev.button_index == BUTTON_RIGHT && get_parent().get_sorted_cursors().size() > 2) { - Variant = get_parent(); - parent.save_color_state(); - parent.remove_child(self); - parent.update_value(); - parent.undo_redo_save_color_state(); - queue_free(); + for (c in sc) { + points.push_back(c.rect_position.x / (rect_size.x - GradientCursor.WIDTH)); + Color color = c.color; + points.push_back(color.r); + points.push_back(color.g); + points.push_back(color.b); + points.push_back(color.a); + } + + value.set_points(points); + update_preview(); } +void GradientEditor::add_cursor(const Variant &x, const Variant &color) { + GradientCursor *cursor = GradientCursor.new(); + cursor->set_label(label); + + add_child(cursor); + cursor.rect_position.x = x; + cursor.color = color; } +void GradientEditor::_gui_input(const Variant &ev) { + if (ev is InputEventMouseButton && ev.button_index == 1 && ev.doubleclick) { + if (ev.position.y > 15) { + Variant = clamp(ev.position.x, 0, rect_size.x - GradientCursor.WIDTH); + save_color_state(); + add_cursor(p, get_gradient_color(p)); + update_value(); + undo_redo_save_color_state(); + } - else if (ev is InputEventMouseMotion && (ev.button_mask & BUTTON_MASK_LEFT) != 0 && sliding) { - rect_position.x += get_local_mouse_position().x; + else if (embedded) { + Variant = load("res://addons/mat_maker_gd/widgets/gradient_editor/gradient_popup.tscn").instance(); + add_child(popup); + Variant = popup.rect_size; + popup.popup(Rect2(ev.global_position, Vector2(0, 0))); + popup.set_global_position(ev.global_position - Vector2(popup_size.x / 2, popup_size.y)); + popup.init(value, graph_node, _undo_redo); + popup.connect("updated", self, "set_value"); + popup.connect("popup_hide", popup, "queue_free"); + } - if (ev.control) { - rect_position.x = round(get_cursor_position()*20.0)*0.05*(get_parent().rect_size.x - WIDTH); + // Showing a color picker popup to change a cursor's color; + } } - rect_position.x = min(max(0, rect_position.x), get_parent().rect_size.x-rect_size.x); - get_parent().update_value(); - label.text = "%.03f" % get_cursor_position(); +Variant; + +void GradientEditor::select_color(const Variant &cursor, const Variant &position) { + active_cursor = cursor; + //var color_picker_popup = preload("res://addons/mat_maker_gd/widgets/color_picker_popup/color_picker_popup.tscn").instance(); + add_child(color_picker_popup); + Variant = color_picker_popup.get_node("ColorPicker"); + color_picker.color = cursor.color; + color_picker.connect("color_changed", cursor, "set_color"); + color_picker_popup.rect_position = position; + color_picker_popup.connect("popup_hide", self, "undo_redo_save_color_state"); + color_picker_popup.connect("popup_hide", color_picker_popup, "queue_free"); + color_picker_popup.popup(); } +// Calculating a color from the gradient and generating the shader; + +Array GradientEditor::get_sorted_cursors() { + Variant = []; + + for (c in get_children()) { + if (c is GradientCursor) { + array.append(c); + } + } + + array.sort_custom(GradientCursor, "sort"); + return array; } +void GradientEditor::generate_preview_image() { + Ref tex = $Gradient.texture; - float GradientCursor::get_cursor_position() { - return rect_position.x / (get_parent().rect_size.x - WIDTH); + if (!tex) { + tex = ImageTexture.new(); + $Gradient.texture = tex; + } + + Ref img = tex.get_data(); + float w = $Gradient.rect_size.x; + float h = $Gradient.rect_size.y; + + if (!img) { + img = Image.new(); + } + + if (img.get_size().x != w || img.get_size().y != h) { + img.create(w, h, false, Image.FORMAT_RGBA8); + } + + img.lock(); + + for (int i = 0; i < w; ++i) { //i in range(w) + float x = float(i) / float(w); + Color col = value.get_gradient_color(x); + + for (int j = 0; j < h; ++j) { //j in range(h) + img.set_pixel(i, j, col); + } + } + + img.unlock(); + tex.create_from_image(img, 0); } - - void GradientCursor::set_color(const Variant &c) { - color = c; - get_parent().update_value(); - update(); +Color GradientEditor::get_gradient_color(const Variant &x) { + return value.get_gradient_color(x / (rect_size.x - GradientCursor.WIDTH)); } - - bool GradientCursor::sort(const Variant &a, const Variant & b) { - return a.get_position() < b.get_position(); +void GradientEditor::update_preview() { + call_deferred("generate_preview_image"); } - - bool GradientCursor::can_drop_data(const Variant &_position, const Variant & data) { - return typeof(data) == TYPE_COLOR; +void GradientEditor::_on_Interpolation_item_selected(const Variant &ID) { + ignore_changes(true); + _undo_redo.create_action("MMGD: gradient interpolation_type changed"); + _undo_redo.add_do_method(value, "set_interpolation_type", ID); + _undo_redo.add_undo_method(value, "set_interpolation_type", value.interpolation_type); + _undo_redo.commit_action(); + ignore_changes(false); + update_preview(); } - - void GradientCursor::drop_data(const Variant &_position, const Variant & data) { - set_color(data); +void GradientEditor::on_resized() { + if (value) { + update_preview(); + call_deferred("update_cursors"); + } } +GradientEditor::GradientEditor() { + = null; + = null; + embedded = true; + *_undo_redo = null; + _saved_points = PoolRealArray(); + ; + + //Script: res://addons/mat_maker_gd/widgets/gradient_editor/gradient_editor.gd + Control *control = memnew(Control); + control->set_name("Control"); + + control->set_name("Control"); + //control->set("name", Control)); + + control->set_filename("res://addons/mat_maker_gd/widgets/gradient_editor/gradient_editor.tscn"); + //control->set("filename", "res://addons/mat_maker_gd/widgets/gradient_editor/gradient_editor.tscn"); + + control->set_margin_right(120); + //control->set("margin_right", 120); + + control->set_margin_bottom(30); + //control->set("margin_bottom", 30); + + control->set_rect_size(Vector2(120, 30)); + //control->set("rect_size", Vector2(120, 30)); + + control->set_rect_min_size(Vector2(120, 32)); + //control->set("rect_min_size", Vector2(120, 32)); + + control->set_focus_mode(1); + //control->set("focus_mode", 1); + + ColorRect *background_control = memnew(ColorRect); + background_control->set_name("Background"); + control->add_child(background_control); + + background_control->set_name("Background"); + //background_control->set("name", Background)); + + //background_control property owner TYPE_OBJECT value: Control:[Control:51414] + + //background_control property material TYPE_OBJECT value: [ShaderMaterial:19166] + Ref background_control_prop_material; + background_control_prop_material.instance(); + background_control->set_material(background_control_prop_material); + //background_control->set("material", background_control_prop_material); + + background_control->set_anchor_right(1); + //background_control->set("anchor_right", 1); + + background_control->set_margin_left(4); + //background_control->set("margin_left", 4); + + background_control->set_margin_right(-4); + //background_control->set("margin_right", -4); + + background_control->set_margin_bottom(15); + //background_control->set("margin_bottom", 15); + + background_control->set_rect_position(Vector2(4, 0)); + //background_control->set("rect_position", Vector2(4, 0)); + + background_control->set_rect_global_position(Vector2(4, 0)); + //background_control->set("rect_global_position", Vector2(4, 0)); + + background_control->set_rect_size(Vector2(0, 15)); + //background_control->set("rect_size", Vector2(0, 15)); + + background_control->set_rect_min_size(Vector2(112, 17)); + //background_control->set("rect_min_size", Vector2(112, 17)); + + background_control->set_mouse_filter(2); + //background_control->set("mouse_filter", 2); + + //background_control property __meta__ TYPE_DICTIONARY value: {_edit_use_anchors_:False} + + TextureRect *gradient_control = memnew(TextureRect); + gradient_control->set_name("Gradient"); + control->add_child(gradient_control); + + gradient_control->set_name("Gradient"); + //gradient_control->set("name", Gradient)); + + //gradient_control property owner TYPE_OBJECT value: Control:[Control:51414] + + gradient_control->set_anchor_right(1); + //gradient_control->set("anchor_right", 1); + + gradient_control->set_margin_left(4); + //gradient_control->set("margin_left", 4); + + gradient_control->set_margin_right(-4); + //gradient_control->set("margin_right", -4); + + gradient_control->set_margin_bottom(15); + //gradient_control->set("margin_bottom", 15); + + gradient_control->set_rect_position(Vector2(4, 0)); + //gradient_control->set("rect_position", Vector2(4, 0)); + + gradient_control->set_rect_global_position(Vector2(4, 0)); + //gradient_control->set("rect_global_position", Vector2(4, 0)); + + gradient_control->set_rect_size(Vector2(0, 15)); + //gradient_control->set("rect_size", Vector2(0, 15)); + + gradient_control->set_rect_min_size(Vector2(112, 17)); + //gradient_control->set("rect_min_size", Vector2(112, 17)); + + gradient_control->set_mouse_filter(2); + //gradient_control->set("mouse_filter", 2); + + //gradient_control property theme TYPE_OBJECT value: [Theme:19167] + Ref gradient_control_prop_theme; + gradient_control_prop_theme.instance(); + gradient_control->set_theme(gradient_control_prop_theme); + //gradient_control->set("theme", gradient_control_prop_theme); + + //gradient_control property __meta__ TYPE_DICTIONARY value: {_edit_use_anchors_:False} + + OptionButton *interpolation_control = memnew(OptionButton); + interpolation_control->set_name("Interpolation"); + control->add_child(interpolation_control); + + interpolation_control->set_name("Interpolation"); + //interpolation_control->set("name", Interpolation)); + + //interpolation_control property owner TYPE_OBJECT value: Control:[Control:51414] + + interpolation_control->set_margin_left(0.418457); + //interpolation_control->set("margin_left", 0.418457); + + interpolation_control->set_margin_top(-2.90374); + //interpolation_control->set("margin_top", -2.90374); + + interpolation_control->set_margin_right(73.418503); + //interpolation_control->set("margin_right", 73.418503); + + interpolation_control->set_margin_bottom(19.0963); + //interpolation_control->set("margin_bottom", 19.0963); + + interpolation_control->set_rect_position(Vector2(0.418457, -2.90374)); + //interpolation_control->set("rect_position", Vector2(0.418457, -2.90374)); + + interpolation_control->set_rect_global_position(Vector2(0.418457, -2.90374)); + //interpolation_control->set("rect_global_position", Vector2(0.418457, -2.90374)); + + interpolation_control->set_rect_size(Vector2(73.000046, 22.00004)); + //interpolation_control->set("rect_size", Vector2(73.000046, 22.00004)); + + interpolation_control->set_rect_scale(Vector2(0.5, 0.5)); + //interpolation_control->set("rect_scale", Vector2(0.5, 0.5)); + + //interpolation_control property icon TYPE_OBJECT value: [AtlasTexture:19168] + Ref interpolation_control_prop_icon; + interpolation_control_prop_icon.instance(); + interpolation_control->set_icon(interpolation_control_prop_icon); + //interpolation_control->set("icon", interpolation_control_prop_icon); + + //interpolation_control property items TYPE_ARRAY value: [, [AtlasTexture:19169], False, 0, Null, , [AtlasTexture:19168], False, 1, Null, , [AtlasTexture:19170], False, 2, Null, , [AtlasTexture:19171], False, 3, Null] + + interpolation_control->set_selected(1); + //interpolation_control->set("selected", 1); + + PopupMenu *popupmenu_interpolation_control = memnew(PopupMenu); + popupmenu_interpolation_control->set_name("PopupMenu"); + interpolation_control->add_child(popupmenu_interpolation_control); + + popupmenu_interpolation_control->set_name("PopupMenu"); + //popupmenu_interpolation_control->set("name", PopupMenu)); + + popupmenu_interpolation_control->set_input_pass_on_modal_close_click(False); + //popupmenu_interpolation_control->set("input_pass_on_modal_close_click", False); + + //popupmenu_interpolation_control property items TYPE_ARRAY value: [, [AtlasTexture:19169], 2, False, False, 0, 0, Null, , False, , [AtlasTexture:19168], 2, True, False, 1, 0, Null, , False, , [AtlasTexture:19170], 2, False, False, 2, 0, Null, , False, , [AtlasTexture:19171], 2, False, False, 3, 0, Null, , False] + + popupmenu_interpolation_control->set_allow_search(True); + //popupmenu_interpolation_control->set("allow_search", True); + + Timer *timer_popupmenu_interpolation_control = memnew(Timer); + timer_popupmenu_interpolation_control->set_name("Timer"); + popupmenu_interpolation_control->add_child(timer_popupmenu_interpolation_control); + + timer_popupmenu_interpolation_control->set_name("Timer"); + //timer_popupmenu_interpolation_control->set("name", Timer)); + + timer_popupmenu_interpolation_control->set_wait_time(0.3); + //timer_popupmenu_interpolation_control->set("wait_time", 0.3); + + timer_popupmenu_interpolation_control->set_one_shot(True); + //timer_popupmenu_interpolation_control->set("one_shot", True); + + Label *value_control = memnew(Label); + value_control->set_name("Value"); + control->add_child(value_control); + + value_control->set_name("Value"); + //value_control->set("name", Value)); + + //value_control property owner TYPE_OBJECT value: Control:[Control:51414] + + value_control->set_anchor_right(1); + //value_control->set("anchor_right", 1); + + value_control->set_margin_top(-1); + //value_control->set("margin_top", -1); + + value_control->set_margin_bottom(14); + //value_control->set("margin_bottom", 14); + + value_control->set_rect_position(Vector2(0, -1)); + //value_control->set("rect_position", Vector2(0, -1)); + + value_control->set_rect_global_position(Vector2(0, -1)); + //value_control->set("rect_global_position", Vector2(0, -1)); + + value_control->set_rect_size(Vector2(0, 15)); + //value_control->set("rect_size", Vector2(0, 15)); + + value_control->set_custom_colors / font_color(Color(1, 1, 1, 1)); + //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_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_x", 1); + + value_control->set_custom_constants / shadow_offset_y(1); + //value_control->set("custom_constants/shadow_offset_y", 1); + + value_control->set_custom_constants / shadow_as_outline(1); + //value_control->set("custom_constants/shadow_as_outline", 1); + + value_control->set_align(1); + //value_control->set("align", 1); + + //value_control property __meta__ TYPE_DICTIONARY value: {_edit_use_anchors_:False} } - GradientCursor::GradientCursor() { - color = ; - sliding = false; - } - - GradientCursor::~GradientCursor() { - } - - - static 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_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"); - - - ClassDB::bind_method(D_METHOD("_ready"), &GradientCursor::_ready); - ClassDB::bind_method(D_METHOD("_draw"), &GradientCursor::_draw); - ClassDB::bind_method(D_METHOD("_gui_input", "ev"), &GradientCursor::_gui_input); - ClassDB::bind_method(D_METHOD("get_cursor_position"), &GradientCursor::get_cursor_position); - ClassDB::bind_method(D_METHOD("set_color", "c"), &GradientCursor::set_color); - ClassDB::bind_method(D_METHOD("can_drop_data", "_position", " data"), &GradientCursor::can_drop_data); - ClassDB::bind_method(D_METHOD("drop_data", "_position", " data"), &GradientCursor::drop_data); - - } - - - Variant = null; - // setget set_value; - Variant = null; - //export ; - bool embedded = true; - UndoRedo *_undo_redo = null; - signal updated(value); - PoolRealArray _saved_points = PoolRealArray(); - - void GradientEditor::_init() { - connect("resized", self, "on_resized"); +GradientEditor::~GradientEditor() { } +static void GradientEditor::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_Variant"), &GradientEditor::get_Variant); + ClassDB::bind_method(D_METHOD("set_Variant", "value"), &GradientEditor::set_Variant); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "Variant", PROPERTY_HINT_RESOURCE_TYPE, "Variant"), "set_Variant", "get_Variant"); - void GradientEditor::ignore_changes(const Variant &val) { - graph_node.ignore_changes(val); + ClassDB::bind_method(D_METHOD("get_Variant"), &GradientEditor::get_Variant); + ClassDB::bind_method(D_METHOD("set_Variant", "value"), &GradientEditor::set_Variant); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "Variant", PROPERTY_HINT_RESOURCE_TYPE, "Variant"), "set_Variant", "get_Variant"); + + ClassDB::bind_method(D_METHOD("get_embedded"), &GradientEditor::get_embedded); + ClassDB::bind_method(D_METHOD("set_embedded", "value"), &GradientEditor::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); + 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); + ADD_PROPERTY(PropertyInfo(Variant::POOL_REAL_ARRAY, "_saved_points"), "set__saved_points", "get__saved_points"); + + ClassDB::bind_method(D_METHOD("get_Variant"), &GradientEditor::get_Variant); + ClassDB::bind_method(D_METHOD("set_Variant", "value"), &GradientEditor::set_Variant); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "Variant", PROPERTY_HINT_RESOURCE_TYPE, "Variant"), "set_Variant", "get_Variant"); + + ClassDB::bind_method(D_METHOD("_init"), &GradientEditor::_init); + ClassDB::bind_method(D_METHOD("ignore_changes", "val"), &GradientEditor::ignore_changes); + ClassDB::bind_method(D_METHOD("save_color_state"), &GradientEditor::save_color_state); + ClassDB::bind_method(D_METHOD("undo_redo_save_color_state"), &GradientEditor::undo_redo_save_color_state); + ClassDB::bind_method(D_METHOD("set_undo_redo", "ur"), &GradientEditor::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("_gui_input", "ev"), &GradientEditor::_gui_input); + ClassDB::bind_method(D_METHOD("select_color", "cursor", " position"), &GradientEditor::select_color); + ClassDB::bind_method(D_METHOD("get_sorted_cursors"), &GradientEditor::get_sorted_cursors); + ClassDB::bind_method(D_METHOD("generate_preview_image"), &GradientEditor::generate_preview_image); + ClassDB::bind_method(D_METHOD("get_gradient_color", "x"), &GradientEditor::get_gradient_color); + ClassDB::bind_method(D_METHOD("update_preview"), &GradientEditor::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); } - - - void GradientEditor::save_color_state() { - PoolRealArray p = value.points; - _saved_points.resize(0); - - for (v in p) { - _saved_points.push_back(v); -} - - ignore_changes(true); -} - - - void GradientEditor::undo_redo_save_color_state() { - PoolRealArray op = ; - PoolRealArray np = ; - - for (v in _saved_points) { - op.push_back(v); -} - - - for (v in value.get_points()) { - np.push_back(v); -} - - _undo_redo.create_action("MMGD: gradient colors changed"); - _undo_redo.add_do_method(value, "set_points", np); - _undo_redo.add_undo_method(value, "set_points", op); - _undo_redo.commit_action(); - ignore_changes(false); -} - - - void GradientEditor::set_undo_redo(const UndoRedo &ur) { - _undo_redo = ur; -} - - //func get_gradient_from_data(data):; - // if typeof(data) == TYPE_ARRAY:; - // return data; - // elif typeof(data) == TYPE_DICTIONARY:; - // if data.has("parameters") and data.parameters.has("gradient"):; - // return data.parameters.gradient; - // if data.has("type") and data.type == "Gradient":; - // return data; - // return null; - //func get_drag_data(_position : Vector2):; - // var data = 0//MMType.serialize_value(value); - // var preview = ColorRect.new(); - // preview.rect_size = Vector2(64, 24); - // preview.material = $Gradient.material; - // set_drag_preview(preview); - // return data; - //; - //func can_drop_data(_position : Vector2, data) -> bool:; - // return get_gradient_from_data(data) != null; - //; - //func drop_data(_position : Vector2, data) -> void:; - // var gradient = get_gradient_from_data(data); - // //if gradient != null:; - // //set_value(MMType.deserialize_value(gradient)); - - void GradientEditor::set_value(const Variant &v) { - value = v; - update_preview(); - call_deferred("update_cursors"); -} - - - void GradientEditor::update_cursors() { - - for (c in get_children()) { - - if (c is GradientCursor) { - remove_child(c); - c.free(); -} - -} - - int vs = value.get_point_count(); - - for (int i = 0; i < vs; ++i) { //i in range(vs) - add_cursor(value.get_point_value(i) * (rect_size.x-GradientCursor.WIDTH), value.get_point_color(i)); -} - - $Interpolation.selected = value.interpolation_type; -} - - - void GradientEditor::update_value() { - value.clear(); - Array sc = get_sorted_cursors(); - PoolRealArray points = PoolRealArray(); - - for (c in sc) { - points.push_back(c.rect_position.x/(rect_size.x-GradientCursor.WIDTH)); - Color color = c.color; - points.push_back(color.r); - points.push_back(color.g); - points.push_back(color.b); - points.push_back(color.a); -} - - value.set_points(points); - update_preview(); -} - - - void GradientEditor::add_cursor(const Variant &x, const Variant & color) { - Variant = GradientCursor.new(); - add_child(cursor); - cursor.rect_position.x = x; - cursor.color = color; -} - - - void GradientEditor::_gui_input(const Variant &ev) { - - if (ev is InputEventMouseButton && ev.button_index == 1 && ev.doubleclick) { - - if (ev.position.y > 15) { - Variant = clamp(ev.position.x, 0, rect_size.x-GradientCursor.WIDTH); - save_color_state(); - add_cursor(p, get_gradient_color(p)); - update_value(); - undo_redo_save_color_state(); -} - - - else if (embedded) { - Variant = load("res://addons/mat_maker_gd/widgets/gradient_editor/gradient_popup.tscn").instance(); - add_child(popup); - Variant = popup.rect_size; - popup.popup(Rect2(ev.global_position, Vector2(0, 0))); - popup.set_global_position(ev.global_position-Vector2(popup_size.x / 2, popup_size.y)); - popup.init(value, graph_node, _undo_redo); - popup.connect("updated", self, "set_value"); - popup.connect("popup_hide", popup, "queue_free"); -} - - // Showing a color picker popup to change a cursor's color; -} - -} - - Variant ; - - void GradientEditor::select_color(const Variant &cursor, const Variant & position) { - active_cursor = cursor; - //var color_picker_popup = preload("res://addons/mat_maker_gd/widgets/color_picker_popup/color_picker_popup.tscn").instance(); - add_child(color_picker_popup); - Variant = color_picker_popup.get_node("ColorPicker"); - color_picker.color = cursor.color; - color_picker.connect("color_changed", cursor, "set_color"); - color_picker_popup.rect_position = position; - color_picker_popup.connect("popup_hide", self, "undo_redo_save_color_state"); - color_picker_popup.connect("popup_hide", color_picker_popup, "queue_free"); - color_picker_popup.popup(); -} - - // Calculating a color from the gradient and generating the shader; - - Array GradientEditor::get_sorted_cursors() { - Variant = []; - - for (c in get_children()) { - - if (c is GradientCursor) { - array.append(c); -} - -} - - array.sort_custom(GradientCursor, "sort"); - return array; -} - - - void GradientEditor::generate_preview_image() { - Ref tex = $Gradient.texture; - - if (!tex) { - tex = ImageTexture.new(); - $Gradient.texture = tex; -} - - Ref img = tex.get_data(); - float w = $Gradient.rect_size.x; - float h = $Gradient.rect_size.y; - - if (!img) { - img = Image.new(); -} - - - if (img.get_size().x != w || img.get_size().y != h) { - img.create(w, h, false, Image.FORMAT_RGBA8); -} - - img.lock(); - - for (int i = 0; i < w; ++i) { //i in range(w) - float x = float(i) / float(w); - Color col = value.get_gradient_color(x); - - for (int j = 0; j < h; ++j) { //j in range(h) - img.set_pixel(i, j, col); -} - -} - - img.unlock(); - tex.create_from_image(img, 0); -} - - - Color GradientEditor::get_gradient_color(const Variant &x) { - return value.get_gradient_color(x / (rect_size.x - GradientCursor.WIDTH)); -} - - - void GradientEditor::update_preview() { - call_deferred("generate_preview_image"); -} - - - void GradientEditor::_on_Interpolation_item_selected(const Variant &ID) { - ignore_changes(true); - _undo_redo.create_action("MMGD: gradient interpolation_type changed"); - _undo_redo.add_do_method(value, "set_interpolation_type", ID); - _undo_redo.add_undo_method(value, "set_interpolation_type", value.interpolation_type); - _undo_redo.commit_action(); - ignore_changes(false); - update_preview(); -} - - - void GradientEditor::on_resized() { - - if (value) { - update_preview(); - call_deferred("update_cursors"); -} - -} - -} - - GradientEditor::GradientEditor() { - = null; - = null; - embedded = true; - *_undo_redo = null; - _saved_points = PoolRealArray(); - ; - } - - GradientEditor::~GradientEditor() { - } - - - static void GradientEditor::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_Variant"), &GradientEditor::get_Variant); - ClassDB::bind_method(D_METHOD("set_Variant", "value"), &GradientEditor::set_Variant); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "Variant", PROPERTY_HINT_RESOURCE_TYPE, "Variant"), "set_Variant", "get_Variant"); - - - ClassDB::bind_method(D_METHOD("get_Variant"), &GradientEditor::get_Variant); - ClassDB::bind_method(D_METHOD("set_Variant", "value"), &GradientEditor::set_Variant); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "Variant", PROPERTY_HINT_RESOURCE_TYPE, "Variant"), "set_Variant", "get_Variant"); - - - ClassDB::bind_method(D_METHOD("get_embedded"), &GradientEditor::get_embedded); - ClassDB::bind_method(D_METHOD("set_embedded", "value"), &GradientEditor::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); - 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); - ADD_PROPERTY(PropertyInfo(Variant::POOL_REAL_ARRAY, "_saved_points"), "set__saved_points", "get__saved_points"); - - - ClassDB::bind_method(D_METHOD("get_Variant"), &GradientEditor::get_Variant); - ClassDB::bind_method(D_METHOD("set_Variant", "value"), &GradientEditor::set_Variant); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "Variant", PROPERTY_HINT_RESOURCE_TYPE, "Variant"), "set_Variant", "get_Variant"); - - - ClassDB::bind_method(D_METHOD("_init"), &GradientEditor::_init); - ClassDB::bind_method(D_METHOD("ignore_changes", "val"), &GradientEditor::ignore_changes); - ClassDB::bind_method(D_METHOD("save_color_state"), &GradientEditor::save_color_state); - ClassDB::bind_method(D_METHOD("undo_redo_save_color_state"), &GradientEditor::undo_redo_save_color_state); - ClassDB::bind_method(D_METHOD("set_undo_redo", "ur"), &GradientEditor::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("_gui_input", "ev"), &GradientEditor::_gui_input); - ClassDB::bind_method(D_METHOD("select_color", "cursor", " position"), &GradientEditor::select_color); - ClassDB::bind_method(D_METHOD("get_sorted_cursors"), &GradientEditor::get_sorted_cursors); - ClassDB::bind_method(D_METHOD("generate_preview_image"), &GradientEditor::generate_preview_image); - ClassDB::bind_method(D_METHOD("get_gradient_color", "x"), &GradientEditor::get_gradient_color); - ClassDB::bind_method(D_METHOD("update_preview"), &GradientEditor::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); - - } - - - diff --git a/modules/material_maker/editor/widgets/gradient_editor/gradient_editor.ctscn b/modules/material_maker/editor/widgets/gradient_editor/gradient_editor.ctscn deleted file mode 100644 index ab8d6eedf..000000000 --- a/modules/material_maker/editor/widgets/gradient_editor/gradient_editor.ctscn +++ /dev/null @@ -1,251 +0,0 @@ - -void construct() { - -//Script: res://addons/mat_maker_gd/widgets/gradient_editor/gradient_editor.gd -Control *control = memnew(Control); -control->set_name("Control"); - -control->set_name("Control"); -//control->set("name", Control)); - -control->set_filename("res://addons/mat_maker_gd/widgets/gradient_editor/gradient_editor.tscn"); -//control->set("filename", "res://addons/mat_maker_gd/widgets/gradient_editor/gradient_editor.tscn"); - -control->set_margin_right(120); -//control->set("margin_right", 120); - -control->set_margin_bottom(30); -//control->set("margin_bottom", 30); - -control->set_rect_size(Vector2(120, 30)); -//control->set("rect_size", Vector2(120, 30)); - -control->set_rect_min_size(Vector2(120, 32)); -//control->set("rect_min_size", Vector2(120, 32)); - -control->set_focus_mode(1); -//control->set("focus_mode", 1); - - - -ColorRect *background_control = memnew(ColorRect); -background_control->set_name("Background"); -control->add_child(background_control); - -background_control->set_name("Background"); -//background_control->set("name", Background)); - -//background_control property owner TYPE_OBJECT value: Control:[Control:51414] - -//background_control property material TYPE_OBJECT value: [ShaderMaterial:19166] -Ref background_control_prop_material; -background_control_prop_material.instance(); -background_control->set_material(background_control_prop_material); -//background_control->set("material", background_control_prop_material); - -background_control->set_anchor_right(1); -//background_control->set("anchor_right", 1); - -background_control->set_margin_left(4); -//background_control->set("margin_left", 4); - -background_control->set_margin_right(-4); -//background_control->set("margin_right", -4); - -background_control->set_margin_bottom(15); -//background_control->set("margin_bottom", 15); - -background_control->set_rect_position(Vector2(4, 0)); -//background_control->set("rect_position", Vector2(4, 0)); - -background_control->set_rect_global_position(Vector2(4, 0)); -//background_control->set("rect_global_position", Vector2(4, 0)); - -background_control->set_rect_size(Vector2(0, 15)); -//background_control->set("rect_size", Vector2(0, 15)); - -background_control->set_rect_min_size(Vector2(112, 17)); -//background_control->set("rect_min_size", Vector2(112, 17)); - -background_control->set_mouse_filter(2); -//background_control->set("mouse_filter", 2); - -//background_control property __meta__ TYPE_DICTIONARY value: {_edit_use_anchors_:False} - - - -TextureRect *gradient_control = memnew(TextureRect); -gradient_control->set_name("Gradient"); -control->add_child(gradient_control); - -gradient_control->set_name("Gradient"); -//gradient_control->set("name", Gradient)); - -//gradient_control property owner TYPE_OBJECT value: Control:[Control:51414] - -gradient_control->set_anchor_right(1); -//gradient_control->set("anchor_right", 1); - -gradient_control->set_margin_left(4); -//gradient_control->set("margin_left", 4); - -gradient_control->set_margin_right(-4); -//gradient_control->set("margin_right", -4); - -gradient_control->set_margin_bottom(15); -//gradient_control->set("margin_bottom", 15); - -gradient_control->set_rect_position(Vector2(4, 0)); -//gradient_control->set("rect_position", Vector2(4, 0)); - -gradient_control->set_rect_global_position(Vector2(4, 0)); -//gradient_control->set("rect_global_position", Vector2(4, 0)); - -gradient_control->set_rect_size(Vector2(0, 15)); -//gradient_control->set("rect_size", Vector2(0, 15)); - -gradient_control->set_rect_min_size(Vector2(112, 17)); -//gradient_control->set("rect_min_size", Vector2(112, 17)); - -gradient_control->set_mouse_filter(2); -//gradient_control->set("mouse_filter", 2); - -//gradient_control property theme TYPE_OBJECT value: [Theme:19167] -Ref gradient_control_prop_theme; -gradient_control_prop_theme.instance(); -gradient_control->set_theme(gradient_control_prop_theme); -//gradient_control->set("theme", gradient_control_prop_theme); - -//gradient_control property __meta__ TYPE_DICTIONARY value: {_edit_use_anchors_:False} - - - -OptionButton *interpolation_control = memnew(OptionButton); -interpolation_control->set_name("Interpolation"); -control->add_child(interpolation_control); - -interpolation_control->set_name("Interpolation"); -//interpolation_control->set("name", Interpolation)); - -//interpolation_control property owner TYPE_OBJECT value: Control:[Control:51414] - -interpolation_control->set_margin_left(0.418457); -//interpolation_control->set("margin_left", 0.418457); - -interpolation_control->set_margin_top(-2.90374); -//interpolation_control->set("margin_top", -2.90374); - -interpolation_control->set_margin_right(73.418503); -//interpolation_control->set("margin_right", 73.418503); - -interpolation_control->set_margin_bottom(19.0963); -//interpolation_control->set("margin_bottom", 19.0963); - -interpolation_control->set_rect_position(Vector2(0.418457, -2.90374)); -//interpolation_control->set("rect_position", Vector2(0.418457, -2.90374)); - -interpolation_control->set_rect_global_position(Vector2(0.418457, -2.90374)); -//interpolation_control->set("rect_global_position", Vector2(0.418457, -2.90374)); - -interpolation_control->set_rect_size(Vector2(73.000046, 22.00004)); -//interpolation_control->set("rect_size", Vector2(73.000046, 22.00004)); - -interpolation_control->set_rect_scale(Vector2(0.5, 0.5)); -//interpolation_control->set("rect_scale", Vector2(0.5, 0.5)); - -//interpolation_control property icon TYPE_OBJECT value: [AtlasTexture:19168] -Ref interpolation_control_prop_icon; -interpolation_control_prop_icon.instance(); -interpolation_control->set_icon(interpolation_control_prop_icon); -//interpolation_control->set("icon", interpolation_control_prop_icon); - -//interpolation_control property items TYPE_ARRAY value: [, [AtlasTexture:19169], False, 0, Null, , [AtlasTexture:19168], False, 1, Null, , [AtlasTexture:19170], False, 2, Null, , [AtlasTexture:19171], False, 3, Null] - -interpolation_control->set_selected(1); -//interpolation_control->set("selected", 1); - - - -PopupMenu *popupmenu_interpolation_control = memnew(PopupMenu); -popupmenu_interpolation_control->set_name("PopupMenu"); -interpolation_control->add_child(popupmenu_interpolation_control); - -popupmenu_interpolation_control->set_name("PopupMenu"); -//popupmenu_interpolation_control->set("name", PopupMenu)); - -popupmenu_interpolation_control->set_input_pass_on_modal_close_click(False); -//popupmenu_interpolation_control->set("input_pass_on_modal_close_click", False); - -//popupmenu_interpolation_control property items TYPE_ARRAY value: [, [AtlasTexture:19169], 2, False, False, 0, 0, Null, , False, , [AtlasTexture:19168], 2, True, False, 1, 0, Null, , False, , [AtlasTexture:19170], 2, False, False, 2, 0, Null, , False, , [AtlasTexture:19171], 2, False, False, 3, 0, Null, , False] - -popupmenu_interpolation_control->set_allow_search(True); -//popupmenu_interpolation_control->set("allow_search", True); - - - -Timer *timer_popupmenu_interpolation_control = memnew(Timer); -timer_popupmenu_interpolation_control->set_name("Timer"); -popupmenu_interpolation_control->add_child(timer_popupmenu_interpolation_control); - -timer_popupmenu_interpolation_control->set_name("Timer"); -//timer_popupmenu_interpolation_control->set("name", Timer)); - -timer_popupmenu_interpolation_control->set_wait_time(0.3); -//timer_popupmenu_interpolation_control->set("wait_time", 0.3); - -timer_popupmenu_interpolation_control->set_one_shot(True); -//timer_popupmenu_interpolation_control->set("one_shot", True); - - - -Label *value_control = memnew(Label); -value_control->set_name("Value"); -control->add_child(value_control); - -value_control->set_name("Value"); -//value_control->set("name", Value)); - -//value_control property owner TYPE_OBJECT value: Control:[Control:51414] - -value_control->set_anchor_right(1); -//value_control->set("anchor_right", 1); - -value_control->set_margin_top(-1); -//value_control->set("margin_top", -1); - -value_control->set_margin_bottom(14); -//value_control->set("margin_bottom", 14); - -value_control->set_rect_position(Vector2(0, -1)); -//value_control->set("rect_position", Vector2(0, -1)); - -value_control->set_rect_global_position(Vector2(0, -1)); -//value_control->set("rect_global_position", Vector2(0, -1)); - -value_control->set_rect_size(Vector2(0, 15)); -//value_control->set("rect_size", Vector2(0, 15)); - -value_control->set_custom_colors/font_color(Color(1, 1, 1, 1)); -//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_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_x", 1); - -value_control->set_custom_constants/shadow_offset_y(1); -//value_control->set("custom_constants/shadow_offset_y", 1); - -value_control->set_custom_constants/shadow_as_outline(1); -//value_control->set("custom_constants/shadow_as_outline", 1); - -value_control->set_align(1); -//value_control->set("align", 1); - -//value_control property __meta__ TYPE_DICTIONARY value: {_edit_use_anchors_:False} - - - - -} 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 0bf6f25b3..07c9386b5 100644 --- a/modules/material_maker/editor/widgets/gradient_editor/gradient_editor.h +++ b/modules/material_maker/editor/widgets/gradient_editor/gradient_editor.h @@ -1,121 +1,64 @@ #ifndef GRADIENT_EDITOR_H #define GRADIENT_EDITOR_H +#include "core/color.h" +#include "core/variant.h" + +#include "scene/gui/control.h" class GradientEditor : public Control { - GDCLASS(GradientEditor, Control); + GDCLASS(GradientEditor, Control); - public: +public: + Variant get_Variant(); + void set_Variant(const Variant &val); - Variant get_Variant(); - void set_Variant(const Variant &val); + Variant get_Variant(); + void set_Variant(const Variant &val); - Variant get_Variant(); - void set_Variant(const Variant &val); + bool get_embedded() const; + void set_embedded(const bool val); - bool get_embedded() const; - void set_embedded(const bool val); + UndoRedo get_undo_redo(); + void set_undo_redo(const UndoRedo &val); - UndoRedo get_*_undo_redo(); - void set_*_undo_redo(const UndoRedo &val); + PoolRealArray get__saved_points(); + void set__saved_points(const PoolRealArray &val); - PoolRealArray get__saved_points(); - void set__saved_points(const PoolRealArray &val); + Variant get_Variant(); + void set_Variant(const Variant &val); - Variant get_Variant(); - void set_Variant(const Variant &val); + void _init(); + void ignore_changes(const Variant &val); + void save_color_state(); + void undo_redo_save_color_state(); + void set_undo_redo(const UndoRedo &ur); + void set_value(const Variant &v); + void update_cursors(); + void update_value(); + void add_cursor(const Variant &x, const Variant &color); + void _gui_input(const Variant &ev); + void select_color(const Variant &cursor, const Variant &position); + Array get_sorted_cursors(); + void generate_preview_image(); + Color get_gradient_color(const Variant &x); + void update_preview(); + void _on_Interpolation_item_selected(const Variant &ID); + void on_resized(); - class GradientCursor { - public: + GradientEditor(); + ~GradientEditor(); - Color get_color(); - void set_color(const Color &val); +protected: + static void _bind_methods(); - bool get_sliding() const; - void set_sliding(const bool val); - - void _ready(); - void _draw(); - void _gui_input(const Variant &ev); - float get_cursor_position(); - void set_color(const Variant &c); - static bool sort(const Variant &a, const Variant & b); - bool can_drop_data(const Variant &_position, const Variant & data); - void drop_data(const Variant &_position, const Variant & data); - - GradientCursor(); - ~GradientCursor(); - - protected: - static void _bind_methods(); - - extends Control; - Color color = ; - bool sliding = false; - onready var label : Label = get_parent().get_node("Value"); - const WIDTH : int = 10; + Variant = null; + Variant = null; + bool embedded = true; + UndoRedo *_undo_redo = null; + signal updated(value); + PoolRealArray _saved_points = PoolRealArray(); + Variant; }; - void _init(); - void ignore_changes(const Variant &val); - void save_color_state(); - void undo_redo_save_color_state(); - void set_undo_redo(const UndoRedo &ur); - void set_value(const Variant &v); - void update_cursors(); - void update_value(); - void add_cursor(const Variant &x, const Variant & color); - void _gui_input(const Variant &ev); - void select_color(const Variant &cursor, const Variant & position); - Array get_sorted_cursors(); - void generate_preview_image(); - Color get_gradient_color(const Variant &x); - void update_preview(); - void _on_Interpolation_item_selected(const Variant &ID); - void on_resized(); - - GradientEditor(); - ~GradientEditor(); - - protected: - static void _bind_methods(); - - //tool - Variant = null; - // setget set_value - Variant = null; - //export - bool embedded = true; - UndoRedo *_undo_redo = null; - signal updated(value); - PoolRealArray _saved_points = PoolRealArray(); - //func get_gradient_from_data(data): - // if typeof(data) == TYPE_ARRAY: - // return data - // elif typeof(data) == TYPE_DICTIONARY: - // if data.has("parameters") and data.parameters.has("gradient"): - // return data.parameters.gradient - // if data.has("type") and data.type == "Gradient": - // return data - // return null - //func get_drag_data(_position : Vector2): - // var data = 0//MMType.serialize_value(value) - // var preview = ColorRect.new() - // preview.rect_size = Vector2(64, 24) - // preview.material = $Gradient.material - // set_drag_preview(preview) - // return data - // - //func can_drop_data(_position : Vector2, data) -> bool: - // return get_gradient_from_data(data) != null - // - //func drop_data(_position : Vector2, data) -> void: - // var gradient = get_gradient_from_data(data) - // //if gradient != null: - // //set_value(MMType.deserialize_value(gradient)) - Variant ; - // Calculating a color from the gradient and generating the shader -}; - - #endif diff --git a/modules/material_maker/editor/widgets/gradient_editor/gradient_popup.cpp b/modules/material_maker/editor/widgets/gradient_editor/gradient_popup.cpp index 142ae1044..07831d54b 100644 --- a/modules/material_maker/editor/widgets/gradient_editor/gradient_popup.cpp +++ b/modules/material_maker/editor/widgets/gradient_editor/gradient_popup.cpp @@ -1,42 +1,333 @@ #include "gradient_popup.h" +//tool; +signal updated(value); - - //tool; - signal updated(value); - - void GradientPopup::init(const Variant &value, const Variant & graph_node, const Variant & undo_redo) { - $Panel/Control.set_undo_redo(undo_redo); - $Panel/Control.graph_node = graph_node; - $Panel/Control.set_value(value); +void GradientPopup::init(const Variant &value, const Variant &graph_node, const Variant &undo_redo) { + $Panel / Control.set_undo_redo(undo_redo); + $Panel / Control.graph_node = graph_node; + $Panel / Control.set_value(value); } - - void GradientPopup::_on_Control_updated(const Variant &value) { - emit_signal("updated", value); +void GradientPopup::_on_Control_updated(const Variant &value) { + emit_signal("updated", value); } - - void GradientPopup::_on_GradientPopup_popup_hide() { - queue_free(); +void GradientPopup::_on_GradientPopup_popup_hide() { + queue_free(); +} } +GradientPopup::GradientPopup() { + //Script: res://addons/mat_maker_gd/widgets/gradient_editor/gradient_popup.gd + Popup *gradientpopup = memnew(Popup); + gradientpopup->set_name("GradientPopup"); + + gradientpopup->set_name("GradientPopup"); + //gradientpopup->set("name", GradientPopup)); + + gradientpopup->set_filename("res://addons/mat_maker_gd/widgets/gradient_editor/gradient_popup.tscn"); + //gradientpopup->set("filename", "res://addons/mat_maker_gd/widgets/gradient_editor/gradient_popup.tscn"); + + gradientpopup->set_margin_right(632); + //gradientpopup->set("margin_right", 632); + + gradientpopup->set_margin_bottom(49); + //gradientpopup->set("margin_bottom", 49); + + gradientpopup->set_rect_size(Vector2(632, 49)); + //gradientpopup->set("rect_size", Vector2(632, 49)); + + gradientpopup->set_size_flags_horizontal(0); + //gradientpopup->set("size_flags_horizontal", 0); + + gradientpopup->set_size_flags_vertical(0); + //gradientpopup->set("size_flags_vertical", 0); + + Panel *panel_gradientpopup = memnew(Panel); + panel_gradientpopup->set_name("Panel"); + gradientpopup->add_child(panel_gradientpopup); + + panel_gradientpopup->set_name("Panel"); + //panel_gradientpopup->set("name", Panel)); + + //panel_gradientpopup property owner TYPE_OBJECT value: GradientPopup:[Popup:51440] + + panel_gradientpopup->set_margin_right(632); + //panel_gradientpopup->set("margin_right", 632); + + panel_gradientpopup->set_margin_bottom(49); + //panel_gradientpopup->set("margin_bottom", 49); + + panel_gradientpopup->set_rect_size(Vector2(632, 49)); + //panel_gradientpopup->set("rect_size", Vector2(632, 49)); + + //panel_gradientpopup property custom_styles/panel TYPE_OBJECT value: [StyleBoxFlat:51436] + Ref panel_gradientpopup_prop_custom_styles / panel; + panel_gradientpopup_prop_custom_styles / panel.instance(); + panel_gradientpopup->set_custom_styles / panel(panel_gradientpopup_prop_custom_styles / panel); + //panel_gradientpopup->set("custom_styles/panel", panel_gradientpopup_prop_custom_styles/panel); + + //Script: res://addons/mat_maker_gd/widgets/gradient_editor/gradient_editor.gd + Control *control_panel_gradientpopup = memnew(Control); + control_panel_gradientpopup->set_name("Control"); + panel_gradientpopup->add_child(control_panel_gradientpopup); + + control_panel_gradientpopup->set_name("Control"); + //control_panel_gradientpopup->set("name", Control)); + + control_panel_gradientpopup->set_filename("res://addons/mat_maker_gd/widgets/gradient_editor/gradient_editor.tscn"); + //control_panel_gradientpopup->set("filename", "res://addons/mat_maker_gd/widgets/gradient_editor/gradient_editor.tscn"); + + //control_panel_gradientpopup property owner TYPE_OBJECT value: GradientPopup:[Popup:51440] + + control_panel_gradientpopup->set_anchor_right(1); + //control_panel_gradientpopup->set("anchor_right", 1); + + control_panel_gradientpopup->set_anchor_bottom(1); + //control_panel_gradientpopup->set("anchor_bottom", 1); + + control_panel_gradientpopup->set_margin_left(10); + //control_panel_gradientpopup->set("margin_left", 10); + + control_panel_gradientpopup->set_margin_top(10); + //control_panel_gradientpopup->set("margin_top", 10); + + control_panel_gradientpopup->set_margin_right(-10); + //control_panel_gradientpopup->set("margin_right", -10); + + control_panel_gradientpopup->set_margin_bottom(-10); + //control_panel_gradientpopup->set("margin_bottom", -10); + + control_panel_gradientpopup->set_rect_position(Vector2(10, 10)); + //control_panel_gradientpopup->set("rect_position", Vector2(10, 10)); + + control_panel_gradientpopup->set_rect_global_position(Vector2(10, 10)); + //control_panel_gradientpopup->set("rect_global_position", Vector2(10, 10)); + + control_panel_gradientpopup->set_rect_min_size(Vector2(120, 32)); + //control_panel_gradientpopup->set("rect_min_size", Vector2(120, 32)); + + control_panel_gradientpopup->set_focus_mode(1); + //control_panel_gradientpopup->set("focus_mode", 1); + + control_panel_gradientpopup->set_embedded(False); + //control_panel_gradientpopup->set("embedded", False); + + ColorRect *background_control_panel_gradientpopup = memnew(ColorRect); + background_control_panel_gradientpopup->set_name("Background"); + control_panel_gradientpopup->add_child(background_control_panel_gradientpopup); + + background_control_panel_gradientpopup->set_name("Background"); + //background_control_panel_gradientpopup->set("name", Background)); + + //background_control_panel_gradientpopup property owner TYPE_OBJECT value: Control:[Control:51442] + + //background_control_panel_gradientpopup property material TYPE_OBJECT value: [ShaderMaterial:19166] + Ref background_control_panel_gradientpopup_prop_material; + background_control_panel_gradientpopup_prop_material.instance(); + background_control_panel_gradientpopup->set_material(background_control_panel_gradientpopup_prop_material); + //background_control_panel_gradientpopup->set("material", background_control_panel_gradientpopup_prop_material); + + background_control_panel_gradientpopup->set_anchor_right(1); + //background_control_panel_gradientpopup->set("anchor_right", 1); + + background_control_panel_gradientpopup->set_margin_left(4); + //background_control_panel_gradientpopup->set("margin_left", 4); + + background_control_panel_gradientpopup->set_margin_right(-4); + //background_control_panel_gradientpopup->set("margin_right", -4); + + background_control_panel_gradientpopup->set_margin_bottom(15); + //background_control_panel_gradientpopup->set("margin_bottom", 15); + + background_control_panel_gradientpopup->set_rect_position(Vector2(4, 0)); + //background_control_panel_gradientpopup->set("rect_position", Vector2(4, 0)); + + background_control_panel_gradientpopup->set_rect_global_position(Vector2(4, 0)); + //background_control_panel_gradientpopup->set("rect_global_position", Vector2(4, 0)); + + background_control_panel_gradientpopup->set_rect_size(Vector2(0, 15)); + //background_control_panel_gradientpopup->set("rect_size", Vector2(0, 15)); + + background_control_panel_gradientpopup->set_rect_min_size(Vector2(112, 17)); + //background_control_panel_gradientpopup->set("rect_min_size", Vector2(112, 17)); + + background_control_panel_gradientpopup->set_mouse_filter(2); + //background_control_panel_gradientpopup->set("mouse_filter", 2); + + //background_control_panel_gradientpopup property __meta__ TYPE_DICTIONARY value: {_edit_use_anchors_:False} + + TextureRect *gradient_control_panel_gradientpopup = memnew(TextureRect); + gradient_control_panel_gradientpopup->set_name("Gradient"); + control_panel_gradientpopup->add_child(gradient_control_panel_gradientpopup); + + gradient_control_panel_gradientpopup->set_name("Gradient"); + //gradient_control_panel_gradientpopup->set("name", Gradient)); + + //gradient_control_panel_gradientpopup property owner TYPE_OBJECT value: Control:[Control:51442] + + gradient_control_panel_gradientpopup->set_anchor_right(1); + //gradient_control_panel_gradientpopup->set("anchor_right", 1); + + gradient_control_panel_gradientpopup->set_margin_left(4); + //gradient_control_panel_gradientpopup->set("margin_left", 4); + + gradient_control_panel_gradientpopup->set_margin_right(-4); + //gradient_control_panel_gradientpopup->set("margin_right", -4); + + gradient_control_panel_gradientpopup->set_margin_bottom(15); + //gradient_control_panel_gradientpopup->set("margin_bottom", 15); + + gradient_control_panel_gradientpopup->set_rect_position(Vector2(4, 0)); + //gradient_control_panel_gradientpopup->set("rect_position", Vector2(4, 0)); + + gradient_control_panel_gradientpopup->set_rect_global_position(Vector2(4, 0)); + //gradient_control_panel_gradientpopup->set("rect_global_position", Vector2(4, 0)); + + gradient_control_panel_gradientpopup->set_rect_size(Vector2(0, 15)); + //gradient_control_panel_gradientpopup->set("rect_size", Vector2(0, 15)); + + gradient_control_panel_gradientpopup->set_rect_min_size(Vector2(112, 17)); + //gradient_control_panel_gradientpopup->set("rect_min_size", Vector2(112, 17)); + + gradient_control_panel_gradientpopup->set_mouse_filter(2); + //gradient_control_panel_gradientpopup->set("mouse_filter", 2); + + //gradient_control_panel_gradientpopup property theme TYPE_OBJECT value: [Theme:19167] + Ref gradient_control_panel_gradientpopup_prop_theme; + gradient_control_panel_gradientpopup_prop_theme.instance(); + gradient_control_panel_gradientpopup->set_theme(gradient_control_panel_gradientpopup_prop_theme); + //gradient_control_panel_gradientpopup->set("theme", gradient_control_panel_gradientpopup_prop_theme); + + //gradient_control_panel_gradientpopup property __meta__ TYPE_DICTIONARY value: {_edit_use_anchors_:False} + + OptionButton *interpolation_control_panel_gradientpopup = memnew(OptionButton); + interpolation_control_panel_gradientpopup->set_name("Interpolation"); + control_panel_gradientpopup->add_child(interpolation_control_panel_gradientpopup); + + interpolation_control_panel_gradientpopup->set_name("Interpolation"); + //interpolation_control_panel_gradientpopup->set("name", Interpolation)); + + //interpolation_control_panel_gradientpopup property owner TYPE_OBJECT value: Control:[Control:51442] + + interpolation_control_panel_gradientpopup->set_margin_left(0.418457); + //interpolation_control_panel_gradientpopup->set("margin_left", 0.418457); + + interpolation_control_panel_gradientpopup->set_margin_top(-2.90374); + //interpolation_control_panel_gradientpopup->set("margin_top", -2.90374); + + interpolation_control_panel_gradientpopup->set_margin_right(73.418503); + //interpolation_control_panel_gradientpopup->set("margin_right", 73.418503); + + interpolation_control_panel_gradientpopup->set_margin_bottom(19.0963); + //interpolation_control_panel_gradientpopup->set("margin_bottom", 19.0963); + + interpolation_control_panel_gradientpopup->set_rect_position(Vector2(0.418457, -2.90374)); + //interpolation_control_panel_gradientpopup->set("rect_position", Vector2(0.418457, -2.90374)); + + interpolation_control_panel_gradientpopup->set_rect_global_position(Vector2(0.418457, -2.90374)); + //interpolation_control_panel_gradientpopup->set("rect_global_position", Vector2(0.418457, -2.90374)); + + interpolation_control_panel_gradientpopup->set_rect_size(Vector2(73.000046, 22.00004)); + //interpolation_control_panel_gradientpopup->set("rect_size", Vector2(73.000046, 22.00004)); + + interpolation_control_panel_gradientpopup->set_rect_scale(Vector2(0.5, 0.5)); + //interpolation_control_panel_gradientpopup->set("rect_scale", Vector2(0.5, 0.5)); + + //interpolation_control_panel_gradientpopup property icon TYPE_OBJECT value: [AtlasTexture:19168] + Ref interpolation_control_panel_gradientpopup_prop_icon; + interpolation_control_panel_gradientpopup_prop_icon.instance(); + interpolation_control_panel_gradientpopup->set_icon(interpolation_control_panel_gradientpopup_prop_icon); + //interpolation_control_panel_gradientpopup->set("icon", interpolation_control_panel_gradientpopup_prop_icon); + + //interpolation_control_panel_gradientpopup property items TYPE_ARRAY value: [, [AtlasTexture:19169], False, 0, Null, , [AtlasTexture:19168], False, 1, Null, , [AtlasTexture:19170], False, 2, Null, , [AtlasTexture:19171], False, 3, Null] + + interpolation_control_panel_gradientpopup->set_selected(1); + //interpolation_control_panel_gradientpopup->set("selected", 1); + + PopupMenu *popupmenu_interpolation_control_panel_gradientpopup = memnew(PopupMenu); + popupmenu_interpolation_control_panel_gradientpopup->set_name("PopupMenu"); + interpolation_control_panel_gradientpopup->add_child(popupmenu_interpolation_control_panel_gradientpopup); + + popupmenu_interpolation_control_panel_gradientpopup->set_name("PopupMenu"); + //popupmenu_interpolation_control_panel_gradientpopup->set("name", PopupMenu)); + + popupmenu_interpolation_control_panel_gradientpopup->set_input_pass_on_modal_close_click(False); + //popupmenu_interpolation_control_panel_gradientpopup->set("input_pass_on_modal_close_click", False); + + //popupmenu_interpolation_control_panel_gradientpopup property items TYPE_ARRAY value: [, [AtlasTexture:19169], 2, False, False, 0, 0, Null, , False, , [AtlasTexture:19168], 2, True, False, 1, 0, Null, , False, , [AtlasTexture:19170], 2, False, False, 2, 0, Null, , False, , [AtlasTexture:19171], 2, False, False, 3, 0, Null, , False] + + popupmenu_interpolation_control_panel_gradientpopup->set_allow_search(True); + //popupmenu_interpolation_control_panel_gradientpopup->set("allow_search", True); + + Timer *timer_popupmenu_interpolation_control_panel_gradientpopup = memnew(Timer); + timer_popupmenu_interpolation_control_panel_gradientpopup->set_name("Timer"); + popupmenu_interpolation_control_panel_gradientpopup->add_child(timer_popupmenu_interpolation_control_panel_gradientpopup); + + timer_popupmenu_interpolation_control_panel_gradientpopup->set_name("Timer"); + //timer_popupmenu_interpolation_control_panel_gradientpopup->set("name", Timer)); + + timer_popupmenu_interpolation_control_panel_gradientpopup->set_wait_time(0.3); + //timer_popupmenu_interpolation_control_panel_gradientpopup->set("wait_time", 0.3); + + timer_popupmenu_interpolation_control_panel_gradientpopup->set_one_shot(True); + //timer_popupmenu_interpolation_control_panel_gradientpopup->set("one_shot", True); + + Label *value_control_panel_gradientpopup = memnew(Label); + value_control_panel_gradientpopup->set_name("Value"); + control_panel_gradientpopup->add_child(value_control_panel_gradientpopup); + + value_control_panel_gradientpopup->set_name("Value"); + //value_control_panel_gradientpopup->set("name", Value)); + + //value_control_panel_gradientpopup property owner TYPE_OBJECT value: Control:[Control:51442] + + value_control_panel_gradientpopup->set_anchor_right(1); + //value_control_panel_gradientpopup->set("anchor_right", 1); + + value_control_panel_gradientpopup->set_margin_top(-1); + //value_control_panel_gradientpopup->set("margin_top", -1); + + value_control_panel_gradientpopup->set_margin_bottom(14); + //value_control_panel_gradientpopup->set("margin_bottom", 14); + + value_control_panel_gradientpopup->set_rect_position(Vector2(0, -1)); + //value_control_panel_gradientpopup->set("rect_position", Vector2(0, -1)); + + value_control_panel_gradientpopup->set_rect_global_position(Vector2(0, -1)); + //value_control_panel_gradientpopup->set("rect_global_position", Vector2(0, -1)); + + value_control_panel_gradientpopup->set_rect_size(Vector2(0, 15)); + //value_control_panel_gradientpopup->set("rect_size", Vector2(0, 15)); + + value_control_panel_gradientpopup->set_custom_colors / font_color(Color(1, 1, 1, 1)); + //value_control_panel_gradientpopup->set("custom_colors/font_color", Color(1, 1, 1, 1)); + + value_control_panel_gradientpopup->set_custom_colors / font_color_shadow(Color(0, 0, 0, 1)); + //value_control_panel_gradientpopup->set("custom_colors/font_color_shadow", Color(0, 0, 0, 1)); + + value_control_panel_gradientpopup->set_custom_constants / shadow_offset_x(1); + //value_control_panel_gradientpopup->set("custom_constants/shadow_offset_x", 1); + + value_control_panel_gradientpopup->set_custom_constants / shadow_offset_y(1); + //value_control_panel_gradientpopup->set("custom_constants/shadow_offset_y", 1); + + value_control_panel_gradientpopup->set_custom_constants / shadow_as_outline(1); + //value_control_panel_gradientpopup->set("custom_constants/shadow_as_outline", 1); + + value_control_panel_gradientpopup->set_align(1); + //value_control_panel_gradientpopup->set("align", 1); + + //value_control_panel_gradientpopup property __meta__ TYPE_DICTIONARY value: {_edit_use_anchors_:False} } - GradientPopup::GradientPopup() { - } - - GradientPopup::~GradientPopup() { - } - - - static void GradientPopup::_bind_methods() { - ClassDB::bind_method(D_METHOD("init", "value", " graph_node", " undo_redo"), &GradientPopup::init); - ClassDB::bind_method(D_METHOD("_on_Control_updated", "value"), &GradientPopup::_on_Control_updated); - ClassDB::bind_method(D_METHOD("_on_GradientPopup_popup_hide"), &GradientPopup::_on_GradientPopup_popup_hide); - - } - - +GradientPopup::~GradientPopup() { +} +static void GradientPopup::_bind_methods() { + ClassDB::bind_method(D_METHOD("init", "value", " graph_node", " undo_redo"), &GradientPopup::init); + ClassDB::bind_method(D_METHOD("_on_Control_updated", "value"), &GradientPopup::_on_Control_updated); + ClassDB::bind_method(D_METHOD("_on_GradientPopup_popup_hide"), &GradientPopup::_on_GradientPopup_popup_hide); +} diff --git a/modules/material_maker/editor/widgets/gradient_editor/gradient_popup.ctscn b/modules/material_maker/editor/widgets/gradient_editor/gradient_popup.ctscn deleted file mode 100644 index e03f703e7..000000000 --- a/modules/material_maker/editor/widgets/gradient_editor/gradient_popup.ctscn +++ /dev/null @@ -1,325 +0,0 @@ - -void construct() { - -//Script: res://addons/mat_maker_gd/widgets/gradient_editor/gradient_popup.gd -Popup *gradientpopup = memnew(Popup); -gradientpopup->set_name("GradientPopup"); - -gradientpopup->set_name("GradientPopup"); -//gradientpopup->set("name", GradientPopup)); - -gradientpopup->set_filename("res://addons/mat_maker_gd/widgets/gradient_editor/gradient_popup.tscn"); -//gradientpopup->set("filename", "res://addons/mat_maker_gd/widgets/gradient_editor/gradient_popup.tscn"); - -gradientpopup->set_margin_right(632); -//gradientpopup->set("margin_right", 632); - -gradientpopup->set_margin_bottom(49); -//gradientpopup->set("margin_bottom", 49); - -gradientpopup->set_rect_size(Vector2(632, 49)); -//gradientpopup->set("rect_size", Vector2(632, 49)); - -gradientpopup->set_size_flags_horizontal(0); -//gradientpopup->set("size_flags_horizontal", 0); - -gradientpopup->set_size_flags_vertical(0); -//gradientpopup->set("size_flags_vertical", 0); - - - -Panel *panel_gradientpopup = memnew(Panel); -panel_gradientpopup->set_name("Panel"); -gradientpopup->add_child(panel_gradientpopup); - -panel_gradientpopup->set_name("Panel"); -//panel_gradientpopup->set("name", Panel)); - -//panel_gradientpopup property owner TYPE_OBJECT value: GradientPopup:[Popup:51440] - -panel_gradientpopup->set_margin_right(632); -//panel_gradientpopup->set("margin_right", 632); - -panel_gradientpopup->set_margin_bottom(49); -//panel_gradientpopup->set("margin_bottom", 49); - -panel_gradientpopup->set_rect_size(Vector2(632, 49)); -//panel_gradientpopup->set("rect_size", Vector2(632, 49)); - -//panel_gradientpopup property custom_styles/panel TYPE_OBJECT value: [StyleBoxFlat:51436] -Ref panel_gradientpopup_prop_custom_styles/panel; -panel_gradientpopup_prop_custom_styles/panel.instance(); -panel_gradientpopup->set_custom_styles/panel(panel_gradientpopup_prop_custom_styles/panel); -//panel_gradientpopup->set("custom_styles/panel", panel_gradientpopup_prop_custom_styles/panel); - - - -//Script: res://addons/mat_maker_gd/widgets/gradient_editor/gradient_editor.gd -Control *control_panel_gradientpopup = memnew(Control); -control_panel_gradientpopup->set_name("Control"); -panel_gradientpopup->add_child(control_panel_gradientpopup); - -control_panel_gradientpopup->set_name("Control"); -//control_panel_gradientpopup->set("name", Control)); - -control_panel_gradientpopup->set_filename("res://addons/mat_maker_gd/widgets/gradient_editor/gradient_editor.tscn"); -//control_panel_gradientpopup->set("filename", "res://addons/mat_maker_gd/widgets/gradient_editor/gradient_editor.tscn"); - -//control_panel_gradientpopup property owner TYPE_OBJECT value: GradientPopup:[Popup:51440] - -control_panel_gradientpopup->set_anchor_right(1); -//control_panel_gradientpopup->set("anchor_right", 1); - -control_panel_gradientpopup->set_anchor_bottom(1); -//control_panel_gradientpopup->set("anchor_bottom", 1); - -control_panel_gradientpopup->set_margin_left(10); -//control_panel_gradientpopup->set("margin_left", 10); - -control_panel_gradientpopup->set_margin_top(10); -//control_panel_gradientpopup->set("margin_top", 10); - -control_panel_gradientpopup->set_margin_right(-10); -//control_panel_gradientpopup->set("margin_right", -10); - -control_panel_gradientpopup->set_margin_bottom(-10); -//control_panel_gradientpopup->set("margin_bottom", -10); - -control_panel_gradientpopup->set_rect_position(Vector2(10, 10)); -//control_panel_gradientpopup->set("rect_position", Vector2(10, 10)); - -control_panel_gradientpopup->set_rect_global_position(Vector2(10, 10)); -//control_panel_gradientpopup->set("rect_global_position", Vector2(10, 10)); - -control_panel_gradientpopup->set_rect_min_size(Vector2(120, 32)); -//control_panel_gradientpopup->set("rect_min_size", Vector2(120, 32)); - -control_panel_gradientpopup->set_focus_mode(1); -//control_panel_gradientpopup->set("focus_mode", 1); - -control_panel_gradientpopup->set_embedded(False); -//control_panel_gradientpopup->set("embedded", False); - - - -ColorRect *background_control_panel_gradientpopup = memnew(ColorRect); -background_control_panel_gradientpopup->set_name("Background"); -control_panel_gradientpopup->add_child(background_control_panel_gradientpopup); - -background_control_panel_gradientpopup->set_name("Background"); -//background_control_panel_gradientpopup->set("name", Background)); - -//background_control_panel_gradientpopup property owner TYPE_OBJECT value: Control:[Control:51442] - -//background_control_panel_gradientpopup property material TYPE_OBJECT value: [ShaderMaterial:19166] -Ref background_control_panel_gradientpopup_prop_material; -background_control_panel_gradientpopup_prop_material.instance(); -background_control_panel_gradientpopup->set_material(background_control_panel_gradientpopup_prop_material); -//background_control_panel_gradientpopup->set("material", background_control_panel_gradientpopup_prop_material); - -background_control_panel_gradientpopup->set_anchor_right(1); -//background_control_panel_gradientpopup->set("anchor_right", 1); - -background_control_panel_gradientpopup->set_margin_left(4); -//background_control_panel_gradientpopup->set("margin_left", 4); - -background_control_panel_gradientpopup->set_margin_right(-4); -//background_control_panel_gradientpopup->set("margin_right", -4); - -background_control_panel_gradientpopup->set_margin_bottom(15); -//background_control_panel_gradientpopup->set("margin_bottom", 15); - -background_control_panel_gradientpopup->set_rect_position(Vector2(4, 0)); -//background_control_panel_gradientpopup->set("rect_position", Vector2(4, 0)); - -background_control_panel_gradientpopup->set_rect_global_position(Vector2(4, 0)); -//background_control_panel_gradientpopup->set("rect_global_position", Vector2(4, 0)); - -background_control_panel_gradientpopup->set_rect_size(Vector2(0, 15)); -//background_control_panel_gradientpopup->set("rect_size", Vector2(0, 15)); - -background_control_panel_gradientpopup->set_rect_min_size(Vector2(112, 17)); -//background_control_panel_gradientpopup->set("rect_min_size", Vector2(112, 17)); - -background_control_panel_gradientpopup->set_mouse_filter(2); -//background_control_panel_gradientpopup->set("mouse_filter", 2); - -//background_control_panel_gradientpopup property __meta__ TYPE_DICTIONARY value: {_edit_use_anchors_:False} - - - -TextureRect *gradient_control_panel_gradientpopup = memnew(TextureRect); -gradient_control_panel_gradientpopup->set_name("Gradient"); -control_panel_gradientpopup->add_child(gradient_control_panel_gradientpopup); - -gradient_control_panel_gradientpopup->set_name("Gradient"); -//gradient_control_panel_gradientpopup->set("name", Gradient)); - -//gradient_control_panel_gradientpopup property owner TYPE_OBJECT value: Control:[Control:51442] - -gradient_control_panel_gradientpopup->set_anchor_right(1); -//gradient_control_panel_gradientpopup->set("anchor_right", 1); - -gradient_control_panel_gradientpopup->set_margin_left(4); -//gradient_control_panel_gradientpopup->set("margin_left", 4); - -gradient_control_panel_gradientpopup->set_margin_right(-4); -//gradient_control_panel_gradientpopup->set("margin_right", -4); - -gradient_control_panel_gradientpopup->set_margin_bottom(15); -//gradient_control_panel_gradientpopup->set("margin_bottom", 15); - -gradient_control_panel_gradientpopup->set_rect_position(Vector2(4, 0)); -//gradient_control_panel_gradientpopup->set("rect_position", Vector2(4, 0)); - -gradient_control_panel_gradientpopup->set_rect_global_position(Vector2(4, 0)); -//gradient_control_panel_gradientpopup->set("rect_global_position", Vector2(4, 0)); - -gradient_control_panel_gradientpopup->set_rect_size(Vector2(0, 15)); -//gradient_control_panel_gradientpopup->set("rect_size", Vector2(0, 15)); - -gradient_control_panel_gradientpopup->set_rect_min_size(Vector2(112, 17)); -//gradient_control_panel_gradientpopup->set("rect_min_size", Vector2(112, 17)); - -gradient_control_panel_gradientpopup->set_mouse_filter(2); -//gradient_control_panel_gradientpopup->set("mouse_filter", 2); - -//gradient_control_panel_gradientpopup property theme TYPE_OBJECT value: [Theme:19167] -Ref gradient_control_panel_gradientpopup_prop_theme; -gradient_control_panel_gradientpopup_prop_theme.instance(); -gradient_control_panel_gradientpopup->set_theme(gradient_control_panel_gradientpopup_prop_theme); -//gradient_control_panel_gradientpopup->set("theme", gradient_control_panel_gradientpopup_prop_theme); - -//gradient_control_panel_gradientpopup property __meta__ TYPE_DICTIONARY value: {_edit_use_anchors_:False} - - - -OptionButton *interpolation_control_panel_gradientpopup = memnew(OptionButton); -interpolation_control_panel_gradientpopup->set_name("Interpolation"); -control_panel_gradientpopup->add_child(interpolation_control_panel_gradientpopup); - -interpolation_control_panel_gradientpopup->set_name("Interpolation"); -//interpolation_control_panel_gradientpopup->set("name", Interpolation)); - -//interpolation_control_panel_gradientpopup property owner TYPE_OBJECT value: Control:[Control:51442] - -interpolation_control_panel_gradientpopup->set_margin_left(0.418457); -//interpolation_control_panel_gradientpopup->set("margin_left", 0.418457); - -interpolation_control_panel_gradientpopup->set_margin_top(-2.90374); -//interpolation_control_panel_gradientpopup->set("margin_top", -2.90374); - -interpolation_control_panel_gradientpopup->set_margin_right(73.418503); -//interpolation_control_panel_gradientpopup->set("margin_right", 73.418503); - -interpolation_control_panel_gradientpopup->set_margin_bottom(19.0963); -//interpolation_control_panel_gradientpopup->set("margin_bottom", 19.0963); - -interpolation_control_panel_gradientpopup->set_rect_position(Vector2(0.418457, -2.90374)); -//interpolation_control_panel_gradientpopup->set("rect_position", Vector2(0.418457, -2.90374)); - -interpolation_control_panel_gradientpopup->set_rect_global_position(Vector2(0.418457, -2.90374)); -//interpolation_control_panel_gradientpopup->set("rect_global_position", Vector2(0.418457, -2.90374)); - -interpolation_control_panel_gradientpopup->set_rect_size(Vector2(73.000046, 22.00004)); -//interpolation_control_panel_gradientpopup->set("rect_size", Vector2(73.000046, 22.00004)); - -interpolation_control_panel_gradientpopup->set_rect_scale(Vector2(0.5, 0.5)); -//interpolation_control_panel_gradientpopup->set("rect_scale", Vector2(0.5, 0.5)); - -//interpolation_control_panel_gradientpopup property icon TYPE_OBJECT value: [AtlasTexture:19168] -Ref interpolation_control_panel_gradientpopup_prop_icon; -interpolation_control_panel_gradientpopup_prop_icon.instance(); -interpolation_control_panel_gradientpopup->set_icon(interpolation_control_panel_gradientpopup_prop_icon); -//interpolation_control_panel_gradientpopup->set("icon", interpolation_control_panel_gradientpopup_prop_icon); - -//interpolation_control_panel_gradientpopup property items TYPE_ARRAY value: [, [AtlasTexture:19169], False, 0, Null, , [AtlasTexture:19168], False, 1, Null, , [AtlasTexture:19170], False, 2, Null, , [AtlasTexture:19171], False, 3, Null] - -interpolation_control_panel_gradientpopup->set_selected(1); -//interpolation_control_panel_gradientpopup->set("selected", 1); - - - -PopupMenu *popupmenu_interpolation_control_panel_gradientpopup = memnew(PopupMenu); -popupmenu_interpolation_control_panel_gradientpopup->set_name("PopupMenu"); -interpolation_control_panel_gradientpopup->add_child(popupmenu_interpolation_control_panel_gradientpopup); - -popupmenu_interpolation_control_panel_gradientpopup->set_name("PopupMenu"); -//popupmenu_interpolation_control_panel_gradientpopup->set("name", PopupMenu)); - -popupmenu_interpolation_control_panel_gradientpopup->set_input_pass_on_modal_close_click(False); -//popupmenu_interpolation_control_panel_gradientpopup->set("input_pass_on_modal_close_click", False); - -//popupmenu_interpolation_control_panel_gradientpopup property items TYPE_ARRAY value: [, [AtlasTexture:19169], 2, False, False, 0, 0, Null, , False, , [AtlasTexture:19168], 2, True, False, 1, 0, Null, , False, , [AtlasTexture:19170], 2, False, False, 2, 0, Null, , False, , [AtlasTexture:19171], 2, False, False, 3, 0, Null, , False] - -popupmenu_interpolation_control_panel_gradientpopup->set_allow_search(True); -//popupmenu_interpolation_control_panel_gradientpopup->set("allow_search", True); - - - -Timer *timer_popupmenu_interpolation_control_panel_gradientpopup = memnew(Timer); -timer_popupmenu_interpolation_control_panel_gradientpopup->set_name("Timer"); -popupmenu_interpolation_control_panel_gradientpopup->add_child(timer_popupmenu_interpolation_control_panel_gradientpopup); - -timer_popupmenu_interpolation_control_panel_gradientpopup->set_name("Timer"); -//timer_popupmenu_interpolation_control_panel_gradientpopup->set("name", Timer)); - -timer_popupmenu_interpolation_control_panel_gradientpopup->set_wait_time(0.3); -//timer_popupmenu_interpolation_control_panel_gradientpopup->set("wait_time", 0.3); - -timer_popupmenu_interpolation_control_panel_gradientpopup->set_one_shot(True); -//timer_popupmenu_interpolation_control_panel_gradientpopup->set("one_shot", True); - - - -Label *value_control_panel_gradientpopup = memnew(Label); -value_control_panel_gradientpopup->set_name("Value"); -control_panel_gradientpopup->add_child(value_control_panel_gradientpopup); - -value_control_panel_gradientpopup->set_name("Value"); -//value_control_panel_gradientpopup->set("name", Value)); - -//value_control_panel_gradientpopup property owner TYPE_OBJECT value: Control:[Control:51442] - -value_control_panel_gradientpopup->set_anchor_right(1); -//value_control_panel_gradientpopup->set("anchor_right", 1); - -value_control_panel_gradientpopup->set_margin_top(-1); -//value_control_panel_gradientpopup->set("margin_top", -1); - -value_control_panel_gradientpopup->set_margin_bottom(14); -//value_control_panel_gradientpopup->set("margin_bottom", 14); - -value_control_panel_gradientpopup->set_rect_position(Vector2(0, -1)); -//value_control_panel_gradientpopup->set("rect_position", Vector2(0, -1)); - -value_control_panel_gradientpopup->set_rect_global_position(Vector2(0, -1)); -//value_control_panel_gradientpopup->set("rect_global_position", Vector2(0, -1)); - -value_control_panel_gradientpopup->set_rect_size(Vector2(0, 15)); -//value_control_panel_gradientpopup->set("rect_size", Vector2(0, 15)); - -value_control_panel_gradientpopup->set_custom_colors/font_color(Color(1, 1, 1, 1)); -//value_control_panel_gradientpopup->set("custom_colors/font_color", Color(1, 1, 1, 1)); - -value_control_panel_gradientpopup->set_custom_colors/font_color_shadow(Color(0, 0, 0, 1)); -//value_control_panel_gradientpopup->set("custom_colors/font_color_shadow", Color(0, 0, 0, 1)); - -value_control_panel_gradientpopup->set_custom_constants/shadow_offset_x(1); -//value_control_panel_gradientpopup->set("custom_constants/shadow_offset_x", 1); - -value_control_panel_gradientpopup->set_custom_constants/shadow_offset_y(1); -//value_control_panel_gradientpopup->set("custom_constants/shadow_offset_y", 1); - -value_control_panel_gradientpopup->set_custom_constants/shadow_as_outline(1); -//value_control_panel_gradientpopup->set("custom_constants/shadow_as_outline", 1); - -value_control_panel_gradientpopup->set_align(1); -//value_control_panel_gradientpopup->set("align", 1); - -//value_control_panel_gradientpopup property __meta__ TYPE_DICTIONARY value: {_edit_use_anchors_:False} - - - - -}