SideBarBigο
Overviewο
The SideBarBig widget is a custom TouchGFX container that provides a curved sidebar visual indicator for menu or list navigation. It displays a handle that moves along an arc-shaped rail to represent the current position among multiple items, offering smooth animated transitions between positions.
Purposeο
This widget serves as a visual position indicator in scrollable menus, lists, or multi-page interfaces. The curved design provides an elegant way to show progress through a sequence of items, with the handle smoothly animating along the arc to indicate the active item. Itβs particularly useful in wearable or embedded UI designs where space is limited and visual feedback needs to be compact yet informative.
Componentsο
The widget consists of the following visual elements:
Rail (rail): Background image displaying the curved track (SideBarBig.png)
Handle (handle): Circular arc segment representing the current position
Overflow Handle (handleOvf): Secondary arc segment used during wrap-around animations
Functionalityο
Position Managementο
setCount(uint16_t cnt): Sets the total number of items in the sequencesetActiveId(uint16_t p): Sets the current active position (0-based index)getActiveId(): Returns the current active positionanimateToId(int16_t p, int16_t animationSteps = -1): Animates the handle to a new position with optional step count
Animation Controlο
handleTickEvent(): Advances animation frames (called automatically via timer registration)Automatic timer management for smooth animations
Wrap-around support when animating beyond bounds
Usage in TouchGFX Designerο
Import the Custom Container Package:
Import the SideBarBig package into your TouchGFX project
Add to Screen/Container:
Drag the SideBarBig custom container onto your screen or parent container
Position it appropriately (typically on the right side for vertical navigation)
Configuration:
All configuration is done programmatically in C++ code
The widget appears as a 36x146 pixel curved sidebar
Usage in C++ Codeο
Basic Setupο
#include <gui/containers/SideBarBig.hpp>
SideBarBig sideBar;
// Initialize with 5 items
sideBar.setCount(5);
// Set current position to first item
sideBar.setActiveId(0);
Position Updatesο
// Immediate position change
sideBar.setActiveId(2);
// Animated transition (default steps)
sideBar.animateToId(3);
// Animated with custom duration
sideBar.animateToId(1, 20); // 20 animation steps
// Get current position
uint16_t currentPos = sideBar.getActiveId();
Integration with Menu Systemsο
// In a menu or list container
class MyMenu : public Container
{
private:
SideBarBig sideBar;
// ... other components
public:
void setupItems(uint16_t itemCount)
{
sideBar.setCount(itemCount);
sideBar.setActiveId(0);
}
void selectItem(uint16_t index)
{
sideBar.animateToId(index);
// Update other UI elements...
}
};
Dynamic Count Changesο
// Update item count dynamically
sideBar.setCount(newItemCount);
// Handle position if it exceeds new count
if (sideBar.getActiveId() >= newItemCount) {
sideBar.setActiveId(newItemCount - 1);
}
Advanced Features and Hidden Gemsο
Smooth Animation: Timer-based animation system with configurable step count for fluid transitions
Wrap-Around Animation: Seamless animation when moving beyond sequence bounds (e.g., from last to first item)
Overflow Visual Effect: Secondary handle appears during wrap-around for enhanced visual feedback
Automatic Handle Hiding: Handle automatically hides when thereβs only one item (no navigation needed)
Angle-Based Positioning: Precise arc positioning using degree calculations (232Β° to 308Β° range)
Memory Efficient: No dynamic memory allocation, uses fixed-size components
Timer Integration: Automatic registration/unregistration with TouchGFX timer system
Invalidation Management: Proper invalidation of visual components during updates
Technical Detailsο
Base Class: Inherits from
SideBarBigBase(generated container)Minimum TouchGFX Version: 4.26.0
Dimensions: 36x146 pixels (configurable in designer)
Animation Range: 76Β° arc (232Β° to 308Β°)
Handle Length: 18Β° arc segment
Timer Widget: Implements
handleTickEvent()for animationWrap-Around Logic: Handles negative indices and overflow by wrapping to opposite end
Best Practicesο
Item Count: Always call
setCount()before setting positionsBounds Checking: Verify position is within valid range before calling
setActiveId()Animation Steps: Use appropriate step counts (10-30) for smooth but not sluggish animation
Position Synchronization: Keep sidebar position synchronized with actual menu/list selection
Single Item Handling: Widget gracefully handles single-item scenarios by hiding the handle
Performance: Avoid excessive animation calls; use immediate updates for rapid changes
Limitationsο
Fixed arc geometry (232Β°-308Β° range)
Designed for vertical curved sidebar layout
No built-in touch interaction (position controlled programmatically)
Animation steps must be positive integers
Handle visibility tied to item count (>1)
Requires manual synchronization with data models
This widget provides an elegant solution for position indication in curved, space-constrained interfaces, offering smooth animations and intuitive visual feedback for navigation through item sequences.