(Source List) Region List rewrite (gtk2 part)

See:  https://docs.google.com/document/d/1sI7p9RoRVZtNx2n67RvBa0_16fuZblV_lNkkKN2g93s/edit?usp=sharing
This commit is contained in:
Ben Loftis 2018-11-15 09:24:37 -06:00
parent 3e6ce20fd7
commit b1019bbbf6
9 changed files with 306 additions and 1182 deletions

View File

@ -702,26 +702,6 @@
<popup name='RegionListMenu' accelerators='true'>
<menuitem action='rlAudition'/>
<menuitem action='rlHide'/>
<menuitem action='rlShow'/>
<separator/>
<menuitem action='rlShowAll'/>
<menuitem action='rlShowAuto'/>
<menu name='Sort' action='RegionListSort'>
<menuitem action='SortAscending'/>
<menuitem action='SortDescending'/>
<separator/>
<menuitem action='SortByRegionName'/>
<menuitem action='SortByRegionLength'/>
<menuitem action='SortByRegionPosition'/>
<menuitem action='SortByRegionTimestamp'/>
<menuitem action='SortByRegionStartinFile'/>
<menuitem action='SortByRegionEndinFile'/>
<menuitem action='SortBySourceFileName'/>
<menuitem action='SortBySourceFileLength'/>
<menuitem action='SortBySourceFileCreationDate'/>
<menuitem action='SortBySourceFilesystem'/>
</menu>
<separator/>
<menuitem action='addExternalAudioToRegionList'/>
<separator/>

View File

@ -2465,14 +2465,8 @@ Editor::set_state (const XMLNode& node, int version)
set_stationary_playhead (yn);
}
RegionListSortType sort_type;
if (node.get_property ("region-list-sort-type", sort_type)) {
_regions->reset_sort_type (sort_type, true);
}
if (node.get_property ("show-editor-mixer", yn)) {
yn = false;
node.get_property ("show-editor-mixer", yn);
{
Glib::RefPtr<ToggleAction> tact = ActionManager::get_toggle_action (X_("Editor"), X_("show-editor-mixer"));
/* do it twice to force the change */
tact->set_active (!yn);
@ -2582,7 +2576,6 @@ Editor::get_state ()
node->set_property ("maximised", _maximised);
node->set_property ("follow-playhead", _follow_playhead);
node->set_property ("stationary-playhead", _stationary_playhead);
node->set_property ("region-list-sort-type", _regions->sort_type ());
node->set_property ("mouse-mode", mouse_mode);
node->set_property ("join-object-range", smart_mode_action->get_active ());
@ -5720,18 +5713,6 @@ Editor::audition_region_from_region_list ()
_regions->selection_mapover (sigc::mem_fun (*this, &Editor::consider_auditioning));
}
void
Editor::hide_region_from_region_list ()
{
_regions->selection_mapover (sigc::mem_fun (*this, &Editor::hide_a_region));
}
void
Editor::show_region_in_region_list ()
{
_regions->selection_mapover (sigc::mem_fun (*this, &Editor::show_a_region));
}
void
Editor::step_edit_status_change (bool yn)
{

View File

@ -1283,8 +1283,6 @@ private:
void define_one_bar (samplepos_t start, samplepos_t end);
void audition_region_from_region_list ();
void hide_region_from_region_list ();
void show_region_in_region_list ();
void naturalize_region ();

View File

@ -667,47 +667,10 @@ Editor::register_actions ()
RadioAction::Group sort_order_group;
/* the region list popup menu */
ActionManager::register_action (rl_actions, X_("RegionListSort"), _("Sort"));
act = ActionManager::register_action (rl_actions, X_("rlAudition"), _("Audition"), sigc::mem_fun(*this, &Editor::audition_region_from_region_list));
act = myactions.register_action (rl_actions, X_("rlAudition"), _("Audition"), sigc::mem_fun(*this, &Editor::audition_region_from_region_list));
ActionManager::region_list_selection_sensitive_actions.push_back (act);
act = ActionManager::register_action (rl_actions, X_("rlHide"), _("Hide"), sigc::mem_fun(*this, &Editor::hide_region_from_region_list));
ActionManager::region_list_selection_sensitive_actions.push_back (act);
act = ActionManager::register_action (rl_actions, X_("rlShow"), _("Show"), sigc::mem_fun(*this, &Editor::show_region_in_region_list));
ActionManager::region_list_selection_sensitive_actions.push_back (act);
ActionManager::register_toggle_action (rl_actions, X_("rlShowAll"), _("Show All"), sigc::mem_fun(*_regions, &EditorRegions::toggle_full));
ActionManager::register_toggle_action (rl_actions, X_("rlShowAuto"), _("Show Automatic Regions"), sigc::mem_fun (*_regions, &EditorRegions::toggle_show_auto_regions));
ActionManager::register_radio_action (rl_actions, sort_order_group, X_("SortAscending"), _("Ascending"),
sigc::bind (sigc::mem_fun (*_regions, &EditorRegions::reset_sort_direction), true));
ActionManager::register_radio_action (rl_actions, sort_order_group, X_("SortDescending"), _("Descending"),
sigc::bind (sigc::mem_fun (*_regions, &EditorRegions::reset_sort_direction), false));
ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionName"), _("By Region Name"),
sigc::bind (sigc::mem_fun (*_regions, &EditorRegions::reset_sort_type), ByName, false));
ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionLength"), _("By Region Length"),
sigc::bind (sigc::mem_fun (*_regions, &EditorRegions::reset_sort_type), ByLength, false));
ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionPosition"), _("By Region Position"),
sigc::bind (sigc::mem_fun (*_regions, &EditorRegions::reset_sort_type), ByPosition, false));
ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionTimestamp"), _("By Region Timestamp"),
sigc::bind (sigc::mem_fun (*_regions, &EditorRegions::reset_sort_type), ByTimestamp, false));
ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionStartinFile"), _("By Region Start in File"),
sigc::bind (sigc::mem_fun (*_regions, &EditorRegions::reset_sort_type), ByStartInFile, false));
ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionEndinFile"), _("By Region End in File"),
sigc::bind (sigc::mem_fun (*_regions, &EditorRegions::reset_sort_type), ByEndInFile, false));
ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFileName"), _("By Source File Name"),
sigc::bind (sigc::mem_fun (*_regions, &EditorRegions::reset_sort_type), BySourceFileName, false));
ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFileLength"), _("By Source File Length"),
sigc::bind (sigc::mem_fun (*_regions, &EditorRegions::reset_sort_type), BySourceFileLength, false));
ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFileCreationDate"), _("By Source File Creation Date"),
sigc::bind (sigc::mem_fun (*_regions, &EditorRegions::reset_sort_type), BySourceFileCreationDate, false));
ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFilesystem"), _("By Source Filesystem"),
sigc::bind (sigc::mem_fun (*_regions, &EditorRegions::reset_sort_type), BySourceFileFS, false));
ActionManager::register_action (rl_actions, X_("removeUnusedRegions"), _("Remove Unused"), sigc::mem_fun (*_regions, &EditorRegions::remove_unused_regions));
myactions.register_action (rl_actions, X_("removeUnusedRegions"), _("Remove Unused"), sigc::mem_fun (*_regions, &EditorRegions::remove_unused_regions));
act = reg_sens (editor_actions, X_("addExistingPTFiles"), _("Import PT session"), sigc::mem_fun (*this, &Editor::external_pt_dialog));
ActionManager::write_sensitive_actions.push_back (act);

View File

@ -48,6 +48,7 @@
#include "editor_drag.h"
#include "midi_time_axis.h"
#include "editor_regions.h"
#include "editor_sources.h"
#include "ui_config.h"
#include "verbose_cursor.h"
@ -1114,6 +1115,7 @@ Editor::canvas_note_event (GdkEvent *event, ArdourCanvas::Item* item)
bool
Editor::canvas_drop_zone_event (GdkEvent* event)
{
printf("canvas_drop_zone_event\n");
GdkEventScroll scroll;
ArdourCanvas::Duple winpos;
@ -1167,6 +1169,8 @@ Editor::track_canvas_drag_motion (Glib::RefPtr<Gdk::DragContext> const& context,
return false;
}
printf("DRAGGING: track_canvas_drag_motion\n");
event.type = GDK_MOTION_NOTIFY;
event.button.x = x;
event.button.y = y;
@ -1197,6 +1201,10 @@ Editor::track_canvas_drag_motion (Glib::RefPtr<Gdk::DragContext> const& context,
if (can_drop) {
region = _regions->get_dragged_region ();
if (!region) {
boost::shared_ptr<ARDOUR::Source> src = _sources->get_dragged_source ();
region = RegionFactory::get_whole_region_for_source (src);
}
if (region) {
@ -1267,6 +1275,11 @@ Editor::drop_regions (const Glib::RefPtr<Gdk::DragContext>& /*context*/,
samplepos_t const pos = window_event_sample (&event, &px, &py);
boost::shared_ptr<Region> region = _regions->get_dragged_region ();
if (!region) {
boost::shared_ptr<ARDOUR::Source> src = _sources->get_dragged_source ();
region = RegionFactory::get_whole_region_for_source (src);
}
if (!region) { return; }
RouteTimeAxisView* rtav = 0;

File diff suppressed because it is too large Load Diff

View File

@ -41,20 +41,12 @@ public:
void clear ();
void toggle_full ();
void toggle_show_auto_regions ();
void reset_sort_direction (bool);
void reset_sort_type (Editing::RegionListSortType, bool);
void set_selected (RegionSelection &);
void selection_mapover (sigc::slot<void,boost::shared_ptr<ARDOUR::Region> >);
boost::shared_ptr<ARDOUR::Region> get_dragged_region ();
boost::shared_ptr<ARDOUR::Region> get_single_selection ();
Editing::RegionListSortType sort_type () const {
return _sort_type;
}
void redisplay ();
void suspend_redisplay () {
@ -84,9 +76,8 @@ private:
struct Columns : public Gtk::TreeModel::ColumnRecord {
Columns () {
add (name);
add (region);
add (color_);
add (position);
add (take_id);
add (start);
add (end);
add (length);
add (sync);
@ -96,15 +87,16 @@ private:
add (glued);
add (muted);
add (opaque);
add (used);
add (path);
add (property_toggles_visible);
add (region);
add (color_);
add (position);
}
Gtk::TreeModelColumn<std::string> name;
Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Region> > region;
Gtk::TreeModelColumn<Gdk::Color> color_;
Gtk::TreeModelColumn<std::string> position;
Gtk::TreeModelColumn<std::string> take_id;
Gtk::TreeModelColumn<samplepos_t> position;
Gtk::TreeModelColumn<std::string> start;
Gtk::TreeModelColumn<std::string> end;
Gtk::TreeModelColumn<std::string> length;
Gtk::TreeModelColumn<std::string> sync;
@ -114,10 +106,9 @@ private:
Gtk::TreeModelColumn<bool> glued;
Gtk::TreeModelColumn<bool> muted;
Gtk::TreeModelColumn<bool> opaque;
Gtk::TreeModelColumn<std::string> used;
Gtk::TreeModelColumn<std::string> path;
/** used to indicate whether the locked/glued/muted/opaque should be visible or not */
Gtk::TreeModelColumn<bool> property_toggles_visible;
Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Region> > region;
Gtk::TreeModelColumn<Gdk::Color> color_;
};
Columns _columns;
@ -153,23 +144,22 @@ private:
void show_context_menu (int button, int time);
int sorter (Gtk::TreeModel::iterator, Gtk::TreeModel::iterator);
void format_position (ARDOUR::samplepos_t pos, char* buf, size_t bufsize, bool onoff = true);
void add_region (boost::shared_ptr<ARDOUR::Region>);
void destroy_region (boost::shared_ptr<ARDOUR::Region>);
void populate_row (boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const &, PBD::PropertyChange const &);
void populate_row_used (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
void populate_row_position (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
void populate_row_end (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
void populate_row_sync (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
void populate_row_fade_in (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used, boost::shared_ptr<ARDOUR::AudioRegion>);
void populate_row_fade_out (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used, boost::shared_ptr<ARDOUR::AudioRegion>);
void populate_row_locked (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
void populate_row_muted (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
void populate_row_glued (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
void populate_row_opaque (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
void populate_row_used (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_position (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_end (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_sync (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_fade_in (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, boost::shared_ptr<ARDOUR::AudioRegion>);
void populate_row_fade_out (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, boost::shared_ptr<ARDOUR::AudioRegion>);
void populate_row_locked (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_muted (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_glued (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_opaque (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_length (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_name (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_source (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
@ -177,20 +167,11 @@ private:
void update_row (boost::shared_ptr<ARDOUR::Region>);
void update_all_rows ();
void insert_into_tmp_regionlist (boost::shared_ptr<ARDOUR::Region>);
void drag_data_received (
Glib::RefPtr<Gdk::DragContext> const &, gint, gint, Gtk::SelectionData const &, guint, guint
);
Glib::RefPtr<Gtk::RadioAction> sort_type_action (Editing::RegionListSortType) const;
void set_full (bool);
Glib::RefPtr<Gtk::Action> hide_action () const;
Glib::RefPtr<Gtk::Action> show_action () const;
Glib::RefPtr<Gtk::Action> remove_unused_regions_action () const;
Glib::RefPtr<Gtk::ToggleAction> toggle_full_action () const;
Glib::RefPtr<Gtk::ToggleAction> toggle_show_auto_regions_action () const;
Gtk::Menu* _menu;
Gtk::ScrolledWindow _scroller;
@ -200,28 +181,17 @@ private:
Glib::RefPtr<Gtk::TreeStore> _model;
bool _show_automatic_regions;
bool ignore_region_list_selection_change;
bool ignore_selected_region_change;
bool _no_redisplay;
Editing::RegionListSortType _sort_type;
std::list<boost::shared_ptr<ARDOUR::Region> > tmp_region_list;
typedef boost::unordered_map<boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::iterator> RegionRowMap;
typedef boost::unordered_map<std::string, Gtk::TreeModel::RowReference > RegionSourceMap;
RegionRowMap region_row_map;
RegionSourceMap parent_regions_sources_map;
PBD::ScopedConnection region_property_connection;
PBD::ScopedConnection check_new_region_connection;
PBD::ScopedConnection editor_freeze_connection;
PBD::ScopedConnection editor_thaw_connection;
bool expanded;
};
#endif /* __gtk_ardour_editor_regions_h__ */

View File

@ -77,11 +77,7 @@ struct ColumnInfo {
EditorSources::EditorSources (Editor* e)
: EditorComponent (e)
, old_focus (0)
, name_editable (0)
, _menu (0)
, ignore_region_list_selection_change (false)
, ignore_selected_region_change (false)
, _sort_type ((Editing::RegionListSortType) 0)
, _selection (0)
{
_display.set_size_request (100, -1);
@ -95,7 +91,6 @@ EditorSources::EditorSources (Editor* e)
_display.set_data ("mouse-edits-require-mod1", (gpointer) 0x1);
_model = TreeStore::create (_columns);
_model->set_sort_func (0, sigc::mem_fun (*this, &EditorSources::sorter));
_model->set_sort_column (0, SORT_ASCENDING);
/* column widths */
@ -110,18 +105,22 @@ EditorSources::EditorSources (Editor* e)
TreeViewColumn* col_name = manage (new TreeViewColumn ("", _columns.name));
col_name->set_fixed_width (bbt_width*2);
col_name->set_sizing (TREE_VIEW_COLUMN_FIXED);
TreeViewColumn* col_nat_pos = manage (new TreeViewColumn ("", _columns.natural_pos));
col_nat_pos->set_fixed_width (bbt_width);
col_nat_pos->set_sizing (TREE_VIEW_COLUMN_FIXED);
col_name->set_sort_column(0);
TreeViewColumn* col_take_id = manage (new TreeViewColumn ("", _columns.take_id));
col_take_id->set_fixed_width (date_width);
col_take_id->set_sizing (TREE_VIEW_COLUMN_FIXED);
col_take_id->set_sort_column(1);
TreeViewColumn* col_nat_pos = manage (new TreeViewColumn ("", _columns.natural_pos));
col_nat_pos->set_fixed_width (bbt_width);
col_nat_pos->set_sizing (TREE_VIEW_COLUMN_FIXED);
col_nat_pos->set_sort_column(6);
TreeViewColumn* col_path = manage (new TreeViewColumn ("", _columns.path));
col_path->set_fixed_width (bbt_width);
col_path->set_sizing (TREE_VIEW_COLUMN_FIXED);
col_path->set_sort_column(3);
_display.append_column (*col_name);
_display.append_column (*col_take_id);
@ -134,7 +133,7 @@ EditorSources::EditorSources (Editor* e)
ColumnInfo ci[] = {
{ 0, _("Source"), _("Source name, with number of channels in []'s") },
{ 1, _("Take ID"), _("Take ID") },
{ 2, _("Nat Pos"), _("Natural Position of the file on timeline") },
{ 2, _("Orig Pos"), _("Original Position of the file on timeline, when it was recorded") },
{ 3, _("Path"), _("Path (folder) of the file locationlosition of end of region") },
{ -1, 0, 0 }
};
@ -151,11 +150,6 @@ EditorSources::EditorSources (Editor* e)
_display.set_headers_visible (true);
_display.set_rules_hint ();
CellRendererText* source_name_cell = dynamic_cast<CellRendererText*>(_display.get_column_cell_renderer (0));
source_name_cell->property_editable() = true;
source_name_cell->signal_edited().connect (sigc::mem_fun (*this, &EditorSources::name_edit));
source_name_cell->signal_editing_started().connect (sigc::mem_fun (*this, &EditorSources::name_editing_started));
_display.get_selection()->set_select_function (sigc::mem_fun (*this, &EditorSources::selection_filter));
//set the color of the name field
@ -163,7 +157,14 @@ EditorSources::EditorSources (Editor* e)
CellRendererText* renderer = dynamic_cast<CellRendererText*>(_display.get_column_cell_renderer (0));
tv_col->add_attribute(renderer->property_text(), _columns.name);
tv_col->add_attribute(renderer->property_foreground_gdk(), _columns.color_);
// tv_col->set_expand (true);
//right-align the Natural Pos column
TreeViewColumn* nat_col = _display.get_column(2);
nat_col->set_alignment (ALIGN_RIGHT);
renderer = dynamic_cast<CellRendererText*>(_display.get_column_cell_renderer (2));
if (renderer) {
renderer->property_xalign() = ( ALIGN_RIGHT );
}
//the PATH field should expand when the pane is opened wider
tv_col = _display.get_column(3);
@ -172,7 +173,7 @@ EditorSources::EditorSources (Editor* e)
tv_col->set_expand (true);
_display.get_selection()->set_mode (SELECTION_MULTIPLE);
_display.add_object_drag (_columns.source.index(), "sources");
_display.add_object_drag (_columns.source.index(), "regions");
_display.set_drag_column (_columns.name.index());
/* setup DnD handling */
@ -219,8 +220,6 @@ EditorSources::focus_in (GdkEventFocus*)
old_focus = 0;
}
name_editable = 0;
/* try to do nothing on focus in (doesn't work, hence selection_count nonsense) */
return true;
}
@ -233,18 +232,12 @@ EditorSources::focus_out (GdkEventFocus*)
old_focus = 0;
}
name_editable = 0;
return false;
}
bool
EditorSources::enter_notify (GdkEventCrossing*)
{
if (name_editable) {
return true;
}
/* arm counter so that ::selection_filter() will deny selecting anything for the
next two attempts to change selection status.
*/
@ -355,8 +348,11 @@ EditorSources::populate_row (TreeModel::Row row, boost::shared_ptr<ARDOUR::Sourc
row[_columns.take_id] = source->take_id();
//Natural Position
//note: this format changes to follow master clock. see populate_row_position
//Natural Position (samples, an invisible column for sorting)
row[_columns.natural_s] = source->natural_position();
//Natural Position (text representation)
char buf[64];
snprintf(buf, 16, "--" );
if (source->natural_position() > 0) {
@ -427,12 +423,7 @@ EditorSources::source_changed (boost::shared_ptr<ARDOUR::Source> source)
void
EditorSources::selection_changed ()
{
/*
* if (ignore_region_list_selection_change) {
return;
}
_editor->_region_selection_change_updates_region_list = false;
// _editor->_region_selection_change_updates_region_list = false;
if (_display.get_selection()->count_selected_rows() > 0) {
@ -445,17 +436,18 @@ EditorSources::selection_changed ()
if ((iter = _model->get_iter (*i))) {
boost::shared_ptr<Region> region = (*iter)[_columns.region];
boost::shared_ptr<ARDOUR::Source> source = (*iter)[_columns.source];
if (source) {
// they could have clicked on a row that is just a placeholder, like "Hidden"
// although that is not allowed by our selection filter. check it anyway
// since we need a region ptr.
set<boost::shared_ptr<Region> > regions;
RegionFactory::get_regions_using_source ( source, regions );
if (region) {
_change_connection.block (true);
_editor->set_selected_regionview_from_region_list (region, Selection::Add);
_change_connection.block (false);
for (set<boost::shared_ptr<Region> >::iterator region = regions.begin(); region != regions.end(); region++ ) {
_change_connection.block (true);
_editor->set_selected_regionview_from_region_list (*region, Selection::Add);
_change_connection.block (false);
}
}
}
@ -464,46 +456,18 @@ EditorSources::selection_changed ()
_editor->get_selection().clear_regions ();
}
_editor->_region_selection_change_updates_region_list = true;
*/
}
void
EditorSources::update_row (boost::shared_ptr<Region> region)
{
/* if (!region || !_session) {
return;
}
RegionRowMap::iterator it;
it = region_row_map.find (region);
if (it != region_row_map.end()){
PropertyChange c;
TreeModel::iterator j = _model->get_iter ((*it).second.get_path());
populate_row(region, (*j), c);
}
*/
// _editor->_region_selection_change_updates_region_list = true;
}
void
EditorSources::update_all_rows ()
{
/*
* if (!_session) {
return;
TreeModel::iterator i;
TreeModel::Children rows = _model->children();
for (i = rows.begin(); i != rows.end(); ++i) {
boost::shared_ptr<ARDOUR::Source> ss = (*i)[_columns.source];
populate_row(*i, ss);
}
RegionRowMap::iterator i;
for (i = region_row_map.begin(); i != region_row_map.end(); ++i) {
TreeModel::iterator j = _model->get_iter ((*i).second.get_path());
boost::shared_ptr<Region> region = (*j)[_columns.region];
}
**/
}
void
@ -575,110 +539,6 @@ EditorSources::format_position (samplepos_t pos, char* buf, size_t bufsize, bool
}
}
void
EditorSources::populate_row (boost::shared_ptr<Region> region, TreeModel::Row const &row, PBD::PropertyChange const &what_changed)
{
/*
* boost::shared_ptr<AudioRegion> audioregion = boost::dynamic_pointer_cast<AudioRegion>(region);
//uint32_t used = _session->playlists->region_use_count (region);
uint32_t used = 1;
PropertyChange c;
const bool all = what_changed == c;
if (all || what_changed.contains (Properties::position)) {
populate_row_position (region, row, used);
}
if (all || what_changed.contains (Properties::start) || what_changed.contains (Properties::sync_position)) {
populate_row_sync (region, row, used);
}
if (all || what_changed.contains (Properties::fade_in)) {
populate_row_fade_in (region, row, used, audioregion);
}
if (all || what_changed.contains (Properties::fade_out)) {
populate_row_fade_out (region, row, used, audioregion);
}
if (all || what_changed.contains (Properties::locked)) {
populate_row_locked (region, row, used);
}
if (all || what_changed.contains (Properties::position_lock_style)) {
populate_row_glued (region, row, used);
}
if (all || what_changed.contains (Properties::muted)) {
populate_row_muted (region, row, used);
}
if (all || what_changed.contains (Properties::opaque)) {
populate_row_opaque (region, row, used);
}
if (all || what_changed.contains (Properties::length)) {
populate_row_end (region, row, used);
populate_row_length (region, row);
}
if (all) {
populate_row_source (region, row);
}
if (all || what_changed.contains (Properties::name)) {
populate_row_name (region, row);
}
if (all) {
populate_row_used (region, row, used);
}
*/
}
#if 0
if (audioRegion && fades_in_seconds) {
samplepos_t left;
int mins;
int millisecs;
left = audioRegion->fade_in()->back()->when;
mins = (int) floor (left / (_session->sample_rate() * 60.0f));
left -= (samplepos_t) floor (mins * _session->sample_rate() * 60.0f);
millisecs = (int) floor ((left * 1000.0f) / _session->sample_rate());
if (audioRegion->fade_in()->back()->when >= _session->sample_rate()) {
sprintf (fadein_str, "%01dM %01dmS", mins, millisecs);
} else {
sprintf (fadein_str, "%01dmS", millisecs);
}
left = audioRegion->fade_out()->back()->when;
mins = (int) floor (left / (_session->sample_rate() * 60.0f));
left -= (samplepos_t) floor (mins * _session->sample_rate() * 60.0f);
millisecs = (int) floor ((left * 1000.0f) / _session->sample_rate());
if (audioRegion->fade_out()->back()->when >= _session->sample_rate()) {
sprintf (fadeout_str, "%01dM %01dmS", mins, millisecs);
} else {
sprintf (fadeout_str, "%01dmS", millisecs);
}
}
#endif
void
EditorSources::populate_row_name (boost::shared_ptr<Region> region, TreeModel::Row const &row)
{
/* if (region->n_channels() > 1) {
row[_columns.name] = string_compose("%1 [%2]", Gtkmm2ext::markup_escape_text (region->name()), region->n_channels());
} else {
row[_columns.name] = Gtkmm2ext::markup_escape_text (region->name());
}
*/
}
void
EditorSources::populate_row_source (boost::shared_ptr<Region> region, TreeModel::Row const &row)
{
/* if (boost::dynamic_pointer_cast<SilentFileSource>(region->source())) {
row[_columns.path] = _("MISSING ") + Gtkmm2ext::markup_escape_text (region->source()->name());
} else {
row[_columns.path] = Gtkmm2ext::markup_escape_text (region->source()->name());
}
*/
}
void
EditorSources::show_context_menu (int button, int time)
{
@ -688,7 +548,7 @@ EditorSources::show_context_menu (int button, int time)
bool
EditorSources::key_press (GdkEventKey* ev)
{
return false;
}
bool
@ -715,23 +575,6 @@ EditorSources::button_press (GdkEventButton *ev)
return false;
}
int
EditorSources::sorter (TreeModel::iterator a, TreeModel::iterator b)
{
}
void
EditorSources::reset_sort_type (RegionListSortType type, bool force)
{
}
void
EditorSources::reset_sort_direction (bool up)
{
}
void
EditorSources::selection_mapover (sigc::slot<void,boost::shared_ptr<Region> > sl)
{
@ -751,26 +594,23 @@ EditorSources::drag_data_received (const RefPtr<Gdk::DragContext>& context,
bool
EditorSources::selection_filter (const RefPtr<TreeModel>& model, const TreeModel::Path& path, bool already_selected)
{
}
void
EditorSources::name_editing_started (CellEditable* ce, const Glib::ustring& path)
{
}
void
EditorSources::name_edit (const std::string& path, const std::string& new_text)
{
return true;
}
/** @return Region that has been dragged out of the list, or 0 */
boost::shared_ptr<Region>
EditorSources::get_dragged_region ()
boost::shared_ptr<ARDOUR::Source>
EditorSources::get_dragged_source ()
{
list<boost::shared_ptr<ARDOUR::Source> > sources;
TreeView* source;
_display.get_object_drag_data (sources, &source);
if (sources.empty()) {
return boost::shared_ptr<ARDOUR::Source> ();
}
assert (sources.size() == 1);
return sources.front ();
}
void
@ -781,10 +621,26 @@ EditorSources::clear ()
_display.set_model (_model);
}
boost::shared_ptr<Region>
boost::shared_ptr<ARDOUR::Source>
EditorSources::get_single_selection ()
{
Glib::RefPtr<TreeSelection> selected = _display.get_selection();
if (selected->count_selected_rows() != 1) {
return boost::shared_ptr<ARDOUR::Source> ();
}
TreeView::Selection::ListHandle_Path rows = selected->get_selected_rows ();
/* only one row selected, so rows.begin() is it */
TreeIter iter = _model->get_iter (*rows.begin());
if (!iter) {
return boost::shared_ptr<ARDOUR::Source> ();
}
return (*iter)[_columns.source];
}
void
@ -806,11 +662,7 @@ EditorSources::get_state () const
{
XMLNode* node = new XMLNode (X_("SourcesList"));
node->set_property (X_("sort-type"), _sort_type);
RefPtr<Action> act = ActionManager::get_action (X_("SourcesList"), X_("SortAscending"));
bool const ascending = RefPtr<RadioAction>::cast_dynamic(act)->get_active ();
node->set_property (X_("sort-ascending"), ascending);
//TODO: save sort state?
return *node;
}
@ -820,105 +672,6 @@ EditorSources::set_state (const XMLNode & node)
{
bool changed = false;
if (node.name() != X_("SourcesList")) {
return;
}
Editing::RegionListSortType t;
if (node.get_property (X_("sort-type"), t)) {
if (_sort_type != t) {
changed = true;
}
reset_sort_type (t, true);
RefPtr<RadioAction> ract = sort_type_action (t);
ract->set_active ();
}
bool yn;
if (node.get_property (X_("sort-ascending"), yn)) {
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 (yn) {
act = ActionManager::get_action (X_("SourcesList"), X_("SortAscending"));
} else {
act = ActionManager::get_action (X_("SourcesList"), X_("SortDescending"));
}
RefPtr<RadioAction>::cast_dynamic(act)->set_active ();
}
}
RefPtr<RadioAction>
EditorSources::sort_type_action (Editing::RegionListSortType t) const
{
const char* action = 0;
switch (t) {
case Editing::ByName:
action = X_("SortByRegionName");
break;
case Editing::ByLength:
action = X_("SortByRegionLength");
break;
case Editing::ByPosition:
action = X_("SortByRegionPosition");
break;
case Editing::ByTimestamp:
action = X_("SortByRegionTimestamp");
break;
case Editing::ByStartInFile:
action = X_("SortByRegionStartinFile");
break;
case Editing::ByEndInFile:
action = X_("SortByRegionEndinFile");
break;
case Editing::BySourceFileName:
action = X_("SortBySourceFileName");
break;
case Editing::BySourceFileLength:
action = X_("SortBySourceFileLength");
break;
case Editing::BySourceFileCreationDate:
action = X_("SortBySourceFileCreationDate");
break;
case Editing::BySourceFileFS:
action = X_("SortBySourceFilesystem");
break;
default:
fatal << string_compose (_("programming error: %1: %2"), "EditorSources: impossible sort type", (int) t) << endmsg;
abort(); /*NOTREACHED*/
}
RefPtr<Action> act = ActionManager::get_action (X_("RegionList"), action);
assert (act);
return RefPtr<RadioAction>::cast_dynamic (act);
}
RefPtr<Action>
EditorSources::hide_action () const
{
return ActionManager::get_action (X_("SourcesList"), X_("rlHide"));
}
RefPtr<Action>
EditorSources::show_action () const
{
return ActionManager::get_action (X_("SourcesList"), X_("rlShow"));
}
RefPtr<Action>

View File

@ -45,16 +45,10 @@ public:
void clear ();
void reset_sort_direction (bool);
void reset_sort_type (Editing::RegionListSortType, bool);
void selection_mapover (sigc::slot<void,boost::shared_ptr<ARDOUR::Region> >);
boost::shared_ptr<ARDOUR::Region> get_dragged_region ();
boost::shared_ptr<ARDOUR::Region> get_single_selection ();
Editing::RegionListSortType sort_type () const {
return _sort_type;
}
boost::shared_ptr<ARDOUR::Source> get_dragged_source ();
boost::shared_ptr<ARDOUR::Source> get_single_selection ();
void block_change_connection (bool b) {
_change_connection.block (b);
@ -74,11 +68,12 @@ private:
struct Columns : public Gtk::TreeModel::ColumnRecord {
Columns () {
add (name);
add (source);
add (color_);
add (take_id);
add (natural_pos);
add (path);
add (take_id);
add (color_);
add (source);
add (natural_s);
}
Gtk::TreeModelColumn<std::string> name;
@ -87,6 +82,7 @@ private:
Gtk::TreeModelColumn<std::string> natural_pos;
Gtk::TreeModelColumn<std::string> path;
Gtk::TreeModelColumn<std::string> take_id;
Gtk::TreeModelColumn<samplepos_t> natural_s;
};
Columns _columns;
@ -104,10 +100,6 @@ private:
bool selection_filter (const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::Path& path, bool yn);
Gtk::Widget* old_focus;
Gtk::CellEditable* name_editable;
void name_editing_started (Gtk::CellEditable*, const Glib::ustring&);
void name_edit (const std::string&, const std::string&);
bool key_press (GdkEventKey *);
bool button_press (GdkEventButton *);
@ -119,53 +111,27 @@ private:
void show_context_menu (int button, int time);
int sorter (Gtk::TreeModel::iterator, Gtk::TreeModel::iterator);
void format_position (ARDOUR::samplepos_t pos, char* buf, size_t bufsize, bool onoff = true);
void add_source (boost::shared_ptr<ARDOUR::Source>);
void remove_source (boost::shared_ptr<ARDOUR::Source>);
void populate_row (boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const &, PBD::PropertyChange const &);
void populate_row_name (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_source (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void update_row (boost::shared_ptr<ARDOUR::Region>);
void update_all_rows ();
void insert_into_tmp_regionlist (boost::shared_ptr<ARDOUR::Region>);
void drag_data_received (
Glib::RefPtr<Gdk::DragContext> const &, gint, gint, Gtk::SelectionData const &, guint, guint
);
Glib::RefPtr<Gtk::RadioAction> sort_type_action (Editing::RegionListSortType) const;
Glib::RefPtr<Gtk::Action> hide_action () const;
Glib::RefPtr<Gtk::Action> show_action () const;
Glib::RefPtr<Gtk::Action> remove_unused_regions_action () const;
Glib::RefPtr<Gtk::Action> remove_unused_regions_action () const; //TODO: what is the equivalent?
Gtk::Menu* _menu;
Gtk::ScrolledWindow _scroller;
Gtk::Frame _frame;
Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Region> > _display;
Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Source> > _display; //TODO .. try changing this to region
Glib::RefPtr<Gtk::TreeStore> _model;
bool ignore_region_list_selection_change;
bool ignore_selected_region_change;
Editing::RegionListSortType _sort_type;
std::list<boost::shared_ptr<ARDOUR::Region> > tmp_region_list;
typedef boost::unordered_map<boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::RowReference> RegionRowMap;
typedef boost::unordered_map<std::string, Gtk::TreeModel::RowReference > RegionSourceMap;
RegionRowMap region_row_map;
RegionSourceMap parent_regions_sources_map;
PBD::ScopedConnection source_property_connection;
PBD::ScopedConnection source_added_connection;