2 Copyright (C) 2016 Paul Davis
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.
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.
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.
19 #ifndef __ardour_push2_menu_h__
20 #define __ardour_push2_menu_h__
29 #include <pangomm/fontdescription.h>
31 #include "pbd/signals.h"
33 #include "canvas/container.h"
35 namespace ArdourCanvas {
40 namespace ArdourSurface {
42 class Push2Menu : public ArdourCanvas::Container
45 Push2Menu (ArdourCanvas::Item* parent, std::vector<std::string>);
47 void render (ArdourCanvas::Rect const& area, Cairo::RefPtr<Cairo::Context> context) const;
50 void set_active (uint32_t index);
52 uint32_t active () const { return _active; }
53 uint32_t items() const { return displays.size(); }
55 uint32_t rows() const { return nrows; }
56 uint32_t cols() const { return ncols; }
58 void set_layout (int cols, int rows);
59 void set_font_description (Pango::FontDescription);
60 void set_text_color (ArdourCanvas::Color);
61 void set_active_color (ArdourCanvas::Color);
63 bool can_scroll_left() const { return first >= nrows; }
64 bool can_scroll_right() const { return last < displays.size() - 1; }
66 enum Direction { DirectionUp, DirectionDown, DirectionLeft, DirectionRight };
67 void scroll (Direction, bool page = false);
69 PBD::Signal0<void> ActiveChanged;
70 PBD::Signal0<void> Rearranged;
73 std::vector<ArdourCanvas::Text*> displays;
74 ArdourCanvas::Rectangle* active_bg;
76 void rearrange (uint32_t initial_display);
88 ArdourCanvas::Color text_color;
89 ArdourCanvas::Color active_color;
90 ArdourCanvas::Color contrast_color;
91 Pango::FontDescription font_description;
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; }
100 #endif /* __ardour_push2_menu_h__ */