region list displays actual playlist use count for each region, rather than a GUI-based count

git-svn-id: svn://localhost/ardour2/branches/3.0@7814 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2010-09-20 19:18:17 +00:00
parent 6a93c41201
commit 97a96ee250
7 changed files with 79 additions and 12 deletions

View File

@ -25,11 +25,13 @@
#include "pbd/basename.h"
#include "pbd/enumwriter.h"
#include "pbd/stacktrace.h"
#include "ardour/audioregion.h"
#include "ardour/audiofilesource.h"
#include "ardour/region_factory.h"
#include "ardour/session.h"
#include "ardour/session_playlists.h"
#include "ardour/silentfilesource.h"
#include "ardour/profile.h"
@ -62,6 +64,7 @@ EditorRegions::EditorRegions (Editor* e)
, _no_redisplay (false)
, ignore_region_list_selection_change (false)
, ignore_selected_region_change (false)
, expanded (false)
{
_display.set_size_request (100, -1);
_display.set_name ("RegionListDisplay");
@ -547,6 +550,9 @@ EditorRegions::redisplay ()
insert_into_tmp_regionlist (i->second);
}
stacktrace (cerr, 22);
cerr << "Redisplay with " << tmp_region_list.size() << " regions\n";
for (list<boost::shared_ptr<Region> >::iterator r = tmp_region_list.begin(); r != tmp_region_list.end(); ++r) {
add_region (*r);
}
@ -709,7 +715,7 @@ void
EditorRegions::populate_row (boost::shared_ptr<Region> region, TreeModel::Row const &row)
{
boost::shared_ptr<AudioRegion> audioregion = boost::dynamic_pointer_cast<AudioRegion>(region);
uint32_t used = _editor->get_regionview_count_from_region_list (region);
uint32_t used = _session->playlists->region_use_count (region);
populate_row_position (region, row, used);
populate_row_end (region, row, used);
@ -941,8 +947,10 @@ EditorRegions::set_full (bool f)
{
if (f) {
_display.expand_all ();
expanded = true;
} else {
_display.collapse_all ();
expanded = false;
}
}
@ -1345,6 +1353,8 @@ EditorRegions::get_state () const
void
EditorRegions::set_state (const XMLNode & node)
{
bool changed = false;
if (node.name() != X_("RegionList")) {
return;
}
@ -1352,6 +1362,9 @@ EditorRegions::set_state (const XMLNode & node)
XMLProperty const * p = node.property (X_("sort-type"));
if (p) {
Editing::RegionListSortType const t = static_cast<Editing::RegionListSortType> (string_2_enum (p->value(), _sort_type));
if (_sort_type != t) {
changed = true;
}
reset_sort_type (t, true);
RefPtr<RadioAction> ract = sort_type_action (t);
ract->set_active ();
@ -1359,10 +1372,17 @@ EditorRegions::set_state (const XMLNode & node)
p = node.property (X_("sort-ascending"));
if (p) {
bool const a = string_is_affirmative (p->value ());
reset_sort_direction (a);
bool const yn = string_is_affirmative (p->value ());
SortType old_sort_type;
int old_sort_column;
_model->get_sort_column_id (old_sort_column, old_sort_type);
if (old_sort_type != (yn ? SORT_ASCENDING : SORT_DESCENDING)) {
changed = true;
}
reset_sort_direction (yn);
RefPtr<Action> act;
if (a) {
if (yn) {
act = ActionManager::get_action (X_("RegionList"), X_("SortAscending"));
} else {
act = ActionManager::get_action (X_("RegionList"), X_("SortDescending"));
@ -1373,18 +1393,29 @@ EditorRegions::set_state (const XMLNode & node)
p = node.property (X_("show-all"));
if (p) {
bool const s = string_is_affirmative (p->value ());
set_full (s);
toggle_full_action()->set_active (s);
bool const yn = string_is_affirmative (p->value ());
if (expanded != yn) {
changed = true;
}
set_full (yn);
toggle_full_action()->set_active (yn);
}
p = node.property (X_("show-automatic-regions"));
if (p) {
bool const s = string_is_affirmative (p->value ());
_show_automatic_regions = s;
redisplay ();
toggle_show_auto_regions_action()->set_active (s);
}
bool const yn = string_is_affirmative (p->value ());
if (yn != _show_automatic_regions) {
_show_automatic_regions = yn;
toggle_show_auto_regions_action()->set_active (yn);
/* no need to set changed because the above toggle
will have triggered a redisplay
*/
}
}
if (changed) {
redisplay ();
}
}
RefPtr<RadioAction>

View File

@ -176,6 +176,7 @@ private:
PBD::ScopedConnection check_new_region_connection;
bool ignore_region_list_selection_change;
bool ignore_selected_region_change;
bool expanded;
};
#endif /* __gtk_ardour_editor_regions_h__ */

View File

@ -151,6 +151,7 @@ public:
uint32_t count_regions_at (framepos_t);
RegionList* regions_touched (framepos_t start, framepos_t end);
RegionList* regions_to_read (framepos_t start, framepos_t end);
uint32_t region_use_count (boost::shared_ptr<Region>) const;
boost::shared_ptr<Region> find_region (const PBD::ID&) const;
boost::shared_ptr<Region> top_region_at (framepos_t frame);
boost::shared_ptr<Region> top_unmuted_region_at (framepos_t frame);

View File

@ -51,6 +51,7 @@ public:
boost::shared_ptr<Playlist> by_name (std::string name);
boost::shared_ptr<Playlist> by_id (const PBD::ID&);
uint32_t source_use_count (boost::shared_ptr<const Source> src) const;
uint32_t region_use_count (boost::shared_ptr<Region> region) const;
template<class T> void foreach (T *obj, void (T::*func)(boost::shared_ptr<Playlist>));
void get (std::vector<boost::shared_ptr<Playlist> >&);
void unassigned (std::list<boost::shared_ptr<Playlist> > & list);

View File

@ -2712,6 +2712,21 @@ Playlist::find_region (const ID& id) const
return boost::shared_ptr<Region> ();
}
uint32_t
Playlist::region_use_count (boost::shared_ptr<Region> r) const
{
RegionLock rlock (const_cast<Playlist*> (this));
uint32_t cnt = 0;
for (RegionList::const_iterator i = regions.begin(); i != regions.end(); ++i) {
if ((*i) == r) {
cnt++;
}
}
return cnt;
}
boost::shared_ptr<Region>
Playlist::region_by_id (const ID& id) const
{

View File

@ -4024,3 +4024,4 @@ Session::step_edit_status_change (bool yn)
}
}

View File

@ -413,3 +413,20 @@ SessionPlaylists::find_crossfade (const PBD::ID& id)
return boost::shared_ptr<Crossfade> ();
}
uint32_t
SessionPlaylists::region_use_count (boost::shared_ptr<Region> region) const
{
Glib::Mutex::Lock lm (lock);
uint32_t cnt = 0;
for (List::iterator i = playlists.begin(); i != playlists.end(); ++i) {
cnt += (*i)->region_use_count (region);
}
for (List::iterator i = unused_playlists.begin(); i != unused_playlists.end(); ++i) {
cnt += (*i)->region_use_count (region);
}
return cnt;
}