roo_display
API Documentation for roo_display
Loading...
Searching...
No Matches
roo_display::ClippedStringViewLabel Class Reference

Like ClippedTextLabel, but does not own the text content. More...

#include <text_label.h>

Inheritance diagram for roo_display::ClippedStringViewLabel:
[legend]
Collaboration diagram for roo_display::ClippedStringViewLabel:
[legend]

Public Member Functions

void drawTo (const Surface &s) const override
 Draw this object's content, respecting the fill mode.
 
Box extents () const override
 Return the bounding box encompassing all pixels that need to be drawn.
 
template<typename String >
 StringViewLabel (String &label, const Font &font, const Color color, FillMode fill_mode=FillMode::kVisible)
 Construct from a string-like value without copying.
 
 StringViewLabel (roo::string_view label, const Font &font, Color color, FillMode fill_mode=FillMode::kVisible)
 Construct from a string_view.
 
- Public Member Functions inherited from roo_display::StringViewLabel
template<typename String >
 StringViewLabel (String &label, const Font &font, const Color color, FillMode fill_mode=FillMode::kVisible)
 Construct from a string-like value without copying.
 
 StringViewLabel (roo::string_view label, const Font &font, Color color, FillMode fill_mode=FillMode::kVisible)
 Construct from a string_view.
 
void drawTo (const Surface &s) const override
 Draw this object's content, respecting the fill mode.
 
Box extents () const override
 Return the bounding box encompassing all pixels that need to be drawn.
 
Box anchorExtents () const override
 Return the bounds used for alignment.
 
const Fontfont () const
 Return the font used by the label.
 
const GlyphMetricsmetrics () const
 Return cached string metrics.
 
const roo::string_view label () const
 Return the label text view.
 
const Color color () const
 Return the label color.
 
const FillMode fill_mode () const
 Return the fill mode.
 
void setColor (Color color)
 Set the label color.
 
void setFillMode (FillMode fill_mode)
 Set the fill mode.
 
- Public Member Functions inherited from roo_display::Drawable
virtual ~Drawable ()
 

Additional Inherited Members

- Static Public Member Functions inherited from roo_display::Drawable
static const DrawableEmpty ()
 A singleton representing a no-op drawable with no bounding box.
 

Detailed Description

Like ClippedTextLabel, but does not own the text content.

Uses no dynamic allocation. Ideal for string literals or temporary labels.

Definition at line 171 of file text_label.h.

Member Function Documentation

◆ drawTo()

void roo_display::ClippedStringViewLabel::drawTo ( const Surface s) const
inlineoverridevirtual

Draw this object's content, respecting the fill mode.

If s.fill_mode() == FillMode::kExtents, the method must fill the entire (clipped) extents() rectangle (using s.bgcolor() for transparent parts).

The default implementation fills the clipped extents() rectangle with bgcolor and then calls drawInteriorTo(). That can cause flicker, so override this method if a better implementation is possible.

The implementation must respect surface parameters, particularly clip_box(), and must not draw outside it. The surface clip box is pre-clipped to fit within this drawable's extents().

Reimplemented from roo_display::Drawable.

Definition at line 175 of file text_label.h.

References roo_display::StringViewLabel::color(), roo_display::Font::drawHorizontalString(), roo_display::StringViewLabel::fill_mode(), roo_display::StringViewLabel::font(), roo_display::kExtents, and roo_display::StringViewLabel::label().

◆ extents()

Box roo_display::ClippedStringViewLabel::extents ( ) const
inlineoverridevirtual

Return the bounding box encompassing all pixels that need to be drawn.

This method is called during a transaction and must not block or perform I/O.

Implements roo_display::Drawable.

Definition at line 183 of file text_label.h.

References roo_display::StringViewLabel::metrics(), and roo_display::GlyphMetrics::screen_extents().

◆ StringViewLabel() [1/2]

roo_display::StringViewLabel::StringViewLabel ( roo::string_view  label,
const Font font,
Color  color,
FillMode  fill_mode = FillMode::kVisible 
)
inline

Construct from a string_view.

Definition at line 121 of file text_label.h.

◆ StringViewLabel() [2/2]

template<typename String >
roo_display::StringViewLabel::StringViewLabel ( String label,
const Font font,
const Color  color,
FillMode  fill_mode = FillMode::kVisible 
)
inline

Construct from a string-like value without copying.

Definition at line 115 of file text_label.h.


The documentation for this class was generated from the following file: