주요 내용으로 건너뛰기

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 voidafterTransition()
Called by Application::handleTickEvent() when the transition to the screen is done.
voidbindTransition(Transition & trans)
Enables the transition to access the containers.
voiddraw()
Tells the screen to draw its entire area.
virtual voiddraw(Rect & rect)
Tell the screen to draw the specified area.
Container &getRootContainer()
Obtain a reference to the root container of this screen.
int16_tgetScreenHeight() const
Gets height of the current screen.
int16_tgetScreenWidth() const
Gets width of the current screen.
virtual voidhandleClickEvent(const ClickEvent & event)
Traverse the drawables in reverse z-order and notify them of a click event.
virtual voidhandleDragEvent(const DragEvent & event)
Traverse the drawables in reverse z-order and notify them of a drag event.
virtual voidhandleGestureEvent(const GestureEvent & event)
Handle gestures.
virtual voidhandleKeyEvent(uint8_t key)
Called by the Application on the reception of a "key", the meaning of which is platform/application specific.
virtual voidhandleTickEvent()
Called by the Application on the current screen with a frequency of Application::TICK_INTERVAL_MS.
voidJSMOC(const Rect & invalidatedArea, Drawable * widgetToDraw)
Recursive JSMOC function.
Screen()
Initializes a new instance of the Screen class.
virtual voidsetupScreen()
Called by Application::switchScreen() when this screen is going to be displayed.
voidstartSMOC(const Rect & invalidatedArea)
Starts a JSMOC run, analyzing what parts of what widgets should be redrawn.
virtual voidtearDownScreen()
Called by Application::switchScreen() when this screen will no longer be displayed.
boolusingSMOC() const
Determines if using JSMOC.
virtual ~Screen()
Finalizes an instance of the Screen class.

Protected Functions

voidadd(Drawable & d)
Add a drawable to the content container.
voidinsert(Drawable * previous, Drawable & d)
Inserts a Drawable after a specific child node.
voidinvalidate() const
Tell the framework that this entire Screen needs to be redrawn.
voidinvalidateRect(Rect & invalidatedArea) const
Request that a region of this root container on the screen is redrawn.
voidremove(Drawable & d)
Removes a drawable from the content container.
voiduseSMOCDrawing(bool enabled)
Determines whether to use JSMOC or painter's algorithm for drawing.

Protected Attributes

Containercontainer
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.

See also:

bindTransition

Enables the transition to access the containers.

Parameters:
transThe 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

virtual void draw(Rect &rect)

Tell the screen to draw the specified area.

Will traverse the drawables tree from in z-order and delegate draw to them.

Parameters:
rectThe 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.

Returns:

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.

Returns:

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.

Returns:

The screen width.

handleClickEvent

virtual void handleClickEvent(const ClickEvent &event)

Traverse the drawables in reverse z-order and notify them of a click event.

Parameters:
eventThe event to handle.

handleDragEvent

virtual void handleDragEvent(const DragEvent &event)

Traverse the drawables in reverse z-order and notify them of a drag event.

Parameters:
eventThe event to handle.

handleGestureEvent

virtual void handleGestureEvent(const GestureEvent &event)

Handle gestures.

Traverses drawables in reverse-z and notifies them of the gesture.

Parameters:
eventThe event to handle.

handleKeyEvent

virtual void handleKeyEvent(uint8_tkey)

Called by the Application on the reception of a "key", the meaning of which is platform/application specific.

Default implementation does nothing.

Parameters:
keyThe key to handle.

handleTickEvent

virtual void handleTickEvent()

Called by the Application on the current screen with a frequency of Application::TICK_INTERVAL_MS.

JSMOC

void JSMOC(const Rect &invalidatedArea ,
Drawable *widgetToDraw
)

Recursive JSMOC function.

This is the actual occlusion culling implementation.

Parameters:
invalidatedAreaThe area to redraw, expressed in absolute coordinates.
widgetToDrawWidget currently being drawn.
Note

JSMOC is an abbreviation of Jesper, Sren & Martin's Occlusion Culling.

Screen

Initializes a new instance of the Screen class.

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.

See also:

startSMOC

void startSMOC(const Rect &invalidatedArea)

Starts a JSMOC run, analyzing what parts of what widgets should be redrawn.

Parameters:
invalidatedAreaThe 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.

See also:

usingSMOC

bool usingSMOC()const

Determines if using JSMOC.

Returns:

true if this screen uses the JSMOC drawing algorithm.

~Screen

virtual ~Screen()

Finalizes an instance of the Screen class.

Protected Functions Documentation

add

void add(Drawable &d)

Add a drawable to the content container.

Parameters:
dThe Drawable to add.
Note

Must not be called with a Drawable that was already added to the screen. If in doubt, call remove() first.

insert

void insert(Drawable *previous ,
Drawable &d
)

Inserts a Drawable after a specific child node.

See Container::insert.

Parameters:
previousThe Drawable to insert after. If null, insert as header.
dThe Drawable to insert.
Note

As with add, do not add the same drawable twice.

See also:

invalidate

void invalidate()const

Tell the framework that this entire Screen needs to be redrawn.

See also:

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()

Parameters:
invalidatedAreaThe 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.

See also:

remove

void remove(Drawable &d)

Removes a drawable from the content container.

Safe to call even if the drawable was never added (in which case nothing happens).

Parameters:
dThe Drawable to remove.

useSMOCDrawing

void useSMOCDrawing(boolenabled)

Determines whether to use JSMOC or painter's algorithm for drawing.

Parameters:
enabledtrue 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).