Only show user-presets in favorite sidebar
[ardour.git] / libs / surfaces / push2 / menu.h
1 /*
2     Copyright (C) 2016 Paul Davis
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
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, 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         class Region;
27 }
28
29 #include <pangomm/fontdescription.h>
30
31 #include "pbd/signals.h"
32
33 #include "canvas/container.h"
34
35 namespace ArdourCanvas {
36         class Text;
37         class Rectangle;
38         class Rect;
39 }
40
41 namespace ArdourSurface {
42
43 class Push2Menu : public ArdourCanvas::Container
44 {
45    public:
46         Push2Menu (ArdourCanvas::Item* parent, std::vector<std::string>);
47
48         void render (ArdourCanvas::Rect const& area, Cairo::RefPtr<Cairo::Context> context) const;
49
50         void set_wrap (bool);
51         void set_active (uint32_t index);
52
53         uint32_t active () const { return _active; }
54         uint32_t items() const { return displays.size(); }
55
56         uint32_t rows() const { return nrows; }
57         uint32_t cols() const { return ncols; }
58
59         void set_layout (int cols, int rows);
60         void set_font_description (Pango::FontDescription);
61         void set_text_color (Gtkmm2ext::Color);
62         void set_active_color (Gtkmm2ext::Color);
63
64         bool can_scroll_left() const { return first >= nrows; }
65         bool can_scroll_right() const { return last < displays.size() - 1; }
66
67         enum Direction { DirectionUp, DirectionDown, DirectionLeft, DirectionRight };
68         void scroll (Direction, bool page = false);
69
70         PBD::Signal0<void> ActiveChanged;
71         PBD::Signal0<void> Rearranged;
72
73    private:
74         std::vector<ArdourCanvas::Text*> displays;
75         ArdourCanvas::Rectangle* active_bg;
76
77         void rearrange (uint32_t initial_display);
78
79         double   baseline;
80         int      row_start;
81         int      col_start;
82         uint32_t ncols;
83         uint32_t nrows;
84         bool     wrap;
85         uint32_t first;
86         uint32_t last;
87         uint32_t _active;
88
89         Gtkmm2ext::Color text_color;
90         Gtkmm2ext::Color active_color;
91         Gtkmm2ext::Color contrast_color;
92         Pango::FontDescription font_description;
93
94         inline int active_row () const { return _active % nrows; }
95         inline int active_col () const { return (_active / nrows); }
96         inline int active_top () const { return active_col() * nrows; }
97 };
98
99 } // namespace
100
101 #endif /* __ardour_push2_menu_h__ */