Ardour  8.7-14-g57a6773833
surfaces/push2/menu.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 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_menu_h__
20 #define __ardour_push2_menu_h__
21 
22 #include <vector>
23 
24 namespace Cairo {
25  class Context;
26 }
27 
28 #include <pangomm/fontdescription.h>
29 
30 #include "pbd/signals.h"
31 
32 #include "canvas/container.h"
33 
34 namespace ArdourCanvas {
35  class Text;
36  class Rectangle;
37  class Rect;
38 }
39 
40 namespace ArdourSurface {
41 
43 {
44  public:
45  Push2Menu (ArdourCanvas::Item* parent, std::vector<std::string>);
46 
47  void render (ArdourCanvas::Rect const& area, Cairo::RefPtr<Cairo::Context> context) const;
48 
49  void set_wrap (bool);
50  void set_active (uint32_t index);
51 
52  uint32_t active () const { return _active; }
53  uint32_t items() const { return _displays.size(); }
54 
55  uint32_t rows() const { return _nrows; }
56  uint32_t cols() const { return _ncols; }
57 
58  void set_layout (int cols, int rows);
59  void set_font_description (Pango::FontDescription);
62 
63  bool can_scroll_left() const { return _first >= _nrows; }
64  bool can_scroll_right() const { return _last < _displays.size() - 1; }
65 
67  void scroll (Direction, bool page = false);
68 
69  PBD::Signal0<void> ActiveChanged;
70  PBD::Signal0<void> Rearranged;
71 
72  private:
73  std::vector<ArdourCanvas::Text*> _displays;
75 
76  void rearrange (uint32_t initial_display);
77 
78  double _baseline;
81  uint32_t _ncols;
82  uint32_t _nrows;
83  bool _wrap;
84  uint32_t _first;
85  uint32_t _last;
86  uint32_t _active;
87 
91  Pango::FontDescription _font_description;
92 
93  inline int active_row () const { return _active % _nrows; }
94  inline int active_col () const { return (_active / _nrows); }
95  inline int active_top () const { return active_col () * _nrows; }
96 };
97 
98 } // namespace
99 
100 #endif /* __ardour_push2_menu_h__ */
void set_layout(int cols, int rows)
Pango::FontDescription _font_description
void render(ArdourCanvas::Rect const &area, Cairo::RefPtr< Cairo::Context > context) const
void set_text_color(Gtkmm2ext::Color)
PBD::Signal0< void > Rearranged
std::vector< ArdourCanvas::Text * > _displays
PBD::Signal0< void > ActiveChanged
void set_active(uint32_t index)
Gtkmm2ext::Color _contrast_color
Push2Menu(ArdourCanvas::Item *parent, std::vector< std::string >)
ArdourCanvas::Rectangle * _active_bg
void scroll(Direction, bool page=false)
void set_active_color(Gtkmm2ext::Color)
void set_font_description(Pango::FontDescription)
Gtkmm2ext::Color _active_color
void rearrange(uint32_t initial_display)
uint32_t Color
Definition: colors.h:33