summaryrefslogtreecommitdiff
path: root/libs/surfaces/maschine2/ui_knob.h
blob: 4bbfb8399bd6d218f5fffa98851bfd7a43afbac6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
 * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#ifndef _ardour_maschine2_knob_h_
#define _ardour_maschine2_knob_h_

#include <boost/shared_ptr.hpp>
#include <sigc++/trackable.h>

#include <cairomm/refptr.h>

#include "pbd/signals.h"

#include "canvas/container.h"

namespace ArdourCanvas {
	class Text;
}

namespace ARDOUR {
	class AutomationControl;
}

namespace Cairo {
	class Context;
	class Region;
}

namespace ArdourSurface {

class Maschine2;
class M2EncoderInterface;

class Maschine2Knob : public sigc::trackable, public ArdourCanvas::Container
{
	public:
		Maschine2Knob (PBD::EventLoop*, ArdourCanvas::Item*);
		virtual ~Maschine2Knob ();

		void set_controllable (boost::shared_ptr<ARDOUR::AutomationControl>);
		void set_control (M2EncoderInterface*);
		boost::shared_ptr<ARDOUR::AutomationControl> controllable() const { return _controllable; }

		void render (ArdourCanvas::Rect const &, Cairo::RefPtr<Cairo::Context>) const;
		void compute_bounding_box() const;

	protected:
		void controllable_changed ();
		void encoder_changed (int);

		PBD::ScopedConnection watch_connection;
		PBD::ScopedConnection encoder_connection;

		boost::shared_ptr<ARDOUR::AutomationControl> _controllable;
		M2EncoderInterface* _ctrl;

	private:
		PBD::EventLoop* _eventloop;

		float  _radius;
		float  _val; // current value [0..1]
		float  _normal; // default value, arc

		ArdourCanvas::Text* text;
};

} // namespace

#endif