2 Copyright (C) 2000 Paul Davis
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.
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.
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.
23 #include <gtkmm2ext/stop_signal.h>
24 #include <gtkmm2ext/gtk_ui.h>
25 #include "ardour/route_group.h"
30 #include "time_axis_view.h"
32 #include "gui_thread.h"
34 #include "ardour/route.h"
40 using namespace ARDOUR;
45 Editor::build_edit_group_list_menu ()
47 using namespace Gtk::Menu_Helpers;
49 edit_group_list_menu = new Menu;
50 edit_group_list_menu->set_name ("ArdourContextMenu");
51 MenuList& items = edit_group_list_menu->items();
53 items.push_back (MenuElem (_("Activate All"), mem_fun(*this, &Editor::activate_all_edit_groups)));
54 items.push_back (MenuElem (_("Disable All"), mem_fun(*this, &Editor::disable_all_edit_groups)));
55 items.push_back (SeparatorElem());
56 items.push_back (MenuElem (_("Add group"), mem_fun(*this, &Editor::new_edit_group)));
61 Editor::activate_all_edit_groups ()
63 Gtk::TreeModel::Children children = group_model->children();
64 for(Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) {
65 (*iter)[group_columns.is_active] = true;
70 Editor::disable_all_edit_groups ()
72 Gtk::TreeModel::Children children = group_model->children();
73 for(Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) {
74 (*iter)[group_columns.is_active] = false;
79 Editor::new_edit_group ()
81 session->add_edit_group ("");
85 Editor::remove_selected_edit_group ()
87 Glib::RefPtr<TreeSelection> selection = edit_group_display.get_selection();
88 TreeView::Selection::ListHandle_Path rows = selection->get_selected_rows ();
94 TreeView::Selection::ListHandle_Path::iterator i = rows.begin();
97 /* selection mode is single, so rows.begin() is it */
99 if ((iter = group_model->get_iter (*i))) {
101 RouteGroup* rg = (*iter)[group_columns.routegroup];
104 session->remove_edit_group (*rg);
110 Editor::edit_group_list_button_clicked ()
116 Editor::edit_group_list_button_press_event (GdkEventButton* ev)
118 if (Keyboard::is_context_menu_event (ev)) {
119 if (edit_group_list_menu == 0) {
120 build_edit_group_list_menu ();
122 edit_group_list_menu->popup (1, ev->time);
129 TreeModel::Path path;
130 TreeViewColumn* column;
134 if (!edit_group_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
138 switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) {
140 if (Keyboard::is_edit_event (ev)) {
141 if ((iter = group_model->get_iter (path))) {
142 if ((group = (*iter)[group_columns.routegroup]) != 0) {
143 // edit_route_group (group);
145 edit_group_display.queue_draw();
155 if ((iter = group_model->get_iter (path))) {
156 bool active = (*iter)[group_columns.is_active];
157 (*iter)[group_columns.is_active] = !active;
159 edit_group_display.queue_draw();
166 if ((iter = group_model->get_iter (path))) {
167 bool visible = (*iter)[group_columns.is_visible];
168 (*iter)[group_columns.is_visible] = !visible;
170 edit_group_display.queue_draw();
184 Editor::edit_group_row_change (const Gtk::TreeModel::Path& path,const Gtk::TreeModel::iterator& iter)
188 if (in_edit_group_row_change) {
192 if ((group = (*iter)[group_columns.routegroup]) == 0) {
196 if ((*iter)[group_columns.is_visible]) {
197 for (TrackViewList::iterator j = track_views.begin(); j != track_views.end(); ++j) {
198 if ((*j)->edit_group() == group) {
199 show_track_in_display (**j);
203 for (TrackViewList::iterator j = track_views.begin(); j != track_views.end(); ++j) {
204 if ((*j)->edit_group() == group) {
205 hide_track_in_display (**j);
210 bool active = (*iter)[group_columns.is_active];
211 group->set_active (active, this);
214 string name = (*iter)[group_columns.text];
216 if (name != group->name()) {
217 group->set_name (name);
222 Editor::add_edit_group (RouteGroup* group)
224 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::add_edit_group), group));
227 TreeModel::Row row = *(group_model->append());
228 row[group_columns.is_active] = group->is_active();
229 row[group_columns.is_visible] = !group->is_hidden();
231 in_edit_group_row_change = true;
233 row[group_columns.routegroup] = group;
235 if (!group->name().empty()) {
236 row[group_columns.text] = group->name();
238 row[group_columns.text] = _("unnamed");
242 group->FlagsChanged.connect (bind (mem_fun(*this, &Editor::group_flags_changed), group));
245 TreeViewColumn* col = edit_group_display.get_column (0);
246 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(edit_group_display.get_column_cell_renderer (0));
247 edit_group_display.set_cursor (group_model->get_path (row), *col, *name_cell, true);
250 in_edit_group_row_change = false;
254 Editor::edit_groups_changed ()
256 ENSURE_GUI_THREAD (mem_fun (*this, &Editor::edit_groups_changed));
258 /* just rebuild the while thing */
260 group_model->clear ();
264 row = *(group_model->append());
265 row[group_columns.is_active] = false;
266 row[group_columns.is_visible] = true;
267 row[group_columns.text] = (_("-all-"));
268 row[group_columns.routegroup] = 0;
271 session->foreach_edit_group (mem_fun (*this, &Editor::add_edit_group));
275 Editor::group_flags_changed (void* src, RouteGroup* group)
277 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::group_flags_changed), src, group));
279 in_edit_group_row_change = true;
281 Gtk::TreeModel::Children children = group_model->children();
282 for(Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) {
283 if (group == (*iter)[group_columns.routegroup]) {
284 (*iter)[group_columns.is_active] = group->is_active();
285 (*iter)[group_columns.is_visible] = !group->is_hidden();
286 (*iter)[group_columns.text] = group->name();
290 in_edit_group_row_change = false;
294 Editor::edit_group_name_edit (const Glib::ustring& path, const Glib::ustring& new_text)
299 if ((iter = group_model->get_iter (path))) {
301 if ((group = (*iter)[group_columns.routegroup]) == 0) {
305 if (new_text != group->name()) {
306 group->set_name (new_text);