Path: blob/master/editor/shader/shader_editor_plugin.h
9896 views
/**************************************************************************/1/* shader_editor_plugin.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "editor/plugins/editor_plugin.h"3334class CodeTextEditor;35class HSplitContainer;36class ItemList;37class MenuButton;38class ShaderCreateDialog;39class ShaderEditor;40class TabContainer;41class TextShaderEditor;42class VBoxContainer;43class HBoxContainer;44class VisualShaderEditor;45class WindowWrapper;4647class ShaderEditorPlugin : public EditorPlugin {48GDCLASS(ShaderEditorPlugin, EditorPlugin);4950struct EditedShader {51Ref<Shader> shader;52Ref<ShaderInclude> shader_inc;53ShaderEditor *shader_editor = nullptr;54String path;55String name;56};5758LocalVector<EditedShader> edited_shaders;5960enum FileMenu {61FILE_MENU_NEW,62FILE_MENU_NEW_INCLUDE,63FILE_MENU_OPEN,64FILE_MENU_OPEN_INCLUDE,65FILE_MENU_SAVE,66FILE_MENU_SAVE_AS,67FILE_MENU_INSPECT,68FILE_MENU_INSPECT_NATIVE_SHADER_CODE,69FILE_MENU_CLOSE,70FILE_MENU_CLOSE_ALL,71FILE_MENU_CLOSE_OTHER_TABS,72FILE_MENU_SHOW_IN_FILE_SYSTEM,73FILE_MENU_COPY_PATH,74FILE_MENU_TOGGLE_FILES_PANEL,75};7677enum PopupMenuType {78FILE,79CONTEXT,80CONTEXT_VALID_ITEM,81};8283VBoxContainer *main_container = nullptr;84HSplitContainer *files_split = nullptr;8586ItemList *shader_list = nullptr;87TabContainer *shader_tabs = nullptr;8889Button *button = nullptr;90MenuButton *file_menu = nullptr;91PopupMenu *context_menu = nullptr;9293WindowWrapper *window_wrapper = nullptr;94Button *make_floating = nullptr;9596ShaderCreateDialog *shader_create_dialog = nullptr;9798float text_shader_zoom_factor = 1.0f;99100Ref<Resource> _get_current_shader();101void _update_shader_list();102void _shader_selected(int p_index, bool p_push_item = true);103void _shader_list_clicked(int p_item, Vector2 p_local_mouse_pos, MouseButton p_mouse_button_index);104void _setup_popup_menu(PopupMenuType p_type, PopupMenu *p_menu);105void _make_script_list_context_menu();106void _menu_item_pressed(int p_index);107void _resource_saved(Object *obj);108void _close_shader(int p_index);109void _close_builtin_shaders_from_scene(const String &p_scene);110void _file_removed(const String &p_removed_file);111void _res_saved_callback(const Ref<Resource> &p_res);112void _set_file_specific_items_disabled(bool p_disabled);113114void _shader_created(Ref<Shader> p_shader);115void _shader_include_created(Ref<ShaderInclude> p_shader_inc);116void _update_shader_list_status();117void _move_shader_tab(int p_from, int p_to);118119Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);120bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;121void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);122123void _window_changed(bool p_visible);124125void _set_text_shader_zoom_factor(float p_zoom_factor);126void _update_shader_editor_zoom_factor(CodeTextEditor *p_shader_editor) const;127128void _switch_to_editor(ShaderEditor *p_editor);129130protected:131void _notification(int p_what);132133public:134virtual String get_plugin_name() const override { return "Shader"; }135virtual void edit(Object *p_object) override;136virtual bool handles(Object *p_object) const override;137virtual void make_visible(bool p_visible) override;138virtual void selected_notify() override;139140ShaderEditor *get_shader_editor(const Ref<Shader> &p_for_shader);141142virtual void set_window_layout(Ref<ConfigFile> p_layout) override;143virtual void get_window_layout(Ref<ConfigFile> p_layout) override;144145virtual String get_unsaved_status(const String &p_for_scene) const override;146virtual void save_external_data() override;147virtual void apply_changes() override;148149ShaderEditorPlugin();150~ShaderEditorPlugin();151};152153154