Ardour  9.0-pre0-582-g084a23a80d
midi_channel_selector.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2011 David Robillard <d@drobilla.net>
3  * Copyright (C) 2008-2012 Hans Baier <hansfbaier@googlemail.com>
4  * Copyright (C) 2010-2013 Paul Davis <paul@linuxaudiosystems.com>
5  * Copyright (C) 2011 Carl Hetherington <carl@carlh.net>
6  * Copyright (C) 2017 Robin Gareus <robin@gareus.org>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22 
23 #pragma once
24 
25 #include <set>
26 #include "sigc++/trackable.h"
27 
28 #include "gtkmm/table.h"
29 #include "gtkmm/box.h"
30 #include "gtkmm/button.h"
31 #include "gtkmm/radiobutton.h"
32 #include "gtkmm/label.h"
33 
35 
36 #include "ardour/types.h"
37 
38 #include "ardour_window.h"
39 
40 namespace ARDOUR {
41  class MidiTrack;
42 }
43 
45 {
46 public:
47  MidiChannelSelector(int n_rows = 4, int n_columns = 4, int start_row = 0, int start_column = 0);
48  virtual ~MidiChannelSelector() = 0;
49 
50  sigc::signal<void> clicked;
51 
52  void set_channel_colors(const uint32_t new_channel_colors[16]);
54 
55 protected:
56  virtual void button_toggled(Gtk::ToggleButton* button, uint8_t button_nr) = 0;
60 
62 };
63 
65 {
66 public:
67  SingleMidiChannelSelector(uint8_t active_channel = 0);
68 
69  uint8_t get_active_channel() const { return _active_channel; }
70 
71  sigc::signal<void, uint8_t> channel_selected;
72 
73 protected:
74  virtual void button_toggled(Gtk::ToggleButton* button, uint8_t button_nr);
75 
77  uint8_t _active_channel;
78 };
79 
81 {
82 public:
84  uint16_t initial_selection = 0xFFFF);
85 
87 
92  sigc::signal<void, ARDOUR::ChannelMode, uint16_t> mode_changed;
93 
94  void set_channel_mode(ARDOUR::ChannelMode mode, uint16_t mask);
96 
102  uint16_t get_selected_channels() const;
103  void set_selected_channels(uint16_t selected_channels);
104 
105 protected:
108 
109  virtual void button_toggled(Gtk::ToggleButton* button, uint8_t button_nr);
111 
112  void select_all(bool on);
113  void invert_selection(void);
114 
119 };
120 
122 {
123 public:
124  MidiChannelSelectorWindow (std::shared_ptr<ARDOUR::MidiTrack>);
126 
127  void set_channel_colors (const uint32_t new_channel_colors[16]);
129 
130 private:
131  std::shared_ptr<ARDOUR::MidiTrack> track;
132  std::vector<Gtk::ToggleButton*> playback_buttons;
133  std::vector<Gtk::ToggleButton*> capture_buttons;
134 
135  std::vector<Gtk::Widget*> playback_mask_controls;
136  std::vector<Gtk::Widget*> capture_mask_controls;
137 
148 
151 
152  void build();
155 
159 
163 
168 
169  void playback_channel_clicked (uint16_t);
170  void capture_channel_clicked (uint16_t);
171 
175 
179 
182 };
183 
std::vector< Gtk::Widget * > capture_mask_controls
Gtk::RadioButtonGroup playback_button_group
Gtk::RadioButtonGroup capture_button_group
void capture_mode_toggled(ARDOUR::ChannelMode)
Gtk::RadioButton capture_filter_button
void set_channel_colors(const uint32_t new_channel_colors[16])
ARDOUR::ChannelMode last_drawn_capture_mode
MidiChannelSelectorWindow(std::shared_ptr< ARDOUR::MidiTrack >)
std::shared_ptr< ARDOUR::MidiTrack > track
std::vector< Gtk::ToggleButton * > capture_buttons
void capture_channel_clicked(uint16_t)
void set_capture_selected_channels(uint16_t)
ARDOUR::ChannelMode last_drawn_playback_mode
std::vector< Gtk::Widget * > playback_mask_controls
std::vector< Gtk::ToggleButton * > playback_buttons
void set_playback_selected_channels(uint16_t)
void playback_mode_toggled(ARDOUR::ChannelMode)
void playback_channel_clicked(uint16_t)
Gtk::RadioButton playback_force_button
Gtk::RadioButton playback_filter_button
bool was_clicked(GdkEventButton *)
void set_default_channel_color()
virtual ~MidiChannelSelector()=0
MidiChannelSelector(int n_rows=4, int n_columns=4, int start_row=0, int start_column=0)
Gtk::Label _button_labels[4][4]
void set_channel_colors(const uint32_t new_channel_colors[16])
ArdourWidgets::StatefulToggleButton _buttons[4][4]
virtual void button_toggled(Gtk::ToggleButton *button, uint8_t button_nr)=0
sigc::signal< void > clicked
void set_channel_mode(ARDOUR::ChannelMode mode, uint16_t mask)
uint16_t get_selected_channels() const
sigc::signal< void, ARDOUR::ChannelMode, uint16_t > mode_changed
ARDOUR::ChannelMode get_channel_mode() const
MidiMultipleChannelSelector(ARDOUR::ChannelMode mode=ARDOUR::FilterChannels, uint16_t initial_selection=0xFFFF)
void set_selected_channels(uint16_t selected_channels)
virtual ~MidiMultipleChannelSelector()
virtual void button_toggled(Gtk::ToggleButton *button, uint8_t button_nr)
SingleMidiChannelSelector(uint8_t active_channel=0)
Gtk::ToggleButton * _last_active_button
virtual void button_toggled(Gtk::ToggleButton *button, uint8_t button_nr)
sigc::signal< void, uint8_t > channel_selected
@ FilterChannels
Ignore events on certain channels.