LVGLPlusPlus
C++ library on top of the lovely LVGL project.
Loading...
Searching...
No Matches
lvppScreen Class Reference

The lvppScreen is a non - lvppBase object for organizing the use of multiple screens in a project. More...

#include <lvpp.h>

Public Member Functions

 lvppScreen (lv_obj_t *_pInitScreen=nullptr)
 Construct a new lvpp Screen object. The default constructor will allocate a new screen object and will use this screen object as the 'parent' screen to any objects which are added via addObject()
 
 ~lvppScreen ()
 
void addObject (lvppBase *pObj)
 Add any lvppBase object pointer to the screen to keep track of.
 
lv_obj_t * getScreen ()
 Get a pointer to the LVGL lv_obj_t screen object.
 
void activateScreen (uint32_t anim_time=0, lv_scr_load_anim_t anim=LV_SCR_LOAD_ANIM_NONE)
 Load/Activate this screen either with or without animation based on parameters given.
 
void activatePriorScreen ()
 If you've activated this screen via activateScreen(), then this method will activate the screen which was active prior to calling activateScreen(). If activation has not yet occured, then this function will have no effect.
 
void disableScrollBars ()
 Defeats the automatic use of scrollbars by LVGL when certain drawing operations might cause them to appear.
 
lvppBasefindObj (const char *pName)
 Obtain a pointer to an object which was prior added to the lvppScreen by addObject().
 
bool setObjValue (const char *objName, int16_t val)
 Set the value of the object objName to val if found.
 
void setObjText (std::string str)
 

Protected Attributes

lv_obj_t * pScreen =nullptr
 The actual underlying LVGL screen pointer.
 
lv_obj_t * pPriorScreen
 Holder for prior screen when activateScreen() is called. Used in activatePriorScreen()
 
std::vector< lvppBase * > objects
 Data structure used to hold all of the object pointers.
 

Detailed Description

The lvppScreen is a non - lvppBase object for organizing the use of multiple screens in a project.

Todo:

Add full compliment of object types to setObjValue

Add a getter similar to setObj* as getObj*()

The purpose is to aid in organized grouping, control, use of widgets that are all on the same screen. The notion of a screen is identical to that of lvgl. As such, the root of this class holds an lv_obj_t poitner to the screen. The concept is to have the lvppScreen object created, then create widgets that are added to the lvppScreen with addObject(). Now some interaction can be had with those objects by either getting the object pointer via findObj() utilizing the object name given to the widget at instantiation time, or, in some cases, actually changing the value of the object via setObjValue(), again using the object name and giving a value. The plan is to expand the setObjValue() to encompass several types of objects and also have a getter too.

Constructor & Destructor Documentation

◆ lvppScreen()

lvppScreen::lvppScreen ( lv_obj_t *  _pInitScreen = nullptr)

Construct a new lvpp Screen object. The default constructor will allocate a new screen object and will use this screen object as the 'parent' screen to any objects which are added via addObject()

Parameters
_pInitScreenThe user can pass in an already allocated screen from lvgl if desired.

lvppScreen

◆ ~lvppScreen()

lvppScreen::~lvppScreen ( )
inline

Member Function Documentation

◆ activatePriorScreen()

void lvppScreen::activatePriorScreen ( )

If you've activated this screen via activateScreen(), then this method will activate the screen which was active prior to calling activateScreen(). If activation has not yet occured, then this function will have no effect.

◆ activateScreen()

void lvppScreen::activateScreen ( uint32_t  anim_time = 0,
lv_scr_load_anim_t  anim = LV_SCR_LOAD_ANIM_NONE 
)

Load/Activate this screen either with or without animation based on parameters given.

If activateScreen() is called with no parameters, then the underlying load screen call is lv_scr_load(). The two optional parameters give the user the ability to animate the new screen utilizing the lv_scr_load_anim() which allows an animation 'time' as well as an animation 'type'.

Parameters
anim_timeNumber of milliseconds spent doing the animated load of the screen.
animThe animation type. This is one of many LV_SCR_LOAD_ANIM_[OVER|MOVE|FADE|OUT]_[LEFT|RIGHT|TOP|BOTTOM]

◆ addObject()

void lvppScreen::addObject ( lvppBase pObj)

Add any lvppBase object pointer to the screen to keep track of.

When an lvppBase derived object is created, the first parameter given to the creation is an object name. This object name will be used in finding/locating and performing any action on that object inside the screen. The purpose here is to allow the user to not have to keep track of every single object pointer but only need to keep track of the names of the objects that will need to be changed or used. In this way, the lvppScreen pointers are the only main objects to keep track of along with the object names.

Parameters
pObjPointer to an lvppBase derived object to have the screen keep track of.

◆ disableScrollBars()

void lvppScreen::disableScrollBars ( )

Defeats the automatic use of scrollbars by LVGL when certain drawing operations might cause them to appear.

When certain drawing operations take place near or beyond the X/Y borders, LVGL will make the decision to show scroll bars left/right or up/down. For instance, when drawing using lvppLine and a line width greater than 1, drawing to the edge of the screen will cause scroll bars to appear. This function will defeat that behavior and allow such drawing to the edge of the screen.

◆ findObj()

lvppBase * lvppScreen::findObj ( const char *  pName)

Obtain a pointer to an object which was prior added to the lvppScreen by addObject().

lvppBase derived objects all have an object name at their creation. This name is used to allow lvppScreen to 'find' an object and pass back the base pointer to the caller. It is up to the caller to know what type of object this is and appropriately cast it to the non-lvppBase type for further use. lvppBase does also have dynamic functions to request what 'type' an object is to make this easier in the absence of RTTI / dynamic_cast<> functionality.

Parameters
pNamePointer to the object name being requested.
Returns
lvppBase* A pointer to the object found or nullptr when the object name was not in the list of objects added to lvppScreen.

◆ getScreen()

lv_obj_t * lvppScreen::getScreen ( )
inline

Get a pointer to the LVGL lv_obj_t screen object.

Returns
lv_obj_t* pointer to an LVGL base object.

◆ setObjText()

void lvppScreen::setObjText ( std::string  str)
Todo:
Function incomplete and needs implementation.

◆ setObjValue()

bool lvppScreen::setObjValue ( const char *  objName,
int16_t  val 
)

Set the value of the object objName to val if found.

Parameters
objNameName of the object we're looking for in the list of objects in the lvppScreen.
valValue to utilize in 'setting' the value once the object is found.
Returns
If the object is found, returns true. Else false.
Todo:

Support more than just bar and slider for value setting. Get clear on what widgets should bet settable.

Create a 'getter' version as well.

Create a setObj() possibly for boolean types like buttons?? OR just use 1/0 as the 'val'?

Member Data Documentation

◆ objects

std::vector<lvppBase*> lvppScreen::objects
protected

Data structure used to hold all of the object pointers.

◆ pPriorScreen

lv_obj_t* lvppScreen::pPriorScreen
protected

Holder for prior screen when activateScreen() is called. Used in activatePriorScreen()

◆ pScreen

lv_obj_t* lvppScreen::pScreen =nullptr
protected

The actual underlying LVGL screen pointer.


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