Horizon
tool_drag_keep_slope.hpp
1 #pragma once
2 #include "board/track.hpp"
3 #include "core/tool.hpp"
4 #include <deque>
5 
6 namespace horizon {
7 
8 class ToolDragKeepSlope : public ToolBase {
9 public:
10  ToolDragKeepSlope(IDocument *c, ToolID tid);
11  ToolResponse begin(const ToolArgs &args) override;
12  ToolResponse update(const ToolArgs &args) override;
13  bool can_begin() override;
14  bool is_specific() override
15  {
16  return true;
17  }
18  std::set<InToolActionID> get_actions() const override
19  {
20  using I = InToolActionID;
21  return {
22  I::LMB,
23  I::CANCEL,
24  I::RMB,
25  };
26  }
27 
28 private:
29  class TrackInfo {
30  public:
31  Track *track = nullptr; // the track itself
32  Track *track_from = nullptr;
33  Track *track_to = nullptr;
34  Coordi pos_from2;
35  Coordi pos_to2;
36  Coordi pos_from_orig;
37  Coordi pos_to_orig;
38  TrackInfo(Track *tr, Track *fr, Track *to);
39  // TrackInfo(Track *a, Track *b, Track *c): track(a), track_from(b),
40  // track_to(c) {}
41  };
42 
43  std::deque<TrackInfo> track_info;
44  Coordi pos_orig;
45 };
46 } // namespace horizon
horizon::IDocument
Definition: idocument.hpp:5
horizon::ToolDragKeepSlope::is_specific
bool is_specific() override
Definition: tool_drag_keep_slope.hpp:14
horizon::ToolDragKeepSlope
Definition: tool_drag_keep_slope.hpp:8
horizon::ToolDragKeepSlope::can_begin
bool can_begin() override
Definition: tool_drag_keep_slope.cpp:13
horizon::ToolDragKeepSlope::begin
ToolResponse begin(const ToolArgs &args) override
Gets called right after the constructor has finished.
Definition: tool_drag_keep_slope.cpp:38
horizon::ToolBase
Common interface for all Tools.
Definition: tool.hpp:121
horizon::ToolDragKeepSlope::update
ToolResponse update(const ToolArgs &args) override
Gets called whenever the user generated some sort of input.
Definition: tool_drag_keep_slope.cpp:91
horizon::ToolResponse
To signal back to the core what the Tool did, a Tool returns a ToolResponse.
Definition: tool.hpp:42
horizon::ToolArgs
This is what a Tool receives when the user did something.
Definition: tool.hpp:23