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 #include <vector>
8 #include <map>
9 #include <fstream>
10 
11 namespace horizon {
12 using json = nlohmann::json;
13 enum class TextOrigin { BASELINE, CENTER, BOTTOM };
14 
18 class Text {
19 public:
20  Text(const UUID &uu, const json &j);
21  Text(const UUID &uu);
22 
23  UUID uuid;
24 
25  TextOrigin origin = TextOrigin::CENTER;
26  TextData::Font font = TextData::Font::SIMPLEX;
27  Placement placement;
28  std::string text;
29  uint64_t size = 1.5_mm;
30  uint64_t width = 0;
31  int layer = 0;
32  bool allow_upside_down = false;
33  std::string text_override;
34 
39  bool overridden = false;
40 
45  bool from_smash = false;
46 
47  UUID get_uuid() const;
48  json serialize() const;
49 };
50 } // namespace horizon
Definition: placement.hpp:8
Used wherever a user-editable text is needed.
Definition: text.hpp:18
bool from_smash
true if this is the result of a smash operation.
Definition: text.hpp:45
bool overridden
When set, the renderer will render text_override instead of text.
Definition: text.hpp:39
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
zip_uint64_t uint64_t
zip_uint64_t_t typedef.
Definition: zip.hpp:108
basic_json<> json
default JSON class
Definition: json_fwd.hpp:62