#include "ardour/audioregion.h"
#include "ardour/audiofilesource.h"
+#include "ardour/region_factory.h"
+#include "ardour/session.h"
#include "ardour/silentfilesource.h"
-#include "ardour/session_region.h"
#include "ardour/profile.h"
-#include <gtkmm2ext/stop_signal.h>
-
#include "editor.h"
#include "editing.h"
#include "keyboard.h"
#include "region_view.h"
#include "utils.h"
#include "editor_regions.h"
+#include "editor_drag.h"
#include "i18n.h"
tv_col->add_attribute(renderer->property_text(), _columns.name);
tv_col->add_attribute(renderer->property_foreground_gdk(), _columns.color_);
+ CellRendererToggle* locked_cell = dynamic_cast<CellRendererToggle*> (_display.get_column_cell_renderer (7));
+ locked_cell->property_activatable() = true;
+ locked_cell->signal_toggled().connect (sigc::mem_fun (*this, &EditorRegions::locked_changed));
+ TreeViewColumn* locked_col = _display.get_column (7);
+ locked_col->add_attribute (locked_cell->property_visible(), _columns.property_toggles_visible);
+
+ CellRendererToggle* glued_cell = dynamic_cast<CellRendererToggle*> (_display.get_column_cell_renderer (8));
+ glued_cell->property_activatable() = true;
+ glued_cell->signal_toggled().connect (sigc::mem_fun (*this, &EditorRegions::glued_changed));
+ TreeViewColumn* glued_col = _display.get_column (8);
+ glued_col->add_attribute (glued_cell->property_visible(), _columns.property_toggles_visible);
+
+ CellRendererToggle* muted_cell = dynamic_cast<CellRendererToggle*> (_display.get_column_cell_renderer (9));
+ muted_cell->property_activatable() = true;
+ muted_cell->signal_toggled().connect (sigc::mem_fun (*this, &EditorRegions::muted_changed));
+ TreeViewColumn* muted_col = _display.get_column (9);
+ muted_col->add_attribute (muted_cell->property_visible(), _columns.property_toggles_visible);
+
+ CellRendererToggle* opaque_cell = dynamic_cast<CellRendererToggle*> (_display.get_column_cell_renderer (10));
+ opaque_cell->property_activatable() = true;
+ opaque_cell->signal_toggled().connect (sigc::mem_fun (*this, &EditorRegions::opaque_changed));
+ TreeViewColumn* opaque_col = _display.get_column (10);
+ opaque_col->add_attribute (opaque_cell->property_visible(), _columns.property_toggles_visible);
+
_display.get_selection()->set_mode (SELECTION_MULTIPLE);
_display.add_object_drag (_columns.region.index(), "regions");
_scroller.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC);
_display.signal_key_press_event().connect (sigc::mem_fun(*this, &EditorRegions::key_press));
- _display.signal_key_release_event().connect (sigc::mem_fun(*this, &EditorRegions::key_release));
_display.signal_button_press_event().connect (sigc::mem_fun(*this, &EditorRegions::button_press), false);
- _display.signal_button_release_event().connect (sigc::mem_fun(*this, &EditorRegions::button_release));
_change_connection = _display.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &EditorRegions::selection_changed));
// _display.signal_popup_menu().connect (sigc::bind (sigc::mem_fun (*this, &Editor::show__display_context_menu), 1, 0));
//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, ui_bind (&EditorRegions::update_row, this, _1), gui_context());
-
+ 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());
}
void
EditorRegions::set_session (ARDOUR::Session* s)
{
- EditorComponent::set_session (s);
-
- if (_session) {
- _session->RegionsAdded.connect (_session_connections, ui_bind (&EditorRegions::handle_new_regions, this, _1), gui_context());
- _session->RegionRemoved.connect (_session_connections, ui_bind (&EditorRegions::handle_region_removed, this, _1), gui_context());
- _session->RegionHiddenChange.connect (_session_connections, ui_bind (&EditorRegions::region_hidden, this, _1), gui_context());
- }
-
- redisplay ();
-}
-
-void
-EditorRegions::handle_region_removed (boost::weak_ptr<Region> wregion)
-{
- ENSURE_GUI_THREAD (*this, &EditorRegions::handle_region_removed, wregion)
-
+ SessionHandlePtr::set_session (s);
redisplay ();
}
void
-EditorRegions::handle_new_regions (vector<boost::weak_ptr<Region> >& v)
-{
- ENSURE_GUI_THREAD (*this, &EditorRegions::handle_new_regions, v)
- add_regions (v);
-}
-
-void
-EditorRegions::region_hidden_weak (boost::weak_ptr<Region> wr)
+EditorRegions::add_regions (vector<boost::shared_ptr<Region> >& regions)
{
- boost::shared_ptr<Region> r (wr.lock());
-
- if (r) {
- region_hidden (r);
- }
-}
-
-void
-EditorRegions::region_hidden (boost::shared_ptr<Region> r)
-{
- ENSURE_GUI_THREAD (*this, &EditorRegions::region_hidden, r)
- redisplay ();
-}
-
-
-void
-EditorRegions::add_regions (vector<boost::weak_ptr<Region> >& regions)
-{
- for (vector<boost::weak_ptr<Region> >::iterator x = regions.begin(); x != regions.end(); ++x) {
- boost::shared_ptr<Region> region ((*x).lock());
- if (region) {
- add_region (region);
- }
+ for (vector<boost::shared_ptr<Region> >::iterator x = regions.begin(); x != regions.end(); ++x) {
+ add_region (*x);
}
}
row[_columns.name] = str;
row[_columns.region] = region;
+ row[_columns.property_toggles_visible] = false;
if (missing_source) {
row[_columns.path] = _("(MISSING) ") + region->source()->name();
if (!found_parent) {
row = *(_model->append());
}
+
+ row[_columns.property_toggles_visible] = true;
}
row[_columns.region] = region;
populate_row(region, (*row));
}
-
void
-EditorRegions::region_changed (PropertyChange what_changed, boost::weak_ptr<Region> region)
+EditorRegions::region_changed (boost::shared_ptr<Region> r, const PropertyChange& what_changed)
{
- ENSURE_GUI_THREAD (*this, &EditorRegions::region_changed, what_changed, region)
-
- boost::shared_ptr<Region> r = region.lock ();
-
- if (!r) {
- return;
- }
-
- if (what_changed & ARDOUR::NameChanged) {
- /* find the region in our model and change its name */
+ if (what_changed.contains (ARDOUR::Properties::name) ||
+ what_changed.contains (ARDOUR::Properties::start) ||
+ what_changed.contains (ARDOUR::Properties::position) ||
+ what_changed.contains (ARDOUR::Properties::length) ||
+ what_changed.contains (ARDOUR::Properties::locked) ||
+ what_changed.contains (ARDOUR::Properties::position_lock_style) ||
+ what_changed.contains (ARDOUR::Properties::muted) ||
+ what_changed.contains (ARDOUR::Properties::opaque)) {
+
+ /* find the region in our model and update its row */
TreeModel::Children rows = _model->children ();
TreeModel::iterator i = rows.begin ();
while (i != rows.end ()) {
}
if (j != children.end()) {
- (*j)[_columns.name] = r->name ();
- break;
+ populate_row (r, *j);
}
++i;
}
}
+
+ if (what_changed.contains (ARDOUR::Properties::hidden)) {
+ redisplay ();
+ }
}
void
} else {
_change_connection.block (true);
- cerr << "\tpush to region selection\n";
_editor->set_selected_regionview_from_region_list (region, Selection::Add);
_change_connection.block (false);
boost::shared_ptr<Region> compared_region = (*i)[_columns.region];
if (r == compared_region) {
- cerr << "\tpush into region list\n";
_display.get_selection()->select(*i);
break;
}
if (!(*i).children().empty()) {
- cerr << "\tlook for " << r->name() << " among children of " << (compared_region ? compared_region->name() : string ("NO REGION")) << endl;
if (set_selected_in_subrow(r, (*i), 2)) {
break;
}
*/
tmp_region_list.clear();
- _session->foreach_region (this, &EditorRegions::insert_into_tmp_regionlist);
+
+ const RegionFactory::RegionMap& regions (RegionFactory::regions());
+ for (RegionFactory::RegionMap::const_iterator i = regions.begin(); i != regions.end(); ++i) {
+ insert_into_tmp_regionlist (i->second);
+ }
for (list<boost::shared_ptr<Region> >::iterator r = tmp_region_list.begin(); r != tmp_region_list.end(); ++r) {
add_region (*r);
boost::shared_ptr<Region> region = (*i)[_columns.region];
if (!region->automatic()) {
- cerr << "level 1 : Updating " << region->name() << "\n";
populate_row(region, (*i));
}
boost::shared_ptr<Region> region = (*i)[_columns.region];
if (!region->automatic()) {
- cerr << "level " << level << " : Updating " << region->name() << "\n";
populate_row(region, (*i));
}
break;
case AudioClock::Frames:
- snprintf (start_str, sizeof (start_str), "%u", region->position());
- snprintf (end_str, sizeof (end_str), "%u", (region->position() + region->length() - 1));
- snprintf (length_str, sizeof (length_str), "%u", region->length());
- snprintf (sync_str, sizeof (sync_str), "%u", region->sync_position() + region->position());
+ snprintf (start_str, sizeof (start_str), "%" PRId64, region->position());
+ snprintf (end_str, sizeof (end_str), "%" PRId64, (region->last_frame()));
+ snprintf (length_str, sizeof (length_str), "%" PRId64, region->length());
+ snprintf (sync_str, sizeof (sync_str), "%" PRId64, region->sync_position() + region->position());
if (audioRegion && !fades_in_seconds) {
snprintf (fadein_str, sizeof (fadein_str), "%u", uint (audioRegion->fade_in()->back()->when));
row[_columns.locked] = region->locked();
- if (region->positional_lock_style() == Region::MusicTime) {
+ if (region->position_lock_style() == MusicTime) {
row[_columns.glued] = true;
} else {
row[_columns.glued] = false;
Glib::RefPtr<Action> act;
+ _hide_action = ActionManager::get_action (X_("RegionList"), X_("rlHide"));
+ _show_action = ActionManager::get_action (X_("RegionList"), X_("rlShow"));
+
act = ActionManager::get_action (X_("RegionList"), X_("rlShowAll"));
if (act) {
_toggle_full_action = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
ActionManager::set_sensitive (ActionManager::region_list_selection_sensitive_actions, false);
}
+ /* Enable the "Show" option if any selected regions are hidden, and vice versa for "Hide" */
+
+ bool have_shown = false;
+ bool have_hidden = false;
+
+ TreeView::Selection::ListHandle_Path rows = _display.get_selection()->get_selected_rows ();
+ for (TreeView::Selection::ListHandle_Path::iterator i = rows.begin(); i != rows.end(); ++i) {
+ TreeIter t = _model->get_iter (*i);
+ boost::shared_ptr<Region> r = (*t)[_columns.region];
+ if (r) {
+ if (r->hidden ()) {
+ have_hidden = true;
+ } else {
+ have_shown = true;
+ }
+ }
+ }
+
+ _hide_action->set_sensitive (have_shown);
+ _show_action->set_sensitive (have_hidden);
+
_menu->popup (button, time);
}
return false;
}
-bool
-EditorRegions::key_release (GdkEventKey* ev)
-{
- switch (ev->keyval) {
- case GDK_Delete:
- remove_region ();
- return true;
- break;
- default:
- break;
- }
-
- return false;
-}
bool
EditorRegions::button_press (GdkEventButton *ev)
if (Keyboard::is_context_menu_event (ev)) {
show_context_menu (ev->button, ev->time);
- return true;
+ return false;
}
if (region != 0 && Keyboard::is_button2_event (ev)) {
return false;
}
-bool
-EditorRegions::button_release (GdkEventButton *ev)
-{
- TreeIter iter;
- TreeModel::Path path;
- TreeViewColumn* column;
- int cellx;
- int celly;
- boost::shared_ptr<Region> region;
-
- if (_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
- if ((iter = _model->get_iter (path))) {
- region = (*iter)[_columns.region];
- }
- }
-
- if (region && Keyboard::is_delete_event (ev)) {
- _session->remove_region_from_region_list (region);
- return true;
- }
-
- return false;
-}
-
int
EditorRegions::sorter (TreeModel::iterator a, TreeModel::iterator b)
{
}
-void
-EditorRegions::remove_region ()
-{
- selection_mapover (sigc::mem_fun (*_editor, &Editor::remove_a_region));
-}
-
void
EditorRegions::drag_data_received (const RefPtr<Gdk::DragContext>& context,
int x, int y,
vector<ustring> paths;
if (data.get_target() == "GTK_TREE_MODEL_ROW") {
+ /* something is being dragged over the region list */
+ _editor->_drags->abort ();
_display.on_drag_data_received (context, x, y, data, info, time);
return;
}
}
+/** @return Region that has been dragged out of the list, or 0 */
boost::shared_ptr<Region>
EditorRegions::get_dragged_region ()
{
list<boost::shared_ptr<Region> > regions;
TreeView* source;
_display.get_object_drag_data (regions, &source);
+
+ if (regions.empty()) {
+ return boost::shared_ptr<Region> ();
+ }
+
assert (regions.size() == 1);
return regions.front ();
}
return (*iter)[_columns.region];
}
+
+void
+EditorRegions::locked_changed (Glib::ustring const & path)
+{
+ TreeIter i = _model->get_iter (path);
+ if (i) {
+ boost::shared_ptr<ARDOUR::Region> region = (*i)[_columns.region];
+ if (region) {
+ region->set_locked (!(*i)[_columns.locked]);
+ }
+ }
+}
+
+void
+EditorRegions::glued_changed (Glib::ustring const & path)
+{
+ TreeIter i = _model->get_iter (path);
+ if (i) {
+ boost::shared_ptr<ARDOUR::Region> region = (*i)[_columns.region];
+ if (region) {
+ /* `glued' means MusicTime, and we're toggling here */
+ region->set_position_lock_style ((*i)[_columns.glued] ? AudioTime : MusicTime);
+ }
+ }
+
+}
+
+void
+EditorRegions::muted_changed (Glib::ustring const & path)
+{
+ TreeIter i = _model->get_iter (path);
+ if (i) {
+ boost::shared_ptr<ARDOUR::Region> region = (*i)[_columns.region];
+ if (region) {
+ region->set_muted (!(*i)[_columns.muted]);
+ }
+ }
+
+}
+
+void
+EditorRegions::opaque_changed (Glib::ustring const & path)
+{
+ TreeIter i = _model->get_iter (path);
+ if (i) {
+ boost::shared_ptr<ARDOUR::Region> region = (*i)[_columns.region];
+ if (region) {
+ region->set_opaque (!(*i)[_columns.opaque]);
+ }
+ }
+
+}