2016-07-10 08:37:45 -04:00
|
|
|
/*
|
2019-08-03 08:34:29 -04:00
|
|
|
* Copyright (C) 2016 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2016-07-10 08:37:45 -04:00
|
|
|
|
|
|
|
#ifndef __ardour_push2_menu_h__
|
|
|
|
#define __ardour_push2_menu_h__
|
|
|
|
|
2016-09-21 16:25:01 -04:00
|
|
|
#include <vector>
|
|
|
|
|
2016-09-16 09:39:28 -04:00
|
|
|
namespace Cairo {
|
|
|
|
class Context;
|
|
|
|
}
|
|
|
|
|
2016-09-21 16:25:01 -04:00
|
|
|
#include <pangomm/fontdescription.h>
|
2016-07-10 08:37:45 -04:00
|
|
|
|
|
|
|
#include "pbd/signals.h"
|
|
|
|
|
2016-09-16 09:39:28 -04:00
|
|
|
#include "canvas/container.h"
|
|
|
|
|
|
|
|
namespace ArdourCanvas {
|
|
|
|
class Text;
|
|
|
|
class Rectangle;
|
2016-09-28 17:24:14 -04:00
|
|
|
class Rect;
|
2016-09-16 09:39:28 -04:00
|
|
|
}
|
|
|
|
|
2016-07-10 08:37:45 -04:00
|
|
|
namespace ArdourSurface {
|
|
|
|
|
2016-09-16 09:39:28 -04:00
|
|
|
class Push2Menu : public ArdourCanvas::Container
|
|
|
|
{
|
2016-07-10 08:37:45 -04:00
|
|
|
public:
|
2016-09-21 16:25:01 -04:00
|
|
|
Push2Menu (ArdourCanvas::Item* parent, std::vector<std::string>);
|
2016-07-10 08:37:45 -04:00
|
|
|
|
2016-09-16 09:39:28 -04:00
|
|
|
void render (ArdourCanvas::Rect const& area, Cairo::RefPtr<Cairo::Context> context) const;
|
2016-07-10 08:37:45 -04:00
|
|
|
|
2016-09-21 16:25:01 -04:00
|
|
|
void set_wrap (bool);
|
|
|
|
void set_active (uint32_t index);
|
2016-07-10 08:37:45 -04:00
|
|
|
|
2016-09-21 16:25:01 -04:00
|
|
|
uint32_t active () const { return _active; }
|
2021-06-18 16:33:32 -04:00
|
|
|
uint32_t items() const { return _displays.size(); }
|
2016-07-10 08:37:45 -04:00
|
|
|
|
2021-06-18 16:33:32 -04:00
|
|
|
uint32_t rows() const { return _nrows; }
|
|
|
|
uint32_t cols() const { return _ncols; }
|
2016-09-21 16:25:01 -04:00
|
|
|
|
|
|
|
void set_layout (int cols, int rows);
|
|
|
|
void set_font_description (Pango::FontDescription);
|
2017-07-17 12:34:35 -04:00
|
|
|
void set_text_color (Gtkmm2ext::Color);
|
|
|
|
void set_active_color (Gtkmm2ext::Color);
|
2016-07-10 08:37:45 -04:00
|
|
|
|
2021-06-18 16:33:32 -04:00
|
|
|
bool can_scroll_left() const { return _first >= _nrows; }
|
|
|
|
bool can_scroll_right() const { return _last < _displays.size() - 1; }
|
2016-07-10 08:37:45 -04:00
|
|
|
|
2016-09-21 16:25:01 -04:00
|
|
|
enum Direction { DirectionUp, DirectionDown, DirectionLeft, DirectionRight };
|
|
|
|
void scroll (Direction, bool page = false);
|
2016-07-10 08:37:45 -04:00
|
|
|
|
2024-10-18 12:01:28 -04:00
|
|
|
PBD::Signal<void()> ActiveChanged;
|
|
|
|
PBD::Signal<void()> Rearranged;
|
2016-09-21 16:25:01 -04:00
|
|
|
|
|
|
|
private:
|
2021-06-18 16:33:32 -04:00
|
|
|
std::vector<ArdourCanvas::Text*> _displays;
|
|
|
|
ArdourCanvas::Rectangle* _active_bg;
|
2016-09-21 16:25:01 -04:00
|
|
|
|
|
|
|
void rearrange (uint32_t initial_display);
|
|
|
|
|
2021-06-18 16:33:32 -04:00
|
|
|
double _baseline;
|
|
|
|
int _row_start;
|
|
|
|
int _col_start;
|
|
|
|
uint32_t _ncols;
|
|
|
|
uint32_t _nrows;
|
|
|
|
bool _wrap;
|
|
|
|
uint32_t _first;
|
|
|
|
uint32_t _last;
|
2016-09-21 16:25:01 -04:00
|
|
|
uint32_t _active;
|
|
|
|
|
2021-06-18 16:33:32 -04:00
|
|
|
Gtkmm2ext::Color _text_color;
|
|
|
|
Gtkmm2ext::Color _active_color;
|
|
|
|
Gtkmm2ext::Color _contrast_color;
|
|
|
|
Pango::FontDescription _font_description;
|
2016-09-21 16:25:01 -04:00
|
|
|
|
2021-06-18 16:33:32 -04:00
|
|
|
inline int active_row () const { return _active % _nrows; }
|
|
|
|
inline int active_col () const { return (_active / _nrows); }
|
|
|
|
inline int active_top () const { return active_col () * _nrows; }
|
2016-07-10 08:37:45 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif /* __ardour_push2_menu_h__ */
|