Skip to main content

SlideMenu

A SlideMenu in TouchGFX is a specialization of the Container that consists of an internal Container, an Image and an optional Button, which can animate between a collapsed and expanded state.

SlideMenu running in the simulator

Widget Group

The SlideMenu can be found in the Containers widget group in TouchGFX Designer.

SlideMenu in TouchGFX Designer

Properties

The properties for the SlideMenu are described in the following sections.

Property GroupProperty Descriptions
NameName of the widget. Name is the unique identifier used in TouchGFX Designer and code.
LocationX and Y specify the top left corner of the widget relative to its parent.

W and H specify the width and height of the widget.
The size of a SlideMenu is determined by the size of its background and button images.

Visible specifies the visibility of the widget.
Making the widget invisible also disables interacting with the widget through the screen.
Expanding DirectionExpanding Direction specifies the direction the SlideMenu should expand.
StateState specifies the initial state of the SlideMenu, either collapsed or expanded.

Collapsed: Visible Pixels specifies the amount of pixels that should be visible when the state is collapsed.

Expanded: Hidden Pixels Specifices the amount of pixels that should be hidden when the state is expanded.

Expanded Timeout specifies the amount of time before automatically returning to the collapsed state from the expanded state.
BackgroundBackground Image specifies the image to use as background.

Background Location specifies the x,y coordinate of the background image relative to the widgets' coordinates.
ButtonUse Button Specifies whether or not to make use of a button to control the state of the widget.

Released Image specifies the image to use for the buttons' released state.

Pressed Image specifies the image to use for the buttons' pressed state.

Button Location specifies the x,y coordinate of the button relative to the widgets' coordinates.
AnimationEasing and Easing Option specify which easing equation to use for animations.

Duration specifies the amount of time the animation should take.
MixinsDraggable specifies if the widget is draggable at runtime.

ClickListener specifies if the widget emits a callback when clicked.

FadeAnimator specifies if the widget can animate changes to its Alpha value.

MoveAnimator specifies if the widget can animate changes to X and Y values.

Interactions

The actions and triggers supported by the SlideMenu are described in the following sections.

Actions

Widget specific actionDescription
Change State of SlideMenuChange the state of a SlideMenu to either collapsed or expanded
Reset Timer of SlideMenuReset the timer automatically returning the SlideMenu state to collapsed
Standard widget actionDescription
Move widgetMove a widget to a new position over time.
Hide widgetHides a widget (sets visibility to false).
Show widgetMake a hidden widget visible (sets visibility to true).

Triggers

TriggerDescription
SlideMenu animation endedA SlideMenu animation from one state to another has ended.
SlideMenu state changedA SlideMenu has had its state changed.

Performance

A SlideMenu is a Container type and does not per default appear in the draw chain. Therefore, the performance is mostly dependent on the drawing performance of the children.

For more details on drawing performance, read the General UI Component Performance section.

Examples

Generated Code

In the generated code for the View base class we can see how the TouchGFX Designer sets up a SlideMenu.

Screen1ViewBase.cpp
#include <gui_generated/screen1_screen/Screen1ViewBase.hpp>
#include "BitmapDatabase.hpp"

Screen1ViewBase::Screen1ViewBase()
{
slideMenuName.setup(touchgfx::SlideMenu::EAST,
touchgfx::Bitmap(BITMAP_LEFT_SLIDE_MENU_BACKGROUND_ID),
touchgfx::Bitmap(BITMAP_LEFT_SLIDE_MENU_BUTTON_ID),
touchgfx::Bitmap(BITMAP_LEFT_SLIDE_MENU_BUTTON_ID),
0, 0, 49, 111);
slideMenuName.setState(touchgfx::SlideMenu::COLLAPSED);
slideMenuName.setVisiblePixelsWhenCollapsed(24);
slideMenuName.setHiddenPixelsWhenExpanded(0);
slideMenuName.setAnimationEasingEquation(touchgfx::EasingEquations::circEaseInOut);
slideMenuName.setAnimationDuration(18);
slideMenuName.setExpandedStateTimeout(180);
slideMenuName.setXY(0, 0);

add(slideMenuName);
}
Tip
You can use these functions and the others available in the SlideMenu class in user code. Remember to force a redraw by calling SlideMenuName.invalidate() if you change the appearance of the widget.

TouchGFX Designer Examples

To further explore the SlideMenu, try creating a new application within TouchGFX Designer with the following UI template:

SlideMenu Example UI template in TouchGFX Designer

API Reference