1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-12 13:20:55 +00:00

Add GraphFrame and integrate it in VisualShader

This commit is contained in:
Hendrik Brucker
2024-02-07 02:37:26 +01:00
parent 7a42afbba0
commit a81561cbd9
25 changed files with 1996 additions and 298 deletions

View File

@@ -42,6 +42,7 @@ class CodeEdit;
class ColorPicker;
class CurveEditor;
class GraphElement;
class GraphFrame;
class MenuButton;
class PopupPanel;
class RichTextLabel;
@@ -120,11 +121,12 @@ public:
bool is_preview_visible(int p_id) const;
void update_node(VisualShader::Type p_type, int p_id);
void update_node_deferred(VisualShader::Type p_type, int p_node_id);
void add_node(VisualShader::Type p_type, int p_id, bool p_just_update);
void add_node(VisualShader::Type p_type, int p_id, bool p_just_update, bool p_update_frames);
void remove_node(VisualShader::Type p_type, int p_id, bool p_just_update);
void connect_nodes(VisualShader::Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port);
void disconnect_nodes(VisualShader::Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port);
void show_port_preview(VisualShader::Type p_type, int p_node_id, int p_port_id, bool p_is_valid);
void update_frames(VisualShader::Type p_type, int p_node);
void set_node_position(VisualShader::Type p_type, int p_id, const Vector2 &p_position);
void refresh_node_ports(VisualShader::Type p_type, int p_node);
void set_input_port_default_value(VisualShader::Type p_type, int p_node_id, int p_port_id, const Variant &p_value);
@@ -133,9 +135,13 @@ public:
void update_curve(int p_node_id);
void update_curve_xyz(int p_node_id);
void set_expression(VisualShader::Type p_type, int p_node_id, const String &p_expression);
void attach_node_to_frame(VisualShader::Type p_type, int p_node_id, int p_frame_id);
void detach_node_from_frame(VisualShader::Type p_type, int p_node_id);
void set_frame_color_enabled(VisualShader::Type p_type, int p_node_id, bool p_enable);
void set_frame_color(VisualShader::Type p_type, int p_node_id, const Color &p_color);
void set_frame_autoshrink_enabled(VisualShader::Type p_type, int p_node_id, bool p_enable);
int get_constant_index(float p_constant) const;
Ref<Script> get_node_script(int p_node_id) const;
void update_node_size(int p_node_id);
void update_theme();
bool is_node_has_parameter_instances_relatively(VisualShader::Type p_type, int p_node) const;
VisualShader::Type get_shader_type() const;
@@ -219,11 +225,11 @@ class VisualShaderEditor : public VBoxContainer {
ConfirmationDialog *remove_varying_dialog = nullptr;
Tree *varyings = nullptr;
PopupPanel *comment_title_change_popup = nullptr;
LineEdit *comment_title_change_edit = nullptr;
PopupPanel *frame_title_change_popup = nullptr;
LineEdit *frame_title_change_edit = nullptr;
PopupPanel *comment_desc_change_popup = nullptr;
TextEdit *comment_desc_change_edit = nullptr;
PopupPanel *frame_tint_color_pick_popup = nullptr;
ColorPicker *frame_tint_color_picker = nullptr;
bool preview_first = true;
bool preview_showed = false;
@@ -281,9 +287,12 @@ class VisualShaderEditor : public VBoxContainer {
FLOAT_CONSTANTS,
CONVERT_CONSTANTS_TO_PARAMETERS,
CONVERT_PARAMETERS_TO_CONSTANTS,
UNLINK_FROM_PARENT_FRAME,
SEPARATOR3, // ignore
SET_COMMENT_TITLE,
SET_COMMENT_DESCRIPTION,
SET_FRAME_TITLE,
ENABLE_FRAME_COLOR,
SET_FRAME_COLOR,
ENABLE_FRAME_AUTOSHRINK,
};
enum ConnectionMenuOptions {
@@ -374,6 +383,9 @@ class VisualShaderEditor : public VBoxContainer {
void _get_next_nodes_recursively(VisualShader::Type p_type, int p_node_id, LocalVector<int> &r_nodes) const;
String _get_description(int p_idx);
Vector<int> nodes_link_to_frame_buffer; // Contains the nodes that are requested to be linked to a frame. This is used to perform one Undo/Redo operation for dragging nodes.
int frame_node_id_to_link_to = -1;
struct DragOp {
VisualShader::Type type = VisualShader::Type::TYPE_MAX;
int node = 0;
@@ -381,6 +393,7 @@ class VisualShaderEditor : public VBoxContainer {
Vector2 to;
};
List<DragOp> drag_buffer;
bool drag_dirty = false;
void _node_dragged(const Vector2 &p_from, const Vector2 &p_to, int p_node);
void _nodes_dragged();
@@ -398,6 +411,9 @@ class VisualShaderEditor : public VBoxContainer {
void _node_changed(int p_id);
void _nodes_linked_to_frame_request(const TypedArray<StringName> &p_nodes, const StringName &p_frame);
void _frame_rect_changed(const GraphFrame *p_frame, const Rect2 &p_new_rect);
void _edit_port_default_input(Object *p_button, int p_node, int p_port);
void _port_edited(const StringName &p_property, const Variant &p_value, const String &p_field, bool p_changing);
@@ -411,29 +427,36 @@ class VisualShaderEditor : public VBoxContainer {
HashSet<int> selected_constants;
HashSet<int> selected_parameters;
int selected_comment = -1;
int selected_frame = -1;
int selected_float_constant = -1;
void _convert_constants_to_parameters(bool p_vice_versa);
void _detach_nodes_from_frame_request();
void _detach_nodes_from_frame(int p_type, const List<int> &p_nodes);
void _replace_node(VisualShader::Type p_type_id, int p_node_id, const StringName &p_from, const StringName &p_to);
void _update_constant(VisualShader::Type p_type_id, int p_node_id, const Variant &p_var, int p_preview_port);
void _update_parameter(VisualShader::Type p_type_id, int p_node_id, const Variant &p_var, int p_preview_port);
void _unlink_node_from_parent_frame(int p_node_id);
void _connection_to_empty(const String &p_from, int p_from_slot, const Vector2 &p_release_position);
void _connection_from_empty(const String &p_to, int p_to_slot, const Vector2 &p_release_position);
bool _check_node_drop_on_connection(const Vector2 &p_position, Ref<GraphEdit::Connection> *r_closest_connection, int *r_node_id = nullptr, int *r_to_port = nullptr);
void _handle_node_drop_on_connection();
void _comment_title_popup_show(const Point2 &p_position, int p_node_id);
void _comment_title_popup_hide();
void _comment_title_popup_focus_out();
void _comment_title_text_changed(const String &p_new_text);
void _comment_title_text_submitted(const String &p_new_text);
void _frame_title_popup_show(const Point2 &p_position, int p_node_id);
void _frame_title_popup_hide();
void _frame_title_popup_focus_out();
void _frame_title_text_changed(const String &p_new_text);
void _frame_title_text_submitted(const String &p_new_text);
void _comment_desc_popup_show(const Point2 &p_position, int p_node_id);
void _comment_desc_popup_hide();
void _comment_desc_confirm();
void _comment_desc_text_changed();
void _frame_color_enabled_changed(int p_node_id);
void _frame_color_popup_show(const Point2 &p_position, int p_node_id);
void _frame_color_popup_hide();
void _frame_color_confirm();
void _frame_color_changed(const Color &p_color);
void _frame_autoshrink_enabled_changed(int p_node_id);
void _parameter_line_edit_changed(const String &p_text, int p_node_id);
void _parameter_line_edit_focus_out(Object *p_line_edit, int p_node_id);