Skeleton for NI Maschine2 Surface
[ardour.git] / libs / surfaces / maschine2 / canvas.h
1 /*
2  * Copyright (C) 2016 Paul Davis
3  * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2, or (at your option)
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19
20 #ifndef _ardour_maschine2_canvas_h_
21 #define _ardour_maschine2_canvas_h_
22
23 #include <cairomm/refptr.h>
24 #include <glibmm/threads.h>
25
26 #include "canvas/canvas.h"
27
28 namespace Cairo {
29         class ImageSurface;
30         class Context;
31         class Region;
32 }
33
34 namespace ArdourSurface {
35
36 class M2Device;
37 class Maschine2;
38
39 /* A canvas which renders to the Push2 display */
40
41 class Maschine2Canvas : public ArdourCanvas::Canvas
42 {
43   public:
44         Maschine2Canvas (Maschine2&, M2Device*);
45         ~Maschine2Canvas();
46
47         void request_redraw ();
48         void request_redraw (ArdourCanvas::Rect const &);
49         bool vblank ();
50
51         Cairo::RefPtr<Cairo::Context> image_context() { return context; }
52
53         ArdourCanvas::Coord width() const { return _width; }
54         ArdourCanvas::Coord height() const { return _height; }
55
56         void request_size (ArdourCanvas::Duple);
57         ArdourCanvas::Rect visible_area () const;
58
59         /* API that does nothing since we have no input events */
60         void ungrab () {}
61         void grab (ArdourCanvas::Item*) {}
62         void focus (ArdourCanvas::Item*) {}
63         void unfocus (ArdourCanvas::Item*) {}
64         void re_enter() {}
65         void pick_current_item (int) {}
66         void pick_current_item (ArdourCanvas::Duple const &, int) {}
67         bool get_mouse_position (ArdourCanvas::Duple&) const { return false; }
68
69         Glib::RefPtr<Pango::Context> get_pango_context ();
70
71   private:
72         int _width;
73         int _height;
74
75         Cairo::RefPtr<Cairo::Context> context;
76         Cairo::RefPtr<Cairo::Region> expose_region;
77         Glib::RefPtr<Pango::Context> pango_context;
78
79         Maschine2& m2;
80         PBD::ScopedConnection vblank_connections;
81
82         bool expose ();
83 };
84
85 } /* namespace ArdourSurface */
86
87 #endif