Maschine2 UI: basic widgets
[ardour.git] / libs / surfaces / maschine2 / ui_menu.h
1 /*
2  * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2, or (at your option)
7  * any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18
19 #ifndef _ardour_maschine2_menu_h_
20 #define _ardour_maschine2_menu_h_
21
22 #include <vector>
23 #include <cairomm/refptr.h>
24
25 #include "pbd/signals.h"
26 #include "canvas/container.h"
27
28 namespace ArdourCanvas {
29         class Text;
30 }
31
32 namespace ARDOUR {
33         class AutomationControl;
34 }
35
36 namespace Cairo {
37         class Context;
38 }
39
40 namespace ArdourSurface {
41
42 class Maschine2;
43 class M2EncoderInterface;
44
45 class Maschine2Menu : public ArdourCanvas::Container
46 {
47         public:
48                 Maschine2Menu (PBD::EventLoop*, ArdourCanvas::Item*, const std::vector<std::string>&, double width = 64);
49                 virtual ~Maschine2Menu ();
50
51                 void set_control (M2EncoderInterface*);
52                 void set_active (uint32_t index);
53                 void set_wrap (bool);
54
55                 uint32_t active () const { return _active; }
56                 uint32_t items() const { return _displays.size(); }
57
58                 PBD::Signal0<void> ActiveChanged;
59
60                 void render (ArdourCanvas::Rect const &, Cairo::RefPtr<Cairo::Context>) const;
61
62         private:
63                 void rearrange (uint32_t);
64                 void encoder_changed (int);
65
66                 M2EncoderInterface* _ctrl;
67                 PBD::EventLoop* _eventloop;
68                 PBD::ScopedConnection encoder_connection;
69
70                 std::vector<ArdourCanvas::Text*> _displays;
71                 ArdourCanvas::Rectangle* _active_bg;
72
73                 double   _baseline;
74                 double   _height;
75                 double   _width;
76                 uint32_t _active;
77                 bool     _wrap;
78
79                 uint32_t _first;
80                 uint32_t _last;
81                 double   _rotary;
82 };
83
84 } // namespace
85
86 #endif