summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuri Rubinsky <chaosus89@gmail.com>2022-11-17 08:40:04 +0300
committerGitHub <noreply@github.com>2022-11-17 08:40:04 +0300
commit966785751f156c9b75be5aabf64bc52390c4b050 (patch)
tree7f1abc3a38046907ad36ef58e2e2ed2d30b90323
parent2846ea1ffafddfc447036b37d255f72cb278b677 (diff)
parent359d13cddc4a9611690ce3e5c463217b54fe0bd0 (diff)
Merge pull request #68741 from Chaosus/vs_fix_varyings_popup
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp22
-rw-r--r--editor/plugins/visual_shader_editor_plugin.h4
2 files changed, 8 insertions, 18 deletions
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index c8f6a2431d..a052d8860e 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -3623,12 +3623,6 @@ void VisualShaderEditor::_show_members_dialog(bool at_mouse_pos, VisualShaderNod
node_filter->select_all();
}
-void VisualShaderEditor::_show_varying_menu() {
- varying_options->set_item_disabled(int(VaryingMenuOptions::REMOVE), visual_shader->get_varyings_count() == 0);
- varying_options->set_position(graph->get_screen_position() + varying_button->get_position() + Size2(0, varying_button->get_size().height));
- varying_options->popup();
-}
-
void VisualShaderEditor::_varying_menu_id_pressed(int p_idx) {
switch (VaryingMenuOptions(p_idx)) {
case VaryingMenuOptions::ADD: {
@@ -4334,7 +4328,7 @@ void VisualShaderEditor::_update_varying_tree() {
}
}
- varying_options->set_item_disabled(int(VaryingMenuOptions::REMOVE), count == 0);
+ varying_button->get_popup()->set_item_disabled(int(VaryingMenuOptions::REMOVE), count == 0);
}
void VisualShaderEditor::_varying_create() {
@@ -4809,17 +4803,15 @@ VisualShaderEditor::VisualShaderEditor() {
graph->get_zoom_hbox()->move_child(add_node, 0);
add_node->connect("pressed", callable_mp(this, &VisualShaderEditor::_show_members_dialog).bind(false, VisualShaderNode::PORT_TYPE_MAX, VisualShaderNode::PORT_TYPE_MAX));
- varying_button = memnew(Button);
- varying_button->set_flat(true);
+ varying_button = memnew(MenuButton);
varying_button->set_text(TTR("Manage Varyings"));
+ varying_button->set_switch_on_hover(true);
graph->get_zoom_hbox()->add_child(varying_button);
- varying_button->connect("pressed", callable_mp(this, &VisualShaderEditor::_show_varying_menu));
- varying_options = memnew(PopupMenu);
- add_child(varying_options);
- varying_options->add_item(TTR("Add Varying"), int(VaryingMenuOptions::ADD));
- varying_options->add_item(TTR("Remove Varying"), int(VaryingMenuOptions::REMOVE));
- varying_options->connect("id_pressed", callable_mp(this, &VisualShaderEditor::_varying_menu_id_pressed));
+ PopupMenu *varying_menu = varying_button->get_popup();
+ varying_menu->add_item(TTR("Add Varying"), int(VaryingMenuOptions::ADD));
+ varying_menu->add_item(TTR("Remove Varying"), int(VaryingMenuOptions::REMOVE));
+ varying_menu->connect("id_pressed", callable_mp(this, &VisualShaderEditor::_varying_menu_id_pressed));
preview_shader = memnew(Button);
preview_shader->set_flat(true);
diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h
index 5e21215738..e673051eb3 100644
--- a/editor/plugins/visual_shader_editor_plugin.h
+++ b/editor/plugins/visual_shader_editor_plugin.h
@@ -165,8 +165,7 @@ class VisualShaderEditor : public VBoxContainer {
Ref<VisualShader> visual_shader;
GraphEdit *graph = nullptr;
Button *add_node = nullptr;
- Button *varying_button = nullptr;
- PopupMenu *varying_options = nullptr;
+ MenuButton *varying_button = nullptr;
Button *preview_shader = nullptr;
OptionButton *edit_type = nullptr;
@@ -283,7 +282,6 @@ class VisualShaderEditor : public VBoxContainer {
void _tools_menu_option(int p_idx);
void _show_members_dialog(bool at_mouse_pos, VisualShaderNode::PortType p_input_port_type = VisualShaderNode::PORT_TYPE_MAX, VisualShaderNode::PortType p_output_port_type = VisualShaderNode::PORT_TYPE_MAX);
- void _show_varying_menu();
void _varying_menu_id_pressed(int p_idx);
void _show_add_varying_dialog();
void _show_remove_varying_dialog();