2009-07-03 18:42:22 -04:00
|
|
|
/*
|
2019-08-02 17:26:43 -04: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-2019 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.
|
|
|
|
*/
|
2009-07-03 18:42:22 -04:00
|
|
|
|
|
|
|
#include <algorithm>
|
2019-08-12 18:56:48 -04:00
|
|
|
#include <cmath>
|
|
|
|
#include <cstdlib>
|
2009-07-03 18:42:22 -04:00
|
|
|
#include <sstream>
|
2019-08-12 18:56:48 -04:00
|
|
|
#include <string>
|
2009-07-03 18:42:22 -04:00
|
|
|
|
|
|
|
#include "pbd/basename.h"
|
2010-01-25 15:34:09 -05:00
|
|
|
#include "pbd/enumwriter.h"
|
2009-07-03 18:42:22 -04:00
|
|
|
|
|
|
|
#include "ardour/audiofilesource.h"
|
2019-08-12 18:56:48 -04:00
|
|
|
#include "ardour/audioregion.h"
|
|
|
|
#include "ardour/profile.h"
|
2010-03-06 10:40:42 -05:00
|
|
|
#include "ardour/region_factory.h"
|
|
|
|
#include "ardour/session.h"
|
2018-11-15 10:24:37 -05:00
|
|
|
#include "ardour/session_playlist.h"
|
2019-08-12 18:56:48 -04:00
|
|
|
#include "ardour/silentfilesource.h"
|
2009-07-03 18:42:22 -04:00
|
|
|
|
2010-09-28 13:27:58 -04:00
|
|
|
#include "gtkmm2ext/treeutils.h"
|
2015-10-15 05:24:15 -04:00
|
|
|
#include "gtkmm2ext/utils.h"
|
2010-09-28 13:27:58 -04:00
|
|
|
|
2017-07-16 22:55:52 -04:00
|
|
|
#include "widgets/choice.h"
|
2017-07-15 11:38:28 -04:00
|
|
|
#include "widgets/tooltips.h"
|
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
#include "actions.h"
|
|
|
|
#include "ardour_ui.h"
|
2011-06-02 13:50:37 -04:00
|
|
|
#include "audio_clock.h"
|
2009-07-03 18:42:22 -04:00
|
|
|
#include "editing.h"
|
2016-08-28 19:27:25 -04:00
|
|
|
#include "editing_convert.h"
|
2019-08-12 18:56:48 -04:00
|
|
|
#include "editor.h"
|
2010-05-05 18:09:07 -04:00
|
|
|
#include "editor_drag.h"
|
2019-08-12 18:56:48 -04:00
|
|
|
#include "editor_regions.h"
|
|
|
|
#include "gui_thread.h"
|
|
|
|
#include "keyboard.h"
|
2012-05-31 19:14:03 -04:00
|
|
|
#include "main_clock.h"
|
2019-08-12 18:56:48 -04:00
|
|
|
#include "region_view.h"
|
2015-01-02 09:44:54 -05:00
|
|
|
#include "ui_config.h"
|
2019-08-12 18:56:48 -04:00
|
|
|
#include "utils.h"
|
2009-07-03 18:42:22 -04:00
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2009-07-03 18:42:22 -04:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace ARDOUR;
|
2017-07-15 11:38:28 -04:00
|
|
|
using namespace ArdourWidgets;
|
2014-06-25 15:27:37 -04:00
|
|
|
using namespace ARDOUR_UI_UTILS;
|
2009-07-03 18:42:22 -04:00
|
|
|
using namespace PBD;
|
|
|
|
using namespace Gtk;
|
|
|
|
using namespace Glib;
|
|
|
|
using namespace Editing;
|
2009-12-04 17:51:32 -05:00
|
|
|
using Gtkmm2ext::Keyboard;
|
2009-07-03 18:42:22 -04:00
|
|
|
|
2011-12-02 08:29:11 -05:00
|
|
|
struct ColumnInfo {
|
2019-08-12 18:56:48 -04:00
|
|
|
int index;
|
|
|
|
int sort_idx;
|
2018-11-15 10:24:37 -05:00
|
|
|
Gtk::AlignmentEnum al;
|
2019-08-12 18:56:48 -04:00
|
|
|
const char* label;
|
|
|
|
const char* tooltip;
|
2011-12-02 08:29:11 -05:00
|
|
|
};
|
|
|
|
|
2018-10-22 17:46:44 -04:00
|
|
|
//#define SHOW_REGION_EXTRAS
|
|
|
|
|
2009-07-03 18:42:22 -04:00
|
|
|
EditorRegions::EditorRegions (Editor* e)
|
2019-08-12 18:56:48 -04:00
|
|
|
: EditorComponent (e)
|
|
|
|
, old_focus (0)
|
|
|
|
, name_editable (0)
|
|
|
|
, tags_editable (0)
|
|
|
|
, _menu (0)
|
|
|
|
, _no_redisplay (false)
|
2009-07-03 18:42:22 -04:00
|
|
|
{
|
|
|
|
_display.set_size_request (100, -1);
|
2010-09-18 19:53:22 -04:00
|
|
|
_display.set_rules_hint (true);
|
2018-11-15 10:24:37 -05:00
|
|
|
_display.set_name ("RegionList");
|
2016-03-27 16:05:39 -04:00
|
|
|
_display.set_fixed_height_mode (true);
|
2018-11-15 10:24:37 -05:00
|
|
|
_display.set_reorderable (false);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-07-03 18:42:22 -04:00
|
|
|
/* Try to prevent single mouse presses from initiating edits.
|
2019-08-12 18:56:48 -04:00
|
|
|
* This relies on a hack in gtktreeview.c:gtk_treeview_button_press() */
|
|
|
|
_display.set_data ("mouse-edits-require-mod1", (gpointer)0x1);
|
2009-07-03 18:42:22 -04:00
|
|
|
|
|
|
|
_model = TreeStore::create (_columns);
|
|
|
|
_model->set_sort_column (0, SORT_ASCENDING);
|
|
|
|
|
2016-06-05 15:46:29 -04:00
|
|
|
/* column widths */
|
2018-11-15 10:24:37 -05:00
|
|
|
int bbt_width, date_width, check_width, height;
|
2016-06-05 15:46:29 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
Glib::RefPtr<Pango::Layout> layout = _display.create_pango_layout (X_ ("000|000|000"));
|
2016-06-05 15:46:29 -04:00
|
|
|
Gtkmm2ext::get_pixel_size (layout, bbt_width, height);
|
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
Glib::RefPtr<Pango::Layout> layout2 = _display.create_pango_layout (X_ ("2099-10-10 10:10:30"));
|
2018-11-15 10:24:37 -05:00
|
|
|
Gtkmm2ext::get_pixel_size (layout2, date_width, height);
|
|
|
|
|
2016-06-05 15:46:29 -04:00
|
|
|
check_width = 20;
|
|
|
|
|
2016-03-27 16:05:39 -04:00
|
|
|
TreeViewColumn* col_name = manage (new TreeViewColumn ("", _columns.name));
|
|
|
|
col_name->set_fixed_width (120);
|
|
|
|
col_name->set_sizing (TREE_VIEW_COLUMN_FIXED);
|
2018-11-15 10:27:04 -05:00
|
|
|
TreeViewColumn* col_tags = manage (new TreeViewColumn ("", _columns.tags));
|
|
|
|
col_tags->set_fixed_width (date_width);
|
|
|
|
col_tags->set_sizing (TREE_VIEW_COLUMN_FIXED);
|
2018-11-15 10:24:37 -05:00
|
|
|
TreeViewColumn* col_start = manage (new TreeViewColumn ("", _columns.start));
|
|
|
|
col_start->set_fixed_width (bbt_width);
|
|
|
|
col_start->set_sizing (TREE_VIEW_COLUMN_FIXED);
|
2016-03-27 16:05:39 -04:00
|
|
|
TreeViewColumn* col_end = manage (new TreeViewColumn ("", _columns.end));
|
2016-06-05 15:46:29 -04:00
|
|
|
col_end->set_fixed_width (bbt_width);
|
2016-03-27 16:05:39 -04:00
|
|
|
col_end->set_sizing (TREE_VIEW_COLUMN_FIXED);
|
|
|
|
TreeViewColumn* col_length = manage (new TreeViewColumn ("", _columns.length));
|
2016-06-05 15:46:29 -04:00
|
|
|
col_length->set_fixed_width (bbt_width);
|
2016-03-27 16:05:39 -04:00
|
|
|
col_length->set_sizing (TREE_VIEW_COLUMN_FIXED);
|
|
|
|
TreeViewColumn* col_sync = manage (new TreeViewColumn ("", _columns.sync));
|
2017-01-10 05:26:23 -05:00
|
|
|
col_sync->set_fixed_width (bbt_width);
|
2016-03-27 16:05:39 -04:00
|
|
|
col_sync->set_sizing (TREE_VIEW_COLUMN_FIXED);
|
|
|
|
TreeViewColumn* col_fadein = manage (new TreeViewColumn ("", _columns.fadein));
|
2016-06-05 15:46:29 -04:00
|
|
|
col_fadein->set_fixed_width (bbt_width);
|
2016-03-27 16:05:39 -04:00
|
|
|
col_fadein->set_sizing (TREE_VIEW_COLUMN_FIXED);
|
|
|
|
TreeViewColumn* col_fadeout = manage (new TreeViewColumn ("", _columns.fadeout));
|
2016-06-05 15:46:29 -04:00
|
|
|
col_fadeout->set_fixed_width (bbt_width);
|
2016-03-27 16:05:39 -04:00
|
|
|
col_fadeout->set_sizing (TREE_VIEW_COLUMN_FIXED);
|
|
|
|
TreeViewColumn* col_locked = manage (new TreeViewColumn ("", _columns.locked));
|
2016-06-05 15:46:29 -04:00
|
|
|
col_locked->set_fixed_width (check_width);
|
2016-03-27 16:05:39 -04:00
|
|
|
col_locked->set_sizing (TREE_VIEW_COLUMN_FIXED);
|
|
|
|
TreeViewColumn* col_glued = manage (new TreeViewColumn ("", _columns.glued));
|
2016-06-05 15:46:29 -04:00
|
|
|
col_glued->set_fixed_width (check_width);
|
2016-03-27 16:05:39 -04:00
|
|
|
col_glued->set_sizing (TREE_VIEW_COLUMN_FIXED);
|
|
|
|
TreeViewColumn* col_muted = manage (new TreeViewColumn ("", _columns.muted));
|
2016-06-05 15:46:29 -04:00
|
|
|
col_muted->set_fixed_width (check_width);
|
2016-03-27 16:05:39 -04:00
|
|
|
col_muted->set_sizing (TREE_VIEW_COLUMN_FIXED);
|
|
|
|
TreeViewColumn* col_opaque = manage (new TreeViewColumn ("", _columns.opaque));
|
2016-06-05 15:46:29 -04:00
|
|
|
col_opaque->set_fixed_width (check_width);
|
2016-03-27 16:05:39 -04:00
|
|
|
col_opaque->set_sizing (TREE_VIEW_COLUMN_FIXED);
|
|
|
|
|
|
|
|
_display.append_column (*col_name);
|
2018-11-15 10:27:04 -05:00
|
|
|
_display.append_column (*col_tags);
|
2018-11-15 10:24:37 -05:00
|
|
|
_display.append_column (*col_start);
|
2018-10-22 17:46:44 -04:00
|
|
|
_display.append_column (*col_length);
|
2018-11-15 10:24:37 -05:00
|
|
|
_display.append_column (*col_locked);
|
|
|
|
_display.append_column (*col_glued);
|
|
|
|
_display.append_column (*col_muted);
|
|
|
|
_display.append_column (*col_opaque);
|
2019-08-12 18:56:48 -04:00
|
|
|
|
2018-10-22 17:46:44 -04:00
|
|
|
#ifdef SHOW_REGION_EXTRAS
|
2016-03-27 16:05:39 -04:00
|
|
|
_display.append_column (*col_end);
|
2019-08-12 18:56:48 -04:00
|
|
|
_display.append_column (*col_sync);
|
2016-03-27 16:05:39 -04:00
|
|
|
_display.append_column (*col_fadein);
|
|
|
|
_display.append_column (*col_fadeout);
|
2018-10-22 17:46:44 -04:00
|
|
|
#endif
|
2011-12-02 08:14:59 -05:00
|
|
|
|
|
|
|
TreeViewColumn* col;
|
2019-08-12 18:56:48 -04:00
|
|
|
Gtk::Label* l;
|
2011-12-02 08:14:59 -05:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
/* clang-format off */
|
2011-12-02 08:29:11 -05:00
|
|
|
ColumnInfo ci[] = {
|
2018-11-15 10:24:37 -05:00
|
|
|
{ 0, 0, ALIGN_LEFT, _("Region"), _("Region name, with number of channels in []'s") },
|
2018-11-15 10:27:04 -05:00
|
|
|
{ 1, 1, ALIGN_LEFT, _("Tags"), _("Tags") },
|
2019-08-12 11:59:48 -04:00
|
|
|
{ 2, -1, ALIGN_CENTER, S_("Lock|L"), _("Region position locked?") },
|
|
|
|
{ 3, -1, ALIGN_CENTER, S_("Glued|G"), _("Region position glued to Bars|Beats time?") },
|
|
|
|
{ 4, -1, ALIGN_CENTER, S_("Mute|M"), _("Region muted?") },
|
|
|
|
{ 5, -1, ALIGN_CENTER, S_("Opaque|O"), _("Region opaque (blocks regions below it from being heard)?") },
|
|
|
|
{ 6, 15, ALIGN_RIGHT, _("Start"), _("Position of start of region") },
|
|
|
|
{ 7, 3, ALIGN_RIGHT, _("Length"), _("Length of the region") },
|
2018-10-22 17:46:44 -04:00
|
|
|
#ifdef SHOW_REGION_EXTRAS
|
2019-08-12 11:59:48 -04:00
|
|
|
{ 8, 4, ALIGN_RIGHT, _("End"), _("Position of end of region") },
|
2018-11-15 10:24:37 -05:00
|
|
|
{ 9, -1, ALIGN_RIGHT, _("Sync"), _("Position of region sync point, relative to start of the region") },
|
|
|
|
{ 10,-1, ALIGN_RIGHT, _("Fade In"), _("Length of region fade-in (units: secondary clock), () if disabled") },
|
|
|
|
{ 11,-1, ALIGN_RIGHT, _("Fade Out"), _("Length of region fade-out (units: secondary clock), () if disabled") },
|
2018-10-22 17:46:44 -04:00
|
|
|
#endif
|
2018-11-15 10:24:37 -05:00
|
|
|
{ -1,-1, ALIGN_CENTER, 0, 0 }
|
2011-12-02 08:29:11 -05:00
|
|
|
};
|
2019-08-12 18:56:48 -04:00
|
|
|
/* clang-format on */
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2011-12-02 08:29:11 -05:00
|
|
|
for (int i = 0; ci[i].index >= 0; ++i) {
|
|
|
|
col = _display.get_column (ci[i].index);
|
2018-11-15 10:24:37 -05:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
/* add the label */
|
2011-12-02 08:29:11 -05:00
|
|
|
l = manage (new Label (ci[i].label));
|
2019-08-12 18:56:48 -04:00
|
|
|
l->set_alignment (ci[i].al);
|
2015-01-05 00:32:14 -05:00
|
|
|
set_tooltip (*l, ci[i].tooltip);
|
2011-12-02 08:29:11 -05:00
|
|
|
col->set_widget (*l);
|
|
|
|
l->show ();
|
2011-12-02 09:52:48 -05:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
col->set_sort_column (ci[i].sort_idx);
|
2018-11-15 10:24:37 -05:00
|
|
|
|
|
|
|
col->set_expand (false);
|
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
/* this sets the alignment of the column header... */
|
2018-11-15 10:24:37 -05:00
|
|
|
col->set_alignment (ci[i].al);
|
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
/* ...and this sets the alignment for the data cells */
|
|
|
|
CellRendererText* renderer = dynamic_cast<CellRendererText*> (_display.get_column_cell_renderer (i));
|
2018-11-15 10:24:37 -05:00
|
|
|
if (renderer) {
|
2019-08-12 18:56:48 -04:00
|
|
|
renderer->property_xalign () = (ci[i].al == ALIGN_RIGHT ? 1.0 : (ci[i].al == ALIGN_LEFT ? 0.0 : 0.5));
|
2015-10-04 14:51:05 -04:00
|
|
|
}
|
2011-12-02 08:29:11 -05:00
|
|
|
}
|
2018-11-15 10:24:37 -05:00
|
|
|
|
2016-03-27 16:05:39 -04:00
|
|
|
_display.set_model (_model);
|
2011-12-02 08:29:11 -05:00
|
|
|
|
2009-07-03 18:42:22 -04:00
|
|
|
_display.set_headers_visible (true);
|
2011-12-02 09:52:48 -05:00
|
|
|
_display.set_rules_hint ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
if (UIConfiguration::instance ().get_use_tooltips ()) {
|
2018-11-01 18:20:50 -04:00
|
|
|
/* show path as the row tooltip */
|
2018-11-15 10:24:37 -05:00
|
|
|
_display.set_tooltip_column (12); /* path */
|
2018-11-01 18:20:50 -04:00
|
|
|
}
|
2019-08-12 18:56:48 -04:00
|
|
|
_display.get_selection ()->set_select_function (sigc::mem_fun (*this, &EditorRegions::selection_filter));
|
2010-09-28 13:27:58 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
/* Name cell: make editable */
|
|
|
|
CellRendererText* region_name_cell = dynamic_cast<CellRendererText*> (_display.get_column_cell_renderer (0));
|
|
|
|
region_name_cell->property_editable () = true;
|
|
|
|
region_name_cell->signal_edited ().connect (sigc::mem_fun (*this, &EditorRegions::name_edit));
|
|
|
|
region_name_cell->signal_editing_started ().connect (sigc::mem_fun (*this, &EditorRegions::name_editing_started));
|
2009-07-03 18:42:22 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
/* Region Name: color turns red if source is missing. */
|
|
|
|
TreeViewColumn* tv_col = _display.get_column (0);
|
|
|
|
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_);
|
2011-12-02 09:52:48 -05:00
|
|
|
tv_col->set_expand (true);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
/* Tags cell: make editable */
|
|
|
|
CellRendererText* region_tags_cell = dynamic_cast<CellRendererText*> (_display.get_column_cell_renderer (1));
|
|
|
|
region_tags_cell->property_editable () = true;
|
|
|
|
region_tags_cell->signal_edited ().connect (sigc::mem_fun (*this, &EditorRegions::tag_edit));
|
|
|
|
region_tags_cell->signal_editing_started ().connect (sigc::mem_fun (*this, &EditorRegions::tag_editing_started));
|
2018-11-15 10:27:04 -05:00
|
|
|
|
2018-10-22 17:46:44 -04:00
|
|
|
/* checkbox cells */
|
|
|
|
int check_start_col = 4;
|
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
CellRendererToggle* locked_cell = dynamic_cast<CellRendererToggle*> (_display.get_column_cell_renderer (check_start_col++));
|
|
|
|
locked_cell->property_activatable () = true;
|
|
|
|
locked_cell->signal_toggled ().connect (sigc::mem_fun (*this, &EditorRegions::locked_changed));
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
CellRendererToggle* glued_cell = dynamic_cast<CellRendererToggle*> (_display.get_column_cell_renderer (check_start_col++));
|
|
|
|
glued_cell->property_activatable () = true;
|
|
|
|
glued_cell->signal_toggled ().connect (sigc::mem_fun (*this, &EditorRegions::glued_changed));
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
CellRendererToggle* muted_cell = dynamic_cast<CellRendererToggle*> (_display.get_column_cell_renderer (check_start_col++));
|
|
|
|
muted_cell->property_activatable () = true;
|
|
|
|
muted_cell->signal_toggled ().connect (sigc::mem_fun (*this, &EditorRegions::muted_changed));
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
CellRendererToggle* opaque_cell = dynamic_cast<CellRendererToggle*> (_display.get_column_cell_renderer (check_start_col));
|
|
|
|
opaque_cell->property_activatable () = true;
|
|
|
|
opaque_cell->signal_toggled ().connect (sigc::mem_fun (*this, &EditorRegions::opaque_changed));
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
_display.get_selection ()->set_mode (SELECTION_MULTIPLE);
|
|
|
|
_display.add_object_drag (_columns.region.index (), "regions");
|
|
|
|
_display.set_drag_column (_columns.name.index ());
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-07-03 18:42:22 -04:00
|
|
|
/* setup DnD handling */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-07-03 18:42:22 -04:00
|
|
|
list<TargetEntry> region_list_target_table;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-07-03 18:42:22 -04:00
|
|
|
region_list_target_table.push_back (TargetEntry ("text/uri-list"));
|
2019-05-13 09:43:58 -04:00
|
|
|
region_list_target_table.push_back (TargetEntry ("text/plain"));
|
2009-07-03 18:42:22 -04:00
|
|
|
region_list_target_table.push_back (TargetEntry ("application/x-rootwin-drop"));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-07-03 18:42:22 -04:00
|
|
|
_display.add_drop_targets (region_list_target_table);
|
2019-08-12 18:56:48 -04:00
|
|
|
_display.signal_drag_data_received ().connect (sigc::mem_fun (*this, &EditorRegions::drag_data_received));
|
2009-07-03 18:42:22 -04:00
|
|
|
|
|
|
|
_scroller.add (_display);
|
|
|
|
_scroller.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
_display.signal_button_press_event ().connect (sigc::mem_fun (*this, &EditorRegions::button_press), false);
|
|
|
|
_change_connection = _display.get_selection ()->signal_changed ().connect (sigc::mem_fun (*this, &EditorRegions::selection_changed));
|
2010-09-28 22:01:35 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
_scroller.signal_key_press_event ().connect (sigc::mem_fun (*this, &EditorRegions::key_press), false);
|
|
|
|
_scroller.signal_focus_in_event ().connect (sigc::mem_fun (*this, &EditorRegions::focus_in), false);
|
|
|
|
_scroller.signal_focus_out_event ().connect (sigc::mem_fun (*this, &EditorRegions::focus_out));
|
2010-09-28 22:01:35 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
_display.signal_enter_notify_event ().connect (sigc::mem_fun (*this, &EditorRegions::enter_notify), false);
|
|
|
|
_display.signal_leave_notify_event ().connect (sigc::mem_fun (*this, &EditorRegions::leave_notify), false);
|
2010-09-28 22:01:35 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
ARDOUR_UI::instance ()->primary_clock->mode_changed.connect (sigc::mem_fun (*this, &EditorRegions::clock_format_changed));
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
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 ());
|
2009-07-03 18:42:22 -04:00
|
|
|
}
|
|
|
|
|
2010-09-28 22:01:35 -04:00
|
|
|
bool
|
|
|
|
EditorRegions::focus_in (GdkEventFocus*)
|
|
|
|
{
|
2010-11-25 15:37:39 -05:00
|
|
|
Window* win = dynamic_cast<Window*> (_scroller.get_toplevel ());
|
2010-09-28 22:01:35 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
if (win) {
|
|
|
|
old_focus = win->get_focus ();
|
|
|
|
} else {
|
|
|
|
old_focus = 0;
|
|
|
|
}
|
2010-09-28 22:01:35 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
name_editable = 0;
|
2018-11-15 10:27:04 -05:00
|
|
|
tags_editable = 0;
|
2010-09-28 22:01:35 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
/* try to do nothing on focus in (doesn't work, hence selection_count nonsense) */
|
|
|
|
return true;
|
2010-09-28 22:01:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
EditorRegions::focus_out (GdkEventFocus*)
|
|
|
|
{
|
2010-11-25 15:37:39 -05:00
|
|
|
if (old_focus) {
|
|
|
|
old_focus->grab_focus ();
|
|
|
|
old_focus = 0;
|
|
|
|
}
|
2010-09-28 22:01:35 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
name_editable = 0;
|
2018-11-15 10:27:04 -05:00
|
|
|
tags_editable = 0;
|
2010-09-28 22:01:35 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
return false;
|
2010-09-28 22:01:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2011-09-30 13:55:14 -04:00
|
|
|
EditorRegions::enter_notify (GdkEventCrossing*)
|
2010-09-28 22:01:35 -04:00
|
|
|
{
|
2018-11-15 10:27:04 -05:00
|
|
|
if (name_editable || tags_editable) {
|
2011-01-01 15:08:26 -05:00
|
|
|
return true;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
Keyboard::magic_widget_grab_focus ();
|
|
|
|
return false;
|
2010-09-28 22:01:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
EditorRegions::leave_notify (GdkEventCrossing*)
|
|
|
|
{
|
2010-11-25 15:37:39 -05:00
|
|
|
if (old_focus) {
|
|
|
|
old_focus->grab_focus ();
|
|
|
|
old_focus = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Keyboard::magic_widget_drop_focus ();
|
|
|
|
return false;
|
2010-09-28 22:01:35 -04:00
|
|
|
}
|
|
|
|
|
2009-07-03 18:42:22 -04:00
|
|
|
void
|
2009-12-17 13:24:23 -05:00
|
|
|
EditorRegions::set_session (ARDOUR::Session* s)
|
2009-07-03 18:42:22 -04:00
|
|
|
{
|
2010-07-19 17:47:07 -04:00
|
|
|
SessionHandlePtr::set_session (s);
|
2019-08-12 18:56:48 -04:00
|
|
|
|
|
|
|
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 ());
|
2018-11-15 10:24:37 -05:00
|
|
|
|
2009-07-03 18:42:22 -04:00
|
|
|
redisplay ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EditorRegions::add_region (boost::shared_ptr<Region> region)
|
|
|
|
{
|
|
|
|
if (!region || !_session) {
|
|
|
|
return;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
/* whole-file regions are shown in the Source List */
|
|
|
|
if (region->whole_file ()) {
|
2019-05-31 14:36:46 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-11-15 10:24:37 -05:00
|
|
|
PropertyChange pc;
|
2019-08-12 18:56:48 -04:00
|
|
|
region_changed (region, pc);
|
2018-11-15 10:24:37 -05:00
|
|
|
}
|
2010-06-28 13:25:32 -04:00
|
|
|
|
2018-11-15 10:24:37 -05:00
|
|
|
void
|
|
|
|
EditorRegions::destroy_region (boost::shared_ptr<ARDOUR::Region> region)
|
|
|
|
{
|
|
|
|
//UNTESTED
|
|
|
|
//At the time of writing, the only way to remove regions is "cleanup"
|
|
|
|
//by definition, "cleanup" only removes regions that aren't on the timeline
|
|
|
|
//so this would be a no-op anyway
|
|
|
|
//perhaps someday we will allow users to manually destroy regions.
|
|
|
|
RegionRowMap::iterator map_it = region_row_map.find (region);
|
2019-08-12 18:56:48 -04:00
|
|
|
if (map_it != region_row_map.end ()) {
|
|
|
|
region_row_map.erase (map_it);
|
|
|
|
_model->erase (map_it->second);
|
2009-07-03 18:42:22 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-14 16:49:43 -05:00
|
|
|
void
|
2011-11-15 13:32:42 -05:00
|
|
|
EditorRegions::remove_unused_regions ()
|
2011-02-14 16:49:43 -05:00
|
|
|
{
|
|
|
|
vector<string> choices;
|
2019-08-12 18:56:48 -04:00
|
|
|
string prompt;
|
2011-02-14 16:49:43 -05:00
|
|
|
|
|
|
|
if (!_session) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
prompt = _ ("Do you really want to remove unused regions?"
|
|
|
|
"\n(This is destructive and cannot be undone)");
|
2011-02-14 16:49:43 -05:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
choices.push_back (_ ("No, do nothing."));
|
|
|
|
choices.push_back (_ ("Yes, remove."));
|
2011-02-14 16:49:43 -05:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
ArdourWidgets::Choice prompter (_ ("Remove unused regions"), prompt, choices);
|
2011-02-14 16:49:43 -05:00
|
|
|
|
|
|
|
if (prompter.run () == 1) {
|
|
|
|
_no_redisplay = true;
|
|
|
|
_session->cleanup_regions ();
|
|
|
|
_no_redisplay = false;
|
|
|
|
redisplay ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-03 18:42:22 -04:00
|
|
|
void
|
2010-03-30 19:40:28 -04:00
|
|
|
EditorRegions::region_changed (boost::shared_ptr<Region> r, const PropertyChange& what_changed)
|
2009-07-03 18:42:22 -04:00
|
|
|
{
|
2018-11-15 10:24:37 -05:00
|
|
|
RegionRowMap::iterator map_it = region_row_map.find (r);
|
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
boost::shared_ptr<ARDOUR::Playlist> pl = r->playlist ();
|
|
|
|
if (!(pl && _session && _session->playlist_is_active (pl))) {
|
|
|
|
/* this region is not on an active playlist
|
|
|
|
* maybe it got deleted, or whatever */
|
|
|
|
if (map_it != region_row_map.end ()) {
|
|
|
|
region_row_map.erase (map_it);
|
|
|
|
_model->erase (map_it->second);
|
2011-02-14 16:49:43 -05:00
|
|
|
}
|
2018-11-15 10:24:37 -05:00
|
|
|
return;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
if (map_it != region_row_map.end ()) {
|
|
|
|
/* found the region, update its row properties */
|
2018-11-15 10:24:37 -05:00
|
|
|
TreeModel::Row row = *(map_it->second);
|
|
|
|
populate_row (r, row, what_changed);
|
2009-07-03 18:42:22 -04:00
|
|
|
|
2018-11-15 10:24:37 -05:00
|
|
|
} else {
|
2019-08-12 18:56:48 -04:00
|
|
|
/* new region, add it to the list */
|
|
|
|
TreeModel::iterator iter = _model->append ();
|
|
|
|
TreeModel::Row row = *iter;
|
|
|
|
region_row_map.insert (pair<boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::iterator> (r, iter));
|
2010-11-25 15:37:39 -05:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
/* set the properties that don't change */
|
2018-11-15 10:24:37 -05:00
|
|
|
row[_columns.region] = r;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
/* now populate the properties that might change... */
|
|
|
|
populate_row (r, row, PropertyChange ());
|
2010-03-30 19:40:28 -04:00
|
|
|
}
|
2009-07-03 18:42:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-10-14 12:10:01 -04:00
|
|
|
EditorRegions::selection_changed ()
|
2009-07-03 18:42:22 -04:00
|
|
|
{
|
2010-09-28 13:27:58 -04:00
|
|
|
_editor->_region_selection_change_updates_region_list = false;
|
2010-09-18 19:31:39 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
if (_display.get_selection ()->count_selected_rows () > 0) {
|
|
|
|
TreeIter iter;
|
|
|
|
TreeView::Selection::ListHandle_Path rows = _display.get_selection ()->get_selected_rows ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
_editor->get_selection ().clear_regions ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
for (TreeView::Selection::ListHandle_Path::iterator i = rows.begin (); i != rows.end (); ++i) {
|
2012-05-23 22:54:10 -04:00
|
|
|
if ((iter = _model->get_iter (*i))) {
|
2009-07-03 18:42:22 -04:00
|
|
|
boost::shared_ptr<Region> region = (*iter)[_columns.region];
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
// 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.
|
2010-09-28 13:27:58 -04:00
|
|
|
|
2009-07-03 18:42:22 -04:00
|
|
|
if (region) {
|
2013-01-04 17:46:51 -05:00
|
|
|
_change_connection.block (true);
|
|
|
|
_editor->set_selected_regionview_from_region_list (region, Selection::Add);
|
|
|
|
_change_connection.block (false);
|
2009-07-03 18:42:22 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2019-08-12 18:56:48 -04:00
|
|
|
_editor->get_selection ().clear_regions ();
|
2009-07-03 18:42:22 -04:00
|
|
|
}
|
2010-09-18 19:31:39 -04:00
|
|
|
|
2010-09-28 13:27:58 -04:00
|
|
|
_editor->_region_selection_change_updates_region_list = true;
|
2009-07-03 18:42:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EditorRegions::set_selected (RegionSelection& regions)
|
|
|
|
{
|
2019-08-12 18:56:48 -04:00
|
|
|
for (RegionSelection::iterator i = regions.begin (); i != regions.end (); ++i) {
|
|
|
|
boost::shared_ptr<Region> r ((*i)->region ());
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-02-14 16:49:43 -05:00
|
|
|
RegionRowMap::iterator it;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-02-14 16:49:43 -05:00
|
|
|
it = region_row_map.find (r);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
if (it != region_row_map.end ()) {
|
2018-10-15 16:04:53 -04:00
|
|
|
TreeModel::iterator j = it->second;
|
2019-08-12 18:56:48 -04:00
|
|
|
_display.get_selection ()->select (*j);
|
2009-07-03 18:42:22 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EditorRegions::redisplay ()
|
2009-10-14 12:10:01 -04:00
|
|
|
{
|
2009-07-03 18:42:22 -04:00
|
|
|
if (_no_redisplay || !_session) {
|
|
|
|
return;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
_display.set_model (Glib::RefPtr<Gtk::TreeStore> (0));
|
2009-07-03 18:42:22 -04:00
|
|
|
_model->clear ();
|
2011-02-14 16:49:43 -05:00
|
|
|
_model->set_sort_column (-2, SORT_ASCENDING); //Disable sorting to gain performance
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
region_row_map.clear ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2019-05-31 14:36:46 -04:00
|
|
|
RegionFactory::foreach_region (sigc::mem_fun (*this, &EditorRegions::add_region));
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-02-14 16:49:43 -05:00
|
|
|
_model->set_sort_column (0, SORT_ASCENDING); // renabale sorting
|
2009-07-03 18:42:22 -04:00
|
|
|
_display.set_model (_model);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EditorRegions::update_row (boost::shared_ptr<Region> region)
|
2009-10-14 12:10:01 -04:00
|
|
|
{
|
2009-07-03 18:42:22 -04:00
|
|
|
if (!region || !_session) {
|
|
|
|
return;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2011-02-14 16:49:43 -05:00
|
|
|
RegionRowMap::iterator it;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-02-14 16:49:43 -05:00
|
|
|
it = region_row_map.find (region);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
if (it != region_row_map.end ()) {
|
|
|
|
PropertyChange c;
|
2018-10-15 16:04:53 -04:00
|
|
|
TreeModel::iterator j = it->second;
|
2019-08-12 18:56:48 -04:00
|
|
|
populate_row (region, (*j), c);
|
2009-07-03 18:42:22 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-10-18 19:51:45 -04:00
|
|
|
EditorRegions::clock_format_changed ()
|
2009-07-03 18:42:22 -04:00
|
|
|
{
|
|
|
|
if (!_session) {
|
|
|
|
return;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2018-10-18 19:51:45 -04:00
|
|
|
PropertyChange change;
|
|
|
|
change.add (ARDOUR::Properties::start);
|
|
|
|
change.add (ARDOUR::Properties::length);
|
|
|
|
change.add (ARDOUR::Properties::position);
|
|
|
|
change.add (ARDOUR::Properties::sync_position);
|
|
|
|
change.add (ARDOUR::Properties::fade_in);
|
|
|
|
change.add (ARDOUR::Properties::fade_out);
|
|
|
|
|
2011-02-14 16:49:43 -05:00
|
|
|
RegionRowMap::iterator i;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
for (i = region_row_map.begin (); i != region_row_map.end (); ++i) {
|
2018-10-15 16:04:53 -04:00
|
|
|
TreeModel::iterator j = i->second;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-02-14 16:49:43 -05:00
|
|
|
boost::shared_ptr<Region> region = (*j)[_columns.region];
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
populate_row (region, (*j), change);
|
2009-07-03 18:42:22 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-09-18 12:39:17 -04:00
|
|
|
EditorRegions::format_position (samplepos_t pos, char* buf, size_t bufsize, bool onoff)
|
2009-07-03 18:42:22 -04:00
|
|
|
{
|
2010-12-14 13:13:37 -05:00
|
|
|
Timecode::BBT_Time bbt;
|
2019-08-12 18:56:48 -04:00
|
|
|
Timecode::Time timecode;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2015-04-27 20:53:20 -04:00
|
|
|
if (pos < 0) {
|
2019-08-12 18:56:48 -04:00
|
|
|
error << string_compose (_ ("EditorRegions::format_position: negative timecode position: %1"), pos) << endmsg;
|
2015-04-27 20:53:20 -04:00
|
|
|
snprintf (buf, bufsize, "invalid");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
switch (ARDOUR_UI::instance ()->primary_clock->mode ()) {
|
|
|
|
case AudioClock::BBT:
|
|
|
|
bbt = _session->tempo_map ().bbt_at_sample (pos);
|
|
|
|
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:
|
|
|
|
samplepos_t left;
|
|
|
|
int hrs;
|
|
|
|
int mins;
|
|
|
|
float secs;
|
|
|
|
|
|
|
|
left = pos;
|
|
|
|
hrs = (int)floor (left / (_session->sample_rate () * 60.0f * 60.0f));
|
|
|
|
left -= (samplecnt_t)floor (hrs * _session->sample_rate () * 60.0f * 60.0f);
|
|
|
|
mins = (int)floor (left / (_session->sample_rate () * 60.0f));
|
|
|
|
left -= (samplecnt_t)floor (mins * _session->sample_rate () * 60.0f);
|
|
|
|
secs = left / (float)_session->sample_rate ();
|
|
|
|
if (onoff) {
|
|
|
|
snprintf (buf, bufsize, "%02d:%02d:%06.3f", hrs, mins, secs);
|
|
|
|
} else {
|
|
|
|
snprintf (buf, bufsize, "(%02d:%02d:%06.3f)", hrs, mins, secs);
|
|
|
|
}
|
|
|
|
break;
|
2017-11-22 14:36:28 -05:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
case AudioClock::Seconds:
|
|
|
|
if (onoff) {
|
|
|
|
snprintf (buf, bufsize, "%.1f", pos / (float)_session->sample_rate ());
|
|
|
|
} else {
|
|
|
|
snprintf (buf, bufsize, "(%.1f)", pos / (float)_session->sample_rate ());
|
|
|
|
}
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
case AudioClock::Samples:
|
|
|
|
if (onoff) {
|
|
|
|
snprintf (buf, bufsize, "%" PRId64, pos);
|
|
|
|
} else {
|
|
|
|
snprintf (buf, bufsize, "(%" PRId64 ")", pos);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AudioClock::Timecode:
|
|
|
|
default:
|
|
|
|
_session->timecode_time (pos, timecode);
|
|
|
|
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;
|
2009-07-03 18:42:22 -04:00
|
|
|
}
|
2010-09-20 11:12:44 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-09-20 11:12:44 -04:00
|
|
|
void
|
2019-08-12 18:56:48 -04:00
|
|
|
EditorRegions::populate_row (boost::shared_ptr<Region> region, TreeModel::Row const& row, PBD::PropertyChange const& what_changed)
|
2010-09-20 11:12:44 -04:00
|
|
|
{
|
2019-08-12 18:56:48 -04:00
|
|
|
/* the grid is most interested in the regions that are *visible* in the editor.
|
|
|
|
* this is a convenient place to flag changes to the grid cache, on a visible region */
|
2018-11-15 10:24:37 -05:00
|
|
|
PropertyChange grid_interests;
|
|
|
|
grid_interests.add (ARDOUR::Properties::position);
|
|
|
|
grid_interests.add (ARDOUR::Properties::length);
|
|
|
|
grid_interests.add (ARDOUR::Properties::sync_position);
|
|
|
|
if (what_changed.contains (grid_interests)) {
|
2019-08-12 18:56:48 -04:00
|
|
|
_editor->mark_region_boundary_cache_dirty ();
|
2018-11-15 10:24:37 -05:00
|
|
|
}
|
|
|
|
|
2018-11-15 10:27:04 -05:00
|
|
|
{
|
|
|
|
Gdk::Color c;
|
2019-08-12 18:56:48 -04:00
|
|
|
bool missing_source = boost::dynamic_pointer_cast<SilentFileSource> (region->source ()) != NULL;
|
2018-11-15 10:27:04 -05:00
|
|
|
if (missing_source) {
|
2019-08-12 18:56:48 -04:00
|
|
|
set_color_from_rgba (c, UIConfiguration::instance ().color ("region list missing source"));
|
2018-11-15 10:27:04 -05:00
|
|
|
} else {
|
2019-08-12 18:56:48 -04:00
|
|
|
set_color_from_rgba (c, UIConfiguration::instance ().color ("region list whole file"));
|
2018-11-15 10:27:04 -05:00
|
|
|
}
|
|
|
|
row[_columns.color_] = c;
|
2018-11-15 10:24:37 -05:00
|
|
|
}
|
2019-08-12 18:56:48 -04:00
|
|
|
|
|
|
|
boost::shared_ptr<AudioRegion> audioregion = boost::dynamic_pointer_cast<AudioRegion> (region);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2016-06-26 14:29:41 -04:00
|
|
|
PropertyChange c;
|
2019-08-12 18:56:48 -04:00
|
|
|
const bool all = what_changed == c;
|
2016-06-26 14:29:41 -04:00
|
|
|
|
|
|
|
if (all || what_changed.contains (Properties::position)) {
|
2018-11-15 10:24:37 -05:00
|
|
|
populate_row_position (region, row);
|
2016-06-26 14:29:41 -04:00
|
|
|
}
|
2017-01-10 05:26:23 -05:00
|
|
|
if (all || what_changed.contains (Properties::start) || what_changed.contains (Properties::sync_position)) {
|
2018-11-15 10:24:37 -05:00
|
|
|
populate_row_sync (region, row);
|
2016-06-26 14:29:41 -04:00
|
|
|
}
|
|
|
|
if (all || what_changed.contains (Properties::fade_in)) {
|
2018-11-15 10:24:37 -05:00
|
|
|
populate_row_fade_in (region, row, audioregion);
|
2016-06-26 14:29:41 -04:00
|
|
|
}
|
|
|
|
if (all || what_changed.contains (Properties::fade_out)) {
|
2018-11-15 10:24:37 -05:00
|
|
|
populate_row_fade_out (region, row, audioregion);
|
2016-06-26 14:29:41 -04:00
|
|
|
}
|
|
|
|
if (all || what_changed.contains (Properties::locked)) {
|
2018-11-15 10:24:37 -05:00
|
|
|
populate_row_locked (region, row);
|
2016-06-26 14:29:41 -04:00
|
|
|
}
|
|
|
|
if (all || what_changed.contains (Properties::position_lock_style)) {
|
2018-11-15 10:24:37 -05:00
|
|
|
populate_row_glued (region, row);
|
2016-06-26 14:29:41 -04:00
|
|
|
}
|
|
|
|
if (all || what_changed.contains (Properties::muted)) {
|
2018-11-15 10:24:37 -05:00
|
|
|
populate_row_muted (region, row);
|
2016-06-26 14:29:41 -04:00
|
|
|
}
|
|
|
|
if (all || what_changed.contains (Properties::opaque)) {
|
2018-11-15 10:24:37 -05:00
|
|
|
populate_row_opaque (region, row);
|
2016-06-26 14:29:41 -04:00
|
|
|
}
|
|
|
|
if (all || what_changed.contains (Properties::length)) {
|
2018-11-15 10:24:37 -05:00
|
|
|
populate_row_end (region, row);
|
2016-06-26 14:29:41 -04:00
|
|
|
populate_row_length (region, row);
|
|
|
|
}
|
|
|
|
if (all) {
|
|
|
|
populate_row_source (region, row);
|
|
|
|
}
|
2018-11-15 10:27:04 -05:00
|
|
|
if (all || what_changed.contains (Properties::name) || what_changed.contains (Properties::tags)) {
|
2016-06-26 14:29:41 -04:00
|
|
|
populate_row_name (region, row);
|
|
|
|
}
|
2010-09-20 11:12:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
2009-07-03 18:42:22 -04:00
|
|
|
if (audioRegion && fades_in_seconds) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2017-09-18 12:39:17 -04:00
|
|
|
samplepos_t left;
|
2009-07-03 18:42:22 -04:00
|
|
|
int mins;
|
|
|
|
int millisecs;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-07-03 18:42:22 -04:00
|
|
|
left = audioRegion->fade_in()->back()->when;
|
2017-09-18 12:39:17 -04:00
|
|
|
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());
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2017-09-18 12:39:17 -04:00
|
|
|
if (audioRegion->fade_in()->back()->when >= _session->sample_rate()) {
|
2009-07-03 18:42:22 -04:00
|
|
|
sprintf (fadein_str, "%01dM %01dmS", mins, millisecs);
|
|
|
|
} else {
|
|
|
|
sprintf (fadein_str, "%01dmS", millisecs);
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-07-03 18:42:22 -04:00
|
|
|
left = audioRegion->fade_out()->back()->when;
|
2017-09-18 12:39:17 -04:00
|
|
|
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());
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2017-09-18 12:39:17 -04:00
|
|
|
if (audioRegion->fade_out()->back()->when >= _session->sample_rate()) {
|
2009-07-03 18:42:22 -04:00
|
|
|
sprintf (fadeout_str, "%01dM %01dmS", mins, millisecs);
|
|
|
|
} else {
|
|
|
|
sprintf (fadeout_str, "%01dmS", millisecs);
|
|
|
|
}
|
|
|
|
}
|
2010-09-20 11:12:44 -04:00
|
|
|
#endif
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-09-20 11:12:44 -04:00
|
|
|
void
|
2019-08-12 18:56:48 -04:00
|
|
|
EditorRegions::populate_row_length (boost::shared_ptr<Region> region, TreeModel::Row const& row)
|
2010-09-20 11:12:44 -04:00
|
|
|
{
|
2010-11-25 15:37:39 -05:00
|
|
|
char buf[16];
|
2016-06-21 09:55:28 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
if (ARDOUR_UI::instance ()->primary_clock->mode () == AudioClock::BBT) {
|
|
|
|
TempoMap& map (_session->tempo_map ());
|
|
|
|
Timecode::BBT_Time bbt = map.bbt_at_beat (map.beat_at_sample (region->last_sample ()) - map.beat_at_sample (region->first_sample ()));
|
|
|
|
snprintf (buf, sizeof (buf), "%03d|%02d|%04d", bbt.bars, bbt.beats, bbt.ticks);
|
2016-06-21 09:55:28 -04:00
|
|
|
} else {
|
2019-08-12 18:56:48 -04:00
|
|
|
format_position (region->length (), buf, sizeof (buf));
|
2016-06-21 09:55:28 -04:00
|
|
|
}
|
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
row[_columns.length] = buf;
|
2010-09-20 11:12:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-08-12 18:56:48 -04:00
|
|
|
EditorRegions::populate_row_end (boost::shared_ptr<Region> region, TreeModel::Row const& row)
|
2010-09-20 11:12:44 -04:00
|
|
|
{
|
2018-10-22 17:46:44 -04:00
|
|
|
#ifndef SHOW_REGION_EXTRAS
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
if (region->last_sample () >= region->first_sample ()) {
|
2010-11-25 15:37:39 -05:00
|
|
|
char buf[16];
|
2019-08-12 18:56:48 -04:00
|
|
|
format_position (region->last_sample (), buf, sizeof (buf));
|
2010-11-25 15:37:39 -05:00
|
|
|
row[_columns.end] = buf;
|
2015-04-27 20:53:20 -04:00
|
|
|
} else {
|
|
|
|
row[_columns.end] = "empty";
|
2010-11-25 15:37:39 -05:00
|
|
|
}
|
2010-09-20 11:12:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-08-12 18:56:48 -04:00
|
|
|
EditorRegions::populate_row_position (boost::shared_ptr<Region> region, TreeModel::Row const& row)
|
2010-09-20 11:12:44 -04:00
|
|
|
{
|
2019-08-12 18:56:48 -04:00
|
|
|
row[_columns.position] = region->position ();
|
2018-11-15 10:24:37 -05:00
|
|
|
|
|
|
|
char buf[16];
|
2019-08-12 18:56:48 -04:00
|
|
|
format_position (region->position (), buf, sizeof (buf));
|
2018-11-15 10:24:37 -05:00
|
|
|
row[_columns.start] = buf;
|
2010-09-20 11:12:44 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-09-20 11:12:44 -04:00
|
|
|
void
|
2019-08-12 18:56:48 -04:00
|
|
|
EditorRegions::populate_row_sync (boost::shared_ptr<Region> region, TreeModel::Row const& row)
|
2010-09-20 11:12:44 -04:00
|
|
|
{
|
2018-10-22 17:46:44 -04:00
|
|
|
#ifndef SHOW_REGION_EXTRAS
|
|
|
|
return;
|
|
|
|
#endif
|
2019-08-12 18:56:48 -04:00
|
|
|
if (region->sync_position () == region->position ()) {
|
|
|
|
row[_columns.sync] = _ ("Start");
|
|
|
|
} else if (region->sync_position () == (region->last_sample ())) {
|
|
|
|
row[_columns.sync] = _ ("End");
|
2010-11-25 15:37:39 -05:00
|
|
|
} else {
|
2018-11-15 10:24:37 -05:00
|
|
|
char buf[16];
|
2019-08-12 18:56:48 -04:00
|
|
|
format_position (region->sync_position (), buf, sizeof (buf));
|
2018-11-15 10:24:37 -05:00
|
|
|
row[_columns.sync] = buf;
|
2010-11-25 15:37:39 -05:00
|
|
|
}
|
2010-09-20 11:12:44 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-09-20 11:12:44 -04:00
|
|
|
void
|
2019-08-12 18:56:48 -04:00
|
|
|
EditorRegions::populate_row_fade_in (boost::shared_ptr<Region> region, TreeModel::Row const& row, boost::shared_ptr<AudioRegion> audioregion)
|
2010-09-20 11:12:44 -04:00
|
|
|
{
|
2018-10-22 17:46:44 -04:00
|
|
|
#ifndef SHOW_REGION_EXTRAS
|
|
|
|
return;
|
|
|
|
#endif
|
2018-11-15 10:24:37 -05:00
|
|
|
if (!audioregion) {
|
2010-11-25 15:37:39 -05:00
|
|
|
row[_columns.fadein] = "";
|
|
|
|
} else {
|
2018-11-15 10:24:37 -05:00
|
|
|
char buf[32];
|
2019-08-12 18:56:48 -04:00
|
|
|
format_position (audioregion->fade_in ()->back ()->when, buf, sizeof (buf), audioregion->fade_in_active ());
|
2018-11-15 10:24:37 -05:00
|
|
|
row[_columns.fadein] = buf;
|
2010-11-25 15:37:39 -05:00
|
|
|
}
|
2010-09-20 11:12:44 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-09-20 11:12:44 -04:00
|
|
|
void
|
2019-08-12 18:56:48 -04:00
|
|
|
EditorRegions::populate_row_fade_out (boost::shared_ptr<Region> region, TreeModel::Row const& row, boost::shared_ptr<AudioRegion> audioregion)
|
2010-09-20 11:12:44 -04:00
|
|
|
{
|
2018-10-22 17:46:44 -04:00
|
|
|
#ifndef SHOW_REGION_EXTRAS
|
|
|
|
return;
|
|
|
|
#endif
|
2018-11-15 10:24:37 -05:00
|
|
|
if (!audioregion) {
|
2010-11-25 15:37:39 -05:00
|
|
|
row[_columns.fadeout] = "";
|
|
|
|
} else {
|
2018-11-15 10:24:37 -05:00
|
|
|
char buf[32];
|
2019-08-12 18:56:48 -04:00
|
|
|
format_position (audioregion->fade_out ()->back ()->when, buf, sizeof (buf), audioregion->fade_out_active ());
|
2018-11-15 10:24:37 -05:00
|
|
|
row[_columns.fadeout] = buf;
|
2010-11-25 15:37:39 -05:00
|
|
|
}
|
2010-09-20 11:12:44 -04:00
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-09-20 11:12:44 -04:00
|
|
|
void
|
2019-08-12 18:56:48 -04:00
|
|
|
EditorRegions::populate_row_locked (boost::shared_ptr<Region> region, TreeModel::Row const& row)
|
2010-09-20 11:12:44 -04:00
|
|
|
{
|
2019-08-12 18:56:48 -04:00
|
|
|
row[_columns.locked] = region->locked ();
|
2010-09-20 11:12:44 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-09-20 11:12:44 -04:00
|
|
|
void
|
2019-08-12 18:56:48 -04:00
|
|
|
EditorRegions::populate_row_glued (boost::shared_ptr<Region> region, TreeModel::Row const& row)
|
2010-09-20 11:12:44 -04:00
|
|
|
{
|
2019-08-12 18:56:48 -04:00
|
|
|
if (region->position_lock_style () == MusicTime) {
|
2018-11-15 10:24:37 -05:00
|
|
|
row[_columns.glued] = true;
|
2010-11-25 15:37:39 -05:00
|
|
|
} else {
|
2018-11-15 10:24:37 -05:00
|
|
|
row[_columns.glued] = false;
|
2010-11-25 15:37:39 -05:00
|
|
|
}
|
2010-09-20 11:12:44 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-09-20 11:12:44 -04:00
|
|
|
void
|
2019-08-12 18:56:48 -04:00
|
|
|
EditorRegions::populate_row_muted (boost::shared_ptr<Region> region, TreeModel::Row const& row)
|
2010-09-20 11:12:44 -04:00
|
|
|
{
|
2019-08-12 18:56:48 -04:00
|
|
|
row[_columns.muted] = region->muted ();
|
2010-09-20 11:12:44 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-09-20 11:12:44 -04:00
|
|
|
void
|
2019-08-12 18:56:48 -04:00
|
|
|
EditorRegions::populate_row_opaque (boost::shared_ptr<Region> region, TreeModel::Row const& row)
|
2010-09-20 11:12:44 -04:00
|
|
|
{
|
2019-08-12 18:56:48 -04:00
|
|
|
row[_columns.opaque] = region->opaque ();
|
2010-09-20 11:12:44 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-09-20 11:12:44 -04:00
|
|
|
void
|
2019-08-12 18:56:48 -04:00
|
|
|
EditorRegions::populate_row_name (boost::shared_ptr<Region> region, TreeModel::Row const& row)
|
2010-09-20 11:12:44 -04:00
|
|
|
{
|
2019-08-12 18:56:48 -04:00
|
|
|
if (region->n_channels () > 1) {
|
|
|
|
row[_columns.name] = string_compose ("%1 [%2]", Gtkmm2ext::markup_escape_text (region->name ()), region->n_channels ());
|
2009-07-03 18:42:22 -04:00
|
|
|
} else {
|
2019-08-12 18:56:48 -04:00
|
|
|
row[_columns.name] = Gtkmm2ext::markup_escape_text (region->name ());
|
2009-07-03 18:42:22 -04:00
|
|
|
}
|
2018-11-15 10:27:04 -05:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
row[_columns.tags] = region->tags ();
|
2011-06-01 13:00:29 -04:00
|
|
|
}
|
2010-09-20 11:12:44 -04:00
|
|
|
|
|
|
|
void
|
2019-08-12 18:56:48 -04:00
|
|
|
EditorRegions::populate_row_source (boost::shared_ptr<Region> region, TreeModel::Row const& row)
|
2010-09-20 11:12:44 -04:00
|
|
|
{
|
2019-08-12 18:56:48 -04:00
|
|
|
if (boost::dynamic_pointer_cast<SilentFileSource> (region->source ())) {
|
|
|
|
row[_columns.path] = _ ("MISSING ") + Gtkmm2ext::markup_escape_text (region->source ()->name ());
|
2010-09-20 11:12:44 -04:00
|
|
|
} else {
|
2019-08-12 18:56:48 -04:00
|
|
|
row[_columns.path] = Gtkmm2ext::markup_escape_text (region->source ()->name ());
|
2010-09-20 11:12:44 -04:00
|
|
|
}
|
2009-07-03 18:42:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EditorRegions::show_context_menu (int button, int time)
|
|
|
|
{
|
2018-10-22 17:46:44 -04:00
|
|
|
using namespace Gtk::Menu_Helpers;
|
2019-08-12 18:56:48 -04:00
|
|
|
Gtk::Menu* menu = dynamic_cast<Menu*> (ActionManager::get_widget (X_ ("/PopupRegionMenu")));
|
2018-10-22 17:46:44 -04:00
|
|
|
menu->popup (button, time);
|
2009-07-03 18:42:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-09-28 13:27:58 -04:00
|
|
|
EditorRegions::key_press (GdkEventKey* ev)
|
2009-07-03 18:42:22 -04:00
|
|
|
{
|
2019-08-12 18:56:48 -04:00
|
|
|
TreeViewColumn* col;
|
2010-09-28 13:27:58 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
switch (ev->keyval) {
|
2019-08-12 18:56:48 -04:00
|
|
|
case GDK_Tab:
|
|
|
|
case GDK_ISO_Left_Tab:
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
if (name_editable) {
|
|
|
|
name_editable->editing_done ();
|
|
|
|
name_editable = 0;
|
|
|
|
}
|
2010-09-28 22:01:35 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
if (tags_editable) {
|
|
|
|
tags_editable->editing_done ();
|
|
|
|
tags_editable = 0;
|
|
|
|
}
|
2018-11-15 10:27:04 -05:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
col = _display.get_column (0); // select&focus on name column
|
2010-09-28 13:27:58 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
|
|
|
|
treeview_select_previous (_display, _model, col);
|
|
|
|
} else {
|
|
|
|
treeview_select_next (_display, _model, col);
|
|
|
|
}
|
2010-09-28 13:27:58 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
return true;
|
|
|
|
break;
|
2010-09-28 13:27:58 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
default:
|
|
|
|
break;
|
2010-11-25 15:37:39 -05:00
|
|
|
}
|
2010-09-28 13:27:58 -04:00
|
|
|
|
2009-07-03 18:42:22 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2019-08-12 18:56:48 -04:00
|
|
|
EditorRegions::button_press (GdkEventButton* ev)
|
2009-07-03 18:42:22 -04:00
|
|
|
{
|
|
|
|
boost::shared_ptr<Region> region;
|
2019-08-12 18:56:48 -04:00
|
|
|
TreeIter iter;
|
|
|
|
TreeModel::Path path;
|
|
|
|
TreeViewColumn* column;
|
|
|
|
int cellx;
|
|
|
|
int celly;
|
2009-07-03 18:42:22 -04:00
|
|
|
|
|
|
|
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 (Keyboard::is_context_menu_event (ev)) {
|
|
|
|
show_context_menu (ev->button, ev->time);
|
2019-08-11 20:07:03 -04:00
|
|
|
return true;
|
2009-07-03 18:42:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (region != 0 && Keyboard::is_button2_event (ev)) {
|
2019-08-12 18:56:48 -04:00
|
|
|
/* start/stop audition */
|
2009-07-03 18:42:22 -04:00
|
|
|
if (!Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
|
|
|
|
_editor->consider_auditioning (region);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-07-03 18:42:22 -04:00
|
|
|
return false;
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2009-07-03 18:42:22 -04:00
|
|
|
|
|
|
|
void
|
2019-08-12 18:56:48 -04:00
|
|
|
EditorRegions::selection_mapover (sigc::slot<void, boost::shared_ptr<Region> > sl)
|
2009-07-03 18:42:22 -04:00
|
|
|
{
|
2019-08-12 18:56:48 -04:00
|
|
|
Glib::RefPtr<TreeSelection> selection = _display.get_selection ();
|
|
|
|
TreeView::Selection::ListHandle_Path rows = selection->get_selected_rows ();
|
|
|
|
TreeView::Selection::ListHandle_Path::iterator i = rows.begin ();
|
2009-07-03 18:42:22 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
if (selection->count_selected_rows () == 0 || _session == 0) {
|
2009-07-03 18:42:22 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
for (; i != rows.end (); ++i) {
|
2009-07-03 18:42:22 -04:00
|
|
|
TreeIter iter;
|
|
|
|
|
|
|
|
if ((iter = _model->get_iter (*i))) {
|
|
|
|
/* some rows don't have a region associated with them, but can still be
|
|
|
|
selected (XXX maybe prevent them from being selected)
|
|
|
|
*/
|
|
|
|
|
|
|
|
boost::shared_ptr<Region> r = (*iter)[_columns.region];
|
|
|
|
|
|
|
|
if (r) {
|
|
|
|
sl (r);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
void
|
2009-07-03 18:42:22 -04:00
|
|
|
EditorRegions::drag_data_received (const RefPtr<Gdk::DragContext>& context,
|
2017-07-01 12:42:24 -04:00
|
|
|
int x, int y,
|
|
|
|
const SelectionData& data,
|
|
|
|
guint info, guint time)
|
2009-07-03 18:42:22 -04:00
|
|
|
{
|
2010-09-14 11:45:21 -04:00
|
|
|
vector<string> paths;
|
2009-07-03 18:42:22 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
if (data.get_target () == "GTK_TREE_MODEL_ROW") {
|
2010-05-05 18:09:07 -04:00
|
|
|
/* something is being dragged over the region list */
|
|
|
|
_editor->_drags->abort ();
|
2009-07-03 18:42:22 -04:00
|
|
|
_display.on_drag_data_received (context, x, y, data, info, time);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_editor->convert_drop_to_paths (paths, context, x, y, data, info, time) == 0) {
|
2019-08-12 18:56:48 -04:00
|
|
|
samplepos_t pos = 0;
|
|
|
|
bool copy = ((context->get_actions () & (Gdk::ACTION_COPY | Gdk::ACTION_LINK | Gdk::ACTION_MOVE)) == Gdk::ACTION_COPY);
|
2013-03-21 16:33:02 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
if (UIConfiguration::instance ().get_only_copy_imported_files () || copy) {
|
2017-01-10 05:26:23 -05:00
|
|
|
_editor->do_import (paths, Editing::ImportDistinctFiles, Editing::ImportAsRegion,
|
2016-12-16 09:57:14 -05:00
|
|
|
SrcBest, SMFTrackName, SMFTempoIgnore, pos);
|
2009-07-03 18:42:22 -04:00
|
|
|
} else {
|
|
|
|
_editor->do_embed (paths, Editing::ImportDistinctFiles, ImportAsRegion, pos);
|
|
|
|
}
|
|
|
|
context->drag_finish (true, false, time);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-09-28 13:27:58 -04:00
|
|
|
EditorRegions::selection_filter (const RefPtr<TreeModel>& model, const TreeModel::Path& path, bool already_selected)
|
2009-07-03 18:42:22 -04:00
|
|
|
{
|
2010-11-25 15:37:39 -05:00
|
|
|
if (already_selected) {
|
2019-08-12 18:56:48 -04:00
|
|
|
/* deselecting path, if it is selected, is OK */
|
2010-11-25 15:37:39 -05:00
|
|
|
return true;
|
|
|
|
}
|
2010-09-28 13:27:58 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
/* not possible to select rows that do not represent regions, like "Hidden" */
|
2009-07-03 18:42:22 -04:00
|
|
|
TreeModel::iterator iter = model->get_iter (path);
|
|
|
|
if (iter) {
|
2019-08-12 18:56:48 -04:00
|
|
|
boost::shared_ptr<Region> r = (*iter)[_columns.region];
|
2009-07-03 18:42:22 -04:00
|
|
|
if (!r) {
|
|
|
|
return false;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2009-07-03 18:42:22 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-09-28 22:01:35 -04:00
|
|
|
void
|
2016-03-19 10:33:00 -04:00
|
|
|
EditorRegions::name_editing_started (CellEditable* ce, const Glib::ustring& path)
|
2010-09-28 22:01:35 -04:00
|
|
|
{
|
2010-11-25 15:37:39 -05:00
|
|
|
name_editable = ce;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
/* give it a special name */
|
2010-11-05 12:53:57 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
Gtk::Entry* e = dynamic_cast<Gtk::Entry*> (ce);
|
2010-11-05 12:53:57 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
if (e) {
|
2019-08-12 18:56:48 -04:00
|
|
|
e->set_name (X_ ("RegionNameEditorEntry"));
|
2016-03-19 10:33:00 -04:00
|
|
|
|
|
|
|
TreeIter iter;
|
|
|
|
if ((iter = _model->get_iter (path))) {
|
|
|
|
boost::shared_ptr<Region> region = (*iter)[_columns.region];
|
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
if (region) {
|
|
|
|
e->set_text (region->name ());
|
2016-03-19 10:33:00 -04:00
|
|
|
}
|
|
|
|
}
|
2010-11-25 15:37:39 -05:00
|
|
|
}
|
2010-09-28 22:01:35 -04:00
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-07-03 18:42:22 -04:00
|
|
|
void
|
2010-09-14 12:51:02 -04:00
|
|
|
EditorRegions::name_edit (const std::string& path, const std::string& new_text)
|
2009-07-03 18:42:22 -04:00
|
|
|
{
|
2010-11-25 15:37:39 -05:00
|
|
|
name_editable = 0;
|
2010-09-28 22:01:35 -04:00
|
|
|
|
2009-07-03 18:42:22 -04:00
|
|
|
boost::shared_ptr<Region> region;
|
2019-08-12 18:56:48 -04:00
|
|
|
TreeIter row_iter;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2016-03-19 10:33:00 -04:00
|
|
|
if ((row_iter = _model->get_iter (path))) {
|
2019-08-12 18:56:48 -04:00
|
|
|
region = (*row_iter)[_columns.region];
|
2016-03-19 10:33:00 -04:00
|
|
|
(*row_iter)[_columns.name] = new_text;
|
2009-07-03 18:42:22 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-07-03 18:42:22 -04:00
|
|
|
if (region) {
|
2018-11-15 10:27:04 -05:00
|
|
|
region->set_name (new_text);
|
|
|
|
|
|
|
|
populate_row_name (region, (*row_iter));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EditorRegions::tag_editing_started (CellEditable* ce, const Glib::ustring& path)
|
|
|
|
{
|
|
|
|
tags_editable = ce;
|
|
|
|
|
|
|
|
/* give it a special name */
|
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
Gtk::Entry* e = dynamic_cast<Gtk::Entry*> (ce);
|
2018-11-15 10:27:04 -05:00
|
|
|
|
|
|
|
if (e) {
|
2019-08-12 18:56:48 -04:00
|
|
|
e->set_name (X_ ("RegionTagEditorEntry"));
|
2018-11-15 10:27:04 -05:00
|
|
|
|
|
|
|
TreeIter iter;
|
|
|
|
if ((iter = _model->get_iter (path))) {
|
|
|
|
boost::shared_ptr<Region> region = (*iter)[_columns.region];
|
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
if (region) {
|
|
|
|
e->set_text (region->tags ());
|
2009-07-03 18:42:22 -04:00
|
|
|
}
|
|
|
|
}
|
2018-11-15 10:27:04 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EditorRegions::tag_edit (const std::string& path, const std::string& new_text)
|
|
|
|
{
|
|
|
|
tags_editable = 0;
|
|
|
|
|
|
|
|
boost::shared_ptr<Region> region;
|
2019-08-12 18:56:48 -04:00
|
|
|
TreeIter row_iter;
|
2018-11-15 10:27:04 -05:00
|
|
|
|
|
|
|
if ((row_iter = _model->get_iter (path))) {
|
2019-08-12 18:56:48 -04:00
|
|
|
region = (*row_iter)[_columns.region];
|
2018-11-15 10:27:04 -05:00
|
|
|
(*row_iter)[_columns.tags] = new_text;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (region) {
|
|
|
|
region->set_tags (new_text);
|
2009-07-03 18:42:22 -04:00
|
|
|
|
2016-03-19 10:33:00 -04:00
|
|
|
populate_row_name (region, (*row_iter));
|
|
|
|
}
|
2009-07-03 18:42:22 -04:00
|
|
|
}
|
|
|
|
|
2010-05-05 18:09:07 -04:00
|
|
|
/** @return Region that has been dragged out of the list, or 0 */
|
2009-07-03 18:42:22 -04:00
|
|
|
boost::shared_ptr<Region>
|
|
|
|
EditorRegions::get_dragged_region ()
|
|
|
|
{
|
|
|
|
list<boost::shared_ptr<Region> > regions;
|
2019-08-12 18:56:48 -04:00
|
|
|
TreeView* source;
|
2009-07-03 18:42:22 -04:00
|
|
|
_display.get_object_drag_data (regions, &source);
|
2010-05-05 18:09:07 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
if (regions.empty ()) {
|
2010-05-05 18:09:07 -04:00
|
|
|
return boost::shared_ptr<Region> ();
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
assert (regions.size () == 1);
|
2009-07-03 18:42:22 -04:00
|
|
|
return regions.front ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EditorRegions::clear ()
|
|
|
|
{
|
|
|
|
_display.set_model (Glib::RefPtr<Gtk::TreeStore> (0));
|
|
|
|
_model->clear ();
|
|
|
|
_display.set_model (_model);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-02-15 07:23:57 -05:00
|
|
|
/* Clean up the maps */
|
2019-08-12 18:56:48 -04:00
|
|
|
region_row_map.clear ();
|
2009-07-03 18:42:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
boost::shared_ptr<Region>
|
|
|
|
EditorRegions::get_single_selection ()
|
|
|
|
{
|
2019-08-12 18:56:48 -04:00
|
|
|
Glib::RefPtr<TreeSelection> selected = _display.get_selection ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
if (selected->count_selected_rows () != 1) {
|
2009-07-03 18:42:22 -04:00
|
|
|
return boost::shared_ptr<Region> ();
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-07-03 18:42:22 -04:00
|
|
|
TreeView::Selection::ListHandle_Path rows = selected->get_selected_rows ();
|
|
|
|
|
|
|
|
/* only one row selected, so rows.begin() is it */
|
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
TreeIter iter = _model->get_iter (*rows.begin ());
|
2009-07-03 18:42:22 -04:00
|
|
|
|
|
|
|
if (!iter) {
|
|
|
|
return boost::shared_ptr<Region> ();
|
|
|
|
}
|
|
|
|
|
|
|
|
return (*iter)[_columns.region];
|
|
|
|
}
|
2010-06-27 20:41:01 -04:00
|
|
|
|
2016-04-08 13:21:13 -04:00
|
|
|
void
|
2019-08-12 18:56:48 -04:00
|
|
|
EditorRegions::freeze_tree_model ()
|
|
|
|
{
|
|
|
|
_display.set_model (Glib::RefPtr<Gtk::TreeStore> (0));
|
2016-04-08 13:21:13 -04:00
|
|
|
_model->set_sort_column (-2, SORT_ASCENDING); //Disable sorting to gain performance
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-11-15 10:24:37 -05:00
|
|
|
EditorRegions::thaw_tree_model ()
|
|
|
|
{
|
2016-04-08 13:21:13 -04:00
|
|
|
_model->set_sort_column (0, SORT_ASCENDING); // renabale sorting
|
|
|
|
_display.set_model (_model);
|
|
|
|
}
|
|
|
|
|
2010-06-27 20:41:01 -04:00
|
|
|
void
|
2019-08-12 18:56:48 -04:00
|
|
|
EditorRegions::locked_changed (std::string const& path)
|
2010-06-27 20:41:01 -04:00
|
|
|
{
|
|
|
|
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
|
2019-08-12 18:56:48 -04:00
|
|
|
EditorRegions::glued_changed (std::string const& path)
|
2010-06-27 20:41:01 -04:00
|
|
|
{
|
|
|
|
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
|
2019-08-12 18:56:48 -04:00
|
|
|
EditorRegions::muted_changed (std::string const& path)
|
2010-06-27 20:41:01 -04:00
|
|
|
{
|
|
|
|
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
|
2019-08-12 18:56:48 -04:00
|
|
|
EditorRegions::opaque_changed (std::string const& path)
|
2010-06-27 20:41:01 -04:00
|
|
|
{
|
|
|
|
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]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-09-18 22:18:59 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
XMLNode&
|
2010-09-18 22:18:59 -04:00
|
|
|
EditorRegions::get_state () const
|
|
|
|
{
|
2019-08-12 18:56:48 -04:00
|
|
|
XMLNode* node = new XMLNode (X_ ("RegionList"));
|
2010-09-18 22:18:59 -04:00
|
|
|
|
2019-05-31 14:36:46 -04:00
|
|
|
//TODO: save sort state?
|
2019-08-12 18:56:48 -04:00
|
|
|
// node->set_property (X_("sort-col"), _sort_type);
|
|
|
|
// node->set_property (X_("sort-asc"), _sort_type);
|
2010-09-18 22:18:59 -04:00
|
|
|
|
|
|
|
return *node;
|
|
|
|
}
|
2011-02-14 16:49:43 -05:00
|
|
|
|
2010-09-18 22:18:59 -04:00
|
|
|
void
|
2019-08-12 18:56:48 -04:00
|
|
|
EditorRegions::set_state (const XMLNode& node)
|
2010-09-18 22:18:59 -04:00
|
|
|
{
|
2010-11-25 15:37:39 -05:00
|
|
|
bool changed = false;
|
2010-09-20 15:18:17 -04:00
|
|
|
|
2019-08-12 18:56:48 -04:00
|
|
|
if (node.name () != X_ ("RegionList")) {
|
2010-09-18 22:18:59 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
if (changed) {
|
|
|
|
redisplay ();
|
|
|
|
}
|
2010-09-18 22:18:59 -04:00
|
|
|
}
|
|
|
|
|
2011-02-14 16:49:43 -05:00
|
|
|
RefPtr<Action>
|
2011-11-15 13:32:42 -05:00
|
|
|
EditorRegions::remove_unused_regions_action () const
|
2011-02-14 16:49:43 -05:00
|
|
|
{
|
2019-08-12 18:56:48 -04:00
|
|
|
return ActionManager::get_action (X_ ("RegionList"), X_ ("removeUnusedRegions"));
|
2011-02-14 16:49:43 -05:00
|
|
|
}
|