ardour
route_group_dialog.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 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 #include <iostream>
21 
22 #include "ardour/route_group.h"
23 #include "ardour/session.h"
24 
25 #include <gtkmm/table.h>
26 #include <gtkmm/stock.h>
27 #include <gtkmm/messagedialog.h>
28 
29 #include "route_group_dialog.h"
30 #include "group_tabs.h"
31 #include "utils.h"
32 
33 #include "i18n.h"
34 
35 using namespace Gtk;
36 using namespace ARDOUR;
37 using namespace ARDOUR_UI_UTILS;
38 using namespace std;
39 using namespace PBD;
40 
42  : ArdourDialog (_("Track/bus Group"))
43  , _group (g)
44  , _initial_name (g->name ())
45  , _active (_("Active"))
46  , _gain (_("Gain"))
47  , _relative (_("Relative"))
48  , _mute (_("Muting"))
49  , _solo (_("Soloing"))
50  , _rec_enable (_("Record enable"))
51  , _select (_("Selection"))
52  , _route_active (_("Active state"))
53  , _share_color (_("Color"))
54  , _share_monitoring (_("Monitoring"))
55 {
56  set_modal (true);
57  set_skip_taskbar_hint (true);
58  set_resizable (true);
59  set_name (N_("RouteGroupDialog"));
60 
61  VBox* main_vbox = manage (new VBox);
62  Gtk::Label* l;
63 
64  get_vbox()->set_spacing (4);
65 
66  main_vbox->set_spacing (18);
67  main_vbox->set_border_width (5);
68 
69  HBox* hbox = manage (new HBox);
70  hbox->set_spacing (6);
71  l = manage (new Label (_("Name:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false ));
72 
73  hbox->pack_start (*l, false, true);
74  hbox->pack_start (_name, true, true);
75 
76  VBox* top_vbox = manage (new VBox);
77  top_vbox->set_spacing (4);
78 
79  top_vbox->pack_start (*hbox, false, true);
80  top_vbox->pack_start (_active);
81 
82  l = manage (new Label (_("Color"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
83  hbox = manage (new HBox);
84  hbox->set_spacing (12);
85  hbox->pack_start (*l, false, false);
86  hbox->pack_start (_color, false, false);
87  top_vbox->pack_start (*hbox, false, false);
88 
89  main_vbox->pack_start (*top_vbox, false, false);
90 
91  _active.set_active (_group->is_active ());
92 
93  Gdk::Color c;
95  _color.set_color (c);
96 
97  VBox* options_box = manage (new VBox);
98  options_box->set_spacing (6);
99 
100  l = manage (new Label (_("<b>Sharing</b>"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false ));
101  l->set_use_markup ();
102  options_box->pack_start (*l, false, true);
103 
104  _gain.set_active (_group->is_gain());
105  _relative.set_active (_group->is_relative());
106  _mute.set_active (_group->is_mute());
107  _solo.set_active (_group->is_solo());
108  _rec_enable.set_active (_group->is_recenable());
109  _select.set_active (_group->is_select());
110  _route_active.set_active (_group->is_route_active());
111  _share_color.set_active (_group->is_color());
112  _share_monitoring.set_active (_group->is_monitoring());
113 
114  if (_group->name ().empty()) {
115  _initial_name = "1";
116  while (!unique_name (_initial_name)) {
118  }
119  _name.set_text (_initial_name);
120  update();
121  } else {
122  _name.set_text (_initial_name);
123  }
124 
125  _name.signal_activate ().connect (sigc::bind (sigc::mem_fun (*this, &Dialog::response), RESPONSE_OK));
126  _name.signal_changed().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
127  _active.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
128  _color.signal_color_set().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
129  _gain.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
130  _relative.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
131  _mute.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
132  _solo.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
133  _rec_enable.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
134  _select.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
135  _route_active.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
136  _share_color.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
137  _share_monitoring.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
138 
139  gain_toggled ();
140 
141  Table* table = manage (new Table (11, 4, false));
142  table->set_row_spacings (6);
143 
144  l = manage (new Label ("", Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
145  l->set_padding (8, 0);
146  table->attach (*l, 0, 1, 0, 8, Gtk::FILL, Gtk::FILL, 0, 0);
147 
148  table->attach (_gain, 1, 3, 1, 2, Gtk::FILL, Gtk::FILL, 0, 0);
149 
150  l = manage (new Label ("", Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
151  l->set_padding (0, 0);
152  table->attach (*l, 1, 2, 2, 3, Gtk::FILL, Gtk::FILL, 0, 0);
153  table->attach (_relative, 2, 3, 2, 3, Gtk::FILL, Gtk::FILL, 0, 0);
154 
155  table->attach (_mute, 1, 3, 3, 4, Gtk::FILL, Gtk::FILL, 0, 0);
156  table->attach (_solo, 1, 3, 4, 5, Gtk::FILL, Gtk::FILL, 0, 0);
157  table->attach (_rec_enable, 1, 3, 5, 6, Gtk::FILL, Gtk::FILL, 0, 0);
158  table->attach (_select, 1, 3, 6, 7, Gtk::FILL, Gtk::FILL, 0, 0);
159  table->attach (_route_active, 1, 3, 7, 8, Gtk::FILL, Gtk::FILL, 0, 0);
160  table->attach (_share_color, 1, 3, 8, 9, Gtk::FILL, Gtk::FILL, 0, 0);
161  table->attach (_share_monitoring, 1, 3, 9, 10, Gtk::FILL, Gtk::FILL, 0, 0);
162 
163  options_box->pack_start (*table, false, true);
164  main_vbox->pack_start (*options_box, false, true);
165 
166  get_vbox()->pack_start (*main_vbox, false, false);
167 
168  _gain.signal_toggled().connect(sigc::mem_fun (*this, &RouteGroupDialog::gain_toggled));
169 
170  if (creating_new) {
171  add_button (Stock::CANCEL, RESPONSE_CANCEL);
172  add_button (Stock::NEW, RESPONSE_OK);
173  set_default_response (RESPONSE_OK);
174  } else {
175  add_button (Stock::CLOSE, RESPONSE_CLOSE);
176  set_default_response (RESPONSE_CLOSE);
177  }
178 
179  show_all_children ();
180 }
181 
183 bool
185 {
186  while (1) {
187  int const r = run ();
188  if (r == Gtk::RESPONSE_CANCEL) {
189  /* cancel, so just bail now */
190  return Gtk::RESPONSE_CANCEL;
191  }
192 
193  if (unique_name (_name.get_text())) {
194  /* not cancelled and the name is ok, so all is well */
195  return false;
196  }
197 
199  MessageDialog msg (
200  _("The group name is not unique. Please use a different name."),
201  false,
202  Gtk::MESSAGE_ERROR,
203  Gtk::BUTTONS_OK,
204  true
205  );
206 
207  msg.run ();
208  }
209 
210  abort(); /* NOTREACHED */
211  return false;
212 }
213 
214 void
216 {
217  PropertyList plist;
218 
219  plist.add (Properties::gain, _gain.get_active());
220  plist.add (Properties::recenable, _rec_enable.get_active());
221  plist.add (Properties::mute, _mute.get_active());
222  plist.add (Properties::solo, _solo.get_active ());
223  plist.add (Properties::select, _select.get_active());
224  plist.add (Properties::route_active, _route_active.get_active());
225  plist.add (Properties::relative, _relative.get_active());
226  plist.add (Properties::active, _active.get_active());
227  plist.add (Properties::name, string (_name.get_text()));
228  plist.add (Properties::color, _share_color.get_active());
229  plist.add (Properties::monitoring, _share_monitoring.get_active());
230 
231  _group->apply_changes (plist);
232 
234 }
235 
236 void
238 {
239  _relative.set_sensitive (_gain.get_active ());
240 }
241 
243 bool
244 RouteGroupDialog::unique_name (std::string const name) const
245 {
246  if (name.empty()) return false; // do not allow empty name, empty means unset.
247  list<RouteGroup*> route_groups = _group->session().route_groups ();
248  list<RouteGroup*>::iterator i = route_groups.begin ();
249  while (i != route_groups.end() && ((*i)->name() != name || *i == _group)) {
250  ++i;
251  }
252 
253  return (i == route_groups.end ());
254 }
bool is_mute() const
Definition: route_group.h:70
bool is_gain() const
Definition: route_group.h:69
Session & session() const
bool is_select() const
Definition: route_group.h:73
Definition: ardour_ui.h:130
bool unique_name(std::string const name) const
static void set_group_color(ARDOUR::RouteGroup *, uint32_t)
Definition: group_tabs.cc:562
Gtk::CheckButton _rec_enable
Gtk::CheckButton _route_active
Definition: Beats.hpp:239
RouteGroupDialog(ARDOUR::RouteGroup *, bool)
LIBARDOUR_API PBD::PropertyDescriptor< bool > gain
Definition: route_group.cc:44
Gtk::CheckButton _share_color
#define _(Text)
Definition: i18n.h:11
virtual bool apply_changes(PropertyBase const &)
Definition: stateful.cc:337
uint32_t gdk_color_to_rgba(Gdk::Color const &)
Definition: utils.cc:285
void set_color_from_rgba(Gdk::Color &, uint32_t)
Definition: utils.cc:276
std::list< RouteGroup * > const & route_groups() const
Definition: session.h:516
Gtk::CheckButton _relative
LIBARDOUR_API PBD::PropertyDescriptor< bool > recenable
Definition: route_group.cc:47
LIBARDOUR_API PBD::PropertyDescriptor< bool > route_active
Definition: route_group.cc:49
Definition: amp.h:29
virtual bool set_name(const std::string &str)
bool is_active() const
Definition: route_group.h:66
bool is_route_active() const
Definition: route_group.h:74
bool is_recenable() const
Definition: route_group.h:72
std::string _initial_name
LIBARDOUR_API PBD::PropertyDescriptor< bool > mute
Definition: route_group.cc:45
Gtk::CheckButton _mute
Gtk::CheckButton _active
LIBARDOUR_API PBD::PropertyDescriptor< bool > active
Definition: route_group.cc:43
LIBARDOUR_API std::string bump_name_number(const std::string &s)
Definition: utils.cc:200
bool is_monitoring() const
Definition: route_group.h:76
bool is_solo() const
Definition: route_group.h:71
static uint32_t group_color(ARDOUR::RouteGroup *)
Definition: group_tabs.cc:616
const char * name
LIBARDOUR_API PBD::PropertyDescriptor< bool > solo
Definition: route_group.cc:46
Gtk::ColorButton _color
LIBARDOUR_API PBD::PropertyDescriptor< bool > relative
Definition: route_group.cc:42
std::string name() const
bool is_color() const
Definition: route_group.h:75
bool is_relative() const
Definition: route_group.h:67
ARDOUR::RouteGroup * _group
Gtk::CheckButton _select
LIBARDOUR_API PBD::PropertyDescriptor< bool > select
Definition: route_group.cc:48
Definition: debug.h:30
Gtk::CheckButton _gain
Gtk::CheckButton _share_monitoring
Gtk::CheckButton _solo
bool add(PropertyBase *prop)
#define N_(Text)
Definition: i18n.h:12
LIBARDOUR_API PBD::PropertyDescriptor< bool > color
Definition: route_group.cc:50
LIBARDOUR_API PBD::PropertyDescriptor< bool > monitoring
Definition: route_group.cc:51