mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-23 04:16:50 +01:00
More cleanups to the gradient editor.
This commit is contained in:
parent
f21019adab
commit
dbca350602
@ -95,8 +95,8 @@ 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::sort(GradientCursor *a, const GradientCursor *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 {
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
|
||||
float get_cursor_position();
|
||||
|
||||
static bool sort(const Variant &a, const Variant &b);
|
||||
static bool sort(GradientCursor *a, GradientCursor *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);
|
||||
|
@ -1,20 +1,28 @@
|
||||
|
||||
#include "gradient_editor.h"
|
||||
|
||||
Variant GradientEditor::get_Variant() {
|
||||
return Variant;
|
||||
#include "../../../nodes/bases/gradient_base.h"
|
||||
#include "../../mm_graph_node.h"
|
||||
|
||||
#include "scene/gui/color_rect.h"
|
||||
#include "scene/gui/label.h"
|
||||
#include "scene/gui/option_button.h"
|
||||
#include "scene/resources/material.h"
|
||||
|
||||
MMGraphNode *GradientEditor::get_graph_node() {
|
||||
return graph_node;
|
||||
}
|
||||
|
||||
void GradientEditor::set_Variant(const Variant &val) {
|
||||
Variant = val;
|
||||
void GradientEditor::set_graph_node(MMGraphNode *val) {
|
||||
graph_node = val;
|
||||
}
|
||||
|
||||
Variant GradientEditor::get_Variant() {
|
||||
return Variant;
|
||||
Ref<GradientBase> GradientEditor::get_value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
void GradientEditor::set_Variant(const Variant &val) {
|
||||
Variant = val;
|
||||
void GradientEditor::set_value(const Ref<GradientBase> &val) {
|
||||
value = val;
|
||||
}
|
||||
|
||||
bool GradientEditor::get_embedded() const {
|
||||
@ -25,58 +33,58 @@ void GradientEditor::set_embedded(const bool 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(UndoRedo *val) {
|
||||
_undo_redo = val;
|
||||
}
|
||||
|
||||
PoolRealArray GradientEditor::get__saved_points() {
|
||||
PoolRealArray GradientEditor::get_saved_points() {
|
||||
return _saved_points;
|
||||
}
|
||||
|
||||
void GradientEditor::set__saved_points(const PoolRealArray &val) {
|
||||
void GradientEditor::set_saved_points(const PoolRealArray &val) {
|
||||
_saved_points = val;
|
||||
}
|
||||
|
||||
Variant GradientEditor::get_Variant() {
|
||||
return Variant;
|
||||
GradientCursor *GradientEditor::get_active_cursor() {
|
||||
return active_cursor;
|
||||
}
|
||||
|
||||
void GradientEditor::set_Variant(const Variant &val) {
|
||||
Variant = val;
|
||||
void GradientEditor::set_active_cursor(GradientCursor *val) {
|
||||
active_cursor = val;
|
||||
}
|
||||
|
||||
void GradientEditor::_init() {
|
||||
connect("resized", self, "on_resized");
|
||||
connect("resized", this, "on_resized");
|
||||
}
|
||||
|
||||
void GradientEditor::ignore_changes(const Variant &val) {
|
||||
graph_node.ignore_changes(val);
|
||||
void GradientEditor::ignore_changes(const bool val) {
|
||||
graph_node->ignore_changes(val);
|
||||
}
|
||||
|
||||
void GradientEditor::save_color_state() {
|
||||
PoolRealArray p = value.points;
|
||||
PoolRealArray p = value->get_points();
|
||||
_saved_points.resize(0);
|
||||
|
||||
for (v in p) {
|
||||
_saved_points.push_back(v);
|
||||
for (int i = 0; i < p.size(); ++i) {
|
||||
_saved_points.push_back(p[i]);
|
||||
}
|
||||
|
||||
ignore_changes(true);
|
||||
}
|
||||
|
||||
void GradientEditor::undo_redo_save_color_state() {
|
||||
PoolRealArray op = ;
|
||||
PoolRealArray np = ;
|
||||
PoolRealArray op;
|
||||
PoolRealArray np;
|
||||
|
||||
for (v in _saved_points) {
|
||||
op.push_back(v);
|
||||
for (int i = 0; i < _saved_points.size(); ++i) {
|
||||
op.push_back(_saved_points[i]);
|
||||
}
|
||||
|
||||
for (v in value.get_points()) {
|
||||
for (v in value->get_points()) {
|
||||
np.push_back(v);
|
||||
}
|
||||
|
||||
@ -91,31 +99,6 @@ 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();
|
||||
@ -166,32 +149,32 @@ void GradientEditor::add_cursor(const Variant &x, const Variant &color) {
|
||||
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);
|
||||
void GradientEditor::_gui_input(const Ref<InputEvent> &ev) {
|
||||
Ref<InputEventMouseButton> iemb = ev;
|
||||
|
||||
if (iemb.is_valid() && ev->get_button_index() == 1 && iemb->get_doubleclick()) {
|
||||
if (iemb->get_position().y > 15) {
|
||||
Variant = clamp(iemb->get_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();
|
||||
} else if (embedded) {
|
||||
GradientPopup *popup = memnew(GradientPopup);
|
||||
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");
|
||||
Vector2 popup_size = popup->get_size();
|
||||
popup->popup(Rect2(ev->get_global_position(), Vector2(0, 0)));
|
||||
popup->set_global_position(ev->get_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;
|
||||
}
|
||||
}
|
||||
|
||||
void GradientEditor::select_color(const Variant &cursor, const Variant &position) {
|
||||
void GradientEditor::select_color(const GradientCursor *cursor, const Vector2 &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);
|
||||
@ -222,8 +205,8 @@ Array GradientEditor::get_sorted_cursors() {
|
||||
void GradientEditor::generate_preview_image() {
|
||||
Ref<ImageTexture> tex = $Gradient.texture;
|
||||
|
||||
if (!tex) {
|
||||
tex = ImageTexture.new();
|
||||
if (!tex.is_valid()) {
|
||||
tex.instance();
|
||||
$Gradient.texture = tex;
|
||||
}
|
||||
|
||||
@ -231,159 +214,176 @@ void GradientEditor::generate_preview_image() {
|
||||
float w = $Gradient.rect_size.x;
|
||||
float h = $Gradient.rect_size.y;
|
||||
|
||||
if (!img) {
|
||||
img = Image.new();
|
||||
if (!img.is_valid()) {
|
||||
img = memnew(Image);
|
||||
}
|
||||
|
||||
if (img.get_size().x != w || img.get_size().y != h) {
|
||||
img.create(w, h, false, Image.FORMAT_RGBA8);
|
||||
if (img->get_size().x != w || img.get_size().y != h) {
|
||||
img->create(w, h, false, Image.FORMAT_RGBA8);
|
||||
}
|
||||
|
||||
img.lock();
|
||||
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);
|
||||
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->set_pixel(i, j, col);
|
||||
}
|
||||
}
|
||||
|
||||
img.unlock();
|
||||
tex.create_from_image(img, 0);
|
||||
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));
|
||||
Color GradientEditor::get_gradient_color(const float x) {
|
||||
return value->get_gradient_color(x / (get_size().x - GradientCursor->WIDTH));
|
||||
}
|
||||
|
||||
void GradientEditor::update_preview() {
|
||||
call_deferred("generate_preview_image");
|
||||
}
|
||||
|
||||
void GradientEditor::_on_Interpolation_item_selected(const Variant &ID) {
|
||||
void GradientEditor::_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, "set_interpolation_type", ID);
|
||||
_undo_redo.add_undo_method(value, "set_interpolation_type", value.interpolation_type);
|
||||
_undo_redo.add_undo_method(value, "set_interpolation_type", value->get_interpolation_type());
|
||||
_undo_redo.commit_action();
|
||||
ignore_changes(false);
|
||||
update_preview();
|
||||
}
|
||||
|
||||
void GradientEditor::on_resized() {
|
||||
if (value) {
|
||||
if (value.is_valid()) {
|
||||
update_preview();
|
||||
call_deferred("update_cursors");
|
||||
}
|
||||
}
|
||||
|
||||
GradientEditor::GradientEditor() {
|
||||
= null;
|
||||
= null;
|
||||
embedded = true;
|
||||
*_undo_redo = null;
|
||||
_saved_points = PoolRealArray();
|
||||
graph_node = nullptr;
|
||||
embedded = false;
|
||||
_undo_redo = nullptr;
|
||||
active_cursor = nullptr;
|
||||
|
||||
Control *control = memnew(Control);
|
||||
control->set_name("Control");
|
||||
control->set_rect_min_size(Vector2(120, 32));
|
||||
control->set_focus_mode(1);
|
||||
set_custom_minimum_size(Vector2(120, 32));
|
||||
set_focus_mode(FOCUS_CLICK);
|
||||
|
||||
ColorRect *background_control = memnew(ColorRect);
|
||||
background_control->set_name("Background");
|
||||
control->add_child(background_control);
|
||||
background_control->set_custom_minimum_size(Vector2(112, 17));
|
||||
background_control->set_mouse_filter(MOUSE_FILTER_IGNORE);
|
||||
|
||||
background_control->set_name("Background");
|
||||
String bg_shader_code = "shader_type canvas_item;\n"
|
||||
"\n"
|
||||
"void fragment() {\n"
|
||||
" COLOR = vec4(vec3(2.0*fract(0.5*(floor(0.12*FRAGCOORD.x)+floor(0.125*FRAGCOORD.y)))), 1.0);/n"
|
||||
"}";
|
||||
|
||||
Ref<Shader> bg_shader;
|
||||
bg_shader.instance();
|
||||
bg_shader->set_code(bg_shader_code);
|
||||
|
||||
//background_control property material TYPE_OBJECT value: [ShaderMaterial:19166]
|
||||
Ref<ShaderMaterial> background_control_prop_material;
|
||||
background_control_prop_material.instance();
|
||||
background_control_prop_material->set_shader(bg_shader_code);
|
||||
background_control->set_material(background_control_prop_material);
|
||||
background_control->set_rect_min_size(Vector2(112, 17));
|
||||
background_control->set_mouse_filter(2);
|
||||
|
||||
add_child(background_control);
|
||||
|
||||
TextureRect *gradient_control = memnew(TextureRect);
|
||||
gradient_control->set_name("Gradient");
|
||||
control->add_child(gradient_control);
|
||||
add_child(gradient_control);
|
||||
gradient_control->set_rect_min_size(Vector2(112, 17));
|
||||
gradient_control->set_mouse_filter(2);
|
||||
gradient_control->set_mouse_filter(MOUSE_FILTER_IGNORE);
|
||||
|
||||
//gradient_control property theme TYPE_OBJECT value: [Theme:19167]
|
||||
Ref<Theme> gradient_control_prop_theme;
|
||||
gradient_control_prop_theme.instance();
|
||||
gradient_control->set_theme(gradient_control_prop_theme);
|
||||
|
||||
OptionButton *interpolation_control = memnew(OptionButton);
|
||||
interpolation_control->set_name("Interpolation");
|
||||
control->add_child(interpolation_control);
|
||||
interpolation_control->set_rect_scale(Vector2(0.5, 0.5));
|
||||
|
||||
//interpolation_control property icon TYPE_OBJECT value: [AtlasTexture:19168]
|
||||
Ref<AtlasTexture> interpolation_control_prop_icon;
|
||||
interpolation_control_prop_icon.instance();
|
||||
interpolation_control->set_icon(interpolation_control_prop_icon);
|
||||
interpolation_control->add_item("0", 0);
|
||||
interpolation_control->add_item("1", 1);
|
||||
interpolation_control->add_item("2", 2);
|
||||
interpolation_control->add_item("3", 3);
|
||||
|
||||
//Ref<AtlasTexture> 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->connect("item_selected", this, "_on_Interpolation_item_selected");
|
||||
add_child(interpolation_control);
|
||||
|
||||
Label *value_control = memnew(Label);
|
||||
value_control->set_name("Value");
|
||||
control->add_child(value_control);
|
||||
value_control->set_align(ALIGN_CENTER);
|
||||
add_child(value_control);
|
||||
|
||||
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_constants / shadow_offset_x(1);
|
||||
value_control->set_custom_constants / shadow_offset_y(1);
|
||||
value_control->set_custom_constants / shadow_as_outline(1);
|
||||
value_control->set_align(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_constants/shadow_offset_x", 1);
|
||||
value_control->set("custom_constants/shadow_offset_y", 1);
|
||||
value_control->set("custom_constants/shadow_as_outline", 1);
|
||||
}
|
||||
|
||||
GradientEditor::~GradientEditor() {
|
||||
}
|
||||
|
||||
static void GradientEditor::_bind_methods() {
|
||||
signal updated(value);
|
||||
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::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("updated", PropertyInfo(Variant::OBJECT, "value", PROPERTY_HINT_RESOURCE_TYPE, "GradientBase")));
|
||||
|
||||
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_graph_node"), &GradientEditor::get_graph_node);
|
||||
//ClassDB::bind_method(D_METHOD("set_graph_node", "value"), &GradientEditor::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);
|
||||
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);
|
||||
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_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_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("get_active_cursor"), &GradientEditor::get_active_cursor);
|
||||
//ClassDB::bind_method(D_METHOD("set_active_cursor", "value"), &GradientEditor::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("_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_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);
|
||||
}
|
||||
|
@ -2,49 +2,62 @@
|
||||
#define GRADIENT_EDITOR_H
|
||||
|
||||
#include "core/color.h"
|
||||
#include "core/os/input_event.h"
|
||||
#include "core/reference.h"
|
||||
#include "core/undo_redo.h"
|
||||
#include "core/variant.h"
|
||||
|
||||
#include "scene/gui/control.h"
|
||||
|
||||
class MMGraphNode;
|
||||
class GradientBase;
|
||||
class GradientCursor;
|
||||
|
||||
class GradientEditor : public Control {
|
||||
GDCLASS(GradientEditor, Control);
|
||||
|
||||
public:
|
||||
Variant get_Variant();
|
||||
void set_Variant(const Variant &val);
|
||||
MMGraphNode *get_graph_node();
|
||||
void set_graph_node(MMGraphNode *val);
|
||||
|
||||
Variant get_Variant();
|
||||
void set_Variant(const Variant &val);
|
||||
Ref<GradientBase> get_value();
|
||||
void set_value(const Ref<GradientBase> &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(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);
|
||||
GradientCursor *get_active_cursor();
|
||||
void set_active_cursor(GradientCursor *val);
|
||||
|
||||
void _init();
|
||||
|
||||
void ignore_changes(const Variant &val);
|
||||
void ignore_changes(const bool 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);
|
||||
|
||||
void add_cursor(const float x, const Color &color);
|
||||
void _gui_input(const Ref<InputEvent> &ev);
|
||||
|
||||
void select_color(const GradientCursor *cursor, const Vector2 &position);
|
||||
|
||||
Array get_sorted_cursors();
|
||||
void generate_preview_image();
|
||||
Color get_gradient_color(const Variant &x);
|
||||
|
||||
Color get_gradient_color(const float x);
|
||||
void update_preview();
|
||||
void _on_Interpolation_item_selected(const Variant &ID);
|
||||
|
||||
void _on_Interpolation_item_selected(const int ID);
|
||||
void on_resized();
|
||||
|
||||
GradientEditor();
|
||||
@ -53,12 +66,12 @@ public:
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
Variant graph_node = null;
|
||||
Variant value = null;
|
||||
bool embedded = true;
|
||||
UndoRedo *_undo_redo = null;
|
||||
MMGraphNode *graph_node;
|
||||
Ref<GradientBase> value;
|
||||
bool embedded;
|
||||
UndoRedo *_undo_redo;
|
||||
PoolRealArray _saved_points;
|
||||
active_cursor;
|
||||
GradientCursor *active_cursor;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,333 +1,47 @@
|
||||
|
||||
#include "gradient_popup.h"
|
||||
|
||||
//tool;
|
||||
signal updated(value);
|
||||
#include "core/object.h"
|
||||
#include "gradient_editor.h"
|
||||
|
||||
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);
|
||||
#include "scene/gui/panel.h"
|
||||
|
||||
void GradientPopup::init(const Ref<GradientBase> &value, MMGraphNode *graph_node, UndoRedo &undo_redo) {
|
||||
_gradient_editor->set_undo_redo(undo_redo);
|
||||
_gradient_editor->set_graph_node(graph_node);
|
||||
_gradient_editor->set_value(value);
|
||||
}
|
||||
|
||||
void GradientPopup::_on_Control_updated(const Variant &value) {
|
||||
void GradientPopup::_on_Control_updated(const Ref<GradientBase> &value) {
|
||||
emit_signal("updated", value);
|
||||
}
|
||||
|
||||
void GradientPopup::_on_GradientPopup_popup_hide() {
|
||||
queue_free();
|
||||
}
|
||||
queue_delete();
|
||||
}
|
||||
|
||||
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);
|
||||
set_h_size_flags(0);
|
||||
set_v_size_flags(0);
|
||||
|
||||
Panel *panel_gradientpopup = memnew(Panel);
|
||||
panel_gradientpopup->set_name("Panel");
|
||||
gradientpopup->add_child(panel_gradientpopup);
|
||||
add_child(panel_gradientpopup);
|
||||
|
||||
panel_gradientpopup->set_name("Panel");
|
||||
//panel_gradientpopup->set("name", Panel));
|
||||
Ref<StyleBoxFlat> panel_gradientpopup_prop_custom_styles;
|
||||
panel_gradientpopup_prop_custom_styles.instance();
|
||||
panel_gradientpopup->set("custom_styles/panel", panel_gradientpopup_prop_custom_styles);
|
||||
|
||||
//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<StyleBoxFlat> 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<ShaderMaterial> 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<Theme> 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<AtlasTexture> 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}
|
||||
_gradient_editor = memnew(GradientEditor);
|
||||
panel_gradientpopup->add_child(_gradient_editor);
|
||||
}
|
||||
|
||||
GradientPopup::~GradientPopup() {
|
||||
}
|
||||
|
||||
static void GradientPopup::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("init", "value", " graph_node", " undo_redo"), &GradientPopup::init);
|
||||
void GradientPopup::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("updated", PropertyInfo(Variant::OBJECT, "value", PROPERTY_HINT_RESOURCE_TYPE, "GradientBase")));
|
||||
|
||||
//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);
|
||||
}
|
||||
|
@ -1,25 +1,30 @@
|
||||
#ifndef GRADIENT_POPUP_H
|
||||
#define GRADIENT_POPUP_H
|
||||
|
||||
#include "core/reference.h"
|
||||
|
||||
#include "scene/gui/popup.h"
|
||||
|
||||
class GradientBase;
|
||||
class UndoRedo;
|
||||
class MMGraphNode;
|
||||
class GradientEditor;
|
||||
|
||||
class GradientPopup : public Popup {
|
||||
GDCLASS(GradientPopup, Popup);
|
||||
GDCLASS(GradientPopup, Popup);
|
||||
|
||||
public:
|
||||
public:
|
||||
void init(const Ref<GradientBase> &value, MMGraphNode *graph_node, UndoRedo &undo_redo);
|
||||
void _on_Control_updated(const Ref<GradientBase> &value);
|
||||
void _on_GradientPopup_popup_hide();
|
||||
|
||||
void init(const Variant &value, const Variant & graph_node, const Variant & undo_redo);
|
||||
void _on_Control_updated(const Variant &value);
|
||||
void _on_GradientPopup_popup_hide();
|
||||
GradientPopup();
|
||||
~GradientPopup();
|
||||
|
||||
GradientPopup();
|
||||
~GradientPopup();
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
//tool
|
||||
signal updated(value);
|
||||
GradientEditor *_gradient_editor;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user