Horizon
tool_place_text.hpp
1 #pragma once
2 #include "core.hpp"
3 #include "tool_helper_move.hpp"
4 #include <forward_list>
5 
6 namespace horizon {
7 
8 class ToolPlaceText : public ToolHelperMove {
9 public:
10  ToolPlaceText(Core *c, ToolID tid);
11  ToolResponse begin(const ToolArgs &args) override;
12  ToolResponse update(const ToolArgs &args) override;
13  bool can_begin() override;
14 
15  class Settings : public ToolSettings {
16  public:
17  json serialize() const override;
18  void load_from_json(const json &j) override;
19  uint64_t width = 0;
20  uint64_t size = 1.5_mm;
21  };
22 
23  const ToolSettings *get_settings_const() const override
24  {
25  return &settings;
26  }
27 
28  void apply_settings() override;
29 
30 protected:
31  ToolSettings *get_settings() override
32  {
33  return &settings;
34  }
35 
36 private:
37  Text *temp = 0;
38  std::forward_list<Text *> texts_placed;
39  Settings settings;
40 };
41 } // namespace horizon
a class to store JSON values
Definition: json.hpp:161
This is what a Tool receives when the user did something.
Definition: core.hpp:27
ToolResponse update(const ToolArgs &args) override
Gets called whenever the user generated some sort of input.
Definition: tool_place_text.cpp:64
Definition: core.hpp:96
Definition: tool_place_text.hpp:15
Definition: tool_place_text.hpp:8
Definition: tool_helper_move.hpp:5
bool can_begin() override
Definition: tool_place_text.cpp:26
Used wherever a user-editable text is needed.
Definition: text.hpp:19
ToolResponse begin(const ToolArgs &args) override
Gets called right after the constructor has finished.
Definition: tool_place_text.cpp:39
Where Tools and and documents meet.
Definition: core.hpp:232
To signal back to the core what the Tool did, a Tool returns a ToolResponse.
Definition: core.hpp:46
Definition: block.cpp:9