X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_region_list.cc;h=0e14391895fd78c3b8add627634b36095cb13366;hb=965c295451916cf7f04d33fbf41ff2beb573439b;hp=397c401e0cadf51910976fef27ba981149aa77b6;hpb=02115563feabd8d0019bfda605c88552c24f0890;p=ardour.git diff --git a/gtk2_ardour/editor_region_list.cc b/gtk2_ardour/editor_region_list.cc index 397c401e0c..0e14391895 100644 --- a/gtk2_ardour/editor_region_list.cc +++ b/gtk2_ardour/editor_region_list.cc @@ -15,27 +15,31 @@ 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 #include #include "editor.h" #include "editing.h" +#include "keyboard.h" #include "ardour_ui.h" #include "gui_thread.h" #include "actions.h" +#include "region_view.h" #include "utils.h" #include "i18n.h" @@ -48,22 +52,17 @@ using namespace Glib; using namespace Editing; void -Editor::handle_audio_region_removed (boost::shared_ptr region) +Editor::handle_audio_region_removed (boost::weak_ptr wregion) { - ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::handle_audio_region_removed), region)); + ENSURE_GUI_THREAD (mem_fun (*this, &Editor::redisplay_regions)); redisplay_regions (); } void -Editor::handle_new_audio_region (boost::shared_ptr region) +Editor::handle_new_audio_regions (vector >& v) { - ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::handle_new_audio_region), region)); - - /* don't copy region - the one we are being notified - about belongs to the session, and so it will - never be edited. - */ - add_audio_region_to_region_display (region); + ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::handle_new_audio_regions), v)); + add_audio_regions_to_region_display (v); } void @@ -74,12 +73,28 @@ Editor::region_hidden (boost::shared_ptr r) redisplay_regions (); } +void +Editor::add_audio_regions_to_region_display (vector >& regions) +{ + region_list_display.set_model (Glib::RefPtr(0)); + for (vector >::iterator x = regions.begin(); x != regions.end(); ++x) { + boost::shared_ptr region ((*x).lock()); + if (region) { + add_audio_region_to_region_display (region); + } + } + region_list_display.set_model (region_list_model); +} + void Editor::add_audio_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; @@ -91,12 +106,11 @@ Editor::add_audio_region_to_region_display (boost::shared_ptr regio TreeModel::Row parent; TreeModel::Row child; - if (iter == region_list_model->children().end()) { - + if (!iter) { + parent = *(region_list_model->append()); parent[region_list_columns.name] = _("Hidden"); - /// XXX FIX ME parent[region_list_columns.region]->reset (); } else { @@ -104,31 +118,44 @@ Editor::add_audio_region_to_region_display (boost::shared_ptr regio parent = *(region_list_model->insert(iter)); parent[region_list_columns.name] = _("Hidden"); - /// XXX FIX ME parent[region_list_columns.region]->reset (); } else { + parent = *iter; } - } row = *(region_list_model->append (parent.children())); } else if (region->whole_file()) { + TreeModel::iterator i; + TreeModel::Children rows = region_list_model->children(); + + for (i = rows.begin(); i != rows.end(); ++i) { + + boost::shared_ptr rr = (*i)[region_list_columns.region]; + + if (rr && region->region_list_equivalent (rr)) { + return; + } + } + 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 = ".../"; - str += PBD::basename_nosuffix (region->source()->name()); - - } else { - str = region->name(); - } + /* XXX there was old code here to try to show an abbreviated version + of the path name for whole file regions. + */ + + str = region->name(); } else { @@ -136,6 +163,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; @@ -161,6 +200,18 @@ Editor::add_audio_region_to_region_display (boost::shared_ptr regio break; } } + + TreeModel::iterator ii; + TreeModel::Children subrows = (*i).children(); + + for (ii = subrows.begin(); ii != subrows.end(); ++ii) { + + boost::shared_ptr rrr = (*ii)[region_list_columns.region]; + + if (region->region_list_equivalent (rrr)) { + return; + } + } } if (!found_parent) { @@ -195,12 +246,19 @@ 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); + } } } } @@ -220,6 +278,10 @@ Editor::insert_into_tmp_audio_regionlist(boost::shared_ptr region) void Editor::redisplay_regions () { + if (no_region_list_redisplay) { + return; + } + if (session) { region_list_display.set_model (Glib::RefPtr(0)); @@ -241,12 +303,6 @@ Editor::redisplay_regions () } } -void -Editor::region_list_clear () -{ - region_list_model->clear(); -} - void Editor::build_region_list_menu () { @@ -337,39 +393,17 @@ Editor::region_list_display_button_press (GdkEventButton *ev) } } - if (region == 0) { - return false; - } - - if (Keyboard::is_delete_event (ev)) { - session->remove_region_from_region_list (region); - return true; - } - if (Keyboard::is_context_menu_event (ev)) { show_region_list_display_context_menu (ev->button, ev->time); return true; } - switch (ev->button) { - case 1: - /* audition on double click */ - if (ev->type == GDK_2BUTTON_PRESS) { - consider_auditioning (region); - return true; - } - return false; - break; - - case 2: - if (!Keyboard::modifier_state_equals (ev->state, Keyboard::Control)) { + if (region != 0 && Keyboard::is_button2_event (ev)) { + // start/stop audition + if (!Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { consider_auditioning (region); } return true; - break; - - default: - break; } return false; @@ -414,7 +448,7 @@ Editor::consider_auditioning (boost::shared_ptr region) if (r == last_audition_region) { return; } - } + } session->audition_region (r); last_audition_region = r; @@ -539,7 +573,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); + } } } } @@ -582,9 +625,18 @@ Editor::region_list_display_drag_data_received (const RefPtr& { vector paths; + if (data.get_target() == "GTK_TREE_MODEL_ROW") { + region_list_display.on_drag_data_received (context, x, y, data, info, time); + return; + } + if (convert_drop_to_paths (paths, context, x, y, data, info, time) == 0) { - nframes_t pos = 0; - do_embed (paths, false, ImportAsRegion, 0, pos, true); + nframes64_t pos = 0; + if (Profile->get_sae() || Config->get_only_copy_imported_files()) { + do_import (paths, Editing::ImportDistinctFiles, Editing::ImportAsRegion, SrcBest, pos); + } else { + do_embed (paths, Editing::ImportDistinctFiles, ImportAsRegion, pos); + } context->drag_finish (true, false, time); } } @@ -593,8 +645,42 @@ bool Editor::region_list_selection_filter (const RefPtr& model, const TreeModel::Path& path, bool yn) { /* not possible to select rows that do not represent regions, like "Hidden" */ + + TreeModel::iterator iter = model->get_iter (path); + + if (iter) { + boost::shared_ptr r =(*iter)[region_list_columns.region]; + if (!r) { + return false; + } + } - /// XXXX FIXME boost::shared_ptr r = ((model->get_iter (path)))[region_list_columns.region]; - /// return r != 0; return true; } + +void +Editor::region_name_edit (const Glib::ustring& path, const Glib::ustring& new_text) +{ + boost::shared_ptr region; + TreeIter iter; + + if ((iter = region_list_model->get_iter (path))) { + region = (*iter)[region_list_columns.region]; + (*iter)[region_list_columns.name] = new_text; + } + + /* now mapover everything */ + + if (region) { + vector equivalents; + get_regions_corresponding_to (region, equivalents); + + for (vector::iterator i = equivalents.begin(); i != equivalents.end(); ++i) { + if (new_text != (*i)->region()->name()) { + (*i)->region()->set_name (new_text); + } + } + } + +} +