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 &);
52 Cairo::RefPtr<Cairo::Context> image_context() { return context; }
54 int rows() const { return _rows; }
55 int cols() const { return _cols; }
57 static double inter_button_spacing() { return 120.0; }
59 ArdourCanvas::Coord width() const { return cols(); }
60 ArdourCanvas::Coord height() const { return rows(); }
61 void request_size (ArdourCanvas::Duple);
62 ArdourCanvas::Rect visible_area () const;
64 /* API that does nothing since we have no input events */
66 void grab (ArdourCanvas::Item*) {}
67 void focus (ArdourCanvas::Item*) {}
68 void unfocus (ArdourCanvas::Item*) {}
70 void pick_current_item (int) {}
71 void pick_current_item (ArdourCanvas::Duple const &, int) {}
72 bool get_mouse_position (ArdourCanvas::Duple&) const { return false; }
79 static const int pixels_per_row;
80 int pixel_area () const { return _rows * pixels_per_row; }
82 uint8_t frame_header[16];
83 uint16_t* device_frame_buffer;
85 Cairo::RefPtr<Cairo::ImageSurface> frame_buffer;
86 Cairo::RefPtr<Cairo::Context> context;
87 Cairo::RefPtr<Cairo::Region> expose_region;
90 int blit_to_device_frame_buffer ();
93 } /* namespace ArdourSurface */
95 #endif /* __ardour_push2_canvas_h__ */