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