CurvePalette.hpp
1 #pragma once
2 #include <Process/Tools/ToolPalette.hpp>
3 
4 #include <Curve/CurvePresenter.hpp>
5 #include <Curve/CurveView.hpp>
6 #include <Curve/Palette/CurveEditionSettings.hpp>
7 #include <Curve/Palette/CurvePoint.hpp>
8 #include <Curve/Palette/Tools/MoveTool.hpp>
9 #include <Curve/Palette/Tools/SmartTool.hpp>
10 
11 #include <score/statemachine/GraphicsSceneToolPalette.hpp>
12 
13 #include <QPoint>
14 
15 #include <score_plugin_curve_export.h>
16 namespace score
17 {
18 class CommandStackFacade;
19 class ObjectLocker;
20 } // namespace score
21 namespace Process
22 {
23 struct LayerContext;
24 }
25 
26 namespace Curve
27 {
28 class Model;
29 class Presenter;
30 class View;
31 
32 class SCORE_PLUGIN_CURVE_EXPORT ToolPalette : public GraphicsSceneToolPalette
33 {
34 public:
35  ToolPalette(const score::DocumentContext& ctx, Presenter& pres);
36  ~ToolPalette();
37  Presenter& presenter() const;
38 
39  Curve::EditionSettings& editionSettings() const;
40 
41  const Model& model() const;
42  void on_pressed(QPointF point);
43  void on_moved(QPointF point);
44  void on_released(QPointF point);
45 
46  void on_cancel();
47 
48  void activate(Curve::Tool);
49  void desactivate(Curve::Tool);
50 
51  // From double-click :
52  void createPoint(QPointF);
53 
54 private:
55  Curve::Point ScenePointToCurvePoint(const QPointF& point)
56  {
57  const auto rect = m_presenter.rect();
58  return {point.x() / rect.width(), 1. - point.y() / rect.height()};
59  }
60 
61  Presenter& m_presenter;
62 
63  SmartTool m_selectTool;
64  CreateTool m_createTool;
65  SetSegmentTool m_setSegmentTool;
66  CreatePenTool m_createPenTool;
67 };
68 
69 template <typename Context_T>
70 struct ToolPalette_T final : public ToolPalette
71 {
72  ToolPalette_T(const Context_T& ctx, Presenter& pres)
73  : ToolPalette{ctx.context, pres}
74  , m_inputDisp{pres.view(), *this, ctx}
75  {
76  }
77 
79 };
80 }
Definition: MoveTool.hpp:43
Definition: MoveTool.hpp:25
Definition: CurveEditionSettings.hpp:34
Definition: CurveModel.hpp:25
Definition: CurvePresenter.hpp:32
Definition: MoveTool.hpp:34
Definition: score-plugin-curve/Curve/Palette/Tools/SmartTool.hpp:16
Definition: CurvePalette.hpp:33
Definition: GraphicsSceneToolPalette.hpp:10
Definition: ToolPalette.hpp:14
Utilities and base classes for 1D curves.
Definition: FocusDispatcher.hpp:12
Base classes and tools to implement processes and layers.
Definition: JSONVisitor.hpp:1324
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Definition: CurvePalette.hpp:71
Definition: DocumentContext.hpp:18