2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* shader_editor_plugin.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 12:16:55 +00:00
|
|
|
/* https://godotengine.org */
|
2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
2022-01-03 20:27:34 +00:00
|
|
|
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
2014-02-10 01:10:30 +00:00
|
|
|
/* */
|
|
|
|
/* 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. */
|
|
|
|
/*************************************************************************/
|
2018-01-04 23:50:27 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
#ifndef SHADER_EDITOR_PLUGIN_H
|
|
|
|
#define SHADER_EDITOR_PLUGIN_H
|
|
|
|
|
2017-03-05 13:21:25 +00:00
|
|
|
#include "editor/editor_plugin.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2022-05-27 09:02:55 +00:00
|
|
|
class HSplitContainer;
|
2022-09-03 04:15:21 +00:00
|
|
|
class ItemList;
|
2022-11-11 19:12:48 +00:00
|
|
|
class MenuButton;
|
2022-05-27 09:02:55 +00:00
|
|
|
class ShaderCreateDialog;
|
2022-09-03 04:15:21 +00:00
|
|
|
class TabContainer;
|
|
|
|
class TextShaderEditor;
|
|
|
|
class VisualShaderEditor;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
class ShaderEditorPlugin : public EditorPlugin {
|
2017-03-05 15:44:50 +00:00
|
|
|
GDCLASS(ShaderEditorPlugin, EditorPlugin);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2022-05-27 09:02:55 +00:00
|
|
|
struct EditedShader {
|
|
|
|
Ref<Shader> shader;
|
2022-03-08 10:39:16 +00:00
|
|
|
Ref<ShaderInclude> shader_inc;
|
2022-09-03 03:54:40 +00:00
|
|
|
TextShaderEditor *shader_editor = nullptr;
|
2022-05-27 09:02:55 +00:00
|
|
|
VisualShaderEditor *visual_shader_editor = nullptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
LocalVector<EditedShader> edited_shaders;
|
|
|
|
|
2022-09-30 15:20:51 +00:00
|
|
|
// Always valid operations come first in the enum, file-specific ones
|
|
|
|
// should go after FILE_SAVE which is used to build the menu accordingly.
|
2022-05-27 09:02:55 +00:00
|
|
|
enum {
|
|
|
|
FILE_NEW,
|
2022-03-08 10:39:16 +00:00
|
|
|
FILE_NEW_INCLUDE,
|
2022-05-27 09:02:55 +00:00
|
|
|
FILE_OPEN,
|
2022-03-08 10:39:16 +00:00
|
|
|
FILE_OPEN_INCLUDE,
|
2022-05-27 09:02:55 +00:00
|
|
|
FILE_SAVE,
|
|
|
|
FILE_SAVE_AS,
|
|
|
|
FILE_INSPECT,
|
|
|
|
FILE_CLOSE,
|
|
|
|
FILE_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
HSplitContainer *main_split = nullptr;
|
|
|
|
ItemList *shader_list = nullptr;
|
|
|
|
TabContainer *shader_tabs = nullptr;
|
|
|
|
|
2022-04-04 13:06:57 +00:00
|
|
|
Button *button = nullptr;
|
2022-05-27 09:02:55 +00:00
|
|
|
MenuButton *file_menu = nullptr;
|
|
|
|
|
|
|
|
ShaderCreateDialog *shader_create_dialog = nullptr;
|
|
|
|
|
|
|
|
void _update_shader_list();
|
|
|
|
void _shader_selected(int p_index);
|
2022-07-28 16:28:38 +00:00
|
|
|
void _shader_list_clicked(int p_item, Vector2 p_local_mouse_pos, MouseButton p_mouse_button_index);
|
2022-05-27 09:02:55 +00:00
|
|
|
void _menu_item_pressed(int p_index);
|
|
|
|
void _resource_saved(Object *obj);
|
|
|
|
void _close_shader(int p_index);
|
|
|
|
|
|
|
|
void _shader_created(Ref<Shader> p_shader);
|
2022-03-08 10:39:16 +00:00
|
|
|
void _shader_include_created(Ref<ShaderInclude> p_shader_inc);
|
2022-06-29 09:31:18 +00:00
|
|
|
void _update_shader_list_status();
|
2022-08-10 02:12:31 +00:00
|
|
|
void _move_shader_tab(int p_from, int p_to);
|
|
|
|
|
|
|
|
Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
|
|
|
|
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);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
2016-10-07 14:31:18 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
public:
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual void edit(Object *p_object) override;
|
|
|
|
virtual bool handles(Object *p_object) const override;
|
|
|
|
virtual void make_visible(bool p_visible) override;
|
|
|
|
virtual void selected_notify() override;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2022-09-03 03:54:40 +00:00
|
|
|
TextShaderEditor *get_shader_editor(const Ref<Shader> &p_for_shader);
|
2022-07-16 06:59:20 +00:00
|
|
|
VisualShaderEditor *get_visual_shader_editor(const Ref<Shader> &p_for_shader);
|
2018-10-27 15:24:41 +00:00
|
|
|
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual void save_external_data() override;
|
|
|
|
virtual void apply_changes() override;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2022-01-27 09:36:51 +00:00
|
|
|
ShaderEditorPlugin();
|
2014-02-10 01:10:30 +00:00
|
|
|
~ShaderEditorPlugin();
|
|
|
|
};
|
2016-10-03 19:33:42 +00:00
|
|
|
|
2022-07-23 21:41:51 +00:00
|
|
|
#endif // SHADER_EDITOR_PLUGIN_H
|