move away from "sync source" concepts
[ardour.git] / gtk2_ardour / transport_masters_dialog.h
1 /*
2     Copyright (C) 2018 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
20 #ifndef __ardour_gtk_transport_masters_dialog_h__
21 #define __ardour_gtk_transport_masters_dialog_h__
22
23 #include <vector>
24 #include <string>
25
26 #include <gtkmm/button.h>
27 #include <gtkmm/eventbox.h>
28 #include <gtkmm/radiobutton.h>
29 #include <gtkmm/label.h>
30 #include <gtkmm/table.h>
31 #include <gtkmm/treestore.h>
32
33 #include "ardour_window.h"
34
35 namespace Gtk {
36         class Menu;
37 }
38
39 namespace ARDOUR {
40         class TransportMaster;
41 }
42
43 class FloatingTextEntry;
44
45 class TransportMastersWidget : public Gtk::VBox, public ARDOUR::SessionHandlePtr
46 {
47   public:
48         TransportMastersWidget ();
49         ~TransportMastersWidget ();
50
51         void update (ARDOUR::samplepos_t);
52         void set_transport_master (boost::shared_ptr<ARDOUR::TransportMaster>);
53
54   protected:
55         void on_map ();
56         void on_unmap ();
57
58   private:
59
60         struct Row : sigc::trackable, PBD::ScopedConnectionList {
61                 TransportMastersWidget& parent;
62                 Gtk::EventBox label_box;
63                 Gtk::Label label;
64                 Gtk::Label type;
65                 Gtk::Label format;
66                 Gtk::Label current;
67                 Gtk::Label last;
68                 Gtk::Label timestamp;
69                 Gtk::Label delta;
70                 Gtk::CheckButton collect_button;
71                 Gtk::RadioButton use_button;
72                 Gtk::ComboBoxText port_combo;
73                 Gtk::CheckButton sclock_synced_button;
74                 Gtk::CheckButton fr2997_button;
75                 Gtk::Button request_options;
76                 Gtk::Menu* request_option_menu;
77                 Gtk::Button remove_button;
78                 FloatingTextEntry* name_editor;
79                 samplepos_t save_when;
80
81                 void build_request_options();
82
83                 boost::shared_ptr<ARDOUR::TransportMaster> tm;
84
85                 void update (ARDOUR::Session*, ARDOUR::samplepos_t);
86
87                 Row (TransportMastersWidget& parent);
88
89                 struct PortColumns : public Gtk::TreeModel::ColumnRecord {
90                         PortColumns() {
91                                 add (short_name);
92                                 add (full_name);
93                         }
94                         Gtk::TreeModelColumn<std::string> short_name;
95                         Gtk::TreeModelColumn<std::string> full_name;
96                 };
97
98                 PortColumns port_columns;
99
100                 void populate_port_combo ();
101                 Glib::RefPtr<Gtk::ListStore> build_port_list (std::vector<std::string> const & ports);
102
103                 void use_button_toggled ();
104                 void collect_button_toggled ();
105                 void sync_button_toggled ();
106                 void fr2997_button_toggled ();
107                 void port_choice_changed ();
108                 void connection_handler ();
109                 bool request_option_press (GdkEventButton*);
110                 void prop_change (PBD::PropertyChange);
111                 void remove_clicked ();
112
113                 bool name_press (GdkEventButton*);
114                 void name_edited (std::string, int);
115
116                 PBD::ScopedConnection property_change_connection;
117                 bool ignore_active_change;
118         };
119
120         std::vector<Row*> rows;
121
122         Gtk::Table table;
123         Gtk::Label col_title[14];
124         Gtk::Button add_button;
125
126         sigc::connection update_connection;
127         PBD::ScopedConnection current_connection;
128
129         void rebuild ();
130         void current_changed (boost::shared_ptr<ARDOUR::TransportMaster> old_master, boost::shared_ptr<ARDOUR::TransportMaster> new_master);
131         void add_master ();
132 };
133
134 class TransportMastersWindow : public ArdourWindow
135 {
136   public:
137         TransportMastersWindow ();
138
139         void set_session (ARDOUR::Session*);
140
141   protected:
142         void on_realize ();
143
144   private:
145         TransportMastersWidget w;
146 };
147
148
149 #endif /* __ardour_gtk_transport_masters_dialog_h__ */