Reenable the correct sort column and type when redisplaying regions
[ardour.git] / gtk2_ardour / add_route_dialog.h
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                 MixedTrack,
73                 AudioBus,
74                 MidiBus,
75                 VCAMaster,
76                 FoldbackBus,
77         };
78         TypeWanted type_wanted();
79
80         ARDOUR::ChanCount channels ();
81         uint32_t channel_count ();
82         int count ();
83
84         std::string name_template () const;
85         bool name_template_is_default () const;
86         ARDOUR::PluginInfoPtr requested_instrument ();
87
88         ARDOUR::TrackMode mode();
89         ARDOUR::RouteGroup* route_group ();
90
91         RouteDialogs::InsertAt insert_at();
92         bool use_strict_io();
93
94         std::string get_template_path();
95
96         void reset_name_edited () { name_edited_by_user = false; }
97
98 private:
99         Gtk::Entry name_template_entry;
100         Gtk::Adjustment routes_adjustment;
101         Gtk::SpinButton routes_spinner;
102         Gtk::ComboBoxText channel_combo;
103         Gtk::Label configuration_label;
104         Gtk::Label manual_label;
105         Gtk::Label add_label;
106         Gtk::Label name_label;
107         Gtk::Label group_label;
108         Gtk::Label insert_label;
109         Gtk::Label strict_io_label;
110         Gtk::Label mode_label;
111         Gtk::Label instrument_label;
112         Gtk::ComboBoxText mode_combo;
113         Gtk::ComboBoxText route_group_combo;
114         InstrumentSelector instrument_combo;
115         Gtk::ComboBoxText insert_at_combo;
116         Gtk::ComboBoxText strict_io_combo;
117
118         void track_type_chosen ();
119         void refill_channel_setups ();
120         void refill_route_groups ();
121         void refill_track_modes ();
122         void add_route_group (ARDOUR::RouteGroup *);
123         void group_changed ();
124         void channel_combo_changed ();
125         bool channel_separator (const Glib::RefPtr<Gtk::TreeModel> &m, const Gtk::TreeModel::iterator &i);
126         bool route_separator (const Glib::RefPtr<Gtk::TreeModel> &m, const Gtk::TreeModel::iterator &i);
127         void maybe_update_name_template_entry ();
128
129         struct TrackTemplateColumns : public Gtk::TreeModel::ColumnRecord {
130                 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         static std::vector<std::pair<std::string, std::string> > builtin_types;
168         static std::vector<std::string> channel_combo_strings;
169         static std::vector<std::string> bus_mode_strings;
170
171         bool name_edited_by_user;
172         void name_template_entry_insertion (Glib::ustring const &,int*);
173         void name_template_entry_deletion (int, int);
174 };
175
176 #endif /* __gtk_ardour_add_route_dialog_h__ */