TinyMaterialDesign
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Page< RGB_T > Class Template Reference

One page (tab) of an app: a scrollable Container with a title and an icon for the navigation, that builds its own widgets. More...

#include <Page.h>

Inheritance diagram for Page< RGB_T >:
Inheritance graph
[legend]
Collaboration diagram for Page< RGB_T >:
Collaboration graph
[legend]

Public Member Functions

 Page (const char *title="", IconPainter< RGB_T > icon=nullptr)
 
virtual const char * title () const
 Label and icon of the page in a NavigationBar.
 
virtual IconPainter< RGB_T > icon () const
 
void setTitle (const char *title)
 
void setIcon (IconPainter< RGB_T > icon)
 
virtual void build ()
 Creates the widgets (called once by PageNavigator::begin()).
 
virtual void onShow ()
 The page becomes visible.
 
virtual void onHide ()
 The page is hidden (another page is shown).
 
virtual bool tick (uint32_t nowMs)
 
- Public Member Functions inherited from Container< RGB_T >
 Container ()=default
 
 Container (Bounds containerBounds)
 
void addChild (Widget< RGB_T > &child)
 
bool removeChild (Widget< RGB_T > &child)
 
void clearChildren ()
 Removes all children (they are not deleted) and scrolls to the top.
 
int childrenCount () const
 Number of children added with addChild().
 
void setScrollOffset (int32_t offset)
 
void scrollToChild (const Widget< RGB_T > &child, int32_t margin=4)
 
void setChildProvider (ChildCountFn count, ChildAtFn at)
 
void setUniformItemHeight (int32_t height)
 
void setTheme (const MaterialTheme< RGB_T > &theme) override
 
void draw (tinygpu::ISurface< RGB_T > &target) override
 
void drawBackground (tinygpu::ISurface< RGB_T > &target) override
 
bool update (uint32_t nowMs) override
 
bool onGesture (const tinygpu::GestureEvent &event) override
 Handles one gesture event. Returns true if this widget consumed it.
 
int childCount () const override
 
Widget< RGB_T > * child (int index) override
 
int32_t scrollOffset () const
 Current vertical scroll offset (0 = content's natural top).
 
bool isDraggableAt (int32_t x, int32_t y) const override
 
bool isContainer () const override
 Provides true if the widget is a container.
 
- Public Member Functions inherited from Widget< RGB_T >
virtual ~Widget ()=default
 
virtual void setTheme (const MaterialTheme< RGB_T > &theme)
 
virtual void draw (tinygpu::ISurface< RGB_T > &target)=0
 
virtual bool onGesture (const tinygpu::GestureEvent &event)
 Handles one gesture event. Returns true if this widget consumed it.
 
virtual bool update (uint32_t nowMs)
 
virtual bool isDraggable () const
 
virtual bool isDraggableAt (int32_t x, int32_t y) const
 
virtual int childCount () const
 
virtual Widget< RGB_T > * child (int index)
 
virtual void drawBackground (tinygpu::ISurface< RGB_T > &target)
 
virtual void setThemeTint (RGB_T background, RGB_T foreground)
 
virtual bool isContainer () const
 Provides true if the widget is a container.
 

Additional Inherited Members

- Public Types inherited from Container< RGB_T >
using ChildCountFn = std::function< int()>
 
using ChildAtFn = std::function< Widget< RGB_T > &(int index)>
 
- Static Public Member Functions inherited from Container< RGB_T >
static bool isContinuousType (tinygpu::GestureType type)
 
- Public Attributes inherited from Widget< RGB_T >
Bounds bounds
 
bool visible = true
 
bool enabled = true
 
- Static Public Attributes inherited from Container< RGB_T >
static constexpr int32_t kScrollbarTouchWidth = 12
 
- Protected Member Functions inherited from Container< RGB_T >
int32_t contentHeight () const
 
int32_t scrollThumbHeight (int32_t content) const
 
bool isOnScrollbar (int32_t x, int32_t y) const
 
void scrollToTrackY (int32_t y)
 
void clampScroll ()
 
int effectiveCount () const
 
Widget< RGB_T > * effectiveChild (int index) const
 
- Protected Member Functions inherited from Widget< RGB_T >
const MaterialTheme< RGB_T > & theme () const
 Convenience accessor for draw() overrides - see theme_.
 
- Protected Attributes inherited from Container< RGB_T >
std::vector< Widget< RGB_T > * > children_
 
ChildCountFn childCountFn_
 
ChildAtFn childAtFn_
 
int32_t uniformItemHeight_ = 0
 
Widget< RGB_T > * activeChild_ = nullptr
 
bool scrollDragActive_ = false
 
bool scrollbarDragActive_ = false
 A continuous gesture started on the scrollbar (see isOnScrollbar()).
 
int32_t scrollOffset_ = 0
 
- Protected Attributes inherited from Widget< RGB_T >
const MaterialTheme< RGB_T > * theme_ = nullptr
 

Detailed Description

template<typename RGB_T = TINYMD_DEFAULT_RGB_T>
class tinymd::Page< RGB_T >

One page (tab) of an app: a scrollable Container with a title and an icon for the navigation, that builds its own widgets.

Derive from it and add the widgets in build(); PageNavigator calls it once the page is on the screen (so it already has its theme and bounds):

class ClockPage : public Page<RGB565> { public: ClockPage() : Page("Clock", drawClockIcon) {} void build() override { addChild(time_); ... } bool tick(uint32_t nowMs) override { ... return true; } // redraw };

Constructor & Destructor Documentation

◆ Page()

Page ( const char *  title = "",
IconPainter< RGB_T >  icon = nullptr 
)
inlineexplicit

Member Function Documentation

◆ build()

virtual void build ( )
inlinevirtual

Creates the widgets (called once by PageNavigator::begin()).

Reimplemented in WifiLoginPage< RGB_T >.

◆ icon()

virtual IconPainter< RGB_T > icon ( ) const
inlinevirtual

◆ onHide()

virtual void onHide ( )
inlinevirtual

The page is hidden (another page is shown).

Reimplemented in WifiLoginPage< RGB_T >.

◆ onShow()

virtual void onShow ( )
inlinevirtual

The page becomes visible.

Reimplemented in WifiLoginPage< RGB_T >.

◆ setIcon()

void setIcon ( IconPainter< RGB_T >  icon)
inline

◆ setTitle()

void setTitle ( const char *  title)
inline

◆ tick()

virtual bool tick ( uint32_t  nowMs)
inlinevirtual

Called regularly while the page is shown (PageNavigator::tick()): return true if the page changed and must be redrawn.

Reimplemented in WifiLoginPage< RGB_T >.

◆ title()

virtual const char * title ( ) const
inlinevirtual

Label and icon of the page in a NavigationBar.


The documentation for this class was generated from the following file: