Horizon
tool_place_text.hpp
1 #pragma once
2 #include "core/tool.hpp"
3 #include "tool_helper_move.hpp"
4 #include <forward_list>
5 #include <map>
6 
7 namespace horizon {
8 
9 class ToolPlaceText : public ToolHelperMove {
10 public:
11  using ToolHelperMove::ToolHelperMove;
12  ToolResponse begin(const ToolArgs &args) override;
13  ToolResponse update(const ToolArgs &args) override;
14  bool can_begin() override;
15  bool is_specific() override;
16 
17  class Settings : public ToolSettings {
18  public:
19  json serialize() const override;
20  void load_from_json(const json &j) override;
21  class LayerSettings {
22  public:
24  {
25  }
26  LayerSettings(const json &j);
27  uint64_t width = 0;
28  uint64_t size = 1.5_mm;
29  json serialize() const;
30  };
31  const LayerSettings &get_layer(int l) const;
32  std::map<int, LayerSettings> layers;
33  };
34 
35  ToolSettings *get_settings() override
36  {
37  return &settings;
38  }
39 
40  void apply_settings() override;
41 
42  std::set<InToolActionID> get_actions() const override
43  {
44  using I = InToolActionID;
45  return {
46  I::LMB, I::CANCEL, I::RMB, I::EDIT, I::ROTATE, I::MIRROR, I::ENTER_SIZE, I::ENTER_WIDTH,
47  };
48  }
49 
50 private:
51  class Text *temp = 0;
52  class BoardPackage *pkg = nullptr;
53  std::forward_list<Text *> texts_placed;
54  Settings settings;
55 };
56 } // 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:21
Definition: tool_place_text.hpp:17
Definition: tool_place_text.hpp:9
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:84
bool is_specific() override
Definition: tool_place_text.cpp:70
bool can_begin() override
Definition: tool_place_text.cpp:60
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
zip_uint64_t uint64_t
zip_uint64_t_t typedef.
Definition: zip.hpp:108