Screen
touchgfx/Screen.hpp
A Screen represents a full-screen drawable area. Applications create specific screens by subclassing this class. Each Screen has a root container to which drawables are added. The Screen makes sure to delegate draw requests and various events to the appropriate drawables in correct order.
Inherited by: View< T >
Public Functions
virtual void | afterTransition() |
Called by Application::handleTickEvent() when the transition to the screen is done. | |
void | bindTransition(Transition & trans) |
Enables the transition to access the containers. | |
void | draw() |
Tells the screen to draw its entire area. | |
virtual void | draw(Rect & rect) |
Tell the screen to draw the specified area. | |
Container & | getRootContainer() |
Obtain a reference to the root container of this screen. | |
int16_t | getScreenHeight() const |
Gets height of the current screen. | |
int16_t | getScreenWidth() const |
Gets width of the current screen. | |
virtual void | handleClickEvent(const ClickEvent & event) |
Traverse the drawables in reverse z-order and notify them of a click event. | |
virtual void | handleDragEvent(const DragEvent & event) |
Traverse the drawables in reverse z-order and notify them of a drag event. | |
virtual void | handleGestureEvent(const GestureEvent & event) |
Handle gestures. | |
virtual void | handleKeyEvent(uint8_t key) |
Called by the Application on the reception of a "key", the meaning of which is platform/application specific. | |
virtual void | handleTickEvent() |
Called by the Application on the current screen with a frequency of Application::TICK_INTERVAL_MS. | |
void | JSMOC(const Rect & invalidatedArea, Drawable * widgetToDraw) |
Recursive JSMOC function. | |
Screen() | |
Initializes a new instance of the Screen class. | |
virtual void | setupScreen() |
Called by Application::switchScreen() when this screen is going to be displayed. | |
void | startSMOC(const Rect & invalidatedArea) |
Starts a JSMOC run, analyzing what parts of what widgets should be redrawn. | |
virtual void | tearDownScreen() |
Called by Application::switchScreen() when this screen will no longer be displayed. | |
bool | usingSMOC() const |
Determines if using JSMOC. | |
virtual | ~Screen() |
Finalizes an instance of the Screen class. | |
Protected Functions
void | add(Drawable & d) |
Add a drawable to the content container. | |
void | insert(Drawable * previous, Drawable & d) |
Inserts a Drawable after a specific child node. | |
void | invalidate() const |
Tell the framework that this entire Screen needs to be redrawn. | |
void | invalidateRect(Rect & invalidatedArea) const |
Request that a region of this root container on the screen is redrawn. | |
void | remove(Drawable & d) |
Removes a drawable from the content container. | |
void | useSMOCDrawing(bool enabled) |
Determines whether to use JSMOC or painter's algorithm for drawing. | |
Protected Attributes
Container | container |
The container contains the contents of the screen. | |
Drawable * | focus |
The drawable currently in focus (set when DOWN_PRESSED is received). | |
Public Functions Documentation
afterTransition
virtual void afterTransition | ( | ) |
Called by Application::handleTickEvent() when the transition to the screen is done.
Base version does nothing, but override to do screen specific initialization code that has to be done after the transition to the screen.
bindTransition
void bindTransition | ( | Transition & | trans | ) | |
Enables the transition to access the containers.
trans | The transition to bind. |
draw
void draw | ( | ) |
Tells the screen to draw its entire area.
Note
The more specific draw(Rect&) version is preferred when possible.
draw
Tell the screen to draw the specified area.
Will traverse the drawables tree from in z-order and delegate draw to them.
rect | The area in absolute coordinates. |
Note
The given rect must be in absolute coordinates.
getRootContainer
Container & getRootContainer | ( | ) |
Obtain a reference to the root container of this screen.
The root container.
getScreenHeight
int16_t getScreenHeight | ( | ) | const |
Gets height of the current screen.
In most cases, this is the same as HAL::DISPLAY_HEIGHT.
The screen height.
getScreenWidth
int16_t getScreenWidth | ( | ) | const |
Gets width of the current screen.
In most cases, this is the same as HAL::DISPLAY_WIDTH.
The screen width.
handleClickEvent
virtual void handleClickEvent | ( | const ClickEvent & | event | ) | |
Traverse the drawables in reverse z-order and notify them of a click event.
event | The event to handle. |
handleDragEvent
virtual void handleDragEvent | ( | const DragEvent & | event | ) | |
Traverse the drawables in reverse z-order and notify them of a drag event.
event | The event to handle. |
handleGestureEvent
virtual void handleGestureEvent | ( | const GestureEvent & | event | ) | |
Handle gestures.
Traverses drawables in reverse-z and notifies them of the gesture.
event | The event to handle. |
handleKeyEvent
virtual void handleKeyEvent | ( | uint8_t | key | ) | |
Called by the Application on the reception of a "key", the meaning of which is platform/application specific.
Default implementation does nothing.
key | The key to handle. |
handleTickEvent
virtual void handleTickEvent | ( | ) |
Called by the Application on the current screen with a frequency of Application::TICK_INTERVAL_MS.
JSMOC
Recursive JSMOC function.
This is the actual occlusion culling implementation.
invalidatedArea | The area to redraw, expressed in absolute coordinates. |
widgetToDraw | Widget currently being drawn. |
Note
JSMOC is an abbreviation of Jesper, Sren & Martin's Occlusion Culling.
Screen
setupScreen
virtual void setupScreen | ( | ) |
Called by Application::switchScreen() when this screen is going to be displayed.
Base version does nothing, but place any screen specific initialization code in an overridden version.
startSMOC
Starts a JSMOC run, analyzing what parts of what widgets should be redrawn.
invalidatedArea | The area to redraw, expressed in absolute coordinates. |
Note
SMOC is an abbreviation of Sren & Martin's Occlusion Culling.
tearDownScreen
virtual void tearDownScreen | ( | ) |
Called by Application::switchScreen() when this screen will no longer be displayed.
Base version does nothing, but place any screen specific cleanup code in an overridden version.
usingSMOC
bool usingSMOC | ( | ) | const |
Determines if using JSMOC.
true if this screen uses the JSMOC drawing algorithm.
~Screen
Protected Functions Documentation
add
insert
Inserts a Drawable after a specific child node.
See Container::insert.
Note
As with add, do not add the same drawable twice.
invalidate
void invalidate | ( | ) | const |
invalidateRect
void invalidateRect | ( | Rect & | invalidatedArea | ) | |
Request that a region of this root container on the screen is redrawn.
See Container::invalidateRect.
To invalidate the entire Screen, use invalidate()
invalidatedArea | The area of this drawable to redraw expressed in coordinates relative to the root container. |
Note
The invalidatedArea position is relative to the root container, which is usually the same as the Screen coordinates.
remove
Removes a drawable from the content container.
Safe to call even if the drawable was never added (in which case nothing happens).
d | The Drawable to remove. |
useSMOCDrawing
void useSMOCDrawing | ( | bool | enabled | ) | |
Determines whether to use JSMOC or painter's algorithm for drawing.
enabled | true if JSMOC should be enabled, false if disabled (meaning painter's algorithm is employed instead). |
Protected Attributes Documentation
container
Container container
The container contains the contents of the screen.
focus
Drawable * focus
The drawable currently in focus (set when DOWN_PRESSED is received).