* adjusted formatting a bit to style guide
[ardour.git] / gtk2_ardour / midi_channel_selector.h
1 #ifndef __ardour_ui_midi_channel_selector_h__
2 #define __ardour_ui_midi_channel_selector_h__
3
4 #include "boost/shared_ptr.hpp"
5 #include "gtkmm/table.h"
6 #include "sigc++/trackable.h"
7 #include "gtkmm/button.h"
8 #include "gtkmm/togglebutton.h"
9 #include "gtkmm/label.h"
10 #include <set>
11
12 class MidiChannelSelector : public Gtk::Table
13 {
14 public:
15         MidiChannelSelector(int no_rows = 4, int no_columns = 4, int start_row = 0, int start_column = 0);
16         virtual ~MidiChannelSelector() = 0;
17         
18 protected:
19         virtual void button_toggled(Gtk::ToggleButton *button, uint8_t button_nr) = 0;
20         Gtk::Label        _button_labels[4][4];
21         Gtk::ToggleButton _buttons[4][4];
22         int               _recursion_counter;
23 };
24
25 class SingleMidiChannelSelector : public MidiChannelSelector
26 {
27 public:
28         SingleMidiChannelSelector(uint8_t active_channel = 0);
29         
30         const uint8_t get_active_channel() const { return _active_channel; }
31         
32         sigc::signal<void, uint8_t> channel_selected;
33         
34 protected:
35         virtual void button_toggled(Gtk::ToggleButton *button, uint8_t button_nr);
36
37         Gtk::ToggleButton* _last_active_button;
38         uint8_t            _active_channel;
39 };
40
41 class MidiMultipleChannelSelector : public MidiChannelSelector
42 {
43 public:
44         MidiMultipleChannelSelector(uint16_t initial_selection = 0xFFFF, int8_t force_channel = -1);
45         virtual ~MidiMultipleChannelSelector();
46         
47         /**
48          * @return each bit in the returned word represents a midi channel, eg. 
49          *         bit 0 represents channel 0 and bit 15 represents channel 15
50          *          
51          */
52         const uint16_t get_selected_channels() const;
53         void set_selected_channels(uint16_t selected_channels);
54         
55         sigc::signal<void, uint16_t> selection_changed;
56         sigc::signal<void, int8_t>   force_channel_changed;
57         
58         const int8_t get_force_channel() const;
59         void set_force_channel(int8_t force_channel);
60 protected:
61         enum Mode {
62                 FILTERING_MULTIPLE_CHANNELS,
63                 FORCING_SINGLE_CHANNEL
64         }; 
65
66         Mode _mode;
67         
68         virtual void button_toggled(Gtk::ToggleButton *button, uint8_t button_nr);
69         void force_channels_button_toggled();
70         
71         void select_all(bool on);
72         void invert_selection(void);
73         
74         Gtk::Button            _select_all;
75         Gtk::Button            _select_none;
76         Gtk::Button            _invert_selection;
77         Gtk::ToggleButton      _force_channel;
78 };
79
80 #endif /*__ardour_ui_midi_channel_selector_h__*/