|
UI_Lib
a1366e08a59cc549a65fa26081e6409aa12f26d5
This is a user interface library for graphical LCDs. It offers many different controls and indicators that can be nested depending on the element types.
|
Before adding a new component, decide if it will be a container, control or indicator. Then create new .cpp and .h files in the corresponding folder inside the UI_Lib folder. Also add an include for the .h file to the UI_Lib.h file.
All user interface elements must be derived from the UIElement class that contains some common parameters like location and size of the element. This class also requires the new element to implement a UIElement::Draw function that is used to display the element on screen. Also a UIElement::KeyInput and UIElement::TouchInput function is defined that can be implemented optional (for controls, indicators that don't need user interaction or touch inputs). The UIElement::RecalculateDimensions and UIElement::RecalculateLayout functions are also optional.
The following code snippet shows an example class declaration for an new empty UI element (control).
The following code snippet shows an example class definition for the new empty UIElement (control) from above.
Call the UIElement constructor from this constructor and decide if the element is a container, control or indicator. In the UIElement::KeyInput function handle each key that is supported by the element and return true to indicate that the key was handled. If you return false from UIElement::KeyInput function, the key is propagated to the parent element by the UI_Lib Core. In the UIElement::TouchInput function handle each touch that is supported by the element and return true to indicate that the touch was handled. If you return false from the UIElement::TouchInput function, the touch is propagated to the next element by the UI_Lib Core. Use the UIElement::RecalculateDimensions and UIElement::RecalculateLayout functions to update the dimensions (UIElement::Width and UIElement::Height) or the complete layout.