summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/classes/TabContainer.xml2
-rw-r--r--doc/classes/VisualShaderNodeCustom.xml22
-rw-r--r--editor/editor_toaster.cpp8
-rw-r--r--editor/editor_toaster.h2
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp2
-rw-r--r--editor/plugins/skeleton_3d_editor_plugin.cpp27
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp89
-rw-r--r--editor/plugins/visual_shader_editor_plugin.h4
-rw-r--r--platform/linuxbsd/display_server_x11.cpp8
-rw-r--r--platform/osx/display_server_osx.mm2
-rw-r--r--platform/windows/display_server_windows.cpp2
-rw-r--r--scene/gui/base_button.cpp4
-rw-r--r--scene/gui/base_button.h2
-rw-r--r--scene/gui/menu_button.cpp2
-rw-r--r--scene/gui/rich_text_label.cpp4
-rw-r--r--scene/gui/tab_bar.cpp6
-rw-r--r--scene/gui/tab_container.cpp7
-rw-r--r--scene/register_scene_types.cpp10
-rw-r--r--scene/resources/visual_shader.cpp84
-rw-r--r--scene/resources/visual_shader.h6
-rw-r--r--scene/resources/visual_shader_nodes.cpp6
21 files changed, 223 insertions, 76 deletions
diff --git a/doc/classes/TabContainer.xml b/doc/classes/TabContainer.xml
index 3ff4dffe65..bdc73ee3c4 100644
--- a/doc/classes/TabContainer.xml
+++ b/doc/classes/TabContainer.xml
@@ -121,7 +121,7 @@
<argument index="0" name="tab_idx" type="int" />
<argument index="1" name="title" type="String" />
<description>
- Sets a custom title for the tab at index [code]tab_idx[/code] (tab titles default to the name of the indexed child node). Set it to blank to make it the child's name again.
+ Sets a custom title for the tab at index [code]tab_idx[/code] (tab titles default to the name of the indexed child node). Set it back to the child's name to make the tab default to it again.
</description>
</method>
</methods>
diff --git a/doc/classes/VisualShaderNodeCustom.xml b/doc/classes/VisualShaderNodeCustom.xml
index 7b992abe24..0a962a4aa4 100644
--- a/doc/classes/VisualShaderNodeCustom.xml
+++ b/doc/classes/VisualShaderNodeCustom.xml
@@ -44,6 +44,17 @@
Defining this method is [b]optional[/b].
</description>
</method>
+ <method name="_get_func_code" qualifiers="virtual const">
+ <return type="String" />
+ <argument index="0" name="mode" type="int" enum="Shader.Mode" />
+ <argument index="1" name="type" type="int" enum="VisualShader.Type" />
+ <description>
+ Override this method to add a shader code to the beginning of each shader function (once). The shader code should be returned as a string, which can have multiple lines (the [code]"""[/code] multiline string construct can be used for convenience).
+ If there are multiple custom nodes of different types which use this feature the order of each insertion is undefined.
+ You can customize the generated code based on the shader [code]mode[/code] (see [enum Shader.Mode]) and/or [code]type[/code] (see [enum VisualShader.Type]).
+ Defining this method is [b]optional[/b].
+ </description>
+ </method>
<method name="_get_global_code" qualifiers="virtual const">
<return type="String" />
<argument index="0" name="mode" type="int" enum="Shader.Mode" />
@@ -114,11 +125,20 @@
Defining this method is [b]optional[/b]. If not overridden, no return icon is shown.
</description>
</method>
+ <method name="_is_available" qualifiers="virtual const">
+ <return type="bool" />
+ <argument index="0" name="mode" type="int" enum="Shader.Mode" />
+ <argument index="1" name="type" type="int" enum="VisualShader.Type" />
+ <description>
+ Override this method to prevent the node to be visible in the member dialog for the certain [code]mode[/code] (see [enum Shader.Mode]) and/or [code]type[/code] (see [enum VisualShader.Type]).
+ Defining this method is [b]optional[/b]. If not overridden, it's [code]true[/code].
+ </description>
+ </method>
<method name="_is_highend" qualifiers="virtual const">
<return type="bool" />
<description>
Override this method to enable high-end mark in the Visual Shader Editor's members dialog.
- Defining this method is [b]optional[/b]. If not overridden, it's false.
+ Defining this method is [b]optional[/b]. If not overridden, it's [code]false[/code].
</description>
</method>
</methods>
diff --git a/editor/editor_toaster.cpp b/editor/editor_toaster.cpp
index 319b4709fe..7ca88bd2a2 100644
--- a/editor/editor_toaster.cpp
+++ b/editor/editor_toaster.cpp
@@ -385,12 +385,19 @@ Control *EditorToaster::popup(Control *p_control, Severity p_severity, double p_
}
void EditorToaster::popup_str(String p_message, Severity p_severity, String p_tooltip) {
+ if (is_processing_error) {
+ return;
+ }
+
// Since "_popup_str" adds nodes to the tree, and since the "add_child" method is not
// thread-safe, it's better to defer the call to the next cycle to be thread-safe.
+ is_processing_error = true;
call_deferred(SNAME("_popup_str"), p_message, p_severity, p_tooltip);
+ is_processing_error = false;
}
void EditorToaster::_popup_str(String p_message, Severity p_severity, String p_tooltip) {
+ is_processing_error = true;
// Check if we already have a popup with the given message.
Control *control = nullptr;
for (KeyValue<Control *, Toast> element : toasts) {
@@ -432,6 +439,7 @@ void EditorToaster::_popup_str(String p_message, Severity p_severity, String p_t
} else {
label->set_text(vformat("%s (%d)", p_message, toasts[control].count));
}
+ is_processing_error = false;
}
void EditorToaster::close(Control *p_control) {
diff --git a/editor/editor_toaster.h b/editor/editor_toaster.h
index 2ad8752bee..059245ce66 100644
--- a/editor/editor_toaster.h
+++ b/editor/editor_toaster.h
@@ -82,6 +82,8 @@ private:
};
Map<Control *, Toast> toasts;
+ bool is_processing_error = false; // Makes sure that we don't handle errors that are triggered within the EditorToaster error processing.
+
const double default_message_duration = 5.0;
static void _error_handler(void *p_self, const char *p_func, const char *p_file, int p_line, const char *p_error, const char *p_errorexp, bool p_editor_notify, ErrorHandlerType p_type);
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index e43d1feb08..75f97efdbc 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -3580,7 +3580,7 @@ void CanvasItemEditor::_draw_locks_and_groups(Node *p_node, const Transform2D &p
return;
}
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node);
- if (canvas_item && !canvas_item->is_visible()) {
+ if (canvas_item && !canvas_item->is_visible_in_tree()) {
return;
}
diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp
index aec1a09e48..aadc7a2e66 100644
--- a/editor/plugins/skeleton_3d_editor_plugin.cpp
+++ b/editor/plugins/skeleton_3d_editor_plugin.cpp
@@ -528,22 +528,25 @@ void Skeleton3DEditor::move_skeleton_bone(NodePath p_skeleton_path, int32_t p_se
void Skeleton3DEditor::_joint_tree_selection_changed() {
TreeItem *selected = joint_tree->get_selected();
- if (!selected) {
- return;
- }
- const String path = selected->get_metadata(0);
- if (!path.begins_with("bones/")) {
- return;
+ if (selected) {
+ const String path = selected->get_metadata(0);
+ if (!path.begins_with("bones/")) {
+ return;
+ }
+ const int b_idx = path.get_slicec('/', 1).to_int();
+ selected_bone = b_idx;
+ if (pose_editor) {
+ const String bone_path = "bones/" + itos(b_idx) + "/";
+ pose_editor->set_target(bone_path);
+ pose_editor->set_keyable(keyable);
+ }
}
- const int b_idx = path.get_slicec('/', 1).to_int();
- selected_bone = b_idx;
- if (pose_editor) {
- const String bone_path = "bones/" + itos(b_idx) + "/";
- pose_editor->set_target(bone_path);
- pose_editor->set_keyable(keyable);
+
+ if (pose_editor && pose_editor->is_inside_tree()) {
pose_editor->set_visible(selected);
}
set_bone_options_enabled(selected);
+
_update_properties();
_update_gizmo_visible();
}
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index 94906acb63..7f30dd91e5 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -1082,6 +1082,10 @@ void VisualShaderEditor::edit(VisualShader *p_visual_shader) {
}
}
+void VisualShaderEditor::update_nodes() {
+ _update_nodes();
+}
+
void VisualShaderEditor::add_plugin(const Ref<VisualShaderNodePlugin> &p_plugin) {
if (plugins.has(p_plugin)) {
return;
@@ -1165,10 +1169,7 @@ bool VisualShaderEditor::_is_available(int p_mode) {
return (p_mode == -1 || (p_mode & current_mode) != 0);
}
-void VisualShaderEditor::update_custom_nodes() {
- if (members_dialog->is_visible()) {
- return;
- }
+void VisualShaderEditor::_update_nodes() {
clear_custom_types();
List<StringName> class_list;
ScriptServer::get_global_class_list(&class_list);
@@ -1184,6 +1185,9 @@ void VisualShaderEditor::update_custom_nodes() {
Ref<VisualShaderNodeCustom> ref;
ref.instantiate();
ref->set_script(script);
+ if (!ref->is_available(visual_shader->get_mode(), visual_shader->get_shader_type())) {
+ continue;
+ }
String name;
if (ref->has_method("_get_name")) {
@@ -1240,6 +1244,32 @@ void VisualShaderEditor::update_custom_nodes() {
}
}
+ // Disables not-supported copied items.
+ {
+ for (CopyItem &item : copy_items_buffer) {
+ Ref<VisualShaderNodeCustom> custom = Object::cast_to<VisualShaderNodeCustom>(item.node.ptr());
+
+ if (custom.is_valid()) {
+ if (!custom->is_available(visual_shader->get_mode(), visual_shader->get_shader_type())) {
+ item.disabled = true;
+ } else {
+ item.disabled = false;
+ }
+ } else {
+ for (int i = 0; i < add_options.size(); i++) {
+ if (add_options[i].type == item.node->get_class_name()) {
+ if ((add_options[i].func != visual_shader->get_mode() && add_options[i].func != -1) || !_is_available(add_options[i].mode)) {
+ item.disabled = true;
+ } else {
+ item.disabled = false;
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+
Array keys = added.keys();
keys.sort();
@@ -3370,15 +3400,23 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
selected_float_constant = -1;
}
- if (to_change.is_empty() && copy_items_buffer.is_empty()) {
+ bool copy_buffer_empty = true;
+ for (const CopyItem &item : copy_items_buffer) {
+ if (!item.disabled) {
+ copy_buffer_empty = false;
+ break;
+ }
+ }
+
+ if (to_change.is_empty() && copy_buffer_empty) {
_show_members_dialog(true);
} else {
popup_menu->set_item_disabled(NodeMenuOptions::CUT, to_change.is_empty());
popup_menu->set_item_disabled(NodeMenuOptions::COPY, to_change.is_empty());
- popup_menu->set_item_disabled(NodeMenuOptions::PASTE, copy_items_buffer.is_empty());
+ popup_menu->set_item_disabled(NodeMenuOptions::PASTE, copy_buffer_empty);
popup_menu->set_item_disabled(NodeMenuOptions::DELETE, to_change.is_empty());
popup_menu->set_item_disabled(NodeMenuOptions::DUPLICATE, to_change.is_empty());
- popup_menu->set_item_disabled(NodeMenuOptions::CLEAR_COPY_BUFFER, copy_items_buffer.is_empty());
+ popup_menu->set_item_disabled(NodeMenuOptions::CLEAR_COPY_BUFFER, copy_buffer_empty);
int temp = popup_menu->get_item_index(NodeMenuOptions::SEPARATOR2);
if (temp != -1) {
@@ -3715,6 +3753,17 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, List<CopyItem> &r_items, c
if (p_duplicate) {
undo_redo->create_action(TTR("Duplicate VisualShader Node(s)"));
} else {
+ bool copy_buffer_empty = true;
+ for (const CopyItem &item : copy_items_buffer) {
+ if (!item.disabled) {
+ copy_buffer_empty = false;
+ break;
+ }
+ }
+ if (copy_buffer_empty) {
+ return;
+ }
+
undo_redo->create_action(TTR("Paste VisualShader Node(s)"));
}
@@ -3727,16 +3776,7 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, List<CopyItem> &r_items, c
Set<int> added_set;
for (CopyItem &item : r_items) {
- bool unsupported = false;
- for (int i = 0; i < add_options.size(); i++) {
- if (add_options[i].type == item.node->get_class_name()) {
- if (!_is_available(add_options[i].mode)) {
- unsupported = true;
- }
- break;
- }
- }
- if (unsupported) {
+ if (item.disabled) {
unsupported_set.insert(item.id);
continue;
}
@@ -3777,7 +3817,10 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, List<CopyItem> &r_items, c
}
id_from = base_id;
- for (int i = 0; i < r_items.size(); i++) {
+ for (const CopyItem &item : r_items) {
+ if (item.disabled) {
+ continue;
+ }
undo_redo->add_undo_method(visual_shader.ptr(), "remove_node", type, id_from);
undo_redo->add_undo_method(graph_plugin.ptr(), "remove_node", type, id_from);
id_from++;
@@ -3878,7 +3921,7 @@ void VisualShaderEditor::_mode_selected(int p_id) {
}
visual_shader->set_shader_type(VisualShader::Type(p_id + offset));
- _update_options_menu();
+ _update_nodes();
_update_graph();
graph->grab_focus();
@@ -4465,8 +4508,8 @@ void VisualShaderEditor::_visibility_changed() {
}
void VisualShaderEditor::_bind_methods() {
+ ClassDB::bind_method("_update_nodes", &VisualShaderEditor::_update_nodes);
ClassDB::bind_method("_update_graph", &VisualShaderEditor::_update_graph);
- ClassDB::bind_method("_update_options_menu", &VisualShaderEditor::_update_options_menu);
ClassDB::bind_method("_add_node", &VisualShaderEditor::_add_node);
ClassDB::bind_method("_node_changed", &VisualShaderEditor::_node_changed);
ClassDB::bind_method("_input_select_item", &VisualShaderEditor::_input_select_item);
@@ -5439,7 +5482,7 @@ void VisualShaderEditorPlugin::make_visible(bool p_visible) {
//editor->animation_panel_make_visible(true);
button->show();
EditorNode::get_singleton()->make_bottom_panel_item_visible(visual_shader_editor);
- visual_shader_editor->update_custom_nodes();
+ visual_shader_editor->update_nodes();
visual_shader_editor->set_process_input(true);
//visual_shader_editor->set_process(true);
} else {
@@ -5919,8 +5962,8 @@ void EditorPropertyShaderMode::_option_selected(int p_which) {
}
}
- undo_redo->add_do_method(editor, "_update_options_menu");
- undo_redo->add_undo_method(editor, "_update_options_menu");
+ undo_redo->add_do_method(editor, "_update_nodes");
+ undo_redo->add_undo_method(editor, "_update_nodes");
undo_redo->add_do_method(editor, "_update_graph");
undo_redo->add_undo_method(editor, "_update_graph");
diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h
index e26b606397..4087fc583c 100644
--- a/editor/plugins/visual_shader_editor_plugin.h
+++ b/editor/plugins/visual_shader_editor_plugin.h
@@ -262,6 +262,7 @@ class VisualShaderEditor : public VBoxContainer {
void _show_add_varying_dialog();
void _show_remove_varying_dialog();
+ void _update_nodes();
void _update_graph();
struct AddOption {
@@ -394,6 +395,7 @@ class VisualShaderEditor : public VBoxContainer {
String group_inputs;
String group_outputs;
String expression;
+ bool disabled = false;
};
void _dup_copy_nodes(int p_type, List<CopyItem> &r_nodes, List<VisualShader::Connection> &r_connections);
@@ -476,7 +478,7 @@ protected:
static void _bind_methods();
public:
- void update_custom_nodes();
+ void update_nodes();
void add_plugin(const Ref<VisualShaderNodePlugin> &p_plugin);
void remove_plugin(const Ref<VisualShaderNodePlugin> &p_plugin);
diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp
index 1ed4d8fb32..07cb6a23e8 100644
--- a/platform/linuxbsd/display_server_x11.cpp
+++ b/platform/linuxbsd/display_server_x11.cpp
@@ -2094,7 +2094,7 @@ void DisplayServerX11::window_set_flag(WindowFlags p_flag, bool p_enabled, Windo
XGetWindowAttributes(x11_display, wd.x11_window, &xwa);
ERR_FAIL_COND_MSG(p_window == MAIN_WINDOW_ID, "Main window can't be popup.");
- ERR_FAIL_COND_MSG((xwa.map_state == IsViewable) && (wd.is_popup != p_enabled), "Pupup flag can't changed while window is opened.");
+ ERR_FAIL_COND_MSG((xwa.map_state == IsViewable) && (wd.is_popup != p_enabled), "Popup flag can't changed while window is opened.");
wd.is_popup = p_enabled;
} break;
default: {
@@ -3660,10 +3660,14 @@ void DisplayServerX11::process_events() {
const WindowData &wd = windows[window_id];
+ XWindowAttributes xwa;
+ XSync(x11_display, False);
+ XGetWindowAttributes(x11_display, wd.x11_window, &xwa);
+
// Set focus when menu window is re-used.
// RevertToPointerRoot is used to make sure we don't lose all focus in case
// a subwindow and its parent are both destroyed.
- if (!wd.no_focus && !wd.is_popup) {
+ if ((xwa.map_state == IsViewable) && !wd.no_focus && !wd.is_popup) {
XSetInputFocus(x11_display, wd.x11_window, RevertToPointerRoot, CurrentTime);
}
diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm
index a4cd8f58bd..89ca6e50ec 100644
--- a/platform/osx/display_server_osx.mm
+++ b/platform/osx/display_server_osx.mm
@@ -1864,7 +1864,7 @@ void DisplayServerOSX::window_set_flag(WindowFlags p_flag, bool p_enabled, Windo
} break;
case WINDOW_FLAG_POPUP: {
ERR_FAIL_COND_MSG(p_window == MAIN_WINDOW_ID, "Main window can't be popup.");
- ERR_FAIL_COND_MSG([wd.window_object isVisible] && (wd.is_popup != p_enabled), "Pupup flag can't changed while window is opened.");
+ ERR_FAIL_COND_MSG([wd.window_object isVisible] && (wd.is_popup != p_enabled), "Popup flag can't changed while window is opened.");
wd.is_popup = p_enabled;
} break;
default: {
diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp
index 163f5c350b..27b4a2018f 100644
--- a/platform/windows/display_server_windows.cpp
+++ b/platform/windows/display_server_windows.cpp
@@ -1238,7 +1238,7 @@ void DisplayServerWindows::window_set_flag(WindowFlags p_flag, bool p_enabled, W
} break;
case WINDOW_FLAG_POPUP: {
ERR_FAIL_COND_MSG(p_window == MAIN_WINDOW_ID, "Main window can't be popup.");
- ERR_FAIL_COND_MSG(IsWindowVisible(wd.hWnd) && (wd.is_popup != p_enabled), "Pupup flag can't changed while window is opened.");
+ ERR_FAIL_COND_MSG(IsWindowVisible(wd.hWnd) && (wd.is_popup != p_enabled), "Popup flag can't changed while window is opened.");
wd.is_popup = p_enabled;
} break;
case WINDOW_FLAG_MAX:
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index 0338326bbe..ab86face7e 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -349,7 +349,7 @@ Ref<Shortcut> BaseButton::get_shortcut() const {
void BaseButton::unhandled_key_input(const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(p_event.is_null());
- if (!_is_focus_owner_in_shorcut_context()) {
+ if (!_is_focus_owner_in_shortcut_context()) {
return;
}
@@ -404,7 +404,7 @@ Node *BaseButton::get_shortcut_context() const {
return ctx_node;
}
-bool BaseButton::_is_focus_owner_in_shorcut_context() const {
+bool BaseButton::_is_focus_owner_in_shortcut_context() const {
if (shortcut_context == ObjectID()) {
// No context, therefore global - always "in" context.
return true;
diff --git a/scene/gui/base_button.h b/scene/gui/base_button.h
index 6bfffe7575..a2b6ee0845 100644
--- a/scene/gui/base_button.h
+++ b/scene/gui/base_button.h
@@ -80,7 +80,7 @@ protected:
virtual void unhandled_key_input(const Ref<InputEvent> &p_event) override;
void _notification(int p_what);
- bool _is_focus_owner_in_shorcut_context() const;
+ bool _is_focus_owner_in_shortcut_context() const;
GDVIRTUAL0(_pressed)
GDVIRTUAL1(_toggled, bool)
diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp
index c04690cdb3..7e724e4d71 100644
--- a/scene/gui/menu_button.cpp
+++ b/scene/gui/menu_button.cpp
@@ -36,7 +36,7 @@
void MenuButton::unhandled_key_input(const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(p_event.is_null());
- if (!_is_focus_owner_in_shorcut_context()) {
+ if (!_is_focus_owner_in_shortcut_context()) {
return;
}
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 1c9eb14a24..bad7be7d42 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -3250,6 +3250,10 @@ void RichTextLabel::append_text(const String &p_bbcode) {
push_paragraph(HORIZONTAL_ALIGNMENT_FILL);
pos = brk_end + 1;
tag_stack.push_front(tag);
+ } else if (tag == "left") {
+ push_paragraph(HORIZONTAL_ALIGNMENT_LEFT);
+ pos = brk_end + 1;
+ tag_stack.push_front(tag);
} else if (tag == "right") {
push_paragraph(HORIZONTAL_ALIGNMENT_RIGHT);
pos = brk_end + 1;
diff --git a/scene/gui/tab_bar.cpp b/scene/gui/tab_bar.cpp
index a11248ec6b..2f5df9b756 100644
--- a/scene/gui/tab_bar.cpp
+++ b/scene/gui/tab_bar.cpp
@@ -71,7 +71,7 @@ Size2 TabBar::get_minimum_size() const {
Ref<Texture2D> tex = tabs[i].icon;
if (tex.is_valid()) {
- ms.height = MAX(ms.height, tex->get_size().height);
+ ms.height = MAX(ms.height, tex->get_size().height + y_margin);
ms.width += tex->get_size().width + hseparation;
}
@@ -91,13 +91,13 @@ Size2 TabBar::get_minimum_size() const {
ms.width += button_highlight->get_margin(SIDE_LEFT) + rb->get_width() + hseparation;
}
- ms.height = MAX(rb->get_height() + style->get_minimum_size().height, ms.height);
+ ms.height = MAX(ms.height, rb->get_height() + y_margin);
}
if (close_visible) {
ms.width += button_highlight->get_margin(SIDE_LEFT) + close->get_width() + hseparation;
- ms.height = MAX(close->get_height() + style->get_minimum_size().height, ms.height);
+ ms.height = MAX(ms.height, close->get_height() + y_margin);
}
if (ms.width - ofs > style->get_minimum_size().width) {
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index 102fe18502..ee61c862b7 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -624,7 +624,7 @@ void TabContainer::set_all_tabs_in_front(bool p_in_front) {
all_tabs_in_front = p_in_front;
remove_child(tab_bar);
- add_child(tab_bar, false, all_tabs_in_front ? INTERNAL_MODE_BACK : INTERNAL_MODE_FRONT);
+ add_child(tab_bar, false, all_tabs_in_front ? INTERNAL_MODE_FRONT : INTERNAL_MODE_BACK);
}
bool TabContainer::is_all_tabs_in_front() const {
@@ -635,14 +635,13 @@ void TabContainer::set_tab_title(int p_tab, const String &p_title) {
Control *child = get_tab_control(p_tab);
ERR_FAIL_COND(!child);
- if (p_title.is_empty()) {
- tab_bar->set_tab_title(p_tab, String(child->get_name()));
+ tab_bar->set_tab_title(p_tab, p_title);
+ if (p_title == child->get_name()) {
if (child->has_meta("_tab_name")) {
child->remove_meta("_tab_name");
}
} else {
- tab_bar->set_tab_title(p_tab, p_title);
child->set_meta("_tab_name", p_title);
}
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index 0b66ff004b..a396ef01f4 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -1016,7 +1016,7 @@ void register_scene_types() {
ClassDB::add_compatibility_class("SpringArm", "SpringArm3D");
ClassDB::add_compatibility_class("Sprite", "Sprite2D");
ClassDB::add_compatibility_class("StaticBody", "StaticBody3D");
- ClassDB::add_compatibility_class("CompressedTexture", "CompressedTexture2D");
+ ClassDB::add_compatibility_class("StreamTexture", "CompressedTexture2D");
ClassDB::add_compatibility_class("TextureProgress", "TextureProgressBar");
ClassDB::add_compatibility_class("VehicleBody", "VehicleBody3D");
ClassDB::add_compatibility_class("VehicleWheel", "VehicleWheel3D");
@@ -1046,6 +1046,14 @@ void register_scene_types() {
ClassDB::add_compatibility_class("VisualShaderNodeScalarDerivativeFunc", "VisualShaderNodeDerivativeFunc");
ClassDB::add_compatibility_class("VisualShaderNodeVectorDerivativeFunc", "VisualShaderNodeDerivativeFunc");
ClassDB::add_compatibility_class("World", "World3D");
+
+ // Renamed during 4.0 alpha, added to ease transition between alphas.
+ ClassDB::add_compatibility_class("StreamCubemap", "CompressedCubemap");
+ ClassDB::add_compatibility_class("StreamCubemapArray", "CompressedCubemapArray");
+ ClassDB::add_compatibility_class("StreamTexture2D", "CompressedTexture2D");
+ ClassDB::add_compatibility_class("StreamTexture2DArray", "CompressedTexture2DArray");
+ ClassDB::add_compatibility_class("StreamTexture3D", "CompressedTexture3D");
+ ClassDB::add_compatibility_class("StreamTextureLayered", "CompressedTextureLayered");
#endif /* DISABLE_DEPRECATED */
OS::get_singleton()->yield(); // may take time to init
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp
index 03b768e869..d3e61dbc84 100644
--- a/scene/resources/visual_shader.cpp
+++ b/scene/resources/visual_shader.cpp
@@ -455,32 +455,69 @@ String VisualShaderNodeCustom::generate_code(Shader::Mode p_mode, VisualShader::
for (int i = 0; i < get_output_port_count(); i++) {
output_vars.push_back(p_output_vars[i]);
}
- String code = " {\n";
+
String _code;
GDVIRTUAL_CALL(_get_code, input_vars, output_vars, p_mode, p_type, _code);
- bool nend = _code.ends_with("\n");
- _code = _code.insert(0, " ");
- _code = _code.replace("\n", "\n ");
- code += _code;
- if (!nend) {
- code += "\n }";
- } else {
- code.remove_at(code.size() - 1);
- code += "}";
+ if (_is_valid_code(_code)) {
+ String code = " {\n";
+ bool nend = _code.ends_with("\n");
+ _code = _code.insert(0, " ");
+ _code = _code.replace("\n", "\n ");
+ code += _code;
+ if (!nend) {
+ code += "\n }";
+ } else {
+ code.remove_at(code.size() - 1);
+ code += "}";
+ }
+ code += "\n";
+ return code;
}
- code += "\n";
- return code;
+ return String();
}
String VisualShaderNodeCustom::generate_global_per_node(Shader::Mode p_mode, int p_id) const {
- String ret;
- if (GDVIRTUAL_CALL(_get_global_code, p_mode, ret)) {
- String code = "// " + get_caption() + "\n";
- code += ret;
- code += "\n";
- return code;
+ String _code;
+ if (GDVIRTUAL_CALL(_get_global_code, p_mode, _code)) {
+ if (_is_valid_code(_code)) {
+ String code = "// " + get_caption() + "\n";
+ code += _code;
+ code += "\n";
+ return code;
+ }
}
- return "";
+ return String();
+}
+
+String VisualShaderNodeCustom::generate_global_per_func(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const {
+ String _code;
+ if (GDVIRTUAL_CALL(_get_func_code, p_mode, p_type, _code)) {
+ if (_is_valid_code(_code)) {
+ bool nend = _code.ends_with("\n");
+ String code = "// " + get_caption() + "\n";
+ code += " {\n";
+ _code = _code.insert(0, " ");
+ _code = _code.replace("\n", "\n ");
+ code += _code;
+ if (!nend) {
+ code += "\n }";
+ } else {
+ code.remove_at(code.size() - 1);
+ code += "}";
+ }
+ code += "\n";
+ return code;
+ }
+ }
+ return String();
+}
+
+bool VisualShaderNodeCustom::is_available(Shader::Mode p_mode, VisualShader::Type p_type) const {
+ bool ret;
+ if (GDVIRTUAL_CALL(_is_available, p_mode, p_type, ret)) {
+ return ret;
+ }
+ return true;
}
void VisualShaderNodeCustom::set_input_port_default_value(int p_port, const Variant &p_value, const Variant &p_prev_value) {
@@ -511,6 +548,13 @@ void VisualShaderNodeCustom::_set_input_port_default_value(int p_port, const Var
VisualShaderNode::set_input_port_default_value(p_port, p_value);
}
+bool VisualShaderNodeCustom::_is_valid_code(const String &p_code) const {
+ if (p_code.is_empty() || p_code == "null") {
+ return false;
+ }
+ return true;
+}
+
bool VisualShaderNodeCustom::_is_initialized() {
return is_initialized;
}
@@ -531,8 +575,10 @@ void VisualShaderNodeCustom::_bind_methods() {
GDVIRTUAL_BIND(_get_output_port_type, "port");
GDVIRTUAL_BIND(_get_output_port_name, "port");
GDVIRTUAL_BIND(_get_code, "input_vars", "output_vars", "mode", "type");
+ GDVIRTUAL_BIND(_get_func_code, "mode", "type");
GDVIRTUAL_BIND(_get_global_code, "mode");
GDVIRTUAL_BIND(_is_highend);
+ GDVIRTUAL_BIND(_is_available, "mode", "type");
ClassDB::bind_method(D_METHOD("_set_initialized", "enabled"), &VisualShaderNodeCustom::_set_initialized);
ClassDB::bind_method(D_METHOD("_is_initialized"), &VisualShaderNodeCustom::_is_initialized);
diff --git a/scene/resources/visual_shader.h b/scene/resources/visual_shader.h
index 5cad5fc95b..2d4b2852e9 100644
--- a/scene/resources/visual_shader.h
+++ b/scene/resources/visual_shader.h
@@ -383,14 +383,20 @@ protected:
GDVIRTUAL1RC(int, _get_output_port_type, int)
GDVIRTUAL1RC(String, _get_output_port_name, int)
GDVIRTUAL4RC(String, _get_code, TypedArray<String>, TypedArray<String>, Shader::Mode, VisualShader::Type)
+ GDVIRTUAL2RC(String, _get_func_code, Shader::Mode, VisualShader::Type)
GDVIRTUAL1RC(String, _get_global_code, Shader::Mode)
GDVIRTUAL0RC(bool, _is_highend)
+ GDVIRTUAL2RC(bool, _is_available, Shader::Mode, VisualShader::Type)
+
+ bool _is_valid_code(const String &p_code) const;
protected:
void _set_input_port_default_value(int p_port, const Variant &p_value);
+ bool is_available(Shader::Mode p_mode, VisualShader::Type p_type) const;
virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
virtual String generate_global_per_node(Shader::Mode p_mode, int p_id) const override;
+ virtual String generate_global_per_func(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
static void _bind_methods();
diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp
index a6aa6d8c49..7b4d7e66d4 100644
--- a/scene/resources/visual_shader_nodes.cpp
+++ b/scene/resources/visual_shader_nodes.cpp
@@ -5696,7 +5696,7 @@ String VisualShaderNodeTextureUniformTriplanar::get_input_port_name(int p_port)
String VisualShaderNodeTextureUniformTriplanar::generate_global_per_node(Shader::Mode p_mode, int p_id) const {
String code;
- code += "// TRIPLANAR FUNCTION GLOBAL CODE\n";
+ code += "// " + get_caption() + "\n";
code += " vec4 triplanar_texture(sampler2D p_sampler, vec3 p_weights, vec3 p_triplanar_pos) {\n";
code += " vec4 samp = vec4(0.0);\n";
code += " samp += texture(p_sampler, p_triplanar_pos.xy) * p_weights.z;\n";
@@ -5719,11 +5719,13 @@ String VisualShaderNodeTextureUniformTriplanar::generate_global_per_func(Shader:
String code;
if (p_type == VisualShader::TYPE_VERTEX) {
- code += " // TRIPLANAR FUNCTION VERTEX CODE\n";
+ code += "// " + get_caption() + "\n";
+ code += " {\n";
code += " triplanar_power_normal = pow(abs(NORMAL), vec3(triplanar_sharpness));\n";
code += " triplanar_power_normal /= dot(triplanar_power_normal, vec3(1.0));\n";
code += " triplanar_pos = VERTEX * triplanar_scale + triplanar_offset;\n";
code += " triplanar_pos *= vec3(1.0, -1.0, 1.0);\n";
+ code += " }\n";
}
return code;