Aurore
A Switch-like interface for your app, on every screen
Loading...
Searching...
No Matches
cadran_digits.hpp
Go to the documentation of this file.
1// CadranDigits — a line of text in the display face of the Cadran boards
2// (Sora Bold, OFL, resources/font/sora_bold_latin.ttf, loaded as
3// "cadran/digits"; the default font when it is missing): the big figures,
4// the card values, the chips. Aurore's Label draws with the one default font.
5// Copyright (C) 2026 JigSawFr. GPLv3-or-later (see LICENSE.GPL).
6#pragma once
7
8#include <string>
9#include <vector>
10#include <aurore.hpp>
11
14{
15 public:
17
18 void setText(const std::string& text);
19 const std::string& getText() const { return this->text; }
20 void setFontSize(float size);
21 void setTextColor(NVGcolor color);
23 bool getStyleProperty(const std::string& name, aurore::StyleValue* value) override;
24 bool setStyleProperty(const std::string& name, const aurore::StyleValue& value) override;
26 void setFitWidth(float width);
30 void setFitParent(bool fit);
34 void setSmallUnits(bool small);
37 void setFollowsTextSize(bool follows);
41 void setRolls(bool rolls);
43 void remeasure() { this->measure(); }
44 void onTextScaleChanged() override { this->measure(); }
45
46 void draw(NVGcontext* vg, float x, float y, float width, float height,
47 aurore::Style style, aurore::FrameContext* ctx) override;
48
50
51 protected:
54 std::string getDefaultAccessibilityLabel() override { return this->text; }
55
56 private:
57 std::string text;
58 float fontSize = 32.0f;
59 float drawSize = 32.0f;
60 float fitWidth = 0.0f;
61 bool fitParent = false;
62 bool smallUnits = false;
63 bool followsTextSize = false;
64 bool rolls = false;
66 std::string leaving;
67 aurore::Time roll_since = 0;
68 float leaving_size = 32.0f;
69 bool drawn = false;
70 NVGcolor color;
71 int font;
72
73 void measure();
75 struct Run
76 {
77 std::string text;
78 bool figure;
79 };
80 std::vector<Run> runs(const std::string& text) const;
81 float advance(NVGcontext* vg, float size) const;
83 void write(NVGcontext* vg, const std::string& text, float size, float x, float y, float height) const;
84};
A line of text in Cadran's display face (Sora): big figures, card values, chips.
Definition cadran_digits.hpp:14
aurore::AccessibilityRole getDefaultAccessibilityRole() override
Said as a label's text (a chip, a card say it).
Definition cadran_digits.hpp:53
void onTextScaleChanged() override
Definition cadran_digits.hpp:44
std::string getDefaultAccessibilityLabel() override
Definition cadran_digits.hpp:54
void setFitParent(bool fit)
void setRolls(bool rolls)
void remeasure()
The size taken again after the text size changed (ui/text_size).
Definition cadran_digits.hpp:43
static aurore::View * create()
void draw(NVGcontext *vg, float x, float y, float width, float height, aurore::Style style, aurore::FrameContext *ctx) override
bool getStyleProperty(const std::string &name, aurore::StyleValue *value) override
"textColor" (setThemeColor, XML textColor="@theme/…")
void setFitWidth(float width)
At most that wide: a longer text is drawn smaller to fit (0: never).
void setFontSize(float size)
bool setStyleProperty(const std::string &name, const aurore::StyleValue &value) override
void setFollowsTextSize(bool follows)
void setText(const std::string &text)
void setSmallUnits(bool small)
const std::string & getText() const
Definition cadran_digits.hpp:19
void setTextColor(NVGcolor color)
Definition frame_context.hpp:30
Simple wrapper around StyleValues for the array operator.
Definition style.hpp:115
Definition view.hpp:232
AccessibilityRole
Definition view_style.hpp:78
retro_time_t Time
Definition time.hpp:31
Definition text.hpp:13
Definition view_style.hpp:41