Horizon
Loading...
Searching...
No Matches
tool_place_text.hpp
1#pragma once
2#include "core/tool.hpp"
3#include "tool_helper_move.hpp"
4#include "util/text_data.hpp"
5#include <forward_list>
6#include <map>
7
8namespace horizon {
9
11public:
12 using ToolHelperMove::ToolHelperMove;
13 ToolResponse begin(const ToolArgs &args) override;
14 ToolResponse update(const ToolArgs &args) override;
15 bool can_begin() override;
16 bool is_specific() override;
17
18 class Settings : public ToolSettings {
19 public:
20 json serialize() const override;
21 void load_from_json(const json &j) override;
23 public:
25 {
26 }
27 LayerSettings(const json &j);
28 uint64_t width = 0;
29 uint64_t size = 1.5_mm;
30 json serialize() const;
31 };
32 const LayerSettings &get_layer(int l) const;
33 std::map<int, LayerSettings> layers;
34 TextData::Font font = TextData::Font::SIMPLEX;
35 };
36
37 ToolSettings *get_settings() override
38 {
39 return &settings;
40 }
41
42 void apply_settings() override;
43
44 std::set<InToolActionID> get_actions() const override
45 {
46 using I = InToolActionID;
47 return {
48 I::LMB, I::CANCEL, I::RMB, I::EDIT, I::ROTATE, I::MIRROR, I::ENTER_SIZE, I::ENTER_WIDTH,
49 };
50 }
51
52private:
53 class Text *temp = 0;
54 class BoardPackage *pkg = nullptr;
55 std::forward_list<Text *> texts_placed;
56 Settings settings;
57 ToolResponse finish();
58};
59} // namespace horizon
This is what a Tool receives when the user did something.
Definition tool_pub.hpp:23
Definition tool_helper_move.hpp:6
Definition tool_place_text.hpp:22
Definition tool_place_text.hpp:18
Definition tool_place_text.hpp:10
ToolResponse update(const ToolArgs &args) override
Gets called whenever the user generated some sort of input.
Definition tool_place_text.cpp:133
ToolResponse begin(const ToolArgs &args) override
Gets called right after the constructor has finished.
Definition tool_place_text.cpp:90
bool is_specific() override
Definition tool_place_text.cpp:75
bool can_begin() override
Definition tool_place_text.cpp:65
To signal back to the core what the Tool did, a Tool returns a ToolResponse.
Definition tool_pub.hpp:40
Definition tool_pub.hpp:82
a class to store JSON values
Definition json.hpp:177