Skip to content

Commit

Permalink
Allow to show or hide menu items
Browse files Browse the repository at this point in the history
  • Loading branch information
joseivanlopez committed Sep 30, 2020
1 parent 5b5d24d commit e4bc471
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
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

0 comments on commit e4bc471

Please sign in to comment.