7#include "roo_backport.h"
8#include "roo_backport/string_view.h"
35 template <
typename String>
47 metrics_(
font.getHorizontalStringMetrics(label_)) {}
69 const std::string&
label()
const {
return label_; }
114 template <
typename String>
127 metrics_(
font.getHorizontalStringMetrics(
label)) {}
149 const roo::string_view
label()
const {
return label_; }
162 roo::string_view label_;
Axis-aligned integer rectangle.
Like ClippedTextLabel, but does not own the text content.
Box extents() const override
Return the bounding box encompassing all pixels that need to be drawn.
void drawTo(const Surface &s) const override
Draw this object's content, respecting the fill mode.
Single-line, single-color label with tight extents.
void drawTo(const Surface &s) const override
Draw this object's content, respecting the fill mode.
Box anchorExtents() const override
Return the bounds used for alignment.
ARGB8888 color stored as a 32-bit unsigned integer.
Interface for objects that can be drawn to an output device.
void drawHorizontalString(const Surface &s, roo::string_view text, Color color) const
Draw a UTF-8 string horizontally using a string view.
Per-glyph metrics (bounding box and advance).
int advance() const
Advance in pixels.
const Box & screen_extents() const
Bounding box in screen coordinates (Y down).
Like TextLabel, but does not own the text content.
void drawTo(const Surface &s) const override
Draw this object's content, respecting the fill mode.
const Font & font() const
Return the font used by the label.
const GlyphMetrics & metrics() const
Return cached string metrics.
void setFillMode(FillMode fill_mode)
Set the fill mode.
const roo::string_view label() const
Return the label text view.
void setColor(Color color)
Set the label color.
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 FillMode fill_mode() const
Return the fill mode.
const Color color() const
Return the label color.
StringViewLabel(roo::string_view label, const Font &font, Color color, FillMode fill_mode=FillMode::kVisible)
Construct from a string_view.
StringViewLabel(String &label, const Font &font, const Color color, FillMode fill_mode=FillMode::kVisible)
Construct from a string-like value without copying.
Low-level handle used to draw to an underlying device.
Single-line, single-color text label.
const Color color() const
Return the label color.
void setColor(Color color)
Set the label color.
TextLabel(std::string label, const Font &font, Color color, FillMode fill_mode=FillMode::kVisible)
Construct from an owned string.
const GlyphMetrics & metrics() const
Return cached string metrics.
void drawTo(const Surface &s) const override
Draw this object's content, respecting the fill mode.
const Font & font() const
Return the font used by the label.
const FillMode fill_mode() const
Return the fill mode.
Box anchorExtents() const override
Return the bounds used for alignment.
const std::string & label() const
Return the label text.
Box extents() const override
Return the bounding box encompassing all pixels that need to be drawn.
void setFillMode(FillMode fill_mode)
Set the fill mode.
TextLabel(const String &label, const Font &font, Color color, FillMode fill_mode=FillMode::kVisible)
Construct from a string-like value (moves into internal storage).
Defines 140 opaque HTML named colors.
FillMode
Specifies whether a Drawable should fill its entire extents box, including fully transparent pixels.
@ kVisible
Fully transparent pixels do not need to be filled.
@ kExtents
Fill the entire extents box (possibly with fully transparent pixels).