NvUIPopup Class Reference

The NvUIPopup class encapsulates the text/button that causes the NvUIPopupMenu to appear. More...

#include <NvUI.h>

Inheritance diagram for NvUIPopup:

NvUIButton NvUIElement

List of all members.

Public Member Functions

 NvUIPopup (uint32_t actionCode, NvUIElement *visrep[NvUIButtonState::MAX], NvUIGraphicFrame *popupFrame, NvUIButton *popper, const char *title=NULL, float pt=0, bool shadowed=false)
 Map item value to a name, for setting title after pick.
virtual ~NvUIPopup ()
 Default destructor.
void AddItem (NvUIElement *el, const char *name, uint32_t value)
 Add an NvUIElement to our popup menu container.
void SetActiveItemValue (uint32_t value)
 Call to set which item is active based on value of item (not 'index').
virtual NvUIEventResponse HandleEvent (const NvGestureEvent &ev, NvUST timeUST, NvUIElement *hasFocus)
 Override so we can special-case presses.
virtual NvUIEventResponse HandleReaction (const NvUIReaction &react)
 Override to handle successful selection of a menu item.
virtual void Draw (const NvUIDrawState &ds)
 Override as we manually Draw our popper visual if we have one.
virtual void SetDrawState (uint32_t n)
 Override as we manually match our popper visual if we have one to our own draw state.
virtual void SetOrigin (float x, float y)
 Override as we need to manually position sub-elements.

Protected Member Functions

void PopupStart ()
 Display the popup in our window and flag our button as 'pressed'.
void PopupFinish ()
 Hide the popup, remove from window, and clear our button back to 'active'.

Friends

class NvUIPopupMenu


Detailed Description

The NvUIPopup class encapsulates the text/button that causes the NvUIPopupMenu to appear.

This is the button object that when pressed causes a menu to pop up in the NvUIWindow in which it is contained.

The menu contents are constructed by adding UI elements representing the 'menu items' to the popup, one at a time, also passing in a text string/name and a value for each item. The individual NvUIElements each handle what occurs in the system when one is chosen, allowing for extreme flexibility in construction and handling of menus. The string:value combinations are used after the popup detects a menu item has been selected to appropriately change the popup button's text to match the selection.

See also:
NvUIPopupMenu

NvUIWindow

NvUIButton


Constructor & Destructor Documentation

NvUIPopup::NvUIPopup ( uint32_t  actionCode,
NvUIElement visrep[NvUIButtonState::MAX],
NvUIGraphicFrame popupFrame,
NvUIButton popper,
const char *  title = NULL,
float  pt = 0,
bool  shadowed = false 
)

Map item value to a name, for setting title after pick.

Default constructor for popup object.

Parameters:
actionCode The action code generated when user presses on us, so we know to display/hide popup menu.
visrep Standard array of visuals for button states
popupFrame A graphic frame surrounding the popup menu contents
popper A small button visual that denotes we have a menu for the user
title [optional] Prefix for our button title, prepended to current menu item name. Defaults NULL.
pt [optional] Point size for font for our title. Defaults to 0.
shadowed [optional] Whether our title should have drop shadow. Defaults false.


Member Function Documentation

void NvUIPopup::AddItem ( NvUIElement el,
const char *  name,
uint32_t  value 
)

Add an NvUIElement to our popup menu container.

Parameters:
el NvUIElement to add next in order.
name Title for the value this item represents, for showing to user when we're not popped up.
value Value sent through our reaction when this item is clicked in the menu.

virtual void NvUIPopup::Draw ( const NvUIDrawState ds  )  [virtual]

Override as we manually Draw our popper visual if we have one.

Reimplemented from NvUIButton.

virtual NvUIEventResponse NvUIPopup::HandleEvent ( const NvGestureEvent ev,
NvUST  timeUST,
NvUIElement hasFocus 
) [virtual]

Override so we can special-case presses.

We override and call inherited method first. When it returns, if there was a reaction, and the gesture was a press, then depending on our state we either show or hide our popup menu.

We also then clear the reaction flag, as we never want our base button to cause a reaction, only the menu items in the popup itself cause reactions.

See also:
PopupStart

PopupFinish

NvUIButton

Reimplemented from NvUIButton.

virtual NvUIEventResponse NvUIPopup::HandleReaction ( const NvUIReaction react  )  [virtual]

Override to handle successful selection of a menu item.

When a menu item is selected, we reset our button title to use the selected item's name, we finish/hide the popup menu, and we proxy the reaction to our menu so that it can also react as needed (highlighting the right item, etc.). Finally, call inherited method when we're all done.

See also:
NvUIReaction

NvUIPopupMenu

PopupFinish

NvUIButton

Reimplemented from NvUIButton.

void NvUIPopup::PopupFinish (  )  [protected]

Hide the popup, remove from window, and clear our button back to 'active'.

void NvUIPopup::PopupStart (  )  [protected]

Display the popup in our window and flag our button as 'pressed'.

void NvUIPopup::SetActiveItemValue ( uint32_t  value  ) 

Call to set which item is active based on value of item (not 'index').

virtual void NvUIPopup::SetDrawState ( uint32_t  n  )  [virtual]

Override as we manually match our popper visual if we have one to our own draw state.

Reimplemented from NvUIElement.

virtual void NvUIPopup::SetOrigin ( float  x,
float  y 
) [virtual]

Override as we need to manually position sub-elements.

Specifically, we position our popper visual if we have one, override our title position (as we know better than our button superclass), and set the popup menu position so it is ready to display.

Reimplemented from NvUIButton.


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