View

class

Abstract interface for all UI Views, parent class for all views.

Abstract View class/interface. All UI view/widgets that paint to the screen must inherit from this class. Views handle repaint queues, touch input and painting to the display buffer automatically.

All views have a width and height, along with an absolute x,y coordinate that defines the upper left corner of the view rectangle.

Views must not contain any state. They only draw data to the display. Therefore views might contain or have references to objects holding the actual state information. Some simple views, like TextLabelView, are exceptions to this rule, since it is highly convenient to let them hold some state. (Like text content.)

Something on dependence of AppContext and Appctrl design pattern

See
ResponderView

Public Types

enum type mono::ui::View::Orientation

Define the 4 dirrerent orientations the of display. The display controller apply the orientation transformation to real display. For the UI Views the coordinate system remains the same, it just changes width and height. The origo is always the top left corner (defined relative to gravity), no matter the physical orientation of mono’s display.

Values:

= 0

Expected standard orientation of mono, where the thick edge is at the bottom

=1

Upside-down of PORTRAIT, where the thick edge is at the top

= 2

PORTRAIT rotated 90 degrees clock-wise

= 3

PORTRAIT rotated 90 degrees counter clock-wise

Public Functions

View::View()

Construct an empty view, you should not do this! You should not use View directly, subclass it instead.

View::View(geo::Rect rect)

Construct a view with dimensions, you should not do this! You should not use View directly, subclass it instead.

virtual void View::setPosition(geo::Point pos)

Change the view’s position on the screens coordinate system.

Changes the view’s position on the screen. Note that changing the position does not implicitly redraw the view. This means you will need to update the screen the affected areas to make the change visible.

Parameters
  • pos -

    The new position of the view

virtual void View::setSize(geo::Size siz)

Change the size (width, height) of the view.

Changes the view’s dimensions. The effect of size changes might depend on the specefic view subclass. Some views might use their size to calculate their internal layout - others might only support fixed size.

Note that changing the size here does not redraw the view. The screen needs to be redrawn to make the size change visible.

Parameters
  • siz -

    The new size of the view

virtual void View::setRect(geo::Rect rect)

Set the view’s position and size, by providing a rectangle object.

Note that this method does not repaint the view, you must do that explicitly.

Parameters
  • rect -

    The view rectangle, containing size and position

virtual mono::geo::Point &View::Position()

Get the current position of the view’s upper left corner.

Return
A reference to the current position

virtual mono::geo::Size &View::Size()

Get the view’s current size rectangle.

Return
A reference to the view’s size rectangle

virtual const mono::geo::Rect &View::ViewRect()
const

Get the views view rect

This method returns a reference to the views current view rect.

virtual void View::scheduleRepaint()

Schedule this view for repaint at next display refresh.

This method add the view to the display systems re-paint queue. The queue is executed right after a display refresh. This helps prevent graphical artifacts, when running on a single display buffer system.

Because views have no state information, they do not know when to repaint themselves. You, or classes using views, must call this repaint method when the view is ready to be repainted.

virtual bool View::Visible()
const

Returns the view’s visibility.

Get the view visible state. Non-visible view are ignored by the method scheduleRepaint. You change the visibility state by using the methods show and hide

Return
true if the view can/should be painted on the screen, false otherwise.
See
show
See
hide

virtual void View::show()

Set the view to visible, and paint it.

Change the view’s visibility state to visible. This means it can be scheduled for repaint by scheduleRepaint. This method automatically schedules the view for repaint.

See
hide
See
Visible

virtual void View::hide()

Set the view to be invisible.

Change the view’s state to invisible. This method will remove the view from the dirtyQueue, if it has already been scheduled for repaint.

Any calls to scheduleRepaint will be ignored, until the view is set visible again.

See
show
See
Visible

Public Static Functions

uint16_t View::DisplayWidth()

Returns the horizontal (X-axis) width of the display canvas, in pixels. The width is always defined as perpendicular to gravity

uint16_t View::DisplayHeight()

Returns the vertical (Y-axis) height of the display canvas, in pixels. The height axis is meant to be parallel to the gravitational axis.

View::Orientation View::DisplayOrientation()

Returns the current physical display orientation of the display The orientation is controlled by the IDisplayController

Public Static Attributes

uint32_t View::RepaintScheduledViewsTime

The CPU time used to repaint the latest set of dirty views. This measure includes both the painting algorithms and the transfer time used to comminicate with the disdplay hardware.

Protected Functions

void View::callRepaintScheduledViews()

A member method to call the static method repaintScheduledViews.

See
repaintScheduledViews

virtual void mono::ui::View::repaint()
= 0

Repaint the view content, using the View::painter.

Re-paint the view content. This method should be called when the view content has changed. You can call this method directly, but it might cause graphics artifacts because the display is not double buffered. Instead you should schedule a repaint by calling the scheduleRepaint() method. This method will schedule the repaint, right after the next display update.

The display system will not schedule any repaints automatically. The view does not contain any state information, so you or other classes utilizing view must schedule repaints.

In subclasses of View, this method must be overwritten.

Protected Attributes

geo::Rect mono::ui::View::viewRect

The rect defines the position and size of this view on the screen. This defines where the view rectangles upper left corner is situated, and the width and height in pixels.

bool mono::ui::View::isDirty

Indicate is this view should be repainted on next display refresh.

bool mono::ui::View::visible

Views can be visible of non-visisble (hidden). When a view is not visible scheduleRepaint will ignore requests.

You should use the methods show and hide is toggle visibility.

See
show
See
hide
See
Visible

Protected Static Functions

void View::repaintScheduledViews()

This class method will run through the scheduled re-paints queue and call the repaint method on all of them.

This method is called automatically be the display system, you do not need to call it yourself.

Protected Static Attributes

mono::display::DisplayPainter View::painter

Global View painter object. Once the first View is included in the code, this painter is initialized on the stack. Every view object uses this painter to paint itself.

The painter is initialized with the display controller of the application context. If you want views to draw themselv on another display, you must subclass or change the current display controller of the mono::ApplicationContext object.

mono::GenericQueue<View> View::dirtyQueue

The global re-paint queue.

When you call the scheduleRepaint method, your views is added to the re-paint queue.