1 /*
2  * Copyright (C) 2005-2017 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com>
4  * Copyright (C) 2006-2014 David Robillard <d@drobilla.net>
5  * Copyright (C) 2009-2011 Carl Hetherington <carl@carlh.net>
6  * Copyright (C) 2014-2017 Robin Gareus <robin@gareus.org>
7  * Copyright (C) 2015 Nick Mainsbridge <mainsbridge@gmail.com>
8  * Copyright (C) 2017 Ben Loftis <ben@harrisonconsoles.com>
9  * Copyright (C) 2018 Len Ovens <len@ovenwerks.net>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License along
22  * with this program; if not, write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  */
25 
26 #ifndef __gtk_ardour_add_route_dialog_h__
27 #define __gtk_ardour_add_route_dialog_h__
28 
29 #include <string>
30 
31 #include <gtkmm/entry.h>
32 #include <gtkmm/dialog.h>
33 #include <gtkmm/frame.h>
34 #include <gtkmm/radiobutton.h>
35 #include <gtkmm/adjustment.h>
36 #include <gtkmm/spinbutton.h>
37 #include <gtkmm/button.h>
38 #include <gtkmm/combobox.h>
39 #include <gtkmm/comboboxtext.h>
40 #include <gtkmm/textview.h>
41 #include <gtkmm/treemodel.h>
42 #include <gtkmm/treeview.h>
43 #include <gtkmm/treestore.h>
44 #include <gtkmm/liststore.h>
45 #include <gtkmm/scrolledwindow.h>
46 
47 #include "ardour/plugin.h"
48 #include "ardour/types.h"
49 #include "ardour/template_utils.h"
50 
51 #include "ardour_dialog.h"
52 #include "instrument_selector.h"
53 #include "route_dialogs.h"
54 
55 class Editor;
56 class RouteGroupDialog;
57 
58 class AddRouteDialog : public ArdourDialog
59 {
60 public:
61 	AddRouteDialog ();
62 	~AddRouteDialog ();
63 
64 	enum ResponseId {
65 		Add,
66 		AddAndClose,
67 	};
68 
69 	enum TypeWanted {
70 		AudioTrack,
71 		MidiTrack,
72 		AudioBus,
73 		MidiBus,
74 		VCAMaster,
75 		FoldbackBus,
76 	};
77 	TypeWanted type_wanted();
78 
79 	ARDOUR::ChanCount channels ();
80 	uint32_t channel_count ();
81 	int count ();
82 
83 	std::string name_template () const;
84 	bool name_template_is_default () const;
85 	ARDOUR::PluginInfoPtr requested_instrument ();
86 
87 	ARDOUR::TrackMode mode();
88 	ARDOUR::RouteGroup* route_group ();
89 
90 	RouteDialogs::InsertAt insert_at();
91 	bool use_strict_io();
92 
93 	std::string get_template_path();
94 
reset_name_edited()95 	void reset_name_edited () { name_edited_by_user = false; }
96 
97 private:
98 	Gtk::Entry name_template_entry;
99 	Gtk::Adjustment routes_adjustment;
100 	Gtk::SpinButton routes_spinner;
101 	Gtk::ComboBoxText channel_combo;
102 	Gtk::Label configuration_label;
103 	Gtk::Label manual_label;
104 	Gtk::Label add_label;
105 	Gtk::Label name_label;
106 	Gtk::Label group_label;
107 	Gtk::Label insert_label;
108 	Gtk::Label strict_io_label;
109 	Gtk::Label mode_label;
110 	Gtk::Label instrument_label;
111 	Gtk::ComboBoxText mode_combo;
112 	Gtk::ComboBoxText route_group_combo;
113 	InstrumentSelector instrument_combo;
114 	Gtk::ComboBoxText insert_at_combo;
115 	Gtk::ComboBoxText strict_io_combo;
116 
117 	void track_type_chosen ();
118 	void refill_channel_setups ();
119 	void refill_route_groups ();
120 	void refill_track_modes ();
121 	void add_route_group (ARDOUR::RouteGroup *);
122 	void group_changed ();
123 	void channel_combo_changed ();
124 	bool channel_separator (const Glib::RefPtr<Gtk::TreeModel> &m, const Gtk::TreeModel::iterator &i);
125 	bool route_separator (const Glib::RefPtr<Gtk::TreeModel> &m, const Gtk::TreeModel::iterator &i);
126 	void maybe_update_name_template_entry ();
127 	void instrument_changed ();
128 
129 	struct TrackTemplateColumns : public Gtk::TreeModel::ColumnRecord {
TrackTemplateColumnsTrackTemplateColumns130 		TrackTemplateColumns () {
131 			add (name);
132 			add (path);
133 			add (description);
134 			add (modified_with);
135 		}
136 
137 		Gtk::TreeModelColumn<std::string> name;
138 		Gtk::TreeModelColumn<std::string> path;
139 		Gtk::TreeModelColumn<std::string> description;
140 		Gtk::TreeModelColumn<std::string> modified_with;
141 	};
142 
143 	TrackTemplateColumns track_template_columns;
144 
145 	Glib::RefPtr<Gtk::TreeStore>  trk_template_model;
146 	Gtk::TreeView                 trk_template_chooser;
147 
148 	void trk_template_row_selected ();
149 
150 	Gtk::TextView trk_template_desc;
151 	Gtk::Frame    trk_template_outer_frame;
152 	Gtk::Frame    trk_template_desc_frame;
153 
154 	void reset_template_option_visibility ();
155 	void new_group_dialog_finished (int, RouteGroupDialog*);
156 	void on_show ();
157 	void on_response (int);
158 
159 	struct ChannelSetup {
160 		std::string name;
161 		uint32_t    channels;
162 	};
163 
164 	typedef std::vector<ChannelSetup> ChannelSetups;
165 	ChannelSetups channel_setups;
166 
167 	int last_route_count;
168 	bool route_count_set_by_template;
169 
170 	static std::vector<std::pair<std::string, std::string> > builtin_types;
171 	static std::vector<std::string> channel_combo_strings;
172 	static std::vector<std::string> bus_mode_strings;
173 
174 	bool name_edited_by_user;
175 	void name_template_entry_insertion (Glib::ustring const &,int*);
176 	void name_template_entry_deletion (int, int);
177 };
178 
179 #endif /* __gtk_ardour_add_route_dialog_h__ */
180