godot/editor/plugins/visual_shader_editor_plugin.cpp

/**************************************************************************/
/*  visual_shader_editor_plugin.cpp                                       */
/**************************************************************************/
/*                         This file is part of:                          */
/*                             GODOT ENGINE                               */
/*                        https://godotengine.org                         */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.                  */
/*                                                                        */
/* Permission is hereby granted, free of charge, to any person obtaining  */
/* a copy of this software and associated documentation files (the        */
/* "Software"), to deal in the Software without restriction, including    */
/* without limitation the rights to use, copy, modify, merge, publish,    */
/* distribute, sublicense, and/or sell copies of the Software, and to     */
/* permit persons to whom the Software is furnished to do so, subject to  */
/* the following conditions:                                              */
/*                                                                        */
/* The above copyright notice and this permission notice shall be         */
/* included in all copies or substantial portions of the Software.        */
/*                                                                        */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,        */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF     */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY   */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,   */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE      */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                 */
/**************************************************************************/

#include "visual_shader_editor_plugin.h"

#include "core/config/project_settings.h"
#include "core/io/resource_loader.h"
#include "core/math/math_defs.h"
#include "core/os/keyboard.h"
#include "editor/editor_node.h"
#include "editor/editor_properties.h"
#include "editor/editor_properties_vector.h"
#include "editor/editor_settings.h"
#include "editor/editor_string_names.h"
#include "editor/editor_undo_redo_manager.h"
#include "editor/filesystem_dock.h"
#include "editor/inspector_dock.h"
#include "editor/plugins/curve_editor_plugin.h"
#include "editor/plugins/material_editor_plugin.h"
#include "editor/plugins/shader_editor_plugin.h"
#include "editor/themes/editor_scale.h"
#include "editor/themes/editor_theme_manager.h"
#include "scene/animation/tween.h"
#include "scene/gui/button.h"
#include "scene/gui/check_box.h"
#include "scene/gui/code_edit.h"
#include "scene/gui/color_picker.h"
#include "scene/gui/flow_container.h"
#include "scene/gui/graph_edit.h"
#include "scene/gui/menu_button.h"
#include "scene/gui/option_button.h"
#include "scene/gui/popup.h"
#include "scene/gui/rich_text_label.h"
#include "scene/gui/separator.h"
#include "scene/gui/split_container.h"
#include "scene/gui/texture_rect.h"
#include "scene/gui/tree.h"
#include "scene/gui/view_panner.h"
#include "scene/main/window.h"
#include "scene/resources/curve_texture.h"
#include "scene/resources/style_box_flat.h"
#include "scene/resources/visual_shader_nodes.h"
#include "scene/resources/visual_shader_particle_nodes.h"
#include "servers/display_server.h"
#include "servers/rendering/shader_preprocessor.h"
#include "servers/rendering/shader_types.h"

struct FloatConstantDef {};

static FloatConstantDef float_constant_defs[] =;

const int MAX_FLOAT_CONST_DEFS =;

///////////////////

void VisualShaderNodePlugin::set_editor(VisualShaderEditor *p_editor) {}

Control *VisualShaderNodePlugin::create_editor(const Ref<Resource> &p_parent_resource, const Ref<VisualShaderNode> &p_node) {}

void VisualShaderNodePlugin::_bind_methods() {}

///////////////////

void VSGraphNode::_draw_port(int p_slot_index, Point2i p_pos, bool p_left, const Color &p_color, const Color &p_rim_color) {}

void VSGraphNode::draw_port(int p_slot_index, Point2i p_pos, bool p_left, const Color &p_color) {}

///////////////////

void VSRerouteNode::_notification(int p_what) {}

void VSRerouteNode::draw_port(int p_slot_index, Point2i p_pos, bool p_left, const Color &p_color) {}

VSRerouteNode::VSRerouteNode() {}

void VSRerouteNode::set_icon_opacity(float p_opacity) {}

void VSRerouteNode::_on_mouse_entered() {}

void VSRerouteNode::_on_mouse_exited() {}

///////////////////

VisualShaderGraphPlugin::VisualShaderGraphPlugin() {}

void VisualShaderGraphPlugin::_bind_methods() {}

void VisualShaderGraphPlugin::set_editor(VisualShaderEditor *p_editor) {}

void VisualShaderGraphPlugin::register_shader(VisualShader *p_shader) {}

void VisualShaderGraphPlugin::set_connections(const List<VisualShader::Connection> &p_connections) {}

void VisualShaderGraphPlugin::show_port_preview(VisualShader::Type p_type, int p_node_id, int p_port_id, bool p_is_valid) {}

void VisualShaderGraphPlugin::update_node_deferred(VisualShader::Type p_type, int p_node_id) {}

void VisualShaderGraphPlugin::update_node(VisualShader::Type p_type, int p_node_id) {}

void VisualShaderGraphPlugin::set_input_port_default_value(VisualShader::Type p_type, int p_node_id, int p_port_id, const Variant &p_value) {}

void VisualShaderGraphPlugin::set_parameter_name(VisualShader::Type p_type, int p_node_id, const String &p_name) {}

void VisualShaderGraphPlugin::update_curve(int p_node_id) {}

void VisualShaderGraphPlugin::update_curve_xyz(int p_node_id) {}

int VisualShaderGraphPlugin::get_constant_index(float p_constant) const {}

void VisualShaderGraphPlugin::set_expression(VisualShader::Type p_type, int p_node_id, const String &p_expression) {}

void VisualShaderGraphPlugin::attach_node_to_frame(VisualShader::Type p_type, int p_node_id, int p_frame_id) {}

void VisualShaderGraphPlugin::detach_node_from_frame(VisualShader::Type p_type, int p_node_id) {}

void VisualShaderGraphPlugin::set_frame_color_enabled(VisualShader::Type p_type, int p_node_id, bool p_enable) {}

void VisualShaderGraphPlugin::set_frame_color(VisualShader::Type p_type, int p_node_id, const Color &p_color) {}

void VisualShaderGraphPlugin::set_frame_autoshrink_enabled(VisualShader::Type p_type, int p_node_id, bool p_enable) {}

void VisualShaderGraphPlugin::update_reroute_nodes() {}

Ref<Script> VisualShaderGraphPlugin::get_node_script(int p_node_id) const {}

void VisualShaderGraphPlugin::register_default_input_button(int p_node_id, int p_port_id, Button *p_button) {}

void VisualShaderGraphPlugin::register_expression_edit(int p_node_id, CodeEdit *p_expression_edit) {}

void VisualShaderGraphPlugin::register_curve_editor(int p_node_id, int p_index, CurveEditor *p_curve_editor) {}

void VisualShaderGraphPlugin::update_parameter_refs() {}

VisualShader::Type VisualShaderGraphPlugin::get_shader_type() const {}

// Only updates the linked frames of the given node, not the node itself (in case it's a frame node).
void VisualShaderGraphPlugin::update_frames(VisualShader::Type p_type, int p_node) {}

void VisualShaderGraphPlugin::set_node_position(VisualShader::Type p_type, int p_id, const Vector2 &p_position) {}

bool VisualShaderGraphPlugin::is_preview_visible(int p_id) const {}

void VisualShaderGraphPlugin::clear_links() {}

void VisualShaderGraphPlugin::register_link(VisualShader::Type p_type, int p_id, VisualShaderNode *p_visual_node, GraphElement *p_graph_element) {}

void VisualShaderGraphPlugin::register_output_port(int p_node_id, int p_port, VisualShaderNode::PortType p_port_type, TextureButton *p_button) {}

void VisualShaderGraphPlugin::register_parameter_name(int p_node_id, LineEdit *p_parameter_name) {}

void VisualShaderGraphPlugin::update_theme() {}

bool VisualShaderGraphPlugin::is_node_has_parameter_instances_relatively(VisualShader::Type p_type, int p_node) const {}

void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool p_just_update, bool p_update_frames) {}

void VisualShaderGraphPlugin::remove_node(VisualShader::Type p_type, int p_id, bool p_just_update) {}

void VisualShaderGraphPlugin::connect_nodes(VisualShader::Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port) {}

void VisualShaderGraphPlugin::disconnect_nodes(VisualShader::Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port) {}

VisualShaderGraphPlugin::~VisualShaderGraphPlugin() {}

/////////////////

void VisualShaderEditedProperty::_bind_methods() {}

void VisualShaderEditedProperty::set_edited_property(const Variant &p_variant) {}

Variant VisualShaderEditedProperty::get_edited_property() const {}

/////////////////

Vector2 VisualShaderEditor::selection_center;
List<VisualShaderEditor::CopyItem> VisualShaderEditor::copy_items_buffer;
List<VisualShader::Connection> VisualShaderEditor::copy_connections_buffer;

void VisualShaderEditor::edit_shader(const Ref<Shader> &p_shader) {}

void VisualShaderEditor::apply_shaders() {}

bool VisualShaderEditor::is_unsaved() const {}

void VisualShaderEditor::save_external_data(const String &p_str) {}

void VisualShaderEditor::validate_script() {}

void VisualShaderEditor::add_plugin(const Ref<VisualShaderNodePlugin> &p_plugin) {}

void VisualShaderEditor::remove_plugin(const Ref<VisualShaderNodePlugin> &p_plugin) {}

void VisualShaderEditor::clear_custom_types() {}

void VisualShaderEditor::add_custom_type(const String &p_name, const String &p_type, const Ref<Script> &p_script, const String &p_description, int p_return_icon_type, const String &p_category, bool p_highend) {}

Dictionary VisualShaderEditor::get_custom_node_data(Ref<VisualShaderNodeCustom> &p_custom_node) {}

void VisualShaderEditor::_get_current_mode_limits(int &r_begin_type, int &r_end_type) const {}

void VisualShaderEditor::_script_created(const Ref<Script> &p_script) {}

void VisualShaderEditor::_update_custom_script(const Ref<Script> &p_script) {}

void VisualShaderEditor::_resource_saved(const Ref<Resource> &p_resource) {}

void VisualShaderEditor::_resources_removed() {}

void VisualShaderEditor::_resource_removed(const Ref<Resource> &p_resource) {}

void VisualShaderEditor::_update_options_menu_deferred() {}

void VisualShaderEditor::_rebuild_shader_deferred() {}

bool VisualShaderEditor::_is_available(int p_mode) {}

bool VisualShaderEditor::_update_preview_parameter_tree() {}

void VisualShaderEditor::_preview_tools_menu_option(int p_idx) {}

void VisualShaderEditor::_clear_preview_param() {}

void VisualShaderEditor::_update_preview_parameter_list() {}

void VisualShaderEditor::_update_nodes() {}

String VisualShaderEditor::_get_description(int p_idx) {}

void VisualShaderEditor::_update_options_menu() {}

void VisualShaderEditor::_set_mode(int p_which) {}

Size2 VisualShaderEditor::get_minimum_size() const {}

void VisualShaderEditor::_draw_color_over_button(Object *p_obj, Color p_color) {}

void VisualShaderEditor::_update_parameters(bool p_update_refs) {}

void VisualShaderEditor::_update_parameter_refs(HashSet<String> &p_deleted_names) {}

void VisualShaderEditor::_update_graph() {}

VisualShader::Type VisualShaderEditor::get_current_shader_type() const {}

void VisualShaderEditor::_add_input_port(int p_node, int p_port, int p_port_type, const String &p_name) {}

void VisualShaderEditor::_add_output_port(int p_node, int p_port, int p_port_type, const String &p_name) {}

void VisualShaderEditor::_change_input_port_type(int p_type, int p_node, int p_port) {}

void VisualShaderEditor::_change_output_port_type(int p_type, int p_node, int p_port) {}

void VisualShaderEditor::_change_input_port_name(const String &p_text, Object *p_line_edit, int p_node_id, int p_port_id) {}

void VisualShaderEditor::_change_output_port_name(const String &p_text, Object *p_line_edit, int p_node_id, int p_port_id) {}

void VisualShaderEditor::_expand_output_port(int p_node, int p_port, bool p_expand) {}

void VisualShaderEditor::_remove_input_port(int p_node, int p_port) {}

void VisualShaderEditor::_remove_output_port(int p_node, int p_port) {}

void VisualShaderEditor::_expression_focus_out(Object *p_code_edit, int p_node) {}

void VisualShaderEditor::_set_node_size(int p_type, int p_node, const Vector2 &p_size) {}

// Called once after the node was resized.
void VisualShaderEditor::_node_resized(const Vector2 &p_new_size, int p_type, int p_node) {}

void VisualShaderEditor::_preview_select_port(int p_node, int p_port) {}

void VisualShaderEditor::_frame_title_popup_show(const Point2 &p_position, int p_node_id) {}

void VisualShaderEditor::_frame_title_text_changed(const String &p_new_text) {}

void VisualShaderEditor::_frame_title_text_submitted(const String &p_new_text) {}

void VisualShaderEditor::_frame_title_popup_focus_out() {}

void VisualShaderEditor::_frame_title_popup_hide() {}

void VisualShaderEditor::_frame_color_enabled_changed(int p_node_id) {}

void VisualShaderEditor::_frame_color_popup_show(const Point2 &p_position, int p_node_id) {}

void VisualShaderEditor::_frame_color_confirm() {}

void VisualShaderEditor::_frame_color_changed(const Color &p_color) {}

void VisualShaderEditor::_frame_color_popup_hide() {}

void VisualShaderEditor::_frame_autoshrink_enabled_changed(int p_node_id) {}

void VisualShaderEditor::_parameter_line_edit_changed(const String &p_text, int p_node_id) {}

void VisualShaderEditor::_parameter_line_edit_focus_out(Object *line_edit, int p_node_id) {}

void VisualShaderEditor::_port_name_focus_out(Object *line_edit, int p_node_id, int p_port_id, bool p_output) {}

void VisualShaderEditor::_port_edited(const StringName &p_property, const Variant &p_value, const String &p_field, bool p_changing) {}

void VisualShaderEditor::_edit_port_default_input(Object *p_button, int p_node, int p_port) {}

void VisualShaderEditor::_set_custom_node_option(int p_index, int p_node, int p_op) {}

void VisualShaderEditor::_setup_node(VisualShaderNode *p_node, const Vector<Variant> &p_ops) {}

void VisualShaderEditor::_add_node(int p_idx, const Vector<Variant> &p_ops, const String &p_resource_path, int p_node_idx) {}

void VisualShaderEditor::_add_varying(const String &p_name, VisualShader::VaryingMode p_mode, VisualShader::VaryingType p_type) {}

void VisualShaderEditor::_remove_varying(const String &p_name) {}

void VisualShaderEditor::_update_varyings() {}

void VisualShaderEditor::_node_dragged(const Vector2 &p_from, const Vector2 &p_to, int p_node) {}

void VisualShaderEditor::_nodes_dragged() {}

void VisualShaderEditor::_connection_request(const String &p_from, int p_from_index, const String &p_to, int p_to_index) {}

void VisualShaderEditor::_disconnection_request(const String &p_from, int p_from_index, const String &p_to, int p_to_index) {}

void VisualShaderEditor::_connection_drag_ended() {}

void VisualShaderEditor::_connection_to_empty(const String &p_from, int p_from_slot, const Vector2 &p_release_position) {}

void VisualShaderEditor::_connection_from_empty(const String &p_to, int p_to_slot, const Vector2 &p_release_position) {}

bool VisualShaderEditor::_check_node_drop_on_connection(const Vector2 &p_position, Ref<GraphEdit::Connection> *r_closest_connection, int *r_from_port, int *r_to_port) {}

void VisualShaderEditor::_handle_node_drop_on_connection() {}

void VisualShaderEditor::_delete_nodes(int p_type, const List<int> &p_nodes) {}

void VisualShaderEditor::_replace_node(VisualShader::Type p_type_id, int p_node_id, const StringName &p_from, const StringName &p_to) {}

void VisualShaderEditor::_update_constant(VisualShader::Type p_type_id, int p_node_id, const Variant &p_var, int p_preview_port) {}

void VisualShaderEditor::_update_parameter(VisualShader::Type p_type_id, int p_node_id, const Variant &p_var, int p_preview_port) {}

void VisualShaderEditor::_convert_constants_to_parameters(bool p_vice_versa) {}

void VisualShaderEditor::_detach_nodes_from_frame(int p_type, const List<int> &p_nodes) {}

void VisualShaderEditor::_detach_nodes_from_frame_request() {}

void VisualShaderEditor::_delete_node_request(int p_type, int p_node) {}

void VisualShaderEditor::_delete_nodes_request(const TypedArray<StringName> &p_nodes) {}

void VisualShaderEditor::_node_selected(Object *p_node) {}

void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {}

void VisualShaderEditor::_show_members_dialog(bool at_mouse_pos, VisualShaderNode::PortType p_input_port_type, VisualShaderNode::PortType p_output_port_type) {}

void VisualShaderEditor::_varying_menu_id_pressed(int p_idx) {}

void VisualShaderEditor::_show_add_varying_dialog() {}

void VisualShaderEditor::_show_remove_varying_dialog() {}

void VisualShaderEditor::_sbox_input(const Ref<InputEvent> &p_event) {}

void VisualShaderEditor::_param_filter_changed(const String &p_text) {}

void VisualShaderEditor::_param_property_changed(const String &p_property, const Variant &p_value, const String &p_field, bool p_changing) {}

void VisualShaderEditor::_update_current_param() {}

void VisualShaderEditor::_param_selected() {}

void VisualShaderEditor::_param_unselected() {}

void VisualShaderEditor::_notification(int p_what) {}

void VisualShaderEditor::_scroll_changed(const Vector2 &p_scroll) {}

void VisualShaderEditor::_node_changed(int p_id) {}

void VisualShaderEditor::_nodes_linked_to_frame_request(const TypedArray<StringName> &p_nodes, const StringName &p_frame) {}

void VisualShaderEditor::_frame_rect_changed(const GraphFrame *p_frame, const Rect2 &p_new_rect) {}

void VisualShaderEditor::_dup_copy_nodes(int p_type, List<CopyItem> &r_items, List<VisualShader::Connection> &r_connections) {}

void VisualShaderEditor::_dup_paste_nodes(int p_type, List<CopyItem> &r_items, const List<VisualShader::Connection> &p_connections, const Vector2 &p_offset, bool p_duplicate) {}

void VisualShaderEditor::_clear_copy_buffer() {}

void VisualShaderEditor::_duplicate_nodes() {}

void VisualShaderEditor::_copy_nodes(bool p_cut) {}

void VisualShaderEditor::_paste_nodes(bool p_use_custom_position, const Vector2 &p_custom_position) {}

void VisualShaderEditor::_mode_selected(int p_id) {}

void VisualShaderEditor::_custom_mode_toggled(bool p_enabled) {}

void VisualShaderEditor::_input_select_item(Ref<VisualShaderNodeInput> p_input, const String &p_name) {}

void VisualShaderEditor::_parameter_ref_select_item(Ref<VisualShaderNodeParameterRef> p_parameter_ref, const String &p_name) {}

void VisualShaderEditor::_varying_select_item(Ref<VisualShaderNodeVarying> p_varying, const String &p_name) {}

void VisualShaderEditor::_float_constant_selected(int p_which) {}

void VisualShaderEditor::_member_filter_changed(const String &p_text) {}

void VisualShaderEditor::_member_selected() {}

void VisualShaderEditor::_member_create() {}

void VisualShaderEditor::_member_cancel() {}

void VisualShaderEditor::_update_varying_tree() {}

void VisualShaderEditor::_varying_create() {}

void VisualShaderEditor::_varying_name_changed(const String &p_name) {}

void VisualShaderEditor::_varying_deleted() {}

void VisualShaderEditor::_varying_selected() {}

void VisualShaderEditor::_varying_unselected() {}

void VisualShaderEditor::_tools_menu_option(int p_idx) {}

void VisualShaderEditor::_node_menu_id_pressed(int p_idx) {}

void VisualShaderEditor::_connection_menu_id_pressed(int p_idx) {}

Variant VisualShaderEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {}

bool VisualShaderEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {}

void VisualShaderEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {}

void VisualShaderEditor::_show_preview_text() {}

void VisualShaderEditor::_preview_close_requested() {}

static ShaderLanguage::DataType _visual_shader_editor_get_global_shader_uniform_type(const StringName &p_variable) {}

void VisualShaderEditor::_update_preview() {}

void VisualShaderEditor::_update_next_previews(int p_node_id) {}

void VisualShaderEditor::_get_next_nodes_recursively(VisualShader::Type p_type, int p_node_id, LocalVector<int> &r_nodes) const {}

void VisualShaderEditor::_visibility_changed() {}

void VisualShaderEditor::_show_shader_preview() {}

void VisualShaderEditor::_bind_methods() {}

VisualShaderEditor::VisualShaderEditor() {}

class VisualShaderNodePluginInputEditor : public OptionButton {};

////////////////

class VisualShaderNodePluginVaryingEditor : public OptionButton {};

////////////////

class VisualShaderNodePluginParameterRefEditor : public OptionButton {};

////////////////

class VisualShaderNodePluginDefaultEditor : public VBoxContainer {};

Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_parent_resource, const Ref<VisualShaderNode> &p_node) {}

void EditorPropertyVisualShaderMode::_option_selected(int p_which) {}

void EditorPropertyVisualShaderMode::update_property() {}

void EditorPropertyVisualShaderMode::setup(const Vector<String> &p_options) {}

void EditorPropertyVisualShaderMode::set_option_button_clip(bool p_enable) {}

EditorPropertyVisualShaderMode::EditorPropertyVisualShaderMode() {}

bool EditorInspectorVisualShaderModePlugin::can_handle(Object *p_object) {}

bool EditorInspectorVisualShaderModePlugin::parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const BitField<PropertyUsageFlags> p_usage, const bool p_wide) {}

//////////////////////////////////

void VisualShaderNodePortPreview::_shader_changed() {}

void VisualShaderNodePortPreview::setup(const Ref<VisualShader> &p_shader, Ref<ShaderMaterial> &p_preview_material, VisualShader::Type p_type, bool p_has_transparency, int p_node, int p_port, bool p_is_valid) {}

Size2 VisualShaderNodePortPreview::get_minimum_size() const {}

void VisualShaderNodePortPreview::_notification(int p_what) {}

//////////////////////////////////

String VisualShaderConversionPlugin::converts_to() const {}

bool VisualShaderConversionPlugin::handles(const Ref<Resource> &p_resource) const {}

Ref<Resource> VisualShaderConversionPlugin::convert(const Ref<Resource> &p_resource) const {}