Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to show or hide menu items #105

Merged
merged 1 commit into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/NCMenuBar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ NCMenuBar::rebuildMenuTree()
if ( ! item->isMenu() )
YUI_THROW( YUIException( "NCMenuBar: Only menus allowed on toplevel. ") );

if ( ! item->isVisible() )
continue;

Menu * menu = new Menu();
menu->item = item;
menu->position = wpos( 0, width );
Expand Down Expand Up @@ -189,6 +192,15 @@ NCMenuBar::setItemEnabled( YMenuItem * item, bool enabled )
}


void
NCMenuBar::setItemVisible( YMenuItem * item, bool visible )
{
YMenuWidget::setItemVisible( item, visible );
rebuildMenuTree();
wRedraw();
}


void
NCMenuBar::activateItem( YMenuItem * item )
{
Expand Down
7 changes: 7 additions & 0 deletions src/NCMenuBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ class NCMenuBar: public YMenuBar, public NCWidget
**/
virtual void setItemEnabled( YMenuItem * item, bool enabled );

/**
* show or hide an item.
*
* Reimplemented from YMenuWidget.
**/
virtual void setItemVisible( YMenuItem * item, bool visible );

/**
* Support for the Rest API for UI testing:
*
Expand Down
3 changes: 3 additions & 0 deletions src/NCPopupMenu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ NCPopupMenu::NCPopupMenu( const wpos & at, YItemIterator begin, YItemIterator en
YMenuItem * menuItem = dynamic_cast<YMenuItem *>( *it );
YUI_CHECK_PTR( menuItem );

if ( ! menuItem->isVisible() )
continue;

row[0] = menuItem->label();
row[1] = menuItem->hasChildren() ? "..." : "";

Expand Down