Ardour  9.2-79-gba93f2fe52
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 
24 #include "canvas/canvas.h"
25 
26 namespace Cairo {
27  class ImageSurface;
28  class Context;
29  class Region;
30 }
31 
32 namespace Pango {
33  class Context;
34 }
35 
36 namespace ArdourSurface {
37 
38 class Push2;
39 
40 /* A canvas which renders to the Push2 display */
41 
43 {
44  public:
45  Push2Canvas (Push2& p2, int cols, int rows);
47 
48  void request_redraw ();
50  void queue_resize ();
51  bool vblank ();
52 
53  int rows() const { return _rows; }
54  int cols() const { return _cols; }
55 
56  static double inter_button_spacing() { return 120.0; }
57 
58  ArdourCanvas::Coord width() const { return cols(); }
59  ArdourCanvas::Coord height() const { return rows(); }
62 
63  /* API that does nothing since we have no input events */
64  void ungrab () {}
68  void re_enter() {}
69  void pick_current_item (int) {}
70  void pick_current_item (ArdourCanvas::Duple const &, int) {}
71  bool get_mouse_position (ArdourCanvas::Duple&) const { return false; }
72 
73  Glib::RefPtr<Pango::Context> get_pango_context ();
74 
75  private:
77  int _cols;
78  int _rows;
79 
80  static const int _pixels_per_row;
81 
82  int pixel_area () const { return _rows * _pixels_per_row; }
83 
84  uint8_t _sample_header[16];
86 
87  Cairo::RefPtr<Cairo::ImageSurface> _sample_buffer;
88  Cairo::RefPtr<Cairo::Context> _context;
89  Cairo::RefPtr<Cairo::Region> _expose_region;
90  Glib::RefPtr<Pango::Context> _pango_context;
91 
92  bool expose ();
94 };
95 
96 } /* namespace ArdourSurface */
97 
98 #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