跳轉到主要內容

SlideMenu

SlideMenu is a menu that can expand and collapse at the touch of a button. The SlideMenu can expand in any of the four directions. Menu items can be added, just like items are added to a normal container.

The relative positions of the background and state change button is configurable as is the direction in which the SlideMenu expands and collapses. How much of the SlideMenu that is visible when collapsed can also be set with the. It is, of course, important that the state change button is accessible when collapsed. The SlideMenu will collapse after a given timeout is reached. The timer can be reset, for example when the user interacts with elements in the list.

Menu elements are added normally using the add() method and are positioned relative to the SlideMenu.

Inherits from: Container, Drawable

Public Types

enumExpandDirection { SOUTH, NORTH, EAST, WEST }
Values that represent the expand directions.
enumState { COLLAPSED, EXPANDED }
Values that represent the SlideMenu states.

Public Functions

virtual voidadd(Drawable & d)
Adds a drawable to the container.
virtual voidanimateToState(State newState)
Animate to the given expanded or collapsed state.
virtual uint16_tgetAnimationDuration() const
Gets the animation duration.
virtual EasingEquationgetAnimationEasingEquation() const
Gets the animation easing equation.
virtual int16_tgetBackgroundX() const
Gets the background Image x coordinate.
virtual int16_tgetBackgroundY() const
Gets the background Image y coordinate.
virtual ExpandDirectiongetExpandDirection() const
Gets the expand direction.
virtual uint16_tgetExpandedStateTimeout() const
Gets expanded state timeout.
virtual uint16_tgetExpandedStateTimer() const
Gets the expanded state timer.
virtual int16_tgetHiddenPixelsWhenExpanded() const
Gets the hidden pixels when expanded.
virtual StategetState()
Gets the current expanded or collapsed state.
virtual int16_tgetStateChangeButtonX() const
Gets the state change button x coordinate.
virtual int16_tgetStateChangeButtonY() const
Gets the state change button y coordinate.
virtual int16_tgetVisiblePixelsWhenCollapsed() const
Gets the visible pixels when collapsed.
virtual voidhandleTickEvent()
Called periodically by the framework if the Drawable instance has subscribed to timer ticks.
virtual voidremove(Drawable & d)
Removes the drawable from the container.
virtual voidresetExpandedStateTimer()
Resets the expanded state timer.
virtual voidsetAnimationDuration(uint16_t duration)
Sets the animation duration.
virtual voidsetAnimationEasingEquation(EasingEquation animationEasingEquation)
Sets the animation easing equation.
virtual voidsetExpandDirection(ExpandDirection newExpandDirection)
Sets the expand direction.
virtual voidsetExpandedStateTimeout(uint16_t timeout)
Sets the expanded state timeout in ticks.
virtual voidsetHiddenPixelsWhenExpanded(int16_t hiddenPixels)
Sets the amount of hidden pixels when expanded.
virtual voidsetState(State newState)
Sets the state of the SlideMenu.
virtual voidsetStateChangedAnimationEndedCallback(GenericCallback< const SlideMenu & > & callback)
Set the state change animation ended callback.
virtual voidsetStateChangedCallback(GenericCallback< const SlideMenu & > & callback)
Set the state changed callback.
virtual voidsetup(ExpandDirection newExpandDirection, const Bitmap & backgroundBMP, const Bitmap & stateChangeButtonBMP, const Bitmap & stateChangeButtonPressedBMP)
Setup the SlideMenu by positioning the stateChangeButton next to background image relative to the expand direction, and center it in the other dimension.
virtual voidsetup(ExpandDirection newExpandDirection, const Bitmap & backgroundBMP, const Bitmap & stateChangeButtonBMP, const Bitmap & stateChangeButtonPressedBMP, int16_t backgroundX, int16_t backgroundY, int16_t stateChangeButtonX, int16_t stateChangeButtonY)
Setup method for the SlideMenu.
virtual voidsetup(ExpandDirection newExpandDirection, const Bitmap & backgroundBMP, int16_t backgroundX, int16_t backgroundY)
Setup method for the SlideMenu.
virtual voidsetVisiblePixelsWhenCollapsed(int16_t visiblePixels)
Sets the amount of visible pixels when collapsed.
SlideMenu()
virtual ~SlideMenu()

Protected Functions

voidanimationEndedHandler(const MoveAnimator< Container > & container)
Handler for the state change animation ended event.
virtual int16_tgetCollapsedXCoordinate()
Gets the x coordinate for the collapsed state.
virtual int16_tgetCollapsedYCoordinate()
Gets the y coordinate for the collapsed state.
virtual int16_tgetExpandedXCoordinate()
Gets the x coordinate for the expanded state.
virtual int16_tgetExpandedYCoordinate()
Gets the y coordinate for the expanded state.
voidstateChangeButtonClickedHandler(const AbstractButton & button)
Handler for the state change button clicked event.

Protected Attributes

uint16_tanimationDuration
The animation duration of the state change animation.
Callback< SlideMenu, const MoveAnimator< Container > & >animationEndedCallback
The local state changed animation ended callback.
EasingEquationanimationEquation
The easing equation used for the state change animation.
Imagebackground
The background of the SlideMenu.
StatecurrentState
The current state of the SlideMenu.
ExpandDirectionexpandDirection
The expand direction of the SlideMenu.
uint16_texpandedStateTimeout
The expanded state timeout.
uint16_texpandedStateTimer
The timer that counts towards the expandedStateTimeout. If reached the SlideMenu will animate to COLLAPSED.
int16_thiddenPixelsWhenExpanded
The number of hidden pixels when expanded.
MoveAnimator< Container >menuContainer
The container holding the actual menu items. This is the container that performs the state change animation.
Callback< SlideMenu, const AbstractButton & >onStateChangeButtonClicked
The local state changed button clicked callback.
ButtonstateChangeButton
The state change button that toggles the SlideMenu state.
GenericCallback< const SlideMenu & > *stateChangedAnimationEndedCallback
The public state changed animation ended callback.
GenericCallback< const SlideMenu & > *stateChangedCallback
The public state changed button clicked callback.
int16_tvisiblePixelsWhenCollapsed
The number of visible pixels when collapsed.

Additional inherited members

Public Functions inherited from Container

Container()
virtual boolcontains(const Drawable & d)
Query if a given Drawable has been added directly to this Container.
virtual voiddraw(const Rect & invalidatedArea) const
Draw this drawable.
virtual voidforEachChild(GenericCallback< Drawable & > * function)
Executes the specified callback function for each child in the Container.
virtual Drawable *getFirstChild()
Obtain a pointer to the first child of this container.
virtual voidgetLastChild(int16_t x, int16_t y, Drawable ** last)
Gets the last child in the list of children in this Container.
virtual voidgetLastChildNear(int16_t x, int16_t y, Drawable * last, int16_t fingerAdjustmentX, int16_t * fingerAdjustmentY)
Works similar to getLastChild() but also considers the current set finger size in HAL.
virtual RectgetSolidRect() const
Get (the largest possible) rectangle that is guaranteed to be solid (opaque).
virtual voidinsert(Drawable * previous, Drawable & d)
Inserts a Drawable after a specific child node.
virtual voidinvalidateContent() const
Tell the framework that the contents of the Drawable needs to be redrawn.
virtual voidremoveAll()
Removes all children in the Container by resetting their parent and sibling pointers.
virtual voidunlink()
Removes all children by unlinking the first child.

Protected Functions inherited from Container

virtual RectgetContainedArea() const
Gets a rectangle describing the total area covered by the children of this container.
virtual voidmoveChildrenRelative(int16_t deltaX, int16_t deltaY)
Calls moveRelative on all children.

Protected Attributes inherited from Container

Drawable *firstChild
Pointer to the first child of this container. Subsequent children can be found through firstChild's nextSibling.

Public Functions inherited from Drawable

voidcenter()
Centers the Drawable inside its parent.
voidcenterX()
Center the Drawable horizontally inside its parent.
voidcenterY()
Center the Drawable vertically inside its parent.
virtual voidchildGeometryChanged()
This function can be called on parent nodes to signal that the size or position of one or more of its children has changed.
virtual voiddraw(const Rect & invalidatedArea) const =0
Draw this drawable.
Drawable()
Initializes a new instance of the Drawable class.
voiddrawToDynamicBitmap(BitmapId id)
Render the Drawable object into a dynamic bitmap.
voidexpand(int margin =0)
Expands the Drawable to have the same size as its parent with a given margin around the edge.
RectgetAbsoluteRect() const
Helper function for obtaining the rectangle this Drawable covers, expressed in absolute coordinates.
virtual Drawable *getFirstChild()
Function for obtaining the first child of this drawable if any.
int16_tgetHeight() const
Gets the height of this Drawable.
virtual voidgetLastChild(int16_t x, int16_t y, Drawable ** last) =0
Function for obtaining the the last child of this drawable that intersects with the specified point.
Drawable *getNextSibling()
Gets the next sibling node.
Drawable *getParent() const
Returns the parent node.
const Rect &getRect() const
Gets the rectangle this Drawable covers, in coordinates relative to its parent.
virtual RectgetSolidRect() const =0
Get (the largest possible) rectangle that is guaranteed to be solid (opaque).
virtual RectgetSolidRectAbsolute()
Helper function for obtaining the largest solid rect (as implemented by getSolidRect()) expressed in absolute coordinates.
virtual voidgetVisibleRect(Rect & rect) const
Function for finding the visible part of this drawable.
int16_tgetWidth() const
Gets the width of this Drawable.
int16_tgetX() const
Gets the x coordinate of this Drawable, relative to its parent.
int16_tgetY() const
Gets the y coordinate of this Drawable, relative to its parent.
virtual voidhandleClickEvent(const ClickEvent & event)
Defines the event handler interface for ClickEvents.
virtual voidhandleDragEvent(const DragEvent & event)
Defines the event handler interface for DragEvents.
virtual voidhandleGestureEvent(const GestureEvent & event)
Defines the event handler interface for GestureEvents.
virtual voidinvalidate() const
Tell the framework that this entire Drawable needs to be redrawn.
virtual voidinvalidateContent() const
Tell the framework that the contents of the Drawable needs to be redrawn.
virtual voidinvalidateRect(Rect & invalidatedArea) const
Request that a region of this drawable is redrawn.
boolisTouchable() const
Gets whether this Drawable receives touch events or not.
boolisVisible() const
Gets whether this Drawable is visible.
virtual voidmoveRelative(int16_t x, int16_t y)
Moves the drawable.
virtual voidmoveTo(int16_t x, int16_t y)
Moves the drawable.
virtual voidsetHeight(int16_t height)
Sets the height of this drawable.
voidsetPosition(const Drawable & drawable)
Sets the position of the Drawable to the same as the given Drawable.
voidsetPosition(int16_t x, int16_t y, int16_t width, int16_t height)
Sets the size and position of this Drawable, relative to its parent.
voidsetTouchable(bool touch)
Controls whether this Drawable receives touch events or not.
voidsetVisible(bool vis)
Controls whether this Drawable should be visible.
virtual voidsetWidth(int16_t width)
Sets the width of this drawable.
voidsetWidthHeight(const Bitmap & bitmap)
Sets the dimensions (width and height) of the Drawable without changing the x and y coordinates).
voidsetWidthHeight(const Drawable & drawable)
Sets the dimensions (width and height) of the Drawable without changing the x and y coordinates).
voidsetWidthHeight(const Rect & rect)
Sets the dimensions (width and height) of the Drawable without changing the x and y coordinates).
voidsetWidthHeight(int16_t width, int16_t height)
Sets the dimensions (width and height) of the Drawable without changing the x and y coordinates).
virtual voidsetX(int16_t x)
Sets the x coordinate of this Drawable, relative to its parent.
voidsetXY(const Drawable & drawable)
Sets the x and y coordinates of this Drawable.
voidsetXY(int16_t x, int16_t y)
Sets the x and y coordinates of this Drawable, relative to its parent.
virtual voidsetY(int16_t y)
Sets the y coordinate of this Drawable, relative to its parent.
virtual voidtranslateRectToAbsolute(Rect & r) const
Helper function for converting a region of this Drawable to absolute coordinates.
virtual ~Drawable()
Finalizes an instance of the Drawable class.

Protected Attributes inherited from Drawable

Drawable *nextSibling
Pointer to the next Drawable.
Drawable *parent
Pointer to this drawable's parent.
Rectrect
The coordinates of this Drawable, relative to its parent.
booltouchable
True if this drawable should receive touch events.
boolvisible
True if this drawable should be drawn.

Public Types Documentation

ExpandDirection

Values that represent the expand directions.

SOUTHMenu expands downwards (Towards the south)
NORTHMenu expands upwards (Towards the north)
EASTMenu expands to the right (Towards the east)
WESTMenu expands to the left (Towards the west)

State

enum State

Values that represent the SlideMenu states.

COLLAPSEDMenu is currently collapsed.
EXPANDEDMenu is currently expanded.

Public Functions Documentation

add

virtual void add(Drawable &d)

Adds a drawable to the container.

Make sure the x and y coordinates of the Drawable is correct relative to the SlideMenu.

Parameters:
dThe drawable to add.

Reimplements: touchgfx::Container::add

animateToState

virtual void animateToState(StatenewState)

Animate to the given expanded or collapsed state.

Parameters:
newStateThe new state of the SlideMenu.
See also:

getAnimationDuration

virtual uint16_t getAnimationDuration()const

Gets the animation duration.

Returns:

The animation duration.

getAnimationEasingEquation

virtual EasingEquation getAnimationEasingEquation()const

Gets the animation easing equation.

Returns:

The animation easing equation.

getBackgroundX

virtual int16_t getBackgroundX()const

Gets the background Image x coordinate.

Returns:

The background Image x coordinate.

getBackgroundY

virtual int16_t getBackgroundY()const

Gets the background Image y coordinate.

Returns:

The background Image y coordinate.

getExpandDirection

virtual ExpandDirection getExpandDirection()const

Gets the expand direction.

Returns:

The expand direction.

getExpandedStateTimeout

virtual uint16_t getExpandedStateTimeout()const

Gets expanded state timeout.

Returns:

The expanded state timeout.

getExpandedStateTimer

virtual uint16_t getExpandedStateTimer()const

Gets the expanded state timer.

Returns:

The expanded state timer.

See also:

getHiddenPixelsWhenExpanded

virtual int16_t getHiddenPixelsWhenExpanded()const

Gets the hidden pixels when expanded.

Returns:

The hidden pixels when expanded.

getState

virtual State getState()

Gets the current expanded or collapsed state.

Returns:

The current state.

See also:

getStateChangeButtonX

virtual int16_t getStateChangeButtonX()const

Gets the state change button x coordinate.

Returns:

The state change button x coordinate.

getStateChangeButtonY

virtual int16_t getStateChangeButtonY()const

Gets the state change button y coordinate.

Returns:

The state change button y coordinate.

getVisiblePixelsWhenCollapsed

virtual int16_t getVisiblePixelsWhenCollapsed()const

Gets the visible pixels when collapsed.

Returns:

The visible pixels when collapsed.

handleTickEvent

virtual void handleTickEvent()

Called periodically by the framework if the Drawable instance has subscribed to timer ticks.

See also:

Reimplements: touchgfx::Drawable::handleTickEvent

remove

virtual void remove(Drawable &d)

Removes the drawable from the container.

Parameters:
dThe drawable to remove.

Reimplements: touchgfx::Container::remove

resetExpandedStateTimer

virtual void resetExpandedStateTimer()

Resets the expanded state timer.

The SlideMenu will automatically animate to the COLLAPSED state after a number of ticks, as set with setExpandedStateTimeout(). This method resets this timer.

See also:

setAnimationDuration

virtual void setAnimationDuration(uint16_tduration)

Sets the animation duration.

Parameters:
durationThe animation duration.

setAnimationEasingEquation

virtual void setAnimationEasingEquation(EasingEquationanimationEasingEquation)

Sets the animation easing equation.

Parameters:
animationEasingEquationThe animation easing equation.

setExpandDirection

virtual void setExpandDirection(ExpandDirectionnewExpandDirection)

Sets the expand direction.

Parameters:
newExpandDirectionThe new expand direction.

setExpandedStateTimeout

virtual void setExpandedStateTimeout(uint16_ttimeout)

Sets the expanded state timeout in ticks.

The SlideMenu will animate to the COLLAPSED state when this number of ticks has been executed while the SlideMenu is in the EXPANDED state. The timer can be reset with the resetExpandedStateTimer method.

Parameters:
timeoutThe timeout in ticks.

setHiddenPixelsWhenExpanded

virtual void setHiddenPixelsWhenExpanded(int16_thiddenPixels)

Sets the amount of hidden pixels when expanded.

Parameters:
hiddenPixelsThe hidden pixels.

setState

virtual void setState(StatenewState)

Sets the state of the SlideMenu.

No animation is performed.

Parameters:
newStateThe new state of the SlideMenu.
See also:

setStateChangedAnimationEndedCallback

Set the state change animation ended callback.

This callback is called when a state change animation has ended.

Parameters:
callbackThe callback.

setStateChangedCallback

virtual void setStateChangedCallback(GenericCallback< const SlideMenu & > &callback)

Set the state changed callback.

This callback is called when the state change button is clicked.

Parameters:
callbackThe callback.

setup

virtual void setup(ExpandDirectionnewExpandDirection ,
const Bitmap &backgroundBMP ,
const Bitmap &stateChangeButtonBMP ,
const Bitmap &stateChangeButtonPressedBMP
)

Setup the SlideMenu by positioning the stateChangeButton next to background image relative to the expand direction, and center it in the other dimension.

The width and height of the SlideMenu will be automatically set to span both elements. Default values are: expandedStateTimeout = 200, visiblePixelsWhenCollapsed = 0, hiddenPixelsWhenExpanded = 0, animationDuration = 10, animationEquation = cubicEaseInOut.

Parameters:
newExpandDirectionThe new expand direction.
backgroundBMPThe background bitmap.
stateChangeButtonBMPThe state change button bitmap.
stateChangeButtonPressedBMPThe state change button pressed bitmap.

setup

virtual void setup(ExpandDirectionnewExpandDirection ,
const Bitmap &backgroundBMP ,
const Bitmap &stateChangeButtonBMP ,
const Bitmap &stateChangeButtonPressedBMP ,
int16_tbackgroundX ,
int16_tbackgroundY ,
int16_tstateChangeButtonX ,
int16_tstateChangeButtonY
)

Setup method for the SlideMenu.

Positioning of the background image and the stateChangeButton is done by stating the X and Y coordinates for the elements (relative to the SlideMenu). The width and height of the SlideMenu will be automatically set to span both elements. Default values are: expandedStateTimeout = 200, visiblePixelsWhenCollapsed = 0, hiddenPixelsWhenExpanded = 0, animationDuration = 10, animationEquation = cubicEaseInOut.

Parameters:
newExpandDirectionThe new expand direction.
backgroundBMPThe background bitmap.
stateChangeButtonBMPThe state change button bitmap.
stateChangeButtonPressedBMPThe state change button pressed bitmap.
backgroundXThe background x coordinate.
backgroundYThe background y coordinate.
stateChangeButtonXThe state change button x coordinate.
stateChangeButtonYThe state change button y coordinate.

setup

virtual void setup(ExpandDirectionnewExpandDirection ,
const Bitmap &backgroundBMP ,
int16_tbackgroundX ,
int16_tbackgroundY
)

Setup method for the SlideMenu.

Positioning of the background is done by stating the X and Y coordinates for the element (relative to the SlideMenu). The width and height of the SlideMenu will be automatically set to the size of the background. Default values are: expandedStateTimeout = 200, visiblePixelsWhenCollapsed = 0, hiddenPixelsWhenExpanded = 0, animationDuration * = 10, animationEquation = cubicEaseInOut.

Parameters:
newExpandDirectionThe new expand direction.
backgroundBMPThe background bitmap.
backgroundXThe background x coordinate.
backgroundYThe background y coordinate.

setVisiblePixelsWhenCollapsed

virtual void setVisiblePixelsWhenCollapsed(int16_tvisiblePixels)

Sets the amount of visible pixels when collapsed.

Parameters:
visiblePixelsThe visible pixels.

SlideMenu

~SlideMenu

virtual ~SlideMenu()

Protected Functions Documentation

animationEndedHandler

void animationEndedHandler(const MoveAnimator< Container > &container)

Handler for the state change animation ended event.

Parameters:
containerThe menuContainer.

getCollapsedXCoordinate

virtual int16_t getCollapsedXCoordinate()

Gets the x coordinate for the collapsed state.

Returns:

The collapsed x coordinate.

getCollapsedYCoordinate

virtual int16_t getCollapsedYCoordinate()

Gets the y coordinate for the collapsed state.

Returns:

The collapsed y coordinate.

getExpandedXCoordinate

virtual int16_t getExpandedXCoordinate()

Gets the x coordinate for the expanded state.

Returns:

The expanded x coordinate.

getExpandedYCoordinate

virtual int16_t getExpandedYCoordinate()

Gets the y coordinate for the expanded state.

Returns:

The expanded y coordinate.

stateChangeButtonClickedHandler

Handler for the state change button clicked event.

Parameters:
buttonThe state change button.

Protected Attributes Documentation

animationDuration

uint16_t animationDuration

The animation duration of the state change animation.

animationEndedCallback

Callback< SlideMenu, const MoveAnimator< Container > & > animationEndedCallback

The local state changed animation ended callback.

animationEquation

EasingEquation animationEquation

The easing equation used for the state change animation.

background

Image background

The background of the SlideMenu.

currentState

State currentState

The current state of the SlideMenu.

expandDirection

ExpandDirection expandDirection

The expand direction of the SlideMenu.

expandedStateTimeout

uint16_t expandedStateTimeout

The expanded state timeout.

expandedStateTimer

uint16_t expandedStateTimer

The timer that counts towards the expandedStateTimeout. If reached the SlideMenu will animate to COLLAPSED.

hiddenPixelsWhenExpanded

int16_t hiddenPixelsWhenExpanded

The number of hidden pixels when expanded.

MoveAnimator< Container > menuContainer

The container holding the actual menu items. This is the container that performs the state change animation.

onStateChangeButtonClicked

Callback< SlideMenu, const AbstractButton & > onStateChangeButtonClicked

The local state changed button clicked callback.

stateChangeButton

Button stateChangeButton

The state change button that toggles the SlideMenu state.

stateChangedAnimationEndedCallback

GenericCallback< const SlideMenu & > * stateChangedAnimationEndedCallback

The public state changed animation ended callback.

stateChangedCallback

GenericCallback< const SlideMenu & > * stateChangedCallback

The public state changed button clicked callback.

visiblePixelsWhenCollapsed

int16_t visiblePixelsWhenCollapsed

The number of visible pixels when collapsed.