Horizon
text.hpp
1 #pragma once
2 #include "util/uuid.hpp"
3 #include "nlohmann/json_fwd.hpp"
4 #include "common.hpp"
5 #include "util/placement.hpp"
6 #include "util/text_data.hpp"
7 
8 namespace horizon {
9 using json = nlohmann::json;
10 enum class TextOrigin { BASELINE, CENTER, BOTTOM };
11 
15 class Text {
16 public:
17  Text(const UUID &uu, const json &j);
18  Text(const UUID &uu);
19 
20  UUID uuid;
21 
22  TextOrigin origin = TextOrigin::CENTER;
23  TextData::Font font = TextData::Font::SIMPLEX;
24  Placement placement;
25  std::string text;
26  uint64_t size = 1.5_mm;
27  uint64_t width = 0;
28  int layer = 0;
29  bool allow_upside_down = false;
30  std::string text_override;
31 
36  bool overridden = false;
37 
42  bool from_smash = false;
43 
44  UUID get_uuid() const;
45  json serialize() const;
46 };
47 } // namespace horizon
Definition: placement.hpp:8
Used wherever a user-editable text is needed.
Definition: text.hpp:15
bool from_smash
true if this is the result of a smash operation.
Definition: text.hpp:42
bool overridden
When set, the renderer will render text_override instead of text.
Definition: text.hpp:36
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
a class to store JSON values
Definition: json.hpp:177
basic_json<> json
default JSON class
Definition: json_fwd.hpp:62