X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_region_list.cc;h=8a50332193400448173cfba7c0b5392dae996abe;hb=376c5381edca72ce25a04d449e7df39ecbc0d4d0;hp=2f2aea7b7d6703f31e7dfd08b330e62aa622e543;hpb=afa29d319007ce20bd1546c343e9277c58c80c1a;p=ardour.git diff --git a/gtk2_ardour/editor_region_list.cc b/gtk2_ardour/editor_region_list.cc index 2f2aea7b7d..8a50332193 100644 --- a/gtk2_ardour/editor_region_list.cc +++ b/gtk2_ardour/editor_region_list.cc @@ -15,24 +15,26 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ #include #include #include #include +#include #include #include #include +#include #include #include #include "editor.h" #include "editing.h" +#include "keyboard.h" #include "ardour_ui.h" #include "gui_thread.h" #include "actions.h" @@ -48,26 +50,26 @@ using namespace Glib; using namespace Editing; void -Editor::handle_audio_region_removed (boost::weak_ptr wregion) +Editor::handle_region_removed (boost::weak_ptr wregion) { - ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::handle_audio_region_removed), wregion)); + ENSURE_GUI_THREAD (mem_fun (*this, &Editor::redisplay_regions)); redisplay_regions (); } void -Editor::handle_new_audio_region (boost::weak_ptr wregion) +Editor::handle_new_region (boost::weak_ptr wregion) { - ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::handle_new_audio_region), wregion)); + ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::handle_new_region), wregion)); /* don't copy region - the one we are being notified about belongs to the session, and so it will never be edited. */ - boost::shared_ptr region (wregion.lock()); + boost::shared_ptr region (wregion.lock()); if (region) { - add_audio_region_to_region_display (region); + add_region_to_region_display (region); } } @@ -80,11 +82,14 @@ Editor::region_hidden (boost::shared_ptr r) } void -Editor::add_audio_region_to_region_display (boost::shared_ptr region) +Editor::add_region_to_region_display (boost::shared_ptr region) { string str; TreeModel::Row row; Gdk::Color c; + bool missing_source; + + missing_source = boost::dynamic_pointer_cast(region->source()); if (!show_automatic_regions_in_region_list && region->automatic()) { return; @@ -124,18 +129,23 @@ Editor::add_audio_region_to_region_display (boost::shared_ptr regio } else if (region->whole_file()) { row = *(region_list_model->append()); - set_color(c, rgba_from_style ("RegionListWholeFile", 0xff, 0, 0, 0, "fg", Gtk::STATE_NORMAL, false )); + if (missing_source) { + c.set_rgb(65535,0,0); // FIXME: error color from style + } else { + set_color(c, rgba_from_style ("RegionListWholeFile", 0xff, 0, 0, 0, "fg", Gtk::STATE_NORMAL, false )); + } row[region_list_columns.color_] = c; if (region->source()->name()[0] == '/') { // external file if (region->whole_file()) { - str = ".../"; boost::shared_ptr afs = boost::dynamic_pointer_cast(region->source()); + str = ".../"; + if (afs) { - str += region_name_from_path (afs->path(), region->n_channels() > 1); + str = region_name_from_path (afs->path(), region->n_channels() > 1); } else { str += region->source()->name(); } @@ -150,6 +160,18 @@ Editor::add_audio_region_to_region_display (boost::shared_ptr regio } + if (region->n_channels() > 1) { + std::stringstream foo; + foo << region->n_channels (); + str += " ["; + str += foo.str(); + str += ']'; + } + + if (missing_source) { + str += _(" (MISSING)"); + } + row[region_list_columns.name] = str; row[region_list_columns.region] = region; @@ -209,25 +231,32 @@ Editor::region_list_selection_changed() TreeView::Selection::ListHandle_Path::iterator i = rows.begin(); TreeIter iter; - /* just set the first selected region (in fact, the selection model might be SINGLE, which - means there can only be one. - */ - if ((iter = region_list_model->get_iter (*i))) { - set_selected_regionview_from_region_list (((*iter)[region_list_columns.region]), Selection::Set); + boost::shared_ptr r = (*iter)[region_list_columns.region]; + + /* they could have clicked on a row that is just a placeholder, like "Hidden" */ + + if (r) { + + /* just set the first selected region (in fact, the selection model might be SINGLE, which + means there can only be one. + */ + + set_selected_regionview_from_region_list (r, Selection::Set); + } } } } void -Editor::insert_into_tmp_audio_regionlist(boost::shared_ptr region) +Editor::insert_into_tmp_regionlist(boost::shared_ptr region) { /* keep all whole files at the beginning */ if (region->whole_file()) { - tmp_audio_region_list.push_front (region); + tmp_region_list.push_front (region); } else { - tmp_audio_region_list.push_back (region); + tmp_region_list.push_back (region); } } @@ -243,24 +272,18 @@ Editor::redisplay_regions () sorting. */ - tmp_audio_region_list.clear(); - session->foreach_audio_region (this, &Editor::insert_into_tmp_audio_regionlist); + tmp_region_list.clear(); + session->foreach_region (this, &Editor::insert_into_tmp_regionlist); - for (list >::iterator r = tmp_audio_region_list.begin(); r != tmp_audio_region_list.end(); ++r) { - add_audio_region_to_region_display (*r); + for (list >::iterator r = tmp_region_list.begin(); r != tmp_region_list.end(); ++r) { + add_region_to_region_display (*r); } - tmp_audio_region_list.clear(); + tmp_region_list.clear(); region_list_display.set_model (region_list_model); } } -void -Editor::region_list_clear () -{ - region_list_model->clear(); -} - void Editor::build_region_list_menu () { @@ -548,7 +571,16 @@ Editor::region_list_selection_mapover (slot > sl) TreeIter iter; if ((iter = region_list_model->get_iter (*i))) { - sl (((*iter)[region_list_columns.region])); + + /* some rows don't have a region associated with them, but can still be + selected (XXX maybe prevent them from being selected) + */ + + boost::shared_ptr r = (*iter)[region_list_columns.region]; + + if (r) { + sl (r); + } } } } @@ -562,6 +594,7 @@ Editor::hide_a_region (boost::shared_ptr r) void Editor::remove_a_region (boost::shared_ptr r) { + cerr << "remove " << r->name(); session->remove_region_from_region_list (r); } @@ -580,6 +613,7 @@ Editor::hide_region_from_region_list () void Editor::remove_region_from_region_list () { + cerr << "Mapping remove over region selection\n"; region_list_selection_mapover (mem_fun (*this, &Editor::remove_a_region)); }