1 // Aseprite
2 // Copyright (C) 2001-2016  David Capello
3 //
4 // This program is distributed under the terms of
5 // the End-User License Agreement for Aseprite.
6 
7 #ifndef APP_COMMANDS_FILTERS_COLOR_CURVE_EDITOR_H_INCLUDED
8 #define APP_COMMANDS_FILTERS_COLOR_CURVE_EDITOR_H_INCLUDED
9 #pragma once
10 
11 #include "gfx/point.h"
12 #include "obs/signal.h"
13 #include "ui/widget.h"
14 
15 namespace filters {
16   class ColorCurve;
17 }
18 
19 namespace app {
20   using namespace filters;
21 
22   class ColorCurveEditor : public ui::Widget {
23   public:
24     ColorCurveEditor(ColorCurve* curve, const gfx::Rect& viewBounds);
25 
getCurve()26     ColorCurve* getCurve() const { return m_curve; }
27 
28     obs::signal<void()> CurveEditorChange;
29 
30   protected:
31     bool onProcessMessage(ui::Message* msg) override;
32     void onSizeHint(ui::SizeHintEvent& ev) override;
33     void onPaint(ui::PaintEvent& ev) override;
34 
35   private:
36     gfx::Point* getClosestPoint(const gfx::Point& viewPt);
37     bool editNodeManually(gfx::Point& viewPt);
38     gfx::Point viewToClient(const gfx::Point& viewPt);
39     gfx::Point screenToView(const gfx::Point& screenPt);
40     gfx::Point clientToView(const gfx::Point& clientPt);
41     void addPoint(const gfx::Point& viewPoint);
42     void removePoint(gfx::Point* viewPoint);
43 
44     ColorCurve* m_curve;
45     int m_status;
46     gfx::Rect m_viewBounds;
47     gfx::Point* m_hotPoint;
48     gfx::Point* m_editPoint;
49   };
50 
51 } // namespace app
52 
53 #endif
54