X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_regions.cc;h=f406694e4d6df6e11d6fb2488dc3cfae5fe7e9c5;hb=5fef65538040fbac1b9edd1847a269aa925a49c9;hp=ece75522fc6eeb04fd7ded6710558913b01546f2;hpb=5547744d85aa38e1e054f90cf4ea2414e65a79b8;p=ardour.git diff --git a/gtk2_ardour/editor_regions.cc b/gtk2_ardour/editor_regions.cc index ece75522fc..f406694e4d 100644 --- a/gtk2_ardour/editor_regions.cc +++ b/gtk2_ardour/editor_regions.cc @@ -28,10 +28,9 @@ #include "ardour/audioregion.h" #include "ardour/audiofilesource.h" +#include "ardour/silentfilesource.h" #include "ardour/region_factory.h" #include "ardour/session.h" -#include "ardour/session_playlists.h" -#include "ardour/silentfilesource.h" #include "ardour/profile.h" #include "gtkmm2ext/choice.h" @@ -48,11 +47,13 @@ #include "utils.h" #include "editor_regions.h" #include "editor_drag.h" +#include "main_clock.h" #include "i18n.h" using namespace std; using namespace ARDOUR; +using namespace ARDOUR_UI_UTILS; using namespace PBD; using namespace Gtk; using namespace Glib; @@ -79,6 +80,7 @@ EditorRegions::EditorRegions (Editor* e) { _display.set_size_request (100, -1); _display.set_rules_hint (true); + _display.set_name ("EditGroupList"); /* Try to prevent single mouse presses from initiating edits. This relies on a hack in gtktreeview.c:gtk_treeview_button_press() @@ -108,12 +110,12 @@ EditorRegions::EditorRegions (Editor* e) ColumnInfo ci[] = { { 0, _("Region"), _("Region name, with number of channels in []'s") }, - { 1, _("Position"), _("Length of the region") }, - { 2, _("End"), _("Length of the region") }, - { 3, _("End"), _("Length of the region") }, + { 1, _("Position"), _("Position of start of region") }, + { 2, _("End"), _("Position of end of region") }, + { 3, _("Length"), _("Length of the region") }, { 4, _("Sync"), _("Position of region sync point, relative to start of the region") }, - { 5, _("Sync"), _("Region fade-in enabled?") }, - { 6, _("Fade In"), _("Region fade-out enabled?") }, + { 5, _("Fade In"), _("Length of region fade-in (units: secondary clock), () if disabled") }, + { 6, _("Fade Out"), _("Length of region fade-out (units: secondary clock), () if disabled") }, { 7, _("L"), _("Region position locked?") }, { 8, _("G"), _("Region position glued to Bars|Beats time?") }, { 9, _("M"), _("Region muted?") }, @@ -212,11 +214,11 @@ EditorRegions::EditorRegions (Editor* e) //ARDOUR_UI::instance()->secondary_clock.mode_changed.connect (sigc::mem_fun(*this, &Editor::redisplay_regions)); ARDOUR_UI::instance()->secondary_clock->mode_changed.connect (sigc::mem_fun(*this, &EditorRegions::update_all_rows)); - ARDOUR::Region::RegionPropertyChanged.connect (region_property_connection, MISSING_INVALIDATOR, ui_bind (&EditorRegions::region_changed, this, _1, _2), gui_context()); - ARDOUR::RegionFactory::CheckNewRegion.connect (check_new_region_connection, MISSING_INVALIDATOR, ui_bind (&EditorRegions::add_region, this, _1), gui_context()); + ARDOUR::Region::RegionPropertyChanged.connect (region_property_connection, MISSING_INVALIDATOR, boost::bind (&EditorRegions::region_changed, this, _1, _2), gui_context()); + ARDOUR::RegionFactory::CheckNewRegion.connect (check_new_region_connection, MISSING_INVALIDATOR, boost::bind (&EditorRegions::add_region, this, _1), gui_context()); - e->EditorFreeze.connect (editor_freeze_connection, MISSING_INVALIDATOR, ui_bind (&EditorRegions::freeze_tree_model, this), gui_context()); - e->EditorThaw.connect (editor_thaw_connection, MISSING_INVALIDATOR, ui_bind (&EditorRegions::thaw_tree_model, this), gui_context()); + e->EditorFreeze.connect (editor_freeze_connection, MISSING_INVALIDATOR, boost::bind (&EditorRegions::freeze_tree_model, this), gui_context()); + e->EditorThaw.connect (editor_thaw_connection, MISSING_INVALIDATOR, boost::bind (&EditorRegions::thaw_tree_model, this), gui_context()); } bool @@ -293,7 +295,7 @@ EditorRegions::add_region (boost::shared_ptr region) string str; TreeModel::Row row; Gdk::Color c; - bool missing_source = boost::dynamic_pointer_cast(region->source()); + bool missing_source = boost::dynamic_pointer_cast(region->source()) != NULL; if (!_show_automatic_regions && region->automatic()) { return; @@ -303,7 +305,6 @@ EditorRegions::add_region (boost::shared_ptr region) TreeModel::iterator iter = _model->get_iter ("0"); TreeModel::Row parent; - TreeModel::Row child; if (!iter) { parent = *(_model->append()); @@ -340,14 +341,15 @@ EditorRegions::add_region (boost::shared_ptr region) row = *(_model->append()); if (missing_source) { - c.set_rgb(65535,0,0); // FIXME: error color from style + // c.set_rgb(65535,0,0); // FIXME: error color from style + set_color_from_rgba (c, ARDOUR_UI::config()->color ("region list missing source")); } else if (region->automatic()){ - c.set_rgb(0,65535,0); // FIXME: error color from style + // c.set_rgb(0,65535,0); // FIXME: error color from style + set_color_from_rgba (c, ARDOUR_UI::config()->color ("region list automatic")); } else { - set_color(c, rgba_from_style ("RegionListWholeFile", 0xff, 0, 0, 0, "fg", Gtk::STATE_NORMAL, false )); - + set_color_from_rgba (c, ARDOUR_UI::config()->color ("region list whole file")); } row[_columns.color_] = c; @@ -485,6 +487,8 @@ EditorRegions::region_changed (boost::shared_ptr r, const PropertyChange our_interests.add (ARDOUR::Properties::opaque); our_interests.add (ARDOUR::Properties::fade_in); our_interests.add (ARDOUR::Properties::fade_out); + our_interests.add (ARDOUR::Properties::fade_in_active); + our_interests.add (ARDOUR::Properties::fade_out_active); if (what_changed.contains (our_interests)) { @@ -548,7 +552,8 @@ EditorRegions::selection_changed () for (TreeView::Selection::ListHandle_Path::iterator i = rows.begin(); i != rows.end(); ++i) { - if (iter = _model->get_iter (*i)) { + if ((iter = _model->get_iter (*i))) { + boost::shared_ptr region = (*iter)[_columns.region]; // they could have clicked on a row that is just a placeholder, like "Hidden" @@ -557,18 +562,12 @@ EditorRegions::selection_changed () if (region) { - if (region->automatic()) { - - _display.get_selection()->unselect(*i); - - } else { - _change_connection.block (true); - _editor->set_selected_regionview_from_region_list (region, Selection::Add); - - _change_connection.block (false); - } + _change_connection.block (true); + _editor->set_selected_regionview_from_region_list (region, Selection::Add); + _change_connection.block (false); } } + } } else { _editor->get_selection().clear_regions (); @@ -686,7 +685,7 @@ EditorRegions::update_all_rows () } void -EditorRegions::format_position (framepos_t pos, char* buf, size_t bufsize) +EditorRegions::format_position (framepos_t pos, char* buf, size_t bufsize, bool onoff) { Timecode::BBT_Time bbt; Timecode::Time timecode; @@ -694,7 +693,11 @@ EditorRegions::format_position (framepos_t pos, char* buf, size_t bufsize) switch (ARDOUR_UI::instance()->secondary_clock->mode ()) { case AudioClock::BBT: _session->tempo_map().bbt_time (pos, bbt); - snprintf (buf, bufsize, "%03d|%02d|%04d" , bbt.bars, bbt.beats, bbt.ticks); + if (onoff) { + snprintf (buf, bufsize, "%03d|%02d|%04d" , bbt.bars, bbt.beats, bbt.ticks); + } else { + snprintf (buf, bufsize, "(%03d|%02d|%04d)" , bbt.bars, bbt.beats, bbt.ticks); + } break; case AudioClock::MinSec: @@ -709,17 +712,29 @@ EditorRegions::format_position (framepos_t pos, char* buf, size_t bufsize) mins = (int) floor (left / (_session->frame_rate() * 60.0f)); left -= (framecnt_t) floor (mins * _session->frame_rate() * 60.0f); secs = left / (float) _session->frame_rate(); - snprintf (buf, bufsize, "%02d:%02d:%06.3f", hrs, mins, secs); + if (onoff) { + snprintf (buf, bufsize, "%02d:%02d:%06.3f", hrs, mins, secs); + } else { + snprintf (buf, bufsize, "(%02d:%02d:%06.3f)", hrs, mins, secs); + } break; case AudioClock::Frames: - snprintf (buf, bufsize, "%" PRId64, pos); + if (onoff) { + snprintf (buf, bufsize, "%" PRId64, pos); + } else { + snprintf (buf, bufsize, "(%" PRId64 ")", pos); + } break; case AudioClock::Timecode: default: _session->timecode_time (pos, timecode); - snprintf (buf, bufsize, "%02d:%02d:%02d:%02d", timecode.hours, timecode.minutes, timecode.seconds, timecode.frames); + if (onoff) { + snprintf (buf, bufsize, "%02d:%02d:%02d:%02d", timecode.hours, timecode.minutes, timecode.seconds, timecode.frames); + } else { + snprintf (buf, bufsize, "(%02d:%02d:%02d:%02d)", timecode.hours, timecode.minutes, timecode.seconds, timecode.frames); + } break; } } @@ -851,16 +866,9 @@ EditorRegions::populate_row_fade_in (boost::shared_ptr region, TreeModel if (used > 1) { row[_columns.fadein] = _("Multiple"); } else { - - char buf[16]; - format_position (audioregion->fade_in()->back()->when, buf, sizeof (buf)); + char buf[32]; + format_position (audioregion->fade_in()->back()->when, buf, sizeof (buf), audioregion->fade_in_active()); row[_columns.fadein] = buf; - - if (audioregion->fade_in_active()) { - row[_columns.fadein] = string_compose("%1%2%3", " ", buf, " "); - } else { - row[_columns.fadein] = string_compose("%1%2%3", "(", buf, ")"); - } } } } @@ -874,14 +882,9 @@ EditorRegions::populate_row_fade_out (boost::shared_ptr region, TreeMode if (used > 1) { row[_columns.fadeout] = _("Multiple"); } else { - char buf[16]; - format_position (audioregion->fade_out()->back()->when, buf, sizeof (buf)); - - if (audioregion->fade_out_active()) { - row[_columns.fadeout] = string_compose("%1%2%3", " ", buf, " "); - } else { - row[_columns.fadeout] = string_compose("%1%2%3", "(", buf, ")"); - } + char buf[32]; + format_position (audioregion->fade_out()->back()->when, buf, sizeof (buf), audioregion->fade_out_active()); + row[_columns.fadeout] = buf; } } } @@ -1114,7 +1117,7 @@ EditorRegions::sorter (TreeModel::iterator a, TreeModel::iterator b) switch (_sort_type) { case ByName: - cmp = strcasecmp (region1->name().c_str(), region2->name().c_str()); + cmp = region1->name().compare(region2->name()); break; case ByLength: @@ -1139,7 +1142,7 @@ EditorRegions::sorter (TreeModel::iterator a, TreeModel::iterator b) break; case BySourceFileName: - cmp = strcasecmp (region1->source()->name().c_str(), region2->source()->name().c_str()); + cmp = region1->source()->name().compare(region2->source()->name()); break; case BySourceFileLength: @@ -1152,9 +1155,9 @@ EditorRegions::sorter (TreeModel::iterator a, TreeModel::iterator b) case BySourceFileFS: if (region1->source()->name() == region2->source()->name()) { - cmp = strcasecmp (region1->name().c_str(), region2->name().c_str()); + cmp = region1->name().compare(region2->name()); } else { - cmp = strcasecmp (region1->source()->name().c_str(), region2->source()->name().c_str()); + cmp = region1->source()->name().compare(region2->source()->name()); } break; } @@ -1232,7 +1235,9 @@ EditorRegions::drag_data_received (const RefPtr& context, if (_editor->convert_drop_to_paths (paths, context, x, y, data, info, time) == 0) { framepos_t pos = 0; - if (Profile->get_sae() || Config->get_only_copy_imported_files()) { + bool copy = ((context->get_actions() & (Gdk::ACTION_COPY | Gdk::ACTION_LINK | Gdk::ACTION_MOVE)) == Gdk::ACTION_COPY); + + if (Profile->get_sae() || Config->get_only_copy_imported_files() || copy) { _editor->do_import (paths, Editing::ImportDistinctFiles, Editing::ImportAsRegion, SrcBest, pos); } else { _editor->do_embed (paths, Editing::ImportDistinctFiles, ImportAsRegion, pos); @@ -1294,7 +1299,7 @@ EditorRegions::name_edit (const std::string& path, const std::string& new_text) if (region) { vector equivalents; - _editor->get_regions_corresponding_to (region, equivalents); + _editor->get_regions_corresponding_to (region, equivalents, false); for (vector::iterator i = equivalents.begin(); i != equivalents.end(); ++i) { if (new_text != (*i)->region()->name()) { @@ -1556,7 +1561,7 @@ EditorRegions::sort_type_action (Editing::RegionListSortType t) const break; default: fatal << string_compose (_("programming error: %1: %2"), "EditorRegions: impossible sort type", (int) t) << endmsg; - /*NOTREACHED*/ + abort(); /*NOTREACHED*/ } RefPtr act = ActionManager::get_action (X_("RegionList"), action);