Ardour  9.0-pre0-384-ga76afae0e9
surfaces/push2/canvas.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016-2017 Paul Davis <paul@linuxaudiosystems.com>
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 of the License, or
7  * (at your option) 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 along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef __ardour_push2_canvas_h__
20 #define __ardour_push2_canvas_h__
21 
22 #include <cairomm/refptr.h>
23 #include <glibmm/threads.h>
24 
25 #include "canvas/canvas.h"
26 
27 namespace Cairo {
28  class ImageSurface;
29  class Context;
30  class Region;
31 }
32 
33 namespace Pango {
34  class Context;
35 }
36 
37 namespace ArdourSurface {
38 
39 class Push2;
40 
41 /* A canvas which renders to the Push2 display */
42 
44 {
45  public:
46  Push2Canvas (Push2& p2, int cols, int rows);
48 
49  void request_redraw ();
51  void queue_resize ();
52  bool vblank ();
53 
54  int rows() const { return _rows; }
55  int cols() const { return _cols; }
56 
57  static double inter_button_spacing() { return 120.0; }
58 
59  ArdourCanvas::Coord width() const { return cols(); }
60  ArdourCanvas::Coord height() const { return rows(); }
63 
64  /* API that does nothing since we have no input events */
65  void ungrab () {}
69  void re_enter() {}
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; }
73 
74  Glib::RefPtr<Pango::Context> get_pango_context ();
75 
76  private:
78  int _cols;
79  int _rows;
80 
81  static const int _pixels_per_row;
82 
83  int pixel_area () const { return _rows * _pixels_per_row; }
84 
85  uint8_t _sample_header[16];
87 
88  Cairo::RefPtr<Cairo::ImageSurface> _sample_buffer;
89  Cairo::RefPtr<Cairo::Context> _context;
90  Cairo::RefPtr<Cairo::Region> _expose_region;
91  Glib::RefPtr<Pango::Context> _pango_context;
92 
93  bool expose ();
95 };
96 
97 } /* namespace ArdourSurface */
98 
99 #endif /* __ardour_push2_canvas_h__ */
Declaration of the main canvas classes.
void request_size(ArdourCanvas::Duple)
bool get_mouse_position(ArdourCanvas::Duple &) const
void request_redraw(ArdourCanvas::Rect const &)
Cairo::RefPtr< Cairo::Region > _expose_region
Push2Canvas(Push2 &p2, int cols, int rows)
Glib::RefPtr< Pango::Context > _pango_context
ArdourCanvas::Rect visible_area() const
Glib::RefPtr< Pango::Context > get_pango_context()
ArdourCanvas::Coord width() const
void grab(ArdourCanvas::Item *)
ArdourCanvas::Coord height() const
void pick_current_item(ArdourCanvas::Duple const &, int)
Cairo::RefPtr< Cairo::Context > _context
Cairo::RefPtr< Cairo::ImageSurface > _sample_buffer
void focus(ArdourCanvas::Item *)
void unfocus(ArdourCanvas::Item *)
DebugBits Push2