BackgroundView

class mono::ui::BackgroundView

A full screen solid colored background.

Use this view to paint the background any color you like. This view is by default the same size as Mono’s display. It can be used a solid colored background for your GUI.

To save memory you should only have one background view per app.

Painting on top of the background

To ensure that the background is behind all other UI widgets on the screen, it has to be rendered first. Then all other views will apepear on top of the background. To achieve this, it is important to keep track of your repaint order. All paint calls must begin with a scheduleRepaint to the background view.

Example

// Construct the view (should alwaus be a class member)
mono::ui::BackgroundView bg;

// set an exiting new background color
bg.setBackgroundColor(mono::display::RedColor);

//show the background
bg.show();

// show all my other views, after the call to bg.show()

Inherits from mono::ui::View

Public Functions

BackgroundView(display::Color color = StandardBackgroundColor)

Construct a Background view on the entire screen.

This contructor takes a optional color to use for the background. If no argument is provided the color default to the View::StandardBackgroundColor

Also be default the view dimension is the entire display, meaning it has a bounding rect (vireRect) that is (0,0,176,220).

Note: Remember to all show to make the view visible.

Parameters
  • color: An optional bckground color

void setBackgroundColor(display::Color color)

Sets a new background color on the view.

Set a new background color on the view. If the view is shared between multiple UI scenes, you can use this method to change the background color.

When changing the background color the view is not automatically repainted. You must call scheduleRepaint yourself.

mono::display::Color Color() const

Gets the current background color.

void repaint()

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.