2005-09-25 14:42:24 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2000 Paul Davis
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cmath>
|
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
#include <gtkmm2ext/stop_signal.h>
|
2005-10-26 14:12:00 -04:00
|
|
|
#include <gtkmm2ext/gtk_ui.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
#include <ardour/route_group.h>
|
|
|
|
|
|
|
|
#include "editor.h"
|
|
|
|
#include "keyboard.h"
|
|
|
|
#include "marker.h"
|
|
|
|
#include "time_axis_view.h"
|
|
|
|
#include "prompter.h"
|
2005-10-26 14:12:00 -04:00
|
|
|
#include "gui_thread.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#include <ardour/route.h>
|
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
using namespace sigc;
|
2005-09-25 14:42:24 -04:00
|
|
|
using namespace ARDOUR;
|
2006-06-21 19:01:03 -04:00
|
|
|
using namespace PBD;
|
2005-09-25 14:42:24 -04:00
|
|
|
using namespace Gtk;
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::build_edit_group_list_menu ()
|
|
|
|
{
|
|
|
|
using namespace Gtk::Menu_Helpers;
|
|
|
|
|
|
|
|
edit_group_list_menu = new Menu;
|
|
|
|
edit_group_list_menu->set_name ("ArdourContextMenu");
|
|
|
|
MenuList& items = edit_group_list_menu->items();
|
|
|
|
|
2006-01-09 23:25:47 -05:00
|
|
|
items.push_back (MenuElem (_("Activate All"), mem_fun(*this, &Editor::activate_all_edit_groups)));
|
|
|
|
items.push_back (MenuElem (_("Disable All"), mem_fun(*this, &Editor::disable_all_edit_groups)));
|
|
|
|
items.push_back (SeparatorElem());
|
|
|
|
items.push_back (MenuElem (_("Add group"), mem_fun(*this, &Editor::new_edit_group)));
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-01-09 23:25:47 -05:00
|
|
|
Editor::activate_all_edit_groups ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-01-09 23:25:47 -05:00
|
|
|
Gtk::TreeModel::Children children = group_model->children();
|
|
|
|
for(Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) {
|
|
|
|
(*iter)[group_columns.is_active] = true;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-01-09 23:25:47 -05:00
|
|
|
Editor::disable_all_edit_groups ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-10-26 14:12:00 -04:00
|
|
|
Gtk::TreeModel::Children children = group_model->children();
|
|
|
|
for(Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) {
|
2006-01-09 23:25:47 -05:00
|
|
|
(*iter)[group_columns.is_active] = false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::new_edit_group ()
|
|
|
|
{
|
2006-03-09 23:05:11 -05:00
|
|
|
session->add_edit_group ("");
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2006-03-08 18:26:28 -05:00
|
|
|
void
|
|
|
|
Editor::remove_selected_edit_group ()
|
|
|
|
{
|
|
|
|
Glib::RefPtr<TreeSelection> selection = edit_group_display.get_selection();
|
|
|
|
TreeView::Selection::ListHandle_Path rows = selection->get_selected_rows ();
|
|
|
|
|
|
|
|
if (rows.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
TreeView::Selection::ListHandle_Path::iterator i = rows.begin();
|
|
|
|
TreeIter iter;
|
|
|
|
|
|
|
|
/* selection mode is single, so rows.begin() is it */
|
|
|
|
|
|
|
|
if ((iter = group_model->get_iter (*i))) {
|
|
|
|
|
|
|
|
RouteGroup* rg = (*iter)[group_columns.routegroup];
|
|
|
|
|
|
|
|
if (rg) {
|
|
|
|
session->remove_edit_group (*rg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Editor::edit_group_list_button_clicked ()
|
|
|
|
{
|
|
|
|
new_edit_group ();
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
Editor::edit_group_list_button_press_event (GdkEventButton* ev)
|
|
|
|
{
|
2006-01-09 23:25:47 -05:00
|
|
|
if (Keyboard::is_context_menu_event (ev)) {
|
|
|
|
if (edit_group_list_menu == 0) {
|
|
|
|
build_edit_group_list_menu ();
|
|
|
|
}
|
2006-11-21 19:58:22 -05:00
|
|
|
edit_group_list_menu->popup (1, ev->time);
|
2006-01-09 23:25:47 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-10-26 14:12:00 -04:00
|
|
|
RouteGroup* group;
|
|
|
|
TreeIter iter;
|
|
|
|
TreeModel::Path path;
|
|
|
|
TreeViewColumn* column;
|
|
|
|
int cellx;
|
|
|
|
int celly;
|
2006-01-09 23:25:47 -05:00
|
|
|
|
2005-12-29 19:34:21 -05:00
|
|
|
if (!edit_group_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
|
2005-10-26 14:12:00 -04:00
|
|
|
return false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-10-26 14:12:00 -04:00
|
|
|
switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) {
|
2006-03-09 23:05:11 -05:00
|
|
|
case 0:
|
2005-09-25 14:42:24 -04:00
|
|
|
if (Keyboard::is_edit_event (ev)) {
|
2006-01-09 23:25:47 -05:00
|
|
|
if ((iter = group_model->get_iter (path))) {
|
|
|
|
if ((group = (*iter)[group_columns.routegroup]) != 0) {
|
|
|
|
// edit_route_group (group);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-01-09 23:25:47 -05:00
|
|
|
case 1:
|
|
|
|
if ((iter = group_model->get_iter (path))) {
|
2006-03-30 10:50:08 -05:00
|
|
|
bool active = (*iter)[group_columns.is_active];
|
|
|
|
(*iter)[group_columns.is_active] = !active;
|
2006-01-09 23:25:47 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2005-10-26 14:12:00 -04:00
|
|
|
break;
|
2006-03-30 10:50:08 -05:00
|
|
|
|
2006-03-09 23:05:11 -05:00
|
|
|
case 2:
|
2005-10-26 14:12:00 -04:00
|
|
|
if ((iter = group_model->get_iter (path))) {
|
2006-03-30 10:50:08 -05:00
|
|
|
bool visible = (*iter)[group_columns.is_visible];
|
|
|
|
(*iter)[group_columns.is_visible] = !visible;
|
2006-01-09 23:25:47 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2005-10-26 14:12:00 -04:00
|
|
|
break;
|
2006-03-30 10:50:08 -05:00
|
|
|
|
2006-01-09 23:25:47 -05:00
|
|
|
default:
|
|
|
|
break;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-01-09 23:25:47 -05:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-01-09 23:25:47 -05:00
|
|
|
void
|
|
|
|
Editor::edit_group_row_change (const Gtk::TreeModel::Path& path,const Gtk::TreeModel::iterator& iter)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-01-09 23:25:47 -05:00
|
|
|
RouteGroup* group;
|
|
|
|
|
2006-03-09 18:44:39 -05:00
|
|
|
if (in_edit_group_row_change) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-01-09 23:25:47 -05:00
|
|
|
if ((group = (*iter)[group_columns.routegroup]) == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((*iter)[group_columns.is_visible]) {
|
|
|
|
for (TrackViewList::iterator j = track_views.begin(); j != track_views.end(); ++j) {
|
|
|
|
if ((*j)->edit_group() == group) {
|
|
|
|
show_track_in_display (**j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (TrackViewList::iterator j = track_views.begin(); j != track_views.end(); ++j) {
|
|
|
|
if ((*j)->edit_group() == group) {
|
|
|
|
hide_track_in_display (**j);
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
2006-01-09 23:25:47 -05:00
|
|
|
|
|
|
|
bool active = (*iter)[group_columns.is_active];
|
|
|
|
group->set_active (active, this);
|
2006-03-09 18:44:39 -05:00
|
|
|
|
|
|
|
|
|
|
|
string name = (*iter)[group_columns.text];
|
|
|
|
|
|
|
|
if (name != group->name()) {
|
|
|
|
group->set_name (name);
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::add_edit_group (RouteGroup* group)
|
2005-10-26 14:12:00 -04:00
|
|
|
{
|
|
|
|
ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::add_edit_group), group));
|
2006-03-09 23:05:11 -05:00
|
|
|
bool focus = false;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-10-26 14:12:00 -04:00
|
|
|
TreeModel::Row row = *(group_model->append());
|
|
|
|
row[group_columns.is_active] = group->is_active();
|
2006-03-09 18:44:39 -05:00
|
|
|
row[group_columns.is_visible] = !group->is_hidden();
|
2006-03-09 23:05:11 -05:00
|
|
|
|
2006-05-18 21:54:00 -04:00
|
|
|
in_edit_group_row_change = true;
|
|
|
|
|
2005-10-26 14:12:00 -04:00
|
|
|
row[group_columns.routegroup] = group;
|
2006-05-18 21:54:00 -04:00
|
|
|
|
2006-03-09 23:05:11 -05:00
|
|
|
if (!group->name().empty()) {
|
|
|
|
row[group_columns.text] = group->name();
|
|
|
|
} else {
|
|
|
|
row[group_columns.text] = _("unnamed");
|
|
|
|
focus = true;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-09-25 17:19:23 -04:00
|
|
|
group->FlagsChanged.connect (bind (mem_fun(*this, &Editor::group_flags_changed), group));
|
2006-03-09 23:05:11 -05:00
|
|
|
|
|
|
|
if (focus) {
|
2006-03-10 09:35:57 -05:00
|
|
|
TreeViewColumn* col = edit_group_display.get_column (0);
|
|
|
|
CellRendererText* name_cell = dynamic_cast<CellRendererText*>(edit_group_display.get_column_cell_renderer (0));
|
|
|
|
edit_group_display.set_cursor (group_model->get_path (row), *col, *name_cell, true);
|
2006-03-09 23:05:11 -05:00
|
|
|
}
|
2006-05-18 21:54:00 -04:00
|
|
|
|
|
|
|
in_edit_group_row_change = false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2006-03-08 18:26:28 -05:00
|
|
|
void
|
|
|
|
Editor::edit_groups_changed ()
|
|
|
|
{
|
|
|
|
ENSURE_GUI_THREAD (mem_fun (*this, &Editor::edit_groups_changed));
|
|
|
|
|
|
|
|
/* just rebuild the while thing */
|
|
|
|
|
|
|
|
group_model->clear ();
|
|
|
|
|
|
|
|
{
|
|
|
|
TreeModel::Row row;
|
|
|
|
row = *(group_model->append());
|
|
|
|
row[group_columns.is_active] = false;
|
|
|
|
row[group_columns.is_visible] = true;
|
|
|
|
row[group_columns.text] = (_("-all-"));
|
|
|
|
row[group_columns.routegroup] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
session->foreach_edit_group (mem_fun (*this, &Editor::add_edit_group));
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Editor::group_flags_changed (void* src, RouteGroup* group)
|
|
|
|
{
|
2006-01-09 23:25:47 -05:00
|
|
|
ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::group_flags_changed), src, group));
|
2005-10-26 14:12:00 -04:00
|
|
|
|
2006-03-09 18:44:39 -05:00
|
|
|
in_edit_group_row_change = true;
|
|
|
|
|
2006-01-09 23:25:47 -05:00
|
|
|
Gtk::TreeModel::Children children = group_model->children();
|
|
|
|
for(Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) {
|
|
|
|
if (group == (*iter)[group_columns.routegroup]) {
|
|
|
|
(*iter)[group_columns.is_active] = group->is_active();
|
2006-03-09 18:44:39 -05:00
|
|
|
(*iter)[group_columns.is_visible] = !group->is_hidden();
|
|
|
|
(*iter)[group_columns.text] = group->name();
|
2006-01-09 23:25:47 -05:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-03-09 18:44:39 -05:00
|
|
|
|
|
|
|
in_edit_group_row_change = false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2006-03-09 23:05:11 -05:00
|
|
|
void
|
|
|
|
Editor::edit_group_name_edit (const Glib::ustring& path, const Glib::ustring& new_text)
|
|
|
|
{
|
|
|
|
RouteGroup* group;
|
|
|
|
TreeIter iter;
|
|
|
|
|
|
|
|
if ((iter = group_model->get_iter (path))) {
|
|
|
|
|
|
|
|
if ((group = (*iter)[group_columns.routegroup]) == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (new_text != group->name()) {
|
|
|
|
group->set_name (new_text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|