2 Copyright (C) 2016 Paul Davis
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 of the License, or
7 (at your option) any later version.
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.
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
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __ardour_push2_canvas_h__
21 #define __ardour_push2_canvas_h__
23 #include <cairomm/refptr.h>
24 #include <glibmm/threads.h>
26 #include "canvas/canvas.h"
34 namespace ArdourSurface {
38 /* A canvas which renders to the Push2 display */
40 class Push2Canvas : public ArdourCanvas::Canvas
43 Push2Canvas (Push2& p2, int cols, int rows);
46 void request_redraw ();
47 void request_redraw (ArdourCanvas::Rect const &);
50 Cairo::RefPtr<Cairo::Context> image_context() { return context; }
52 int rows() const { return _rows; }
53 int cols() const { return _cols; }
55 static double inter_button_spacing() { return 120.0; }
57 ArdourCanvas::Coord width() const { return cols(); }
58 ArdourCanvas::Coord height() const { return rows(); }
59 void request_size (ArdourCanvas::Duple);
60 ArdourCanvas::Rect visible_area () const;
62 /* API that does nothing since we have no input events */
64 void grab (ArdourCanvas::Item*) {}
65 void focus (ArdourCanvas::Item*) {}
66 void unfocus (ArdourCanvas::Item*) {}
68 void pick_current_item (int) {}
69 void pick_current_item (ArdourCanvas::Duple const &, int) {}
70 bool get_mouse_position (ArdourCanvas::Duple&) const { return false; }
72 Glib::RefPtr<Pango::Context> get_pango_context ();
79 static const int pixels_per_row;
80 int pixel_area () const { return _rows * pixels_per_row; }
82 uint8_t sample_header[16];
83 uint16_t* device_sample_buffer;
85 Cairo::RefPtr<Cairo::ImageSurface> sample_buffer;
86 Cairo::RefPtr<Cairo::Context> context;
87 Cairo::RefPtr<Cairo::Region> expose_region;
88 Glib::RefPtr<Pango::Context> pango_context;
91 int blit_to_device_sample_buffer ();
94 } /* namespace ArdourSurface */
96 #endif /* __ardour_push2_canvas_h__ */