Skip to content

Commit

Permalink
GH-455 Fix collapse/expand fault in all actions menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Naros committed Jun 29, 2024
1 parent 86fa334 commit ea7cf97
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/editor/graph/actions/action_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ void OrchestratorGraphActionMenu::_notification(int p_what)
_tree_view->set_select_mode(Tree::SELECT_ROW);
_tree_view->connect("item_activated", callable_mp(this, &OrchestratorGraphActionMenu::_on_tree_item_activated));
_tree_view->connect("item_selected", callable_mp(this, &OrchestratorGraphActionMenu::_on_tree_item_selected));
_tree_view->connect("nothing_selected", callable_mp(this, &OrchestratorGraphActionMenu::_on_tree_item_activated));
_tree_view->connect("nothing_selected", callable_mp(this, &OrchestratorGraphActionMenu::_on_tree_nothing_selected));
_tree_view->connect("button_clicked", callable_mp(this, &OrchestratorGraphActionMenu::_on_tree_button_clicked));
_tree_view->connect("item_collapsed", callable_mp(this, &OrchestratorGraphActionMenu::_on_tree_item_collapsed));
vbox->add_child(_tree_view);

set_ok_button_text("Add");
Expand Down Expand Up @@ -392,6 +393,23 @@ void OrchestratorGraphActionMenu::_on_tree_item_activated()
_notify_and_close(_tree_view->get_selected());
}

void OrchestratorGraphActionMenu::_on_tree_nothing_selected()
{
// Although Godot Tree dispatches nothing_selected, it does have a selected item,
// so this needs to be cleared and the Add button needs to be disabled.
_tree_view->deselect_all();
get_ok_button()->set_disabled(true);
}

void OrchestratorGraphActionMenu::_on_tree_item_collapsed(TreeItem* p_item)
{
if (!p_item || p_item->get_child_count() > 0)
{
_tree_view->deselect_all();
get_ok_button()->set_disabled(true);
}
}

void OrchestratorGraphActionMenu::_on_tree_button_clicked(TreeItem* p_item, int p_column, int p_id, int p_button_index)
{
// There is currently only 1 button for marking favorites
Expand Down
7 changes: 7 additions & 0 deletions src/editor/graph/actions/action_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ class OrchestratorGraphActionMenu : public ConfirmationDialog
/// Dispatched when a tree element is double-clicked
void _on_tree_item_activated();

/// Dispatched when clicking anywhere in the tree with no selection
void _on_tree_nothing_selected();

/// Dispached when a tree item is collapsed or expanded
/// @param p_item the item collapsed or expanded
void _on_tree_item_collapsed(TreeItem* p_item);

/// Dispatched when the user clicks a button in the tree
/// @param p_item the current tree item who's button was clicked
/// @param p_column the column the button is within
Expand Down

0 comments on commit ea7cf97

Please sign in to comment.