2022-01-17 20:55:43 -05:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2009-2012 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2009-2018 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2013-2021 Robin Gareus <robin@gareus.org>
|
|
|
|
* Copyright (C) 2015-2016 Tim Mayberry <mojofunk@gmail.com>
|
|
|
|
* Copyright (C) 2016 Nick Mainsbridge <mainsbridge@gmail.com>
|
|
|
|
* Copyright (C) 2018-2019 Ben Loftis <ben@harrisonconsoles.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <string>
|
|
|
|
|
2022-01-18 19:59:05 -05:00
|
|
|
#include "pbd/file_utils.h"
|
|
|
|
|
2022-01-17 20:55:43 -05:00
|
|
|
#include "ardour/audiofilesource.h"
|
|
|
|
#include "ardour/audioregion.h"
|
2022-01-18 19:59:05 -05:00
|
|
|
#include "ardour/midi_source.h"
|
2022-01-17 20:55:43 -05:00
|
|
|
#include "ardour/region_factory.h"
|
|
|
|
#include "ardour/session.h"
|
2022-01-18 19:59:05 -05:00
|
|
|
#include "ardour/session_directory.h"
|
2022-01-17 20:55:43 -05:00
|
|
|
#include "ardour/session_playlist.h"
|
|
|
|
#include "ardour/silentfilesource.h"
|
2022-01-18 19:59:05 -05:00
|
|
|
#include "ardour/smf_source.h"
|
2022-01-17 20:55:43 -05:00
|
|
|
|
2022-08-10 23:11:52 -04:00
|
|
|
#include "gtkmm2ext/colors.h"
|
2023-06-12 17:34:54 -04:00
|
|
|
#include "gtkmm2ext/keyboard.h"
|
2022-01-17 20:55:43 -05:00
|
|
|
#include "gtkmm2ext/treeutils.h"
|
|
|
|
#include "gtkmm2ext/utils.h"
|
|
|
|
|
|
|
|
#include "widgets/tooltips.h"
|
|
|
|
|
|
|
|
#include "actions.h"
|
|
|
|
#include "ardour_ui.h"
|
|
|
|
#include "gui_thread.h"
|
|
|
|
#include "keyboard.h"
|
|
|
|
#include "main_clock.h"
|
2022-01-18 23:05:57 -05:00
|
|
|
#include "public_editor.h"
|
2022-01-17 20:55:43 -05:00
|
|
|
#include "region_list_base.h"
|
|
|
|
#include "ui_config.h"
|
2023-08-26 07:30:44 -04:00
|
|
|
#include "utils.h"
|
2022-01-17 20:55:43 -05:00
|
|
|
|
|
|
|
#include "pbd/i18n.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace ARDOUR_UI_UTILS;
|
|
|
|
using namespace PBD;
|
|
|
|
using namespace Gtk;
|
|
|
|
using namespace Temporal;
|
|
|
|
|
|
|
|
using Gtkmm2ext::Keyboard;
|
|
|
|
|
|
|
|
RegionListBase::RegionListBase ()
|
|
|
|
: _name_editable (0)
|
|
|
|
, _tags_editable (0)
|
|
|
|
, _old_focus (0)
|
|
|
|
, _no_redisplay (false)
|
|
|
|
{
|
|
|
|
_display.set_size_request (100, -1);
|
|
|
|
_display.set_rules_hint (true);
|
|
|
|
_display.set_name ("RegionList");
|
|
|
|
_display.set_fixed_height_mode (true);
|
|
|
|
_display.set_reorderable (false);
|
|
|
|
|
|
|
|
_model = TreeStore::create (_columns);
|
|
|
|
_model->set_sort_column (0, SORT_ASCENDING);
|
|
|
|
|
2022-01-18 23:05:57 -05:00
|
|
|
_display.add_object_drag (-1, "x-ardour/region.pbdid", Gtk::TARGET_SAME_APP);
|
2022-01-18 00:52:57 -05:00
|
|
|
_display.set_drag_column (_columns.name.index ());
|
2022-01-18 23:05:57 -05:00
|
|
|
_display.signal_drag_begin ().connect (sigc::mem_fun (*this, &RegionListBase::drag_begin));
|
|
|
|
_display.signal_drag_end ().connect (sigc::mem_fun (*this, &RegionListBase::drag_end));
|
2022-01-18 00:52:57 -05:00
|
|
|
_display.signal_drag_data_get ().connect (sigc::mem_fun (*this, &RegionListBase::drag_data_get));
|
|
|
|
|
2022-01-17 20:55:43 -05:00
|
|
|
_display.set_model (_model);
|
|
|
|
|
|
|
|
_display.set_headers_visible (true);
|
|
|
|
_display.set_rules_hint ();
|
|
|
|
|
|
|
|
if (UIConfiguration::instance ().get_use_tooltips ()) {
|
|
|
|
/* show path as the row tooltip */
|
|
|
|
_display.set_tooltip_column (13); /* path */
|
|
|
|
}
|
|
|
|
|
|
|
|
_display.get_selection ()->set_mode (SELECTION_MULTIPLE);
|
|
|
|
|
|
|
|
_scroller.add (_display);
|
|
|
|
_scroller.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC);
|
|
|
|
|
|
|
|
_display.signal_button_press_event ().connect (sigc::mem_fun (*this, &RegionListBase::button_press), false);
|
|
|
|
_display.signal_enter_notify_event ().connect (sigc::mem_fun (*this, &RegionListBase::enter_notify), false);
|
|
|
|
_display.signal_leave_notify_event ().connect (sigc::mem_fun (*this, &RegionListBase::leave_notify), false);
|
|
|
|
_scroller.signal_focus_in_event ().connect (sigc::mem_fun (*this, &RegionListBase::focus_in), false);
|
|
|
|
_scroller.signal_focus_out_event ().connect (sigc::mem_fun (*this, &RegionListBase::focus_out));
|
|
|
|
_scroller.signal_key_press_event ().connect (sigc::mem_fun (*this, &RegionListBase::key_press), false);
|
|
|
|
|
|
|
|
ARDOUR_UI::instance ()->primary_clock->mode_changed.connect (sigc::mem_fun (*this, &RegionListBase::clock_format_changed));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2022-12-15 12:04:55 -05:00
|
|
|
RegionListBase::setup_col (TreeViewColumn* col, int sort_idx, Gtk::AlignmentEnum al, const char* label, const char* tooltip, bool require_mod_to_edit)
|
2022-01-17 20:55:43 -05:00
|
|
|
{
|
|
|
|
/* add the label */
|
|
|
|
Gtk::Label* l = manage (new Label (label));
|
|
|
|
l->set_alignment (al);
|
|
|
|
ArdourWidgets::set_tooltip (*l, tooltip);
|
|
|
|
col->set_widget (*l);
|
|
|
|
l->show ();
|
|
|
|
|
|
|
|
col->set_sort_column (sort_idx);
|
|
|
|
col->set_expand (false);
|
|
|
|
|
|
|
|
/* this sets the alignment of the column header... */
|
|
|
|
col->set_alignment (al);
|
|
|
|
|
|
|
|
/* ...and this sets the alignment for the data cells */
|
2022-01-26 17:01:44 -05:00
|
|
|
CellRendererText* renderer = dynamic_cast<CellRendererText*> (col->get_first_cell ());
|
2022-01-17 20:55:43 -05:00
|
|
|
if (renderer) {
|
2022-01-26 16:20:26 -05:00
|
|
|
renderer->property_xalign () = (al == ALIGN_END ? 1.0 : (al == ALIGN_START ? 0.0 : 0.5));
|
2022-01-17 20:55:43 -05:00
|
|
|
}
|
2022-12-15 12:04:55 -05:00
|
|
|
if (require_mod_to_edit) {
|
|
|
|
/* Try to prevent single mouse presses from initiating edits.
|
|
|
|
* This relies on a hack in gtktreeview.c:gtk_treeview_button_press() */
|
|
|
|
col->set_data ("mouse-edits-require-mod1", (gpointer)0x1);
|
|
|
|
}
|
2022-01-17 20:55:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RegionListBase::setup_toggle (Gtk::TreeViewColumn* tvc, sigc::slot<void, std::string> cb)
|
|
|
|
{
|
2022-01-26 17:01:44 -05:00
|
|
|
CellRendererToggle* tc = dynamic_cast<CellRendererToggle*> (tvc->get_first_cell ());
|
2022-01-17 20:55:43 -05:00
|
|
|
tc->property_activatable () = true;
|
|
|
|
tc->signal_toggled ().connect (cb);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RegionListBase::add_name_column ()
|
|
|
|
{
|
|
|
|
TreeViewColumn* tvc = append_col (_columns.name, 120);
|
2022-12-15 12:04:55 -05:00
|
|
|
setup_col (tvc, 0, ALIGN_START, _("Name"), ("Region name"), true);
|
2022-01-17 20:55:43 -05:00
|
|
|
|
2022-10-17 13:14:05 -04:00
|
|
|
tvc->set_resizable (true);
|
|
|
|
|
2022-01-17 20:55:43 -05:00
|
|
|
/* Region Name: make editable */
|
2022-01-26 17:01:44 -05:00
|
|
|
CellRendererText* region_name_cell = dynamic_cast<CellRendererText*> (tvc->get_first_cell ());
|
2022-01-17 20:55:43 -05:00
|
|
|
region_name_cell->property_editable () = true;
|
|
|
|
region_name_cell->signal_edited ().connect (sigc::mem_fun (*this, &RegionListBase::name_edit));
|
|
|
|
region_name_cell->signal_editing_started ().connect (sigc::mem_fun (*this, &RegionListBase::name_editing_started));
|
2023-06-12 17:34:54 -04:00
|
|
|
region_name_cell->signal_editing_canceled ().connect (sigc::mem_fun (*this, &RegionListBase::name_editing_canceled));
|
2022-01-17 20:55:43 -05:00
|
|
|
/* Region Name: color turns red if source is missing. */
|
|
|
|
tvc->add_attribute (region_name_cell->property_text (), _columns.name);
|
|
|
|
tvc->add_attribute (region_name_cell->property_foreground_gdk (), _columns.color_);
|
|
|
|
tvc->set_expand (true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RegionListBase::add_tag_column ()
|
|
|
|
{
|
|
|
|
TreeViewColumn* tvc = append_col (_columns.tags, "2099-10-10 10:10:30");
|
2022-01-26 16:19:32 -05:00
|
|
|
setup_col (tvc, 2, ALIGN_START, _("Tags"), _("Tags"));
|
2022-01-17 20:55:43 -05:00
|
|
|
|
|
|
|
/* Tags cell: make editable */
|
2022-01-26 17:01:44 -05:00
|
|
|
CellRendererText* region_tags_cell = dynamic_cast<CellRendererText*> (tvc->get_first_cell ());
|
2022-01-17 20:55:43 -05:00
|
|
|
region_tags_cell->property_editable () = true;
|
|
|
|
region_tags_cell->signal_edited ().connect (sigc::mem_fun (*this, &RegionListBase::tag_edit));
|
|
|
|
region_tags_cell->signal_editing_started ().connect (sigc::mem_fun (*this, &RegionListBase::tag_editing_started));
|
2023-06-12 17:34:54 -04:00
|
|
|
region_tags_cell->signal_editing_canceled ().connect (sigc::mem_fun (*this, &RegionListBase::tag_editing_canceled));
|
2022-01-17 20:55:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
RegionListBase::focus_in (GdkEventFocus*)
|
|
|
|
{
|
|
|
|
Window* win = dynamic_cast<Window*> (_scroller.get_toplevel ());
|
|
|
|
|
|
|
|
if (win) {
|
|
|
|
_old_focus = win->get_focus ();
|
|
|
|
} else {
|
|
|
|
_old_focus = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
_tags_editable = 0;
|
|
|
|
_name_editable = 0;
|
|
|
|
|
|
|
|
/* try to do nothing on focus in (doesn't work, hence selection_count nonsense) */
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
RegionListBase::focus_out (GdkEventFocus*)
|
|
|
|
{
|
|
|
|
if (_old_focus) {
|
|
|
|
_old_focus->grab_focus ();
|
|
|
|
_old_focus = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
_tags_editable = 0;
|
|
|
|
_name_editable = 0;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
RegionListBase::enter_notify (GdkEventCrossing*)
|
|
|
|
{
|
|
|
|
if (_name_editable || _tags_editable) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Keyboard::magic_widget_grab_focus ();
|
2023-06-12 17:34:54 -04:00
|
|
|
|
2022-01-17 20:55:43 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2023-06-12 17:34:54 -04:00
|
|
|
RegionListBase::leave_notify (GdkEventCrossing* ev)
|
2022-01-17 20:55:43 -05:00
|
|
|
{
|
|
|
|
if (_old_focus) {
|
|
|
|
_old_focus->grab_focus ();
|
|
|
|
_old_focus = 0;
|
|
|
|
}
|
2023-06-12 17:34:54 -04:00
|
|
|
|
|
|
|
if (ev->detail != GDK_NOTIFY_INFERIOR && ev->detail != GDK_NOTIFY_ANCESTOR) {
|
|
|
|
Keyboard::magic_widget_drop_focus ();
|
|
|
|
}
|
|
|
|
|
2022-01-17 20:55:43 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-01-18 23:05:57 -05:00
|
|
|
void
|
|
|
|
RegionListBase::drag_begin (Glib::RefPtr<Gdk::DragContext> const&)
|
|
|
|
{
|
|
|
|
if (_display.get_selection ()->count_selected_rows () == 0) {
|
|
|
|
PublicEditor::instance ().pbdid_dragged_dt = DataType::NIL;
|
|
|
|
}
|
|
|
|
TreeView::Selection::ListHandle_Path rows = _display.get_selection ()->get_selected_rows ();
|
|
|
|
for (TreeView::Selection::ListHandle_Path::iterator i = rows.begin (); i != rows.end (); ++i) {
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Region> region = (*_model->get_iter (*i))[_columns.region];
|
2022-01-18 23:05:57 -05:00
|
|
|
PublicEditor::instance ().pbdid_dragged_dt = region->data_type ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RegionListBase::drag_end (Glib::RefPtr<Gdk::DragContext> const&)
|
|
|
|
{
|
|
|
|
PublicEditor::instance ().pbdid_dragged_dt = DataType::NIL;
|
|
|
|
}
|
|
|
|
|
2022-01-18 00:52:57 -05:00
|
|
|
void
|
|
|
|
RegionListBase::drag_data_get (Glib::RefPtr<Gdk::DragContext> const&, Gtk::SelectionData& data, guint, guint)
|
|
|
|
{
|
|
|
|
if (data.get_target () != "x-ardour/region.pbdid") {
|
|
|
|
return;
|
|
|
|
}
|
2022-01-18 23:05:57 -05:00
|
|
|
TreeView::Selection::ListHandle_Path rows = _display.get_selection ()->get_selected_rows ();
|
|
|
|
for (TreeView::Selection::ListHandle_Path::iterator i = rows.begin (); i != rows.end (); ++i) {
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Region> region = (*_model->get_iter (*i))[_columns.region];
|
2022-01-18 23:05:57 -05:00
|
|
|
data.set (data.get_target (), region->id ().to_s ());
|
|
|
|
break;
|
2022-01-18 00:52:57 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-17 20:55:43 -05:00
|
|
|
void
|
|
|
|
RegionListBase::set_session (ARDOUR::Session* s)
|
|
|
|
{
|
|
|
|
SessionHandlePtr::set_session (s);
|
|
|
|
|
|
|
|
if (!s) {
|
|
|
|
clear ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ARDOUR::Region::RegionsPropertyChanged.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&RegionListBase::regions_changed, this, _1, _2), gui_context ());
|
|
|
|
ARDOUR::RegionFactory::CheckNewRegion.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&RegionListBase::add_region, this, _1), gui_context ());
|
|
|
|
|
|
|
|
redisplay ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-02-16 18:33:28 -05:00
|
|
|
RegionListBase::remove_weak_region (std::weak_ptr<ARDOUR::Region> r)
|
2022-01-17 20:55:43 -05:00
|
|
|
{
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<ARDOUR::Region> region = r.lock ();
|
2022-01-18 19:59:05 -05:00
|
|
|
if (!region) {
|
2022-01-17 20:55:43 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-01-18 19:59:05 -05:00
|
|
|
RegionRowMap::iterator map_it = region_row_map.find (region);
|
|
|
|
if (map_it != region_row_map.end ()) {
|
|
|
|
Gtk::TreeModel::iterator r_it = map_it->second;
|
|
|
|
region_row_map.erase (map_it);
|
|
|
|
_model->erase (r_it);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2023-02-16 18:33:28 -05:00
|
|
|
RegionListBase::list_region (std::shared_ptr<ARDOUR::Region> region) const
|
2022-01-18 19:59:05 -05:00
|
|
|
{
|
2022-01-17 20:55:43 -05:00
|
|
|
/* whole-file regions are shown in the Source List */
|
2022-01-18 19:59:05 -05:00
|
|
|
return !region->whole_file ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-02-16 18:33:28 -05:00
|
|
|
RegionListBase::add_region (std::shared_ptr<Region> region)
|
2022-01-18 19:59:05 -05:00
|
|
|
{
|
|
|
|
if (!region || !_session || !list_region (region)) {
|
2022-01-17 20:55:43 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we only show files-on-disk.
|
|
|
|
* if there's some other kind of region, we ignore it (for now)
|
|
|
|
*/
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<FileSource> fs = std::dynamic_pointer_cast<FileSource> (region->source ());
|
2022-01-18 19:59:05 -05:00
|
|
|
if (!fs) {
|
2022-01-17 20:55:43 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-01-18 19:59:05 -05:00
|
|
|
if (fs->empty ()) {
|
|
|
|
/* MIDI sources are allowed to be empty */
|
2023-02-16 18:33:28 -05:00
|
|
|
if (!std::dynamic_pointer_cast<MidiSource> (region->source ())) {
|
2022-01-18 19:59:05 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (region->whole_file ()) {
|
2023-02-16 18:33:28 -05:00
|
|
|
region->DropReferences.connect (_remove_region_connections, MISSING_INVALIDATOR, boost::bind (&RegionListBase::remove_weak_region, this, std::weak_ptr<Region> (region)), gui_context ());
|
2022-01-18 19:59:05 -05:00
|
|
|
}
|
|
|
|
|
2022-01-17 20:55:43 -05:00
|
|
|
PropertyChange pc;
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<RegionList> rl (new RegionList);
|
2022-01-17 20:55:43 -05:00
|
|
|
rl->push_back (region);
|
|
|
|
regions_changed (rl, pc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-02-16 18:33:28 -05:00
|
|
|
RegionListBase::regions_changed (std::shared_ptr<RegionList> rl, const PropertyChange& what_changed)
|
2022-01-17 20:55:43 -05:00
|
|
|
{
|
|
|
|
bool freeze = rl->size () > 2;
|
|
|
|
if (freeze) {
|
|
|
|
freeze_tree_model ();
|
|
|
|
}
|
|
|
|
for (RegionList::const_iterator i = rl->begin (); i != rl->end (); ++i) {
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Region> r = *i;
|
2022-01-17 20:55:43 -05:00
|
|
|
|
2022-01-18 19:59:05 -05:00
|
|
|
RegionRowMap::iterator map_it = region_row_map.find (r);
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<ARDOUR::Playlist> pl = r->playlist ();
|
2022-01-17 20:55:43 -05:00
|
|
|
|
2022-01-18 19:59:05 -05:00
|
|
|
bool is_on_active_playlist = pl && _session && _session->playlist_is_active (pl);
|
|
|
|
|
|
|
|
if (!((is_on_active_playlist || r->whole_file ()) && list_region (r))) {
|
2022-01-17 20:55:43 -05:00
|
|
|
/* this region is not on an active playlist
|
|
|
|
* maybe it got deleted, or whatever */
|
|
|
|
if (map_it != region_row_map.end ()) {
|
2022-01-18 19:59:05 -05:00
|
|
|
Gtk::TreeModel::iterator r_it = map_it->second;
|
2022-01-17 20:55:43 -05:00
|
|
|
region_row_map.erase (map_it);
|
2022-01-18 19:59:05 -05:00
|
|
|
_model->erase (r_it);
|
2022-01-17 20:55:43 -05:00
|
|
|
}
|
2023-05-29 12:05:34 -04:00
|
|
|
continue;
|
2022-01-17 20:55:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (map_it != region_row_map.end ()) {
|
|
|
|
/* found the region, update its row properties */
|
|
|
|
TreeModel::Row row = *(map_it->second);
|
|
|
|
populate_row (r, row, what_changed);
|
|
|
|
} else {
|
|
|
|
/* new region, add it to the list */
|
|
|
|
TreeModel::iterator iter = _model->append ();
|
|
|
|
TreeModel::Row row = *iter;
|
2023-02-16 18:33:28 -05:00
|
|
|
region_row_map.insert (pair<std::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::iterator> (r, iter));
|
2022-01-17 20:55:43 -05:00
|
|
|
|
|
|
|
/* set the properties that don't change */
|
|
|
|
row[_columns.region] = r;
|
|
|
|
|
|
|
|
/* now populate the properties that might change... */
|
|
|
|
populate_row (r, row, PropertyChange ());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (freeze) {
|
|
|
|
thaw_tree_model ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RegionListBase::redisplay ()
|
|
|
|
{
|
|
|
|
if (_no_redisplay || !_session) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* store sort column id and type for later */
|
|
|
|
_model->get_sort_column_id (_sort_col_id, _sort_type);
|
|
|
|
|
2022-01-18 19:59:05 -05:00
|
|
|
_remove_region_connections.drop_connections ();
|
|
|
|
|
2022-01-17 20:55:43 -05:00
|
|
|
_display.set_model (Glib::RefPtr<Gtk::TreeStore> (0));
|
|
|
|
_model->clear ();
|
|
|
|
/* Disable sorting to gain performance */
|
|
|
|
_model->set_sort_column (-2, SORT_ASCENDING);
|
|
|
|
|
|
|
|
region_row_map.clear ();
|
|
|
|
|
|
|
|
RegionFactory::foreach_region (sigc::mem_fun (*this, &RegionListBase::add_region));
|
|
|
|
|
|
|
|
/* re-enabale sorting */
|
|
|
|
_model->set_sort_column (_sort_col_id, _sort_type);
|
|
|
|
_display.set_model (_model);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RegionListBase::clock_format_changed ()
|
|
|
|
{
|
|
|
|
if (!_session) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
PropertyChange change;
|
|
|
|
change.add (ARDOUR::Properties::start);
|
|
|
|
change.add (ARDOUR::Properties::length);
|
|
|
|
change.add (ARDOUR::Properties::sync_position);
|
|
|
|
change.add (ARDOUR::Properties::fade_in);
|
|
|
|
change.add (ARDOUR::Properties::fade_out);
|
|
|
|
|
|
|
|
TreeModel::Children rows = _model->children ();
|
|
|
|
for (TreeModel::iterator i = rows.begin (); i != rows.end (); ++i) {
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<ARDOUR::Region> r = (*i)[_columns.region];
|
2022-01-17 20:55:43 -05:00
|
|
|
populate_row (r, *i, change);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-08-26 07:30:44 -04:00
|
|
|
RegionListBase::format_position (timepos_t const& p, char* buf, size_t bufsize, bool onoff) const
|
2022-01-17 20:55:43 -05:00
|
|
|
{
|
2023-08-26 07:30:44 -04:00
|
|
|
ARDOUR_UI_UTILS::format_position (_session, p, buf, bufsize, onoff);
|
2022-01-17 20:55:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-02-16 18:33:28 -05:00
|
|
|
RegionListBase::populate_row (std::shared_ptr<Region> region, TreeModel::Row const& row, PBD::PropertyChange const& what_changed)
|
2022-01-17 20:55:43 -05:00
|
|
|
{
|
|
|
|
assert (region);
|
|
|
|
|
|
|
|
{
|
|
|
|
Gdk::Color c;
|
2023-02-16 18:33:28 -05:00
|
|
|
bool missing_source = std::dynamic_pointer_cast<SilentFileSource> (region->source ()) != NULL;
|
2022-01-17 20:55:43 -05:00
|
|
|
if (missing_source) {
|
2022-08-10 23:11:52 -04:00
|
|
|
Gtkmm2ext::set_color_from_rgba (c, UIConfiguration::instance ().color ("region list missing source"));
|
2022-01-17 20:55:43 -05:00
|
|
|
} else {
|
2022-08-10 23:11:52 -04:00
|
|
|
Gtkmm2ext::set_color_from_rgba (c, UIConfiguration::instance ().color ("region list whole file"));
|
2022-01-17 20:55:43 -05:00
|
|
|
}
|
|
|
|
row[_columns.color_] = c;
|
|
|
|
}
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<AudioRegion> audioregion = std::dynamic_pointer_cast<AudioRegion> (region);
|
2022-01-17 20:55:43 -05:00
|
|
|
|
|
|
|
PropertyChange c;
|
|
|
|
const bool all = what_changed == c;
|
|
|
|
|
|
|
|
if (all || what_changed.contains (Properties::length)) {
|
|
|
|
populate_row_position (region, row);
|
|
|
|
}
|
|
|
|
if (all || what_changed.contains (Properties::start) || what_changed.contains (Properties::sync_position)) {
|
|
|
|
populate_row_sync (region, row);
|
|
|
|
}
|
|
|
|
if (all || what_changed.contains (Properties::fade_in)) {
|
|
|
|
populate_row_fade_in (region, row, audioregion);
|
|
|
|
}
|
|
|
|
if (all || what_changed.contains (Properties::fade_out)) {
|
|
|
|
populate_row_fade_out (region, row, audioregion);
|
|
|
|
}
|
|
|
|
if (all || what_changed.contains (Properties::locked)) {
|
|
|
|
populate_row_locked (region, row);
|
|
|
|
}
|
|
|
|
if (all || what_changed.contains (Properties::time_domain)) {
|
|
|
|
populate_row_glued (region, row);
|
|
|
|
}
|
|
|
|
if (all || what_changed.contains (Properties::muted)) {
|
|
|
|
populate_row_muted (region, row);
|
|
|
|
}
|
|
|
|
if (all || what_changed.contains (Properties::opaque)) {
|
|
|
|
populate_row_opaque (region, row);
|
|
|
|
}
|
|
|
|
if (all || what_changed.contains (Properties::length)) {
|
|
|
|
populate_row_end (region, row);
|
|
|
|
populate_row_length (region, row);
|
|
|
|
}
|
|
|
|
if (all) {
|
|
|
|
populate_row_source (region, row);
|
|
|
|
}
|
|
|
|
if (all || what_changed.contains (Properties::name) || what_changed.contains (Properties::tags)) {
|
|
|
|
populate_row_name (region, row);
|
|
|
|
}
|
2022-01-18 19:59:05 -05:00
|
|
|
/* CAPTURED DROPOUTS */
|
|
|
|
row[_columns.captd_xruns] = region->source ()->n_captured_xruns ();
|
2022-01-17 20:55:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-02-16 18:33:28 -05:00
|
|
|
RegionListBase::populate_row_length (std::shared_ptr<Region> region, TreeModel::Row const& row)
|
2022-01-17 20:55:43 -05:00
|
|
|
{
|
|
|
|
char buf[16];
|
|
|
|
|
|
|
|
if (ARDOUR_UI::instance ()->primary_clock->mode () == AudioClock::BBT) {
|
|
|
|
TempoMap::SharedPtr map (TempoMap::use ());
|
|
|
|
Temporal::BBT_Time bbt; /* uninitialized until full duration works */
|
|
|
|
// Temporal::BBT_Time bbt = map->bbt_duration_at (region->position(), region->length());
|
|
|
|
snprintf (buf, sizeof (buf), "%03d|%02d|%04d", bbt.bars, bbt.beats, bbt.ticks);
|
|
|
|
} else {
|
|
|
|
format_position (timepos_t (region->length ()), buf, sizeof (buf));
|
|
|
|
}
|
|
|
|
|
|
|
|
row[_columns.length] = buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-02-16 18:33:28 -05:00
|
|
|
RegionListBase::populate_row_end (std::shared_ptr<Region> region, TreeModel::Row const& row)
|
2022-01-17 20:55:43 -05:00
|
|
|
{
|
|
|
|
#ifndef SHOW_REGION_EXTRAS
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (region->last_sample () >= region->first_sample ()) {
|
|
|
|
char buf[16];
|
|
|
|
format_position (region->nt_last (), buf, sizeof (buf));
|
|
|
|
row[_columns.end] = buf;
|
|
|
|
} else {
|
|
|
|
row[_columns.end] = "empty";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-02-16 18:33:28 -05:00
|
|
|
RegionListBase::populate_row_position (std::shared_ptr<Region> region, TreeModel::Row const& row)
|
2022-01-17 20:55:43 -05:00
|
|
|
{
|
|
|
|
row[_columns.position] = region->position ();
|
|
|
|
|
|
|
|
char buf[16];
|
|
|
|
format_position (region->position (), buf, sizeof (buf));
|
|
|
|
row[_columns.start] = buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-02-16 18:33:28 -05:00
|
|
|
RegionListBase::populate_row_sync (std::shared_ptr<Region> region, TreeModel::Row const& row)
|
2022-01-17 20:55:43 -05:00
|
|
|
{
|
|
|
|
#ifndef SHOW_REGION_EXTRAS
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
if (region->sync_position () == region->position ()) {
|
|
|
|
row[_columns.sync] = _("Start");
|
|
|
|
} else if (region->sync_position () == (region->last_sample ())) {
|
|
|
|
row[_columns.sync] = _("End");
|
|
|
|
} else {
|
|
|
|
char buf[16];
|
|
|
|
format_position (region->sync_position (), buf, sizeof (buf));
|
|
|
|
row[_columns.sync] = buf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-02-16 18:33:28 -05:00
|
|
|
RegionListBase::populate_row_fade_in (std::shared_ptr<Region> region, TreeModel::Row const& row, std::shared_ptr<AudioRegion> audioregion)
|
2022-01-17 20:55:43 -05:00
|
|
|
{
|
|
|
|
#ifndef SHOW_REGION_EXTRAS
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
if (!audioregion) {
|
|
|
|
row[_columns.fadein] = "";
|
|
|
|
} else {
|
|
|
|
char buf[32];
|
|
|
|
format_position (audioregion->fade_in ()->back ()->when, buf, sizeof (buf), audioregion->fade_in_active ());
|
|
|
|
row[_columns.fadein] = buf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-02-16 18:33:28 -05:00
|
|
|
RegionListBase::populate_row_fade_out (std::shared_ptr<Region> region, TreeModel::Row const& row, std::shared_ptr<AudioRegion> audioregion)
|
2022-01-17 20:55:43 -05:00
|
|
|
{
|
|
|
|
#ifndef SHOW_REGION_EXTRAS
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
if (!audioregion) {
|
|
|
|
row[_columns.fadeout] = "";
|
|
|
|
} else {
|
|
|
|
char buf[32];
|
|
|
|
format_position (audioregion->fade_out ()->back ()->when, buf, sizeof (buf), audioregion->fade_out_active ());
|
|
|
|
row[_columns.fadeout] = buf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-02-16 18:33:28 -05:00
|
|
|
RegionListBase::populate_row_locked (std::shared_ptr<Region> region, TreeModel::Row const& row)
|
2022-01-17 20:55:43 -05:00
|
|
|
{
|
|
|
|
row[_columns.locked] = region->locked ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-02-16 18:33:28 -05:00
|
|
|
RegionListBase::populate_row_glued (std::shared_ptr<Region> region, TreeModel::Row const& row)
|
2022-01-17 20:55:43 -05:00
|
|
|
{
|
|
|
|
if (region->position_time_domain () == Temporal::BeatTime) {
|
|
|
|
row[_columns.glued] = true;
|
|
|
|
} else {
|
|
|
|
row[_columns.glued] = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-02-16 18:33:28 -05:00
|
|
|
RegionListBase::populate_row_muted (std::shared_ptr<Region> region, TreeModel::Row const& row)
|
2022-01-17 20:55:43 -05:00
|
|
|
{
|
|
|
|
row[_columns.muted] = region->muted ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-02-16 18:33:28 -05:00
|
|
|
RegionListBase::populate_row_opaque (std::shared_ptr<Region> region, TreeModel::Row const& row)
|
2022-01-17 20:55:43 -05:00
|
|
|
{
|
|
|
|
row[_columns.opaque] = region->opaque ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-02-16 18:33:28 -05:00
|
|
|
RegionListBase::populate_row_name (std::shared_ptr<Region> region, TreeModel::Row const& row)
|
2022-01-17 20:55:43 -05:00
|
|
|
{
|
|
|
|
row[_columns.name] = Gtkmm2ext::markup_escape_text (region->name ());
|
|
|
|
|
|
|
|
if (region->data_type () == DataType::MIDI) {
|
|
|
|
row[_columns.channels] = 0; /*TODO: some better recognition of midi regions*/
|
|
|
|
} else {
|
|
|
|
row[_columns.channels] = region->sources ().size ();
|
|
|
|
}
|
|
|
|
|
|
|
|
row[_columns.tags] = region->tags ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-02-16 18:33:28 -05:00
|
|
|
RegionListBase::populate_row_source (std::shared_ptr<Region> region, TreeModel::Row const& row)
|
2022-01-17 20:55:43 -05:00
|
|
|
{
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<ARDOUR::Source> source = region->source ();
|
|
|
|
if (std::dynamic_pointer_cast<SilentFileSource> (source)) {
|
2022-01-18 19:59:05 -05:00
|
|
|
row[_columns.path] = _("MISSING ") + Gtkmm2ext::markup_escape_text (source->name ());
|
|
|
|
} else {
|
|
|
|
row[_columns.path] = Gtkmm2ext::markup_escape_text (source->name ());
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<FileSource> fs = std::dynamic_pointer_cast<FileSource> (source);
|
2022-01-18 19:59:05 -05:00
|
|
|
if (fs) {
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<AudioFileSource> afs = std::dynamic_pointer_cast<AudioFileSource> (source);
|
2022-01-18 19:59:05 -05:00
|
|
|
if (afs) {
|
|
|
|
const string audio_directory = _session->session_directory ().sound_path ();
|
|
|
|
if (!PBD::path_is_within (audio_directory, fs->path ())) {
|
|
|
|
row[_columns.path] = Gtkmm2ext::markup_escape_text (fs->path ());
|
|
|
|
}
|
|
|
|
}
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<SMFSource> mfs = std::dynamic_pointer_cast<SMFSource> (source);
|
2022-01-18 19:59:05 -05:00
|
|
|
if (mfs) {
|
|
|
|
const string midi_directory = _session->session_directory ().midi_path ();
|
|
|
|
if (!PBD::path_is_within (midi_directory, fs->path ())) {
|
|
|
|
row[_columns.path] = Gtkmm2ext::markup_escape_text (fs->path ());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
row[_columns.captd_for] = source->captured_for ();
|
|
|
|
row[_columns.take_id] = source->take_id ();
|
|
|
|
|
|
|
|
/* Natural Position (samples, an invisible column for sorting) */
|
|
|
|
row[_columns.natural_s] = source->natural_position ();
|
|
|
|
|
|
|
|
/* Natural Position (text representation) */
|
|
|
|
if (source->have_natural_position ()) {
|
|
|
|
char buf[64];
|
|
|
|
format_position (source->natural_position (), buf, sizeof (buf));
|
|
|
|
row[_columns.natural_pos] = buf;
|
2022-01-17 20:55:43 -05:00
|
|
|
} else {
|
2022-01-18 19:59:05 -05:00
|
|
|
row[_columns.natural_pos] = X_("--");
|
2022-01-17 20:55:43 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
RegionListBase::key_press (GdkEventKey* ev)
|
|
|
|
{
|
|
|
|
TreeViewColumn* col;
|
|
|
|
|
|
|
|
switch (ev->keyval) {
|
|
|
|
case GDK_Tab:
|
|
|
|
case GDK_ISO_Left_Tab:
|
|
|
|
|
|
|
|
if (_name_editable) {
|
|
|
|
_name_editable->editing_done ();
|
|
|
|
_name_editable = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_tags_editable) {
|
|
|
|
_tags_editable->editing_done ();
|
|
|
|
_tags_editable = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
col = _display.get_column (0); // select&focus on name column
|
|
|
|
|
|
|
|
if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
|
|
|
|
treeview_select_previous (_display, _model, col);
|
|
|
|
} else {
|
|
|
|
treeview_select_next (_display, _model, col);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-06-12 17:34:54 -04:00
|
|
|
void
|
|
|
|
RegionListBase::name_editing_canceled ()
|
|
|
|
{
|
|
|
|
Keyboard::magic_widget_drop_focus ();
|
|
|
|
}
|
|
|
|
|
2022-01-17 20:55:43 -05:00
|
|
|
void
|
|
|
|
RegionListBase::name_editing_started (CellEditable* ce, const Glib::ustring& path)
|
|
|
|
{
|
|
|
|
_name_editable = ce;
|
|
|
|
|
|
|
|
/* give it a special name */
|
|
|
|
|
|
|
|
Gtk::Entry* e = dynamic_cast<Gtk::Entry*> (ce);
|
|
|
|
|
|
|
|
if (e) {
|
|
|
|
e->set_name (X_("RegionNameEditorEntry"));
|
|
|
|
|
|
|
|
TreeIter iter;
|
|
|
|
if ((iter = _model->get_iter (path))) {
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Region> region = (*iter)[_columns.region];
|
2022-01-17 20:55:43 -05:00
|
|
|
|
|
|
|
if (region) {
|
|
|
|
e->set_text (region->name ());
|
2023-06-12 17:34:54 -04:00
|
|
|
Keyboard::magic_widget_grab_focus ();
|
2022-01-17 20:55:43 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RegionListBase::name_edit (const std::string& path, const std::string& new_text)
|
|
|
|
{
|
|
|
|
_name_editable = 0;
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Region> region;
|
2022-01-17 20:55:43 -05:00
|
|
|
TreeIter row_iter;
|
|
|
|
|
|
|
|
if ((row_iter = _model->get_iter (path))) {
|
|
|
|
region = (*row_iter)[_columns.region];
|
|
|
|
(*row_iter)[_columns.name] = new_text;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (region) {
|
|
|
|
region->set_name (new_text);
|
|
|
|
|
|
|
|
populate_row_name (region, (*row_iter));
|
2023-06-12 17:34:54 -04:00
|
|
|
Keyboard::magic_widget_drop_focus ();
|
2022-01-17 20:55:43 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-12 17:34:54 -04:00
|
|
|
void
|
|
|
|
RegionListBase::tag_editing_canceled ()
|
|
|
|
{
|
|
|
|
Keyboard::magic_widget_drop_focus ();
|
|
|
|
}
|
|
|
|
|
2022-01-17 20:55:43 -05:00
|
|
|
void
|
|
|
|
RegionListBase::tag_editing_started (CellEditable* ce, const Glib::ustring& path)
|
|
|
|
{
|
|
|
|
_tags_editable = ce;
|
|
|
|
|
|
|
|
/* give it a special name */
|
|
|
|
|
|
|
|
Gtk::Entry* e = dynamic_cast<Gtk::Entry*> (ce);
|
|
|
|
|
|
|
|
if (e) {
|
|
|
|
e->set_name (X_("RegionTagEditorEntry"));
|
|
|
|
|
|
|
|
TreeIter iter;
|
|
|
|
if ((iter = _model->get_iter (path))) {
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Region> region = (*iter)[_columns.region];
|
2022-01-17 20:55:43 -05:00
|
|
|
|
|
|
|
if (region) {
|
|
|
|
e->set_text (region->tags ());
|
2023-06-12 17:34:54 -04:00
|
|
|
Keyboard::magic_widget_grab_focus ();
|
2022-01-17 20:55:43 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RegionListBase::tag_edit (const std::string& path, const std::string& new_text)
|
|
|
|
{
|
|
|
|
_tags_editable = 0;
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Region> region;
|
2022-01-17 20:55:43 -05:00
|
|
|
TreeIter row_iter;
|
|
|
|
|
|
|
|
if ((row_iter = _model->get_iter (path))) {
|
|
|
|
region = (*row_iter)[_columns.region];
|
|
|
|
(*row_iter)[_columns.tags] = new_text;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (region) {
|
|
|
|
region->set_tags (new_text);
|
|
|
|
|
|
|
|
populate_row_name (region, (*row_iter));
|
2023-06-12 17:34:54 -04:00
|
|
|
Keyboard::magic_widget_drop_focus ();
|
2022-01-17 20:55:43 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RegionListBase::clear ()
|
|
|
|
{
|
2022-01-18 19:59:05 -05:00
|
|
|
_remove_region_connections.drop_connections ();
|
2022-01-17 20:55:43 -05:00
|
|
|
_display.set_model (Glib::RefPtr<Gtk::TreeStore> (0));
|
|
|
|
_model->clear ();
|
|
|
|
_display.set_model (_model);
|
|
|
|
|
|
|
|
/* Clean up the maps */
|
|
|
|
region_row_map.clear ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RegionListBase::freeze_tree_model ()
|
|
|
|
{
|
|
|
|
/* store sort column id and type for later */
|
|
|
|
_model->get_sort_column_id (_sort_col_id, _sort_type);
|
|
|
|
_change_connection.block (true);
|
|
|
|
_display.set_model (Glib::RefPtr<Gtk::TreeStore> (0));
|
|
|
|
_model->set_sort_column (-2, SORT_ASCENDING); //Disable sorting to gain performance
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RegionListBase::thaw_tree_model ()
|
|
|
|
{
|
|
|
|
_model->set_sort_column (_sort_col_id, _sort_type); // re-enabale sorting
|
|
|
|
_display.set_model (_model);
|
|
|
|
_change_connection.block (false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RegionListBase::locked_changed (std::string const& path)
|
|
|
|
{
|
|
|
|
TreeIter i = _model->get_iter (path);
|
|
|
|
if (i) {
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<ARDOUR::Region> region = (*i)[_columns.region];
|
2022-01-17 20:55:43 -05:00
|
|
|
if (region) {
|
|
|
|
region->set_locked (!(*i)[_columns.locked]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RegionListBase::glued_changed (std::string const& path)
|
|
|
|
{
|
|
|
|
TreeIter i = _model->get_iter (path);
|
|
|
|
if (i) {
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<ARDOUR::Region> region = (*i)[_columns.region];
|
2022-01-17 20:55:43 -05:00
|
|
|
if (region) {
|
|
|
|
/* `glued' means MusicTime, and we're toggling here */
|
|
|
|
region->set_position_time_domain ((*i)[_columns.glued] ? Temporal::AudioTime : Temporal::BeatTime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RegionListBase::muted_changed (std::string const& path)
|
|
|
|
{
|
|
|
|
TreeIter i = _model->get_iter (path);
|
|
|
|
if (i) {
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<ARDOUR::Region> region = (*i)[_columns.region];
|
2022-01-17 20:55:43 -05:00
|
|
|
if (region) {
|
|
|
|
region->set_muted (!(*i)[_columns.muted]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RegionListBase::opaque_changed (std::string const& path)
|
|
|
|
{
|
|
|
|
TreeIter i = _model->get_iter (path);
|
|
|
|
if (i) {
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<ARDOUR::Region> region = (*i)[_columns.region];
|
2022-01-17 20:55:43 -05:00
|
|
|
if (region) {
|
|
|
|
region->set_opaque (!(*i)[_columns.opaque]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|