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
enum | ExpandDirection { SOUTH, NORTH, EAST, WEST } |
Values that represent the expand directions. | |
enum | State { COLLAPSED, EXPANDED } |
Values that represent the SlideMenu states. | |
Public Functions
virtual void | add(Drawable & d) |
Adds a drawable to the container. | |
virtual void | animateToState(State newState) |
Animate to the given expanded or collapsed state. | |
virtual uint16_t | getAnimationDuration() const |
Gets the animation duration. | |
virtual EasingEquation | getAnimationEasingEquation() const |
Gets the animation easing equation. | |
virtual int16_t | getBackgroundX() const |
Gets the background Image x coordinate. | |
virtual int16_t | getBackgroundY() const |
Gets the background Image y coordinate. | |
virtual ExpandDirection | getExpandDirection() const |
Gets the expand direction. | |
virtual uint16_t | getExpandedStateTimeout() const |
Gets expanded state timeout. | |
virtual uint16_t | getExpandedStateTimer() const |
Gets the expanded state timer. | |
virtual int16_t | getHiddenPixelsWhenExpanded() const |
Gets the hidden pixels when expanded. | |
virtual State | getState() |
Gets the current expanded or collapsed state. | |
virtual int16_t | getStateChangeButtonX() const |
Gets the state change button x coordinate. | |
virtual int16_t | getStateChangeButtonY() const |
Gets the state change button y coordinate. | |
virtual int16_t | getVisiblePixelsWhenCollapsed() const |
Gets the visible pixels when collapsed. | |
virtual void | handleTickEvent() |
Called periodically by the framework if the Drawable instance has subscribed to timer ticks. | |
virtual void | remove(Drawable & d) |
Removes the drawable from the container. | |
virtual void | resetExpandedStateTimer() |
Resets the expanded state timer. | |
virtual void | setAnimationDuration(uint16_t duration) |
Sets the animation duration. | |
virtual void | setAnimationEasingEquation(EasingEquation animationEasingEquation) |
Sets the animation easing equation. | |
virtual void | setExpandDirection(ExpandDirection newExpandDirection) |
Sets the expand direction. | |
virtual void | setExpandedStateTimeout(uint16_t timeout) |
Sets the expanded state timeout in ticks. | |
virtual void | setHiddenPixelsWhenExpanded(int16_t hiddenPixels) |
Sets the amount of hidden pixels when expanded. | |
virtual void | setState(State newState) |
Sets the state of the SlideMenu. | |
virtual void | setStateChangedAnimationEndedCallback(GenericCallback< const SlideMenu & > & callback) |
Set the state change animation ended callback. | |
virtual void | setStateChangedCallback(GenericCallback< const SlideMenu & > & callback) |
Set the state changed callback. | |
virtual void | setup(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 void | setup(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 void | setup(ExpandDirection newExpandDirection, const Bitmap & backgroundBMP, int16_t backgroundX, int16_t backgroundY) |
Setup method for the SlideMenu. | |
virtual void | setVisiblePixelsWhenCollapsed(int16_t visiblePixels) |
Sets the amount of visible pixels when collapsed. | |
SlideMenu() | |
virtual | ~SlideMenu() |
Protected Functions
void | animationEndedHandler(const MoveAnimator< Container > & container) |
Handler for the state change animation ended event. | |
virtual int16_t | getCollapsedXCoordinate() |
Gets the x coordinate for the collapsed state. | |
virtual int16_t | getCollapsedYCoordinate() |
Gets the y coordinate for the collapsed state. | |
virtual int16_t | getExpandedXCoordinate() |
Gets the x coordinate for the expanded state. | |
virtual int16_t | getExpandedYCoordinate() |
Gets the y coordinate for the expanded state. | |
void | stateChangeButtonClickedHandler(const AbstractButton & button) |
Handler for the state change button clicked event. | |
Protected Attributes
uint16_t | animationDuration |
The animation duration of the state change animation. | |
Callback< SlideMenu, const MoveAnimator< Container > & > | animationEndedCallback |
The local state changed animation ended callback. | |
EasingEquation | animationEquation |
The easing equation used for the state change animation. | |
Image | background |
The background of the SlideMenu. | |
State | currentState |
The current state of the SlideMenu. | |
ExpandDirection | expandDirection |
The expand direction of the SlideMenu. | |
uint16_t | expandedStateTimeout |
The expanded state timeout. | |
uint16_t | expandedStateTimer |
The timer that counts towards the expandedStateTimeout. If reached the SlideMenu will animate to COLLAPSED. | |
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. | |
Callback< SlideMenu, const AbstractButton & > | onStateChangeButtonClicked |
The local state changed button clicked callback. | |
Button | stateChangeButton |
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_t | visiblePixelsWhenCollapsed |
The number of visible pixels when collapsed. | |
Additional inherited members
Public Functions inherited from Container
Container() | |
virtual bool | contains(const Drawable & d) |
Query if a given Drawable has been added directly to this Container. | |
virtual void | draw(const Rect & invalidatedArea) const |
Draw this drawable. | |
virtual void | forEachChild(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 void | getLastChild(int16_t x, int16_t y, Drawable ** last) |
Gets the last child in the list of children in this Container. | |
virtual void | getLastChildNear(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 Rect | getSolidRect() const |
Get (the largest possible) rectangle that is guaranteed to be solid (opaque). | |
virtual void | insert(Drawable * previous, Drawable & d) |
Inserts a Drawable after a specific child node. | |
virtual void | invalidateContent() const |
Tell the framework that the contents of the Drawable needs to be redrawn. | |
virtual void | removeAll() |
Removes all children in the Container by resetting their parent and sibling pointers. | |
virtual void | unlink() |
Removes all children by unlinking the first child. | |
Protected Functions inherited from Container
virtual Rect | getContainedArea() const |
Gets a rectangle describing the total area covered by the children of this container. | |
virtual void | moveChildrenRelative(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
void | center() |
Centers the Drawable inside its parent. | |
void | centerX() |
Center the Drawable horizontally inside its parent. | |
void | centerY() |
Center the Drawable vertically inside its parent. | |
virtual void | childGeometryChanged() |
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 void | draw(const Rect & invalidatedArea) const =0 |
Draw this drawable. | |
Drawable() | |
Initializes a new instance of the Drawable class. | |
void | drawToDynamicBitmap(BitmapId id) |
Render the Drawable object into a dynamic bitmap. | |
void | expand(int margin =0) |
Expands the Drawable to have the same size as its parent with a given margin around the edge. | |
Rect | getAbsoluteRect() 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_t | getHeight() const |
Gets the height of this Drawable. | |
virtual void | getLastChild(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 Rect | getSolidRect() const =0 |
Get (the largest possible) rectangle that is guaranteed to be solid (opaque). | |
virtual Rect | getSolidRectAbsolute() |
Helper function for obtaining the largest solid rect (as implemented by getSolidRect()) expressed in absolute coordinates. | |
virtual void | getVisibleRect(Rect & rect) const |
Function for finding the visible part of this drawable. | |
int16_t | getWidth() const |
Gets the width of this Drawable. | |
int16_t | getX() const |
Gets the x coordinate of this Drawable, relative to its parent. | |
int16_t | getY() const |
Gets the y coordinate of this Drawable, relative to its parent. | |
virtual void | handleClickEvent(const ClickEvent & event) |
Defines the event handler interface for ClickEvents. | |
virtual void | handleDragEvent(const DragEvent & event) |
Defines the event handler interface for DragEvents. | |
virtual void | handleGestureEvent(const GestureEvent & event) |
Defines the event handler interface for GestureEvents. | |
virtual void | invalidate() const |
Tell the framework that this entire Drawable needs to be redrawn. | |
virtual void | invalidateContent() const |
Tell the framework that the contents of the Drawable needs to be redrawn. | |
virtual void | invalidateRect(Rect & invalidatedArea) const |
Request that a region of this drawable is redrawn. | |
bool | isTouchable() const |
Gets whether this Drawable receives touch events or not. | |
bool | isVisible() const |
Gets whether this Drawable is visible. | |
virtual void | moveRelative(int16_t x, int16_t y) |
Moves the drawable. | |
virtual void | moveTo(int16_t x, int16_t y) |
Moves the drawable. | |
virtual void | setHeight(int16_t height) |
Sets the height of this drawable. | |
void | setPosition(const Drawable & drawable) |
Sets the position of the Drawable to the same as the given Drawable. | |
void | setPosition(int16_t x, int16_t y, int16_t width, int16_t height) |
Sets the size and position of this Drawable, relative to its parent. | |
void | setTouchable(bool touch) |
Controls whether this Drawable receives touch events or not. | |
void | setVisible(bool vis) |
Controls whether this Drawable should be visible. | |
virtual void | setWidth(int16_t width) |
Sets the width of this drawable. | |
void | setWidthHeight(const Bitmap & bitmap) |
Sets the dimensions (width and height) of the Drawable without changing the x and y coordinates). | |
void | setWidthHeight(const Drawable & drawable) |
Sets the dimensions (width and height) of the Drawable without changing the x and y coordinates). | |
void | setWidthHeight(const Rect & other) |
Sets the dimensions (width and height) of the Drawable without changing the x and y coordinates). | |
void | setWidthHeight(int16_t width, int16_t height) |
Sets the dimensions (width and height) of the Drawable without changing the x and y coordinates). | |
virtual void | setX(int16_t x) |
Sets the x coordinate of this Drawable, relative to its parent. | |
void | setXY(const Drawable & drawable) |
Sets the x and y coordinates of this Drawable. | |
void | setXY(int16_t x, int16_t y) |
Sets the x and y coordinates of this Drawable, relative to its parent. | |
virtual void | setY(int16_t y) |
Sets the y coordinate of this Drawable, relative to its parent. | |
virtual void | translateRectToAbsolute(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. | |
Rect | rect |
The coordinates of this Drawable, relative to its parent. | |
bool | touchable |
True if this drawable should receive touch events. | |
bool | visible |
True if this drawable should be drawn. | |
Public Types Documentation
ExpandDirection
enum ExpandDirection
Values that represent the expand directions.
SOUTH | Menu expands downwards (Towards the south) |
NORTH | Menu expands upwards (Towards the north) |
EAST | Menu expands to the right (Towards the east) |
WEST | Menu expands to the left (Towards the west) |
State
enum State
Values that represent the SlideMenu states.
COLLAPSED | Menu is currently collapsed. |
EXPANDED | Menu is currently expanded. |
Public Functions Documentation
add
Adds a drawable to the container.
Make sure the x and y coordinates of the Drawable is correct relative to the SlideMenu.
d | The drawable to add. |
Reimplements: touchgfx::Container::add
animateToState
virtual void animateToState | ( | State | newState | ) | |
getAnimationDuration
virtual uint16_t getAnimationDuration | ( | ) | const |
Gets the animation duration.
The animation duration.
getAnimationEasingEquation
virtual EasingEquation getAnimationEasingEquation | ( | ) | const |
Gets the animation easing equation.
The animation easing equation.
getBackgroundX
virtual int16_t getBackgroundX | ( | ) | const |
getBackgroundY
virtual int16_t getBackgroundY | ( | ) | const |
getExpandDirection
virtual ExpandDirection getExpandDirection | ( | ) | const |
Gets the expand direction.
The expand direction.
getExpandedStateTimeout
virtual uint16_t getExpandedStateTimeout | ( | ) | const |
Gets expanded state timeout.
The expanded state timeout.
getExpandedStateTimer
virtual uint16_t getExpandedStateTimer | ( | ) | const |
getHiddenPixelsWhenExpanded
virtual int16_t getHiddenPixelsWhenExpanded | ( | ) | const |
Gets the hidden pixels when expanded.
The hidden pixels when expanded.
getState
virtual State getState | ( | ) |
Gets the current expanded or collapsed state.
The current state.
getStateChangeButtonX
virtual int16_t getStateChangeButtonX | ( | ) | const |
Gets the state change button x coordinate.
The state change button x coordinate.
getStateChangeButtonY
virtual int16_t getStateChangeButtonY | ( | ) | const |
Gets the state change button y coordinate.
The state change button y coordinate.
getVisiblePixelsWhenCollapsed
virtual int16_t getVisiblePixelsWhenCollapsed | ( | ) | const |
Gets the visible pixels when collapsed.
The visible pixels when collapsed.
handleTickEvent
virtual void handleTickEvent | ( | ) |
Called periodically by the framework if the Drawable instance has subscribed to timer ticks.
Reimplements: touchgfx::Drawable::handleTickEvent
remove
Removes the drawable from the container.
d | The 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.
setAnimationDuration
virtual void setAnimationDuration | ( | uint16_t | duration | ) | |
Sets the animation duration.
duration | The animation duration. |
setAnimationEasingEquation
virtual void setAnimationEasingEquation | ( | EasingEquation | animationEasingEquation | ) | |
Sets the animation easing equation.
animationEasingEquation | The animation easing equation. |
setExpandDirection
virtual void setExpandDirection | ( | ExpandDirection | newExpandDirection | ) | |
Sets the expand direction.
newExpandDirection | The new expand direction. |
setExpandedStateTimeout
virtual void setExpandedStateTimeout | ( | uint16_t | timeout | ) | |
setHiddenPixelsWhenExpanded
virtual void setHiddenPixelsWhenExpanded | ( | int16_t | hiddenPixels | ) | |
Sets the amount of hidden pixels when expanded.
hiddenPixels | The hidden pixels. |
setState
setStateChangedAnimationEndedCallback
virtual void setStateChangedAnimationEndedCallback | ( | GenericCallback< const SlideMenu & > & | callback | ) | |
Set the state change animation ended callback.
This callback is called when a state change animation has ended.
callback | The 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.
callback | The callback. |
setup
virtual void setup | ( | 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.
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.
newExpandDirection | The new expand direction. |
backgroundBMP | The background bitmap. |
stateChangeButtonBMP | The state change button bitmap. |
stateChangeButtonPressedBMP | The state change button pressed bitmap. |
setup
virtual void setup | ( | 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.
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.
newExpandDirection | The new expand direction. |
backgroundBMP | The background bitmap. |
stateChangeButtonBMP | The state change button bitmap. |
stateChangeButtonPressedBMP | The state change button pressed bitmap. |
backgroundX | The background x coordinate. |
backgroundY | The background y coordinate. |
stateChangeButtonX | The state change button x coordinate. |
stateChangeButtonY | The state change button y coordinate. |
setup
virtual void setup | ( | ExpandDirection | newExpandDirection , | ||
const Bitmap & | backgroundBMP , | ||||
int16_t | backgroundX , | ||||
int16_t | backgroundY | ||||
) |
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.
newExpandDirection | The new expand direction. |
backgroundBMP | The background bitmap. |
backgroundX | The background x coordinate. |
backgroundY | The background y coordinate. |
setVisiblePixelsWhenCollapsed
virtual void setVisiblePixelsWhenCollapsed | ( | int16_t | visiblePixels | ) | |
Sets the amount of visible pixels when collapsed.
visiblePixels | The visible pixels. |
SlideMenu
~SlideMenu
virtual ~SlideMenu | ( | ) |
Protected Functions Documentation
animationEndedHandler
void animationEndedHandler | ( | const MoveAnimator< Container > & | container | ) | |
Handler for the state change animation ended event.
container | The menuContainer. |
getCollapsedXCoordinate
virtual int16_t getCollapsedXCoordinate | ( | ) |
Gets the x coordinate for the collapsed state.
The collapsed x coordinate.
getCollapsedYCoordinate
virtual int16_t getCollapsedYCoordinate | ( | ) |
Gets the y coordinate for the collapsed state.
The collapsed y coordinate.
getExpandedXCoordinate
virtual int16_t getExpandedXCoordinate | ( | ) |
Gets the x coordinate for the expanded state.
The expanded x coordinate.
getExpandedYCoordinate
virtual int16_t getExpandedYCoordinate | ( | ) |
Gets the y coordinate for the expanded state.
The expanded y coordinate.
stateChangeButtonClickedHandler
void stateChangeButtonClickedHandler | ( | const AbstractButton & | button | ) | |
Handler for the state change button clicked event.
button | The 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
currentState
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.
menuContainer
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
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.