DUDS
Distributed Update of Data from Something
duds::ui::menu::GenericMenuItem Class Reference

A generic take on MenuItem that invokes a Boost signal when the item is chosen, selected, or deselected. More...

#include <GenericMenuItem.hpp>

Inheritance diagram for duds::ui::menu::GenericMenuItem:
Collaboration diagram for duds::ui::menu::GenericMenuItem:

Public Types

typedef boost::signals2::signal< void(MenuView &invokingView, const MenuAccess &access, GenericMenuItem &self) > Signal
 The signal type invoked when the item is chosen, selected, or deselected. More...
 
- Public Types inherited from duds::ui::menu::MenuItem
typedef duds::general::BitFlags< struct MenuItemFlags > Flags
 A set of option and state flags for menu items. More...
 

Public Member Functions

virtual void chose (MenuView &invokingView, const MenuAccess &access)
 Invokes the choseSig signal in response to the user chosing this menu item. More...
 
boost::signals2::connection choseConnect (const typename Signal::slot_type &slot, boost::signals2::connect_position at=boost::signals2::at_back)
 Make a connection to the generic menu item chose signal. More...
 
boost::signals2::connection choseConnect (const typename Signal::group_type &group, const typename Signal::slot_type &slot, boost::signals2::connect_position at=boost::signals2::at_back)
 Make a connection to the generic menu item chose signal. More...
 
boost::signals2::connection choseConnectExtended (const typename Signal::extended_slot_type &slot, boost::signals2::connect_position at=boost::signals2::at_back)
 Make a connection to the generic menu item chose signal. More...
 
boost::signals2::connection choseConnectExtended (const typename Signal::group_type &group, const typename Signal::extended_slot_type &slot, boost::signals2::connect_position at=boost::signals2::at_back)
 Make a connection to the generic menu item chose signal. More...
 
void choseDisconnect (const typename Signal::group_type &group)
 Disconnect a group from the generic menu item chose signal. More...
 
template<typename Slot >
void choseDisconnect (const Slot &slotFunc)
 Disconnect from the generic menu item chose signal. More...
 
virtual void deselect (MenuView &invokingView, const MenuAccess &access)
 Invokes the deselSig signal in response to the user deselecting this menu item. More...
 
boost::signals2::connection deselectConnect (const typename Signal::slot_type &slot, boost::signals2::connect_position at=boost::signals2::at_back)
 Make a connection to the generic menu item deselect signal. More...
 
boost::signals2::connection deselectConnect (const typename Signal::group_type &group, const typename Signal::slot_type &slot, boost::signals2::connect_position at=boost::signals2::at_back)
 Make a connection to the generic menu item deselect signal. More...
 
boost::signals2::connection deselectConnectExtended (const typename Signal::extended_slot_type &slot, boost::signals2::connect_position at=boost::signals2::at_back)
 Make a connection to the generic menu item deselect signal. More...
 
boost::signals2::connection deselectConnectExtended (const typename Signal::group_type &group, const typename Signal::extended_slot_type &slot, boost::signals2::connect_position at=boost::signals2::at_back)
 Make a connection to the generic menu item deselect signal. More...
 
void deselectDisconnect (const typename Signal::group_type &group)
 Disconnect a group from the generic menu item deselect signal. More...
 
template<typename Slot >
void deselectDisconnect (const Slot &slotFunc)
 Disconnect from the generic menu item deselect signal. More...
 
virtual void select (MenuView &invokingView, const MenuAccess &access)
 Invokes the selSig signal in response to the user selecting this menu item. More...
 
boost::signals2::connection selectConnect (const typename Signal::slot_type &slot, boost::signals2::connect_position at=boost::signals2::at_back)
 Make a connection to the generic menu item select signal. More...
 
boost::signals2::connection selectConnect (const typename Signal::group_type &group, const typename Signal::slot_type &slot, boost::signals2::connect_position at=boost::signals2::at_back)
 Make a connection to the generic menu item select signal. More...
 
boost::signals2::connection selectConnectExtended (const typename Signal::extended_slot_type &slot, boost::signals2::connect_position at=boost::signals2::at_back)
 Make a connection to the generic menu item select signal. More...
 
boost::signals2::connection selectConnectExtended (const typename Signal::group_type &group, const typename Signal::extended_slot_type &slot, boost::signals2::connect_position at=boost::signals2::at_back)
 Make a connection to the generic menu item select signal. More...
 
void selectDisconnect (const typename Signal::group_type &group)
 Disconnect a group from the generic menu item select signal. More...
 
template<typename Slot >
void selectDisconnect (const Slot &slotFunc)
 Disconnect from the generic menu item select signal. More...
 
- Public Member Functions inherited from duds::ui::menu::MenuItem
void changeEnabledState (bool state)
 Changes the state of the item to either enabled or disabled. More...
 
void changeToggle (bool state)
 Changes the toggle state of the item to the indicated state. More...
 
void changeVisibility (bool vis)
 Changes the visibility of the item. More...
 
void clearToggle ()
 Clears the toggle state of the item. More...
 
const std::string & description () const
 Returns the optional description text for this item. More...
 
void description (const std::string &d)
 Changes the optional description text for this item. More...
 
void disable ()
 Makes the item disabled. More...
 
void enable ()
 Makes the item enabled. More...
 
Flags flags () const
 Returns the option flags for the item. More...
 
bool hasValue () const
 True if the item is flagged as having a value. More...
 
void hide ()
 Makes the item invisible. More...
 
bool isDisabled () const
 True if the item is flagged as disabled. More...
 
bool isEnabled () const
 True if the item is flagged as enabled. More...
 
bool isInvisible () const
 True if the item is flagged as invisible. More...
 
bool isSelectable () const
 Returns true if the item is both visible and enabled. More...
 
bool isToggle () const
 True if the item is flagged as being a toggle. More...
 
bool isToggledOn () const
 True if the item is in the toggled on (true) state. More...
 
bool isVisible () const
 True if the item is flagged as visible. More...
 
const std::string & label () const
 Returns the label text for this item. More...
 
void label (const std::string &l)
 Changes the label text for this item. More...
 
Menumenu () const
 Returns the menu object that owns this item. More...
 
void remove ()
 Removes the item from its parent menu. More...
 
void setToggle ()
 Sets the toggle state of the item. More...
 
void show ()
 Makes the item visible. More...
 
bool toggle ()
 Toggles the toggle state of the item and returns the new toggle state. More...
 
const std::string & value () const
 Returns the optional value text for the item. More...
 
void value (const std::string &v)
 Changes the optional value text for the item. More...
 

Static Public Member Functions

static std::shared_ptr< GenericMenuItemmake (const std::string &label, Flags flags=Flags::Zero())
 Makes a shared pointer holding a new GenericMenuItem. More...
 
static std::shared_ptr< GenericMenuItemmake (const std::string &label, const std::string &description, Flags flags=Flags::Zero())
 Makes a shared pointer holding a new GenericMenuItem. More...
 
static std::shared_ptr< GenericMenuItemmake (const std::string &label, const std::string &description, const std::string &value, Flags flags=Flags::Zero())
 Makes a shared pointer holding a new GenericMenuItem with an associated value. More...
 

Protected Member Functions

 GenericMenuItem (MenuItemToken, const std::string &label, Flags flags=Flags::Zero())
 Constructs a new GenericMenuItem. More...
 
 GenericMenuItem (MenuItemToken, const std::string &label, const std::string &description, Flags flags=Flags::Zero())
 Constructs a new GenericMenuItem. More...
 
 GenericMenuItem (MenuItemToken, const std::string &label, const std::string &description, const std::string &value, Flags flags=Flags::Zero())
 Constructs a new GenericMenuItem with an associated value. More...
 
- Protected Member Functions inherited from duds::ui::menu::MenuItem
 MenuItem (MenuItemToken, const std::string &label, Flags flags=Flags::Zero())
 Constructs a new MenuItem. More...
 
 MenuItem (MenuItemToken, const std::string &label, const std::string &description, Flags flags=Flags::Zero())
 Constructs a new MenuItem. More...
 
 MenuItem (MenuItemToken, const std::string &label, const std::string &description, const std::string &value, Flags flags=Flags::Zero())
 Constructs a new MenuItem with an associated value. More...
 
 MenuItem (MenuItemToken, const MenuItem &mi)
 Copy constructs a new MenuItem. More...
 

Private Attributes

Signal choseSig
 The signal that is invoked when the user choses this menu item. More...
 
Signal deselSig
 The signal that is invoked when the user deselects this menu item. More...
 
Signal selSig
 The signal that is invoked when the user selects this menu item. More...
 

Additional Inherited Members

- Static Public Attributes inherited from duds::ui::menu::MenuItem
static constexpr Flags Disabled = Flags::Bit(0)
 Indicates that the item may not be chosen by the user. More...
 
static constexpr Flags HasValue = Flags::Bit(2)
 Indicates that the item has a value, or setting, that should be shown in the menu if possible. More...
 
static constexpr Flags Invisible = Flags::Bit(1)
 Indicates that the item will not be rendered. More...
 
static constexpr Flags Toggle = Flags::Bit(3)
 Denotes that the item is a toggle, and that the toggle state should be visible on the menu. More...
 
static constexpr Flags ToggledOn = Flags::Bit(4)
 The toggle state; true when the state is on, when the item is true. More...
 

Detailed Description

A generic take on MenuItem that invokes a Boost signal when the item is chosen, selected, or deselected.

Author
Jeff Jackowski
Examples:
bppmenu.cpp.

Definition at line 23 of file GenericMenuItem.hpp.

Member Typedef Documentation

◆ Signal

typedef boost::signals2::signal< void( MenuView &invokingView, const MenuAccess &access, GenericMenuItem &self ) > duds::ui::menu::GenericMenuItem::Signal

The signal type invoked when the item is chosen, selected, or deselected.

Parameters
invokingViewThe view used to chose or select the menu item.
accessAn access object for the menu that may be used to modify the menu.
selfThe GenericMenuItem that invoked the signal.

Definition at line 38 of file GenericMenuItem.hpp.

Constructor & Destructor Documentation

◆ GenericMenuItem() [1/3]

duds::ui::menu::GenericMenuItem::GenericMenuItem ( MenuItemToken  ,
const std::string &  label,
Flags  flags = Flags::Zero() 
)
inlineprotected

Constructs a new GenericMenuItem.

Note
All MenuItem objects must be managed by std::shared_ptr.
Parameters
labelShort text presented to the user as the menu item.
flagsThe option flags for the item. The default is zero: enabled, visible, no value, and not a toggle.
See also
make(const std::string &, Flags)

Definition at line 62 of file GenericMenuItem.hpp.

◆ GenericMenuItem() [2/3]

duds::ui::menu::GenericMenuItem::GenericMenuItem ( MenuItemToken  ,
const std::string &  label,
const std::string &  description,
Flags  flags = Flags::Zero() 
)
inlineprotected

Constructs a new GenericMenuItem.

Note
All MenuItem objects must be managed by std::shared_ptr.
Parameters
labelShort text presented to the user as the menu item.
descriptionLonger text optionally presented to the user to provide a better idea of what the option does.
flagsThe option flags for the item. The default is zero: enabled, visible, no value, and not a toggle.
See also
make(const std::string &, const std::string &, Flags)

Definition at line 78 of file GenericMenuItem.hpp.

◆ GenericMenuItem() [3/3]

duds::ui::menu::GenericMenuItem::GenericMenuItem ( MenuItemToken  ,
const std::string &  label,
const std::string &  description,
const std::string &  value,
Flags  flags = Flags::Zero() 
)
inlineprotected

Constructs a new GenericMenuItem with an associated value.

Note
All MenuItem objects must be managed by std::shared_ptr.
Parameters
labelShort text presented to the user as the menu item.
descriptionLonger text optionally presented to the user to provide a better idea of what the option does.
valueThe current value associated with the menu item.
flagsThe option flags for the item. While the default is zero, the MenuItem::HasValue flag will be OR'd with the given value by the constructor.
See also
make(const std::string &, const std::string &, const std::string &, Flags)

Definition at line 97 of file GenericMenuItem.hpp.

Member Function Documentation

◆ chose()

void duds::ui::menu::GenericMenuItem::chose ( MenuView invokingView,
const MenuAccess access 
)
virtual

Invokes the choseSig signal in response to the user chosing this menu item.

Use one of the choseConnect() or choseConnectExtended() functions to make connections to the signal.

Implements duds::ui::menu::MenuItem.

Definition at line 14 of file GenericMenuItem.cpp.

Referenced by make().

◆ choseConnect() [1/2]

boost::signals2::connection duds::ui::menu::GenericMenuItem::choseConnect ( const typename Signal::slot_type &  slot,
boost::signals2::connect_position  at = boost::signals2::at_back 
)
inline

Make a connection to the generic menu item chose signal.

See the Boost reference documentation for more details, or the tutorial for an overview of the whole boost::singals2 system.

Definition at line 183 of file GenericMenuItem.hpp.

◆ choseConnect() [2/2]

boost::signals2::connection duds::ui::menu::GenericMenuItem::choseConnect ( const typename Signal::group_type &  group,
const typename Signal::slot_type &  slot,
boost::signals2::connect_position  at = boost::signals2::at_back 
)
inline

Make a connection to the generic menu item chose signal.

See the Boost reference documentation for more details, or the tutorial for an overview of the whole boost::singals2 system.

Definition at line 195 of file GenericMenuItem.hpp.

◆ choseConnectExtended() [1/2]

boost::signals2::connection duds::ui::menu::GenericMenuItem::choseConnectExtended ( const typename Signal::extended_slot_type &  slot,
boost::signals2::connect_position  at = boost::signals2::at_back 
)
inline

Make a connection to the generic menu item chose signal.

See the Boost reference documentation for more details, or the tutorial for an overview of the whole boost::singals2 system.

Definition at line 208 of file GenericMenuItem.hpp.

◆ choseConnectExtended() [2/2]

boost::signals2::connection duds::ui::menu::GenericMenuItem::choseConnectExtended ( const typename Signal::group_type &  group,
const typename Signal::extended_slot_type &  slot,
boost::signals2::connect_position  at = boost::signals2::at_back 
)
inline

Make a connection to the generic menu item chose signal.

See the Boost reference documentation for more details, or the tutorial for an overview of the whole boost::singals2 system.

Definition at line 220 of file GenericMenuItem.hpp.

◆ choseDisconnect() [1/2]

void duds::ui::menu::GenericMenuItem::choseDisconnect ( const typename Signal::group_type &  group)
inline

Disconnect a group from the generic menu item chose signal.

See the Boost reference documentation for more details, or the tutorial for an overview of the whole boost::singals2 system.

Definition at line 233 of file GenericMenuItem.hpp.

◆ choseDisconnect() [2/2]

template<typename Slot >
void duds::ui::menu::GenericMenuItem::choseDisconnect ( const Slot &  slotFunc)
inline

Disconnect from the generic menu item chose signal.

See the Boost reference documentation for more details, or the tutorial for an overview of the whole boost::singals2 system.

Definition at line 245 of file GenericMenuItem.hpp.

◆ deselect()

void duds::ui::menu::GenericMenuItem::deselect ( MenuView invokingView,
const MenuAccess access 
)
virtual

Invokes the deselSig signal in response to the user deselecting this menu item.

Reimplemented from duds::ui::menu::MenuItem.

Definition at line 22 of file GenericMenuItem.cpp.

Referenced by make().

◆ deselectConnect() [1/2]

boost::signals2::connection duds::ui::menu::GenericMenuItem::deselectConnect ( const typename Signal::slot_type &  slot,
boost::signals2::connect_position  at = boost::signals2::at_back 
)
inline

Make a connection to the generic menu item deselect signal.

See the Boost reference documentation for more details, or the tutorial for an overview of the whole boost::singals2 system.

Definition at line 325 of file GenericMenuItem.hpp.

◆ deselectConnect() [2/2]

boost::signals2::connection duds::ui::menu::GenericMenuItem::deselectConnect ( const typename Signal::group_type &  group,
const typename Signal::slot_type &  slot,
boost::signals2::connect_position  at = boost::signals2::at_back 
)
inline

Make a connection to the generic menu item deselect signal.

See the Boost reference documentation for more details, or the tutorial for an overview of the whole boost::singals2 system.

Definition at line 337 of file GenericMenuItem.hpp.

◆ deselectConnectExtended() [1/2]

boost::signals2::connection duds::ui::menu::GenericMenuItem::deselectConnectExtended ( const typename Signal::extended_slot_type &  slot,
boost::signals2::connect_position  at = boost::signals2::at_back 
)
inline

Make a connection to the generic menu item deselect signal.

See the Boost reference documentation for more details, or the tutorial for an overview of the whole boost::singals2 system.

Definition at line 350 of file GenericMenuItem.hpp.

◆ deselectConnectExtended() [2/2]

boost::signals2::connection duds::ui::menu::GenericMenuItem::deselectConnectExtended ( const typename Signal::group_type &  group,
const typename Signal::extended_slot_type &  slot,
boost::signals2::connect_position  at = boost::signals2::at_back 
)
inline

Make a connection to the generic menu item deselect signal.

See the Boost reference documentation for more details, or the tutorial for an overview of the whole boost::singals2 system.

Definition at line 362 of file GenericMenuItem.hpp.

◆ deselectDisconnect() [1/2]

void duds::ui::menu::GenericMenuItem::deselectDisconnect ( const typename Signal::group_type &  group)
inline

Disconnect a group from the generic menu item deselect signal.

See the Boost reference documentation for more details, or the tutorial for an overview of the whole boost::singals2 system.

Definition at line 375 of file GenericMenuItem.hpp.

◆ deselectDisconnect() [2/2]

template<typename Slot >
void duds::ui::menu::GenericMenuItem::deselectDisconnect ( const Slot &  slotFunc)
inline

Disconnect from the generic menu item deselect signal.

See the Boost reference documentation for more details, or the tutorial for an overview of the whole boost::singals2 system.

Definition at line 387 of file GenericMenuItem.hpp.

◆ make() [1/3]

static std::shared_ptr<GenericMenuItem> duds::ui::menu::GenericMenuItem::make ( const std::string &  label,
Flags  flags = Flags::Zero() 
)
inlinestatic

Makes a shared pointer holding a new GenericMenuItem.

Parameters
labelShort text presented to the user as the menu item.
flagsThe option flags for the item. The default is zero: enabled, visible, no value, and not a toggle.

Definition at line 110 of file GenericMenuItem.hpp.

◆ make() [2/3]

static std::shared_ptr<GenericMenuItem> duds::ui::menu::GenericMenuItem::make ( const std::string &  label,
const std::string &  description,
Flags  flags = Flags::Zero() 
)
inlinestatic

Makes a shared pointer holding a new GenericMenuItem.

Parameters
labelShort text presented to the user as the menu item.
descriptionLonger text optionally presented to the user to provide a better idea of what the option does.
flagsThe option flags for the item. The default is zero: enabled, visible, no value, and not a toggle.

Definition at line 124 of file GenericMenuItem.hpp.

◆ make() [3/3]

static std::shared_ptr<GenericMenuItem> duds::ui::menu::GenericMenuItem::make ( const std::string &  label,
const std::string &  description,
const std::string &  value,
Flags  flags = Flags::Zero() 
)
inlinestatic

Makes a shared pointer holding a new GenericMenuItem with an associated value.

Parameters
labelShort text presented to the user as the menu item.
descriptionLonger text optionally presented to the user to provide a better idea of what the option does.
valueThe current value associated with the menu item.
flagsThe option flags for the item. While the default is zero, the MenuItem::HasValue flag will be OR'd with the given value by the constructor.

Definition at line 147 of file GenericMenuItem.hpp.

◆ select()

void duds::ui::menu::GenericMenuItem::select ( MenuView invokingView,
const MenuAccess access 
)
virtual

Invokes the selSig signal in response to the user selecting this menu item.

Reimplemented from duds::ui::menu::MenuItem.

Definition at line 18 of file GenericMenuItem.cpp.

Referenced by make().

◆ selectConnect() [1/2]

boost::signals2::connection duds::ui::menu::GenericMenuItem::selectConnect ( const typename Signal::slot_type &  slot,
boost::signals2::connect_position  at = boost::signals2::at_back 
)
inline

Make a connection to the generic menu item select signal.

See the Boost reference documentation for more details, or the tutorial for an overview of the whole boost::singals2 system.

Definition at line 254 of file GenericMenuItem.hpp.

◆ selectConnect() [2/2]

boost::signals2::connection duds::ui::menu::GenericMenuItem::selectConnect ( const typename Signal::group_type &  group,
const typename Signal::slot_type &  slot,
boost::signals2::connect_position  at = boost::signals2::at_back 
)
inline

Make a connection to the generic menu item select signal.

See the Boost reference documentation for more details, or the tutorial for an overview of the whole boost::singals2 system.

Definition at line 266 of file GenericMenuItem.hpp.

◆ selectConnectExtended() [1/2]

boost::signals2::connection duds::ui::menu::GenericMenuItem::selectConnectExtended ( const typename Signal::extended_slot_type &  slot,
boost::signals2::connect_position  at = boost::signals2::at_back 
)
inline

Make a connection to the generic menu item select signal.

See the Boost reference documentation for more details, or the tutorial for an overview of the whole boost::singals2 system.

Definition at line 279 of file GenericMenuItem.hpp.

◆ selectConnectExtended() [2/2]

boost::signals2::connection duds::ui::menu::GenericMenuItem::selectConnectExtended ( const typename Signal::group_type &  group,
const typename Signal::extended_slot_type &  slot,
boost::signals2::connect_position  at = boost::signals2::at_back 
)
inline

Make a connection to the generic menu item select signal.

See the Boost reference documentation for more details, or the tutorial for an overview of the whole boost::singals2 system.

Definition at line 291 of file GenericMenuItem.hpp.

◆ selectDisconnect() [1/2]

void duds::ui::menu::GenericMenuItem::selectDisconnect ( const typename Signal::group_type &  group)
inline

Disconnect a group from the generic menu item select signal.

See the Boost reference documentation for more details, or the tutorial for an overview of the whole boost::singals2 system.

Definition at line 304 of file GenericMenuItem.hpp.

◆ selectDisconnect() [2/2]

template<typename Slot >
void duds::ui::menu::GenericMenuItem::selectDisconnect ( const Slot &  slotFunc)
inline

Disconnect from the generic menu item select signal.

See the Boost reference documentation for more details, or the tutorial for an overview of the whole boost::singals2 system.

Definition at line 316 of file GenericMenuItem.hpp.

Member Data Documentation

◆ choseSig

Signal duds::ui::menu::GenericMenuItem::choseSig
private

The signal that is invoked when the user choses this menu item.

Definition at line 43 of file GenericMenuItem.hpp.

Referenced by chose().

◆ deselSig

Signal duds::ui::menu::GenericMenuItem::deselSig
private

The signal that is invoked when the user deselects this menu item.

Definition at line 51 of file GenericMenuItem.hpp.

Referenced by deselect().

◆ selSig

Signal duds::ui::menu::GenericMenuItem::selSig
private

The signal that is invoked when the user selects this menu item.

Definition at line 47 of file GenericMenuItem.hpp.

Referenced by select().


The documentation for this class was generated from the following files: