Package tripleplay.ui
Class Menu
java.lang.Object
- Direct Known Subclasses:
PagedMenu
Holds a collection of
MenuItem
s, dispatching a itemTriggered()
signal
when one is selected and triggered. Normally used in conjunction with MenuHost
to popup
the menu (in its own Root
), manage animations, track user input, and handle
cancellation.
Note that a menu can contain arbitrary Element
s, but only those that are
MenuItem
s are eligible for triggering. Changes to the children of previously added Elements
instances are tracked using Elements.childAdded()
and Elements.childRemoved()
.
Note about Container
types other than Elements
: it is assumed that the
children of such containers will NOT change after addition to the menu. Such changes will result
in undefined behavior, potentially including memory leaks. Scroller
, for example, is
safe to use since it has exactly one child element that doesn't change.
TODO: support escape key to cancel; probably in MenuHost
TODO: support/implement full screen menus - this is probably what most phone apps will want
-
Nested Class Summary
Nested classes/interfaces inherited from class tripleplay.ui.Container
Container.Mutable<T extends Container.Mutable<T>>
Nested classes/interfaces inherited from class tripleplay.ui.Element
Element.Take
-
Field Summary
Modifier and TypeFieldDescriptionstatic Style<Menu.AnimFn>
The closing animation function for the menu.static Menu.AnimFn
Generic animation to fade in a menu using the layer alpha.static Menu.AnimFn
Generic animation to fade out a menu using the layer alpha.static Style<Menu.AnimFn>
The opening animation function for the menu. -
Constructor Summary
ConstructorDescriptionCreates a new menu using the given layout for its elements.Menu
(Layout layout, Style.Binding<?>... styles) Creates a new menu using the given layout and style bindings.Creates a new menu using the given layout and styles. -
Method Summary
Modifier and TypeMethodDescriptionvoid
activate()
Opens this menu, using an animation created by the resolvedOPENER
style.void
Closes this menu, using an animation created by the resolvedCLOSER
style.react.SignalView<Menu>
Gets the signal that is dispatched when the menu is closed and no longer usable.react.SignalView<MenuItem>
Gets the signal that is dispatched when a menu item is selected.Methods inherited from class tripleplay.ui.Elements
add, add, childAdded, childAt, childCount, childRemoved, destroy, destroyAll, destroyAt, iterator, remove, removeAll, removeAt, setStylesheet, stylesheet
Methods inherited from class tripleplay.ui.Container
removeFromParent
Methods inherited from class tripleplay.ui.Element
addStyles, addStyles, bindEnabled, bindVisible, bounds, constraint, enabledSlot, hierarchyChanged, isAdded, isEnabled, isShowing, isVisible, location, parent, setConstraint, setEnabled, setStyles, setStyles, setVisible, size, styles, visibleSlot, x, y
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
FADE_IN
Generic animation to fade in a menu using the layer alpha. -
FADE_OUT
Generic animation to fade out a menu using the layer alpha. -
OPENER
The opening animation function for the menu. -
CLOSER
The closing animation function for the menu.
-
-
Constructor Details
-
Menu
Creates a new menu using the given layout for its elements. -
Menu
Creates a new menu using the given layout and styles. -
Menu
Creates a new menu using the given layout and style bindings.
-
-
Method Details
-
deactivated
Gets the signal that is dispatched when the menu is closed and no longer usable. This occurs if an item is triggered or if the menu is manually cancelled (usingdeactivate()
). -
activate
public void activate()Opens this menu, using an animation created by the resolvedOPENER
style. Once the animation is finished, the user can view theMenuItem
choices. When one is selected and dispatched via theitemTriggered()
signal, the menu is deactivated automatically. -
deactivate
public void deactivate()Closes this menu, using an animation created by the resolvedCLOSER
style. This is normally called automatically when the user clicks off the menu or triggers one of itsMenuItem
s. After the animation is complete, thedeactivated()
signal will be dispatched. -
itemTriggered
Gets the signal that is dispatched when a menu item is selected.
-