2005-09-25 14:42:24 -04:00
|
|
|
/*
|
2009-10-14 12:10:01 -04:00
|
|
|
Copyright (C) 2000 Paul Davis
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cmath>
|
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
#include <gtkmm2ext/gtk_ui.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-10-30 11:30:22 -04:00
|
|
|
#include "ardour/session.h"
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/location.h"
|
|
|
|
#include "ardour/profile.h"
|
|
|
|
#include "pbd/memento_command.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
#include "canvas/canvas.h"
|
|
|
|
#include "canvas/item.h"
|
|
|
|
#include "canvas/rectangle.h"
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "editor.h"
|
|
|
|
#include "marker.h"
|
|
|
|
#include "selection.h"
|
|
|
|
#include "editing.h"
|
|
|
|
#include "gui_thread.h"
|
2006-03-05 14:39:16 -05:00
|
|
|
#include "actions.h"
|
2006-04-22 11:28:59 -04:00
|
|
|
#include "prompter.h"
|
2010-01-12 11:14:49 -05:00
|
|
|
#include "editor_drag.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace ARDOUR;
|
2006-06-22 19:40:55 -04:00
|
|
|
using namespace PBD;
|
2005-09-25 14:42:24 -04:00
|
|
|
using namespace Gtk;
|
2007-04-11 09:07:51 -04:00
|
|
|
using namespace Gtkmm2ext;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
Editor::clear_marker_display ()
|
|
|
|
{
|
|
|
|
for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) {
|
|
|
|
delete i->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
location_markers.clear ();
|
2010-11-14 18:47:09 -05:00
|
|
|
_sorted_marker_lists.clear ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::add_new_location (Location *location)
|
|
|
|
{
|
2011-04-22 22:00:23 -04:00
|
|
|
ENSURE_GUI_THREAD (*this, &Editor::add_new_location, location);
|
2006-04-05 21:52:45 -04:00
|
|
|
|
2011-04-22 22:00:23 -04:00
|
|
|
ArdourCanvas::Group* group = add_new_location_internal (location);
|
|
|
|
|
|
|
|
/* Do a full update of the markers in this group */
|
|
|
|
update_marker_labels (group);
|
2014-01-27 21:27:13 -05:00
|
|
|
|
|
|
|
if (location->is_auto_punch()) {
|
|
|
|
update_punch_range_view ();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (location->is_auto_loop()) {
|
|
|
|
update_loop_range_view ();
|
|
|
|
}
|
2011-04-22 22:00:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Add a new location, without a time-consuming update of all marker labels;
|
|
|
|
* the caller must call update_marker_labels () after calling this.
|
|
|
|
* @return canvas group that the location's marker was added to.
|
|
|
|
*/
|
|
|
|
ArdourCanvas::Group*
|
|
|
|
Editor::add_new_location_internal (Location* location)
|
|
|
|
{
|
2005-09-25 14:42:24 -04:00
|
|
|
LocationMarkers *lam = new LocationMarkers;
|
|
|
|
uint32_t color;
|
|
|
|
|
2010-11-12 17:51:54 -05:00
|
|
|
/* make a note here of which group this marker ends up in */
|
|
|
|
ArdourCanvas::Group* group = 0;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (location->is_cd_marker()) {
|
|
|
|
color = location_cd_marker_color;
|
|
|
|
} else if (location->is_mark()) {
|
|
|
|
color = location_marker_color;
|
|
|
|
} else if (location->is_auto_loop()) {
|
|
|
|
color = location_loop_color;
|
|
|
|
} else if (location->is_auto_punch()) {
|
|
|
|
color = location_punch_color;
|
|
|
|
} else {
|
|
|
|
color = location_range_color;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (location->is_mark()) {
|
|
|
|
|
2008-03-17 16:54:03 -04:00
|
|
|
if (location->is_cd_marker() && ruler_cd_marker_action->get_active()) {
|
2010-12-29 08:48:25 -05:00
|
|
|
lam->start = new Marker (*this, *cd_marker_group, color, location->name(), Marker::Mark, location->start());
|
2010-11-12 17:51:54 -05:00
|
|
|
group = cd_marker_group;
|
|
|
|
} else {
|
2010-12-29 08:48:25 -05:00
|
|
|
lam->start = new Marker (*this, *marker_group, color, location->name(), Marker::Mark, location->start());
|
2010-11-12 17:51:54 -05:00
|
|
|
group = marker_group;
|
2008-01-10 16:20:59 -05:00
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-11-12 17:51:54 -05:00
|
|
|
lam->end = 0;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
} else if (location->is_auto_loop()) {
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
// transport marker
|
2010-12-29 08:48:25 -05:00
|
|
|
lam->start = new Marker (*this, *transport_marker_group, color,
|
2005-11-24 09:59:36 -05:00
|
|
|
location->name(), Marker::LoopStart, location->start());
|
2010-12-29 08:48:25 -05:00
|
|
|
lam->end = new Marker (*this, *transport_marker_group, color,
|
2005-11-24 09:59:36 -05:00
|
|
|
location->name(), Marker::LoopEnd, location->end());
|
2010-11-12 17:51:54 -05:00
|
|
|
group = transport_marker_group;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
} else if (location->is_auto_punch()) {
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
// transport marker
|
2010-12-29 08:48:25 -05:00
|
|
|
lam->start = new Marker (*this, *transport_marker_group, color,
|
2005-11-24 09:59:36 -05:00
|
|
|
location->name(), Marker::PunchIn, location->start());
|
2010-12-29 08:48:25 -05:00
|
|
|
lam->end = new Marker (*this, *transport_marker_group, color,
|
2005-11-24 09:59:36 -05:00
|
|
|
location->name(), Marker::PunchOut, location->end());
|
2010-11-12 17:51:54 -05:00
|
|
|
group = transport_marker_group;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-04-18 17:29:48 -04:00
|
|
|
} else if (location->is_session_range()) {
|
2010-11-12 17:51:54 -05:00
|
|
|
|
2010-04-18 17:29:48 -04:00
|
|
|
// session range
|
2010-12-29 08:48:25 -05:00
|
|
|
lam->start = new Marker (*this, *marker_group, color, _("start"), Marker::SessionStart, location->start());
|
|
|
|
lam->end = new Marker (*this, *marker_group, color, _("end"), Marker::SessionEnd, location->end());
|
2010-11-12 17:51:54 -05:00
|
|
|
group = marker_group;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
|
|
|
// range marker
|
2008-03-17 16:54:03 -04:00
|
|
|
if (location->is_cd_marker() && ruler_cd_marker_action->get_active()) {
|
2010-12-29 08:48:25 -05:00
|
|
|
lam->start = new Marker (*this, *cd_marker_group, color,
|
2010-11-12 13:53:15 -05:00
|
|
|
location->name(), Marker::RangeStart, location->start());
|
2010-12-29 08:48:25 -05:00
|
|
|
lam->end = new Marker (*this, *cd_marker_group, color,
|
2010-11-12 13:53:15 -05:00
|
|
|
location->name(), Marker::RangeEnd, location->end());
|
2010-11-12 17:51:54 -05:00
|
|
|
group = cd_marker_group;
|
|
|
|
} else {
|
2010-12-29 08:48:25 -05:00
|
|
|
lam->start = new Marker (*this, *range_marker_group, color,
|
2010-11-12 13:53:15 -05:00
|
|
|
location->name(), Marker::RangeStart, location->start());
|
2010-12-29 08:48:25 -05:00
|
|
|
lam->end = new Marker (*this, *range_marker_group, color,
|
2010-11-12 13:53:15 -05:00
|
|
|
location->name(), Marker::RangeEnd, location->end());
|
2010-11-12 17:51:54 -05:00
|
|
|
group = range_marker_group;
|
2008-01-10 16:20:59 -05:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (location->is_hidden ()) {
|
|
|
|
lam->hide();
|
|
|
|
} else {
|
|
|
|
lam->show ();
|
|
|
|
}
|
|
|
|
|
2012-04-25 08:58:19 -04:00
|
|
|
location->start_changed.connect (*this, invalidator (*this), boost::bind (&Editor::location_changed, this, _1), gui_context());
|
|
|
|
location->end_changed.connect (*this, invalidator (*this), boost::bind (&Editor::location_changed, this, _1), gui_context());
|
|
|
|
location->changed.connect (*this, invalidator (*this), boost::bind (&Editor::location_changed, this, _1), gui_context());
|
|
|
|
location->name_changed.connect (*this, invalidator (*this), boost::bind (&Editor::location_changed, this, _1), gui_context());
|
|
|
|
location->FlagsChanged.connect (*this, invalidator (*this), boost::bind (&Editor::location_flags_changed, this, _1, _2), gui_context());
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
pair<Location*,LocationMarkers*> newpair;
|
|
|
|
|
|
|
|
newpair.first = location;
|
|
|
|
newpair.second = lam;
|
|
|
|
|
|
|
|
location_markers.insert (newpair);
|
2008-01-10 16:20:59 -05:00
|
|
|
|
|
|
|
if (select_new_marker && location->is_mark()) {
|
|
|
|
selection->set (lam->start);
|
|
|
|
select_new_marker = false;
|
|
|
|
}
|
2010-11-10 13:29:32 -05:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
lam->canvas_height_set (_visible_canvas_height);
|
2010-11-11 08:36:38 -05:00
|
|
|
lam->set_show_lines (_show_marker_lines);
|
2010-11-12 17:51:54 -05:00
|
|
|
|
|
|
|
/* Add these markers to the appropriate sorted marker lists, which will render
|
2011-04-22 22:00:23 -04:00
|
|
|
them unsorted until a call to update_marker_labels() sorts them out.
|
2010-11-12 17:51:54 -05:00
|
|
|
*/
|
|
|
|
_sorted_marker_lists[group].push_back (lam->start);
|
|
|
|
if (lam->end) {
|
|
|
|
_sorted_marker_lists[group].push_back (lam->end);
|
|
|
|
}
|
|
|
|
|
2011-04-22 22:00:23 -04:00
|
|
|
return group;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::location_changed (Location *location)
|
|
|
|
{
|
2009-12-11 18:29:48 -05:00
|
|
|
ENSURE_GUI_THREAD (*this, &Editor::location_changed, location)
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
LocationMarkers *lam = find_location_markers (location);
|
|
|
|
|
|
|
|
if (lam == 0) {
|
|
|
|
/* a location that isn't "marked" with markers */
|
|
|
|
return;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-04-18 17:29:48 -04:00
|
|
|
lam->set_name (location->name ());
|
2005-09-25 14:42:24 -04:00
|
|
|
lam->set_position (location->start(), location->end());
|
|
|
|
|
|
|
|
if (location->is_auto_loop()) {
|
|
|
|
update_loop_range_view ();
|
|
|
|
} else if (location->is_auto_punch()) {
|
|
|
|
update_punch_range_view ();
|
|
|
|
}
|
2010-11-12 17:51:54 -05:00
|
|
|
|
|
|
|
check_marker_label (lam->start);
|
|
|
|
if (lam->end) {
|
|
|
|
check_marker_label (lam->end);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Look at a marker and check whether its label, and those of the previous and next markers,
|
|
|
|
* need to have their labels updated (in case those labels need to be shortened or can be
|
|
|
|
* lengthened)
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
Editor::check_marker_label (Marker* m)
|
|
|
|
{
|
|
|
|
/* Get a time-ordered list of markers from the last time anything changed */
|
|
|
|
std::list<Marker*>& sorted = _sorted_marker_lists[m->get_parent()];
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-11-12 17:51:54 -05:00
|
|
|
list<Marker*>::iterator i = find (sorted.begin(), sorted.end(), m);
|
|
|
|
|
|
|
|
list<Marker*>::iterator prev = sorted.end ();
|
|
|
|
list<Marker*>::iterator next = i;
|
|
|
|
++next;
|
|
|
|
|
|
|
|
/* Look to see if the previous marker is still behind `m' in time */
|
|
|
|
if (i != sorted.begin()) {
|
|
|
|
|
|
|
|
prev = i;
|
|
|
|
--prev;
|
|
|
|
|
|
|
|
if ((*prev)->position() > m->position()) {
|
|
|
|
/* This marker is no longer in the correct order with the previous one, so
|
|
|
|
* update all the markers in this group.
|
|
|
|
*/
|
|
|
|
update_marker_labels (m->get_parent ());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Look to see if the next marker is still ahead of `m' in time */
|
|
|
|
if (next != sorted.end() && (*next)->position() < m->position()) {
|
|
|
|
/* This marker is no longer in the correct order with the next one, so
|
|
|
|
* update all the markers in this group.
|
|
|
|
*/
|
|
|
|
update_marker_labels (m->get_parent ());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (prev != sorted.end()) {
|
|
|
|
|
|
|
|
/* Update just the available space between the previous marker and this one */
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2013-04-12 11:15:45 -04:00
|
|
|
double const p = sample_to_pixel (m->position() - (*prev)->position());
|
2010-11-12 17:51:54 -05:00
|
|
|
|
|
|
|
if (m->label_on_left()) {
|
|
|
|
(*prev)->set_right_label_limit (p / 2);
|
|
|
|
} else {
|
|
|
|
(*prev)->set_right_label_limit (p);
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-11-12 17:51:54 -05:00
|
|
|
if ((*prev)->label_on_left ()) {
|
|
|
|
m->set_left_label_limit (p);
|
|
|
|
} else {
|
|
|
|
m->set_left_label_limit (p / 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (next != sorted.end()) {
|
|
|
|
|
|
|
|
/* Update just the available space between this marker and the next */
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2013-04-12 11:15:45 -04:00
|
|
|
double const p = sample_to_pixel ((*next)->position() - m->position());
|
2010-11-12 17:51:54 -05:00
|
|
|
|
|
|
|
if ((*next)->label_on_left()) {
|
|
|
|
m->set_right_label_limit (p / 2);
|
|
|
|
} else {
|
|
|
|
m->set_right_label_limit (p);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m->label_on_left()) {
|
|
|
|
(*next)->set_left_label_limit (p);
|
|
|
|
} else {
|
|
|
|
(*next)->set_left_label_limit (p / 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct MarkerComparator {
|
|
|
|
bool operator() (Marker const * a, Marker const * b) {
|
|
|
|
return a->position() < b->position();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Update all marker labels in all groups */
|
|
|
|
void
|
|
|
|
Editor::update_marker_labels ()
|
|
|
|
{
|
|
|
|
for (std::map<ArdourCanvas::Group *, std::list<Marker *> >::iterator i = _sorted_marker_lists.begin(); i != _sorted_marker_lists.end(); ++i) {
|
|
|
|
update_marker_labels (i->first);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Look at all markers in a group and update label widths */
|
|
|
|
void
|
|
|
|
Editor::update_marker_labels (ArdourCanvas::Group* group)
|
|
|
|
{
|
|
|
|
list<Marker*>& sorted = _sorted_marker_lists[group];
|
|
|
|
|
|
|
|
if (sorted.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We sort the list of markers and then set up the space available between each one */
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-11-12 17:51:54 -05:00
|
|
|
sorted.sort (MarkerComparator ());
|
|
|
|
|
|
|
|
list<Marker*>::iterator i = sorted.begin ();
|
|
|
|
|
|
|
|
list<Marker*>::iterator prev = sorted.end ();
|
|
|
|
list<Marker*>::iterator next = i;
|
2014-03-14 13:43:51 -04:00
|
|
|
|
|
|
|
if (next != sorted.end()) {
|
|
|
|
++next;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-11-12 17:51:54 -05:00
|
|
|
while (i != sorted.end()) {
|
|
|
|
|
|
|
|
if (prev != sorted.end()) {
|
2013-04-12 11:15:45 -04:00
|
|
|
double const p = sample_to_pixel ((*i)->position() - (*prev)->position());
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-11-12 17:51:54 -05:00
|
|
|
if ((*prev)->label_on_left()) {
|
|
|
|
(*i)->set_left_label_limit (p);
|
|
|
|
} else {
|
|
|
|
(*i)->set_left_label_limit (p / 2);
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-11-12 17:51:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (next != sorted.end()) {
|
2013-04-12 11:15:45 -04:00
|
|
|
double const p = sample_to_pixel ((*next)->position() - (*i)->position());
|
2010-11-12 17:51:54 -05:00
|
|
|
|
|
|
|
if ((*next)->label_on_left()) {
|
|
|
|
(*i)->set_right_label_limit (p / 2);
|
|
|
|
} else {
|
|
|
|
(*i)->set_right_label_limit (p);
|
|
|
|
}
|
2014-03-15 10:40:36 -04:00
|
|
|
|
|
|
|
++next;
|
2010-11-12 17:51:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
prev = i;
|
|
|
|
++i;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-12-22 15:21:43 -05:00
|
|
|
Editor::location_flags_changed (Location *location, void*)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2009-12-11 18:29:48 -05:00
|
|
|
ENSURE_GUI_THREAD (*this, &Editor::location_flags_changed, location, src)
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
LocationMarkers *lam = find_location_markers (location);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (lam == 0) {
|
|
|
|
/* a location that isn't "marked" with markers */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
// move cd markers to/from cd marker bar as appropriate
|
|
|
|
ensure_cd_marker_updated (lam, location);
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (location->is_cd_marker()) {
|
|
|
|
lam->set_color_rgba (location_cd_marker_color);
|
|
|
|
} else if (location->is_mark()) {
|
|
|
|
lam->set_color_rgba (location_marker_color);
|
|
|
|
} else if (location->is_auto_punch()) {
|
|
|
|
lam->set_color_rgba (location_punch_color);
|
|
|
|
} else if (location->is_auto_loop()) {
|
|
|
|
lam->set_color_rgba (location_loop_color);
|
|
|
|
} else {
|
|
|
|
lam->set_color_rgba (location_range_color);
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (location->is_hidden()) {
|
|
|
|
lam->hide();
|
|
|
|
} else {
|
|
|
|
lam->show ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
void Editor::update_cd_marker_display ()
|
|
|
|
{
|
|
|
|
for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) {
|
|
|
|
LocationMarkers * lam = i->second;
|
|
|
|
Location * location = i->first;
|
|
|
|
|
|
|
|
ensure_cd_marker_updated (lam, location);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::ensure_cd_marker_updated (LocationMarkers * lam, Location * location)
|
|
|
|
{
|
|
|
|
if (location->is_cd_marker()
|
2008-03-17 16:54:03 -04:00
|
|
|
&& (ruler_cd_marker_action->get_active() && lam->start->get_parent() != cd_marker_group))
|
2008-01-10 16:20:59 -05:00
|
|
|
{
|
|
|
|
//cerr << "reparenting non-cd marker so it can be relocated: " << location->name() << endl;
|
|
|
|
if (lam->start) {
|
|
|
|
lam->start->reparent (*cd_marker_group);
|
|
|
|
}
|
|
|
|
if (lam->end) {
|
|
|
|
lam->end->reparent (*cd_marker_group);
|
|
|
|
}
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
else if ( (!location->is_cd_marker() || !ruler_cd_marker_action->get_active())
|
|
|
|
&& (lam->start->get_parent() == cd_marker_group))
|
2008-01-10 16:20:59 -05:00
|
|
|
{
|
|
|
|
//cerr << "reparenting non-cd marker so it can be relocated: " << location->name() << endl;
|
|
|
|
if (location->is_mark()) {
|
|
|
|
if (lam->start) {
|
|
|
|
lam->start->reparent (*marker_group);
|
|
|
|
}
|
|
|
|
if (lam->end) {
|
|
|
|
lam->end->reparent (*marker_group);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (lam->start) {
|
|
|
|
lam->start->reparent (*range_marker_group);
|
|
|
|
}
|
|
|
|
if (lam->end) {
|
|
|
|
lam->end->reparent (*range_marker_group);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
Editor::LocationMarkers::~LocationMarkers ()
|
|
|
|
{
|
2008-12-18 14:31:00 -05:00
|
|
|
delete start;
|
|
|
|
delete end;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Editor::LocationMarkers *
|
2007-11-07 20:40:25 -05:00
|
|
|
Editor::find_location_markers (Location *location) const
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2007-11-07 20:40:25 -05:00
|
|
|
LocationMarkerMap::const_iterator i;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
for (i = location_markers.begin(); i != location_markers.end(); ++i) {
|
|
|
|
if ((*i).first == location) {
|
|
|
|
return (*i).second;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Location *
|
2007-11-07 20:40:25 -05:00
|
|
|
Editor::find_location_from_marker (Marker *marker, bool& is_start) const
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2007-11-07 20:40:25 -05:00
|
|
|
LocationMarkerMap::const_iterator i;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
for (i = location_markers.begin(); i != location_markers.end(); ++i) {
|
|
|
|
LocationMarkers *lm = (*i).second;
|
|
|
|
if (lm->start == marker) {
|
|
|
|
is_start = true;
|
|
|
|
return (*i).first;
|
|
|
|
} else if (lm->end == marker) {
|
|
|
|
is_start = false;
|
|
|
|
return (*i).first;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::refresh_location_display_internal (Locations::LocationList& locations)
|
|
|
|
{
|
2007-11-12 17:23:01 -05:00
|
|
|
/* invalidate all */
|
|
|
|
|
|
|
|
for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) {
|
|
|
|
i->second->valid = false;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-11-12 17:23:01 -05:00
|
|
|
/* add new ones */
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
for (Locations::LocationList::iterator i = locations.begin(); i != locations.end(); ++i) {
|
2007-11-12 17:23:01 -05:00
|
|
|
|
|
|
|
LocationMarkerMap::iterator x;
|
|
|
|
|
|
|
|
if ((x = location_markers.find (*i)) != location_markers.end()) {
|
|
|
|
x->second->valid = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-04-22 22:00:23 -04:00
|
|
|
add_new_location_internal (*i);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2007-11-12 17:23:01 -05:00
|
|
|
|
|
|
|
/* remove dead ones */
|
|
|
|
|
|
|
|
for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ) {
|
|
|
|
|
|
|
|
LocationMarkerMap::iterator tmp;
|
|
|
|
|
|
|
|
tmp = i;
|
|
|
|
++tmp;
|
|
|
|
|
|
|
|
if (!i->second->valid) {
|
2010-11-14 18:47:09 -05:00
|
|
|
|
|
|
|
remove_sorted_marker (i->second->start);
|
|
|
|
if (i->second->end) {
|
|
|
|
remove_sorted_marker (i->second->end);
|
|
|
|
}
|
2011-05-05 08:45:24 -04:00
|
|
|
|
|
|
|
LocationMarkers* m = i->second;
|
2007-11-12 17:23:01 -05:00
|
|
|
location_markers.erase (i);
|
2011-05-05 08:45:24 -04:00
|
|
|
delete m;
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2007-11-12 17:23:01 -05:00
|
|
|
|
|
|
|
i = tmp;
|
|
|
|
}
|
2008-04-11 10:06:50 -04:00
|
|
|
|
2014-01-27 21:27:13 -05:00
|
|
|
update_punch_range_view ();
|
|
|
|
update_loop_range_view ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::refresh_location_display ()
|
|
|
|
{
|
2009-12-11 18:29:48 -05:00
|
|
|
ENSURE_GUI_THREAD (*this, &Editor::refresh_location_display)
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
if (_session) {
|
|
|
|
_session->locations()->apply (*this, &Editor::refresh_location_display_internal);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2011-04-22 22:00:23 -04:00
|
|
|
update_marker_labels ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-10-14 12:10:01 -04:00
|
|
|
Editor::LocationMarkers::hide()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
start->hide ();
|
2010-11-10 13:29:32 -05:00
|
|
|
if (end) {
|
|
|
|
end->hide ();
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-10-14 12:10:01 -04:00
|
|
|
Editor::LocationMarkers::show()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
start->show ();
|
2010-11-10 13:29:32 -05:00
|
|
|
if (end) {
|
|
|
|
end->show ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-11-11 08:36:38 -05:00
|
|
|
Editor::LocationMarkers::canvas_height_set (double h)
|
2010-11-10 13:29:32 -05:00
|
|
|
{
|
2010-11-11 08:36:38 -05:00
|
|
|
start->canvas_height_set (h);
|
2010-11-10 13:29:32 -05:00
|
|
|
if (end) {
|
2010-11-11 08:36:38 -05:00
|
|
|
end->canvas_height_set (h);
|
2010-11-10 13:29:32 -05:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-10-14 12:10:01 -04:00
|
|
|
Editor::LocationMarkers::set_name (const string& str)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2010-04-18 17:29:48 -04:00
|
|
|
/* XXX: hack: don't change names of session start/end markers */
|
2010-11-12 13:53:15 -05:00
|
|
|
|
|
|
|
if (start->type() != Marker::SessionStart) {
|
2010-04-18 17:29:48 -04:00
|
|
|
start->set_name (str);
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-11-12 13:53:15 -05:00
|
|
|
if (end && end->type() != Marker::SessionEnd) {
|
2010-04-18 17:29:48 -04:00
|
|
|
end->set_name (str);
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-09-17 14:20:37 -04:00
|
|
|
Editor::LocationMarkers::set_position (framepos_t startf,
|
|
|
|
framepos_t endf)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
start->set_position (startf);
|
2010-11-11 08:36:38 -05:00
|
|
|
if (end) {
|
|
|
|
end->set_position (endf);
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-10-14 12:10:01 -04:00
|
|
|
Editor::LocationMarkers::set_color_rgba (uint32_t rgba)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
start->set_color_rgba (rgba);
|
2010-11-11 08:36:38 -05:00
|
|
|
if (end) {
|
|
|
|
end->set_color_rgba (rgba);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::LocationMarkers::set_show_lines (bool s)
|
|
|
|
{
|
|
|
|
start->set_show_line (s);
|
|
|
|
if (end) {
|
|
|
|
end->set_show_line (s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::LocationMarkers::set_selected (bool s)
|
|
|
|
{
|
|
|
|
start->set_selected (s);
|
|
|
|
if (end) {
|
|
|
|
end->set_selected (s);
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2010-11-11 10:21:37 -05:00
|
|
|
void
|
|
|
|
Editor::LocationMarkers::setup_lines ()
|
|
|
|
{
|
|
|
|
start->setup_line ();
|
|
|
|
if (end) {
|
|
|
|
end->setup_line ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2010-09-17 14:20:37 -04:00
|
|
|
Editor::mouse_add_new_marker (framepos_t where, bool is_cd, bool is_xrun)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2008-02-16 17:43:18 -05:00
|
|
|
string markername, markerprefix;
|
2008-01-10 16:20:59 -05:00
|
|
|
int flags = (is_cd ? Location::IsCDMarker|Location::IsMark : Location::IsMark);
|
2008-02-16 17:43:18 -05:00
|
|
|
|
|
|
|
if (is_xrun) {
|
|
|
|
markerprefix = "xrun";
|
|
|
|
flags = Location::IsMark;
|
|
|
|
} else {
|
|
|
|
markerprefix = "mark";
|
|
|
|
}
|
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
if (_session) {
|
|
|
|
_session->locations()->next_available_name(markername, markerprefix);
|
2008-09-10 11:03:30 -04:00
|
|
|
if (!is_xrun && !choose_new_marker_name(markername)) {
|
2009-05-04 21:53:30 -04:00
|
|
|
return;
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2010-08-09 12:40:31 -04:00
|
|
|
Location *location = new Location (*_session, where, where, markername, (Location::Flags) flags);
|
2009-12-17 13:24:23 -05:00
|
|
|
_session->begin_reversible_command (_("add marker"));
|
|
|
|
XMLNode &before = _session->locations()->get_state();
|
|
|
|
_session->locations()->add (location, true);
|
|
|
|
XMLNode &after = _session->locations()->get_state();
|
|
|
|
_session->add_command (new MementoCommand<Locations>(*(_session->locations()), &before, &after));
|
|
|
|
_session->commit_reversible_command ();
|
2007-11-12 17:23:01 -05:00
|
|
|
|
|
|
|
/* find the marker we just added */
|
|
|
|
|
|
|
|
LocationMarkers *lam = find_location_markers (location);
|
|
|
|
if (lam) {
|
|
|
|
/* make it the selected marker */
|
|
|
|
selection->set (lam->start);
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-19 09:54:28 -04:00
|
|
|
void
|
|
|
|
Editor::mouse_add_new_range (framepos_t where)
|
|
|
|
{
|
|
|
|
if (!_session) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make this marker 1/8th of the visible area of the session so that
|
|
|
|
it's reasonably easy to manipulate after creation.
|
|
|
|
*/
|
|
|
|
|
2013-04-12 11:21:12 -04:00
|
|
|
framepos_t const end = where + current_page_samples() / 8;
|
2012-06-19 09:54:28 -04:00
|
|
|
|
|
|
|
string name;
|
|
|
|
_session->locations()->next_available_name (name, _("range"));
|
|
|
|
Location* loc = new Location (*_session, where, end, name, Location::IsRangeMarker);
|
|
|
|
|
|
|
|
begin_reversible_command (_("new range marker"));
|
|
|
|
XMLNode& before = _session->locations()->get_state ();
|
|
|
|
_session->locations()->add (loc, true);
|
|
|
|
XMLNode& after = _session->locations()->get_state ();
|
|
|
|
_session->add_command (new MementoCommand<Locations> (*_session->locations(), &before, &after));
|
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2009-07-21 11:55:17 -04:00
|
|
|
Editor::remove_marker (ArdourCanvas::Item& item, GdkEvent*)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
Marker* marker;
|
|
|
|
bool is_start;
|
|
|
|
|
2005-11-24 09:59:36 -05:00
|
|
|
if ((marker = static_cast<Marker*> (item.get_data ("marker"))) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
if (entered_marker == marker) {
|
|
|
|
entered_marker = NULL;
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
Location* loc = find_location_from_marker (marker, is_start);
|
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
if (_session && loc) {
|
2009-12-11 18:29:48 -05:00
|
|
|
Glib::signal_idle().connect (sigc::bind (sigc::mem_fun(*this, &Editor::really_remove_marker), loc));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
Editor::really_remove_marker (Location* loc)
|
|
|
|
{
|
2009-12-17 13:24:23 -05:00
|
|
|
_session->begin_reversible_command (_("remove marker"));
|
|
|
|
XMLNode &before = _session->locations()->get_state();
|
|
|
|
_session->locations()->remove (loc);
|
|
|
|
XMLNode &after = _session->locations()->get_state();
|
|
|
|
_session->add_command (new MementoCommand<Locations>(*(_session->locations()), &before, &after));
|
|
|
|
_session->commit_reversible_command ();
|
2005-09-25 14:42:24 -04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::location_gone (Location *location)
|
|
|
|
{
|
2009-12-11 18:29:48 -05:00
|
|
|
ENSURE_GUI_THREAD (*this, &Editor::location_gone, location)
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
LocationMarkerMap::iterator i;
|
|
|
|
|
|
|
|
if (location == transport_loop_location()) {
|
2014-01-27 21:27:13 -05:00
|
|
|
update_loop_range_view ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (location == transport_punch_location()) {
|
2014-01-27 21:27:13 -05:00
|
|
|
update_punch_range_view ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
for (i = location_markers.begin(); i != location_markers.end(); ++i) {
|
2010-11-14 18:47:09 -05:00
|
|
|
if (i->first == location) {
|
|
|
|
|
|
|
|
remove_sorted_marker (i->second->start);
|
|
|
|
if (i->second->end) {
|
|
|
|
remove_sorted_marker (i->second->end);
|
|
|
|
}
|
2011-05-05 08:45:24 -04:00
|
|
|
|
|
|
|
LocationMarkers* m = i->second;
|
2005-09-25 14:42:24 -04:00
|
|
|
location_markers.erase (i);
|
2011-05-05 08:45:24 -04:00
|
|
|
delete m;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-05-02 19:14:43 -04:00
|
|
|
Editor::tempo_or_meter_marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item* item)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
marker_menu_item = item;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-05-02 19:14:43 -04:00
|
|
|
MeterMarker* mm;
|
|
|
|
TempoMarker* tm;
|
|
|
|
dynamic_cast_marker_object (marker_menu_item->get_data ("marker"), &mm, &tm);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2010-05-02 19:14:43 -04:00
|
|
|
bool can_remove = false;
|
|
|
|
|
|
|
|
if (mm) {
|
|
|
|
can_remove = mm->meter().movable ();
|
|
|
|
} else if (tm) {
|
|
|
|
can_remove = tm->tempo().movable ();
|
2010-05-09 19:31:07 -04:00
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-05-02 19:14:43 -04:00
|
|
|
delete tempo_or_meter_marker_menu;
|
|
|
|
build_tempo_or_meter_marker_menu (can_remove);
|
|
|
|
tempo_or_meter_marker_menu->popup (1, ev->time);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item* item)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
Marker * marker;
|
2005-11-28 17:36:26 -05:00
|
|
|
if ((marker = reinterpret_cast<Marker *> (item->get_data("marker"))) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
bool is_start;
|
|
|
|
Location * loc = find_location_from_marker (marker, is_start);
|
2011-01-03 20:40:47 -05:00
|
|
|
|
|
|
|
if (loc == transport_loop_location() || loc == transport_punch_location() || loc->is_session_range ()) {
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (transport_marker_menu == 0) {
|
2011-10-16 17:58:29 -04:00
|
|
|
build_range_marker_menu (loc == transport_loop_location() || loc == transport_punch_location(), loc->is_session_range());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
marker_menu_item = item;
|
|
|
|
transport_marker_menu->popup (1, ev->time);
|
2006-03-31 19:21:25 -05:00
|
|
|
|
2011-01-03 20:40:47 -05:00
|
|
|
} else if (loc->is_mark()) {
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-01-03 20:40:47 -05:00
|
|
|
delete marker_menu;
|
|
|
|
build_marker_menu (loc);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-11-28 10:29:49 -05:00
|
|
|
// GTK2FIX use action group sensitivity
|
|
|
|
#ifdef GTK2FIX
|
2011-01-03 20:40:47 -05:00
|
|
|
if (children.size() >= 3) {
|
|
|
|
MenuItem * loopitem = &children[2];
|
|
|
|
if (loopitem) {
|
|
|
|
if (loc->is_mark()) {
|
|
|
|
loopitem->set_sensitive(false);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
loopitem->set_sensitive(true);
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
#endif
|
2011-01-03 20:40:47 -05:00
|
|
|
marker_menu_item = item;
|
|
|
|
marker_menu->popup (1, ev->time);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-01-03 20:40:47 -05:00
|
|
|
} else if (loc->is_range_marker()) {
|
|
|
|
if (range_marker_menu == 0) {
|
2011-10-16 17:58:29 -04:00
|
|
|
build_range_marker_menu (false, false);
|
2006-03-31 19:21:25 -05:00
|
|
|
}
|
2011-01-03 20:40:47 -05:00
|
|
|
marker_menu_item = item;
|
|
|
|
range_marker_menu->popup (1, ev->time);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-07-21 11:55:17 -04:00
|
|
|
Editor::new_transport_marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item*)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (new_transport_marker_menu == 0) {
|
|
|
|
build_new_transport_marker_menu ();
|
|
|
|
}
|
|
|
|
|
|
|
|
new_transport_marker_menu->popup (1, ev->time);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-01-03 20:40:47 -05:00
|
|
|
Editor::build_marker_menu (Location* loc)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
using namespace Menu_Helpers;
|
|
|
|
|
2011-01-03 20:40:47 -05:00
|
|
|
marker_menu = new Menu;
|
|
|
|
MenuList& items = marker_menu->items();
|
|
|
|
marker_menu->set_name ("ArdourContextMenu");
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2010-08-09 10:11:44 -04:00
|
|
|
items.push_back (MenuElem (_("Locate to Here"), sigc::mem_fun(*this, &Editor::marker_menu_set_playhead)));
|
|
|
|
items.push_back (MenuElem (_("Play from Here"), sigc::mem_fun(*this, &Editor::marker_menu_play_from)));
|
2009-12-11 18:29:48 -05:00
|
|
|
items.push_back (MenuElem (_("Move Mark to Playhead"), sigc::mem_fun(*this, &Editor::marker_menu_set_from_playhead)));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
items.push_back (SeparatorElem());
|
|
|
|
|
2010-08-09 10:11:44 -04:00
|
|
|
items.push_back (MenuElem (_("Create Range to Next Marker"), sigc::mem_fun(*this, &Editor::marker_menu_range_to_next)));
|
2008-09-10 11:03:30 -04:00
|
|
|
|
2009-12-11 18:29:48 -05:00
|
|
|
items.push_back (MenuElem (_("Hide"), sigc::mem_fun(*this, &Editor::marker_menu_hide)));
|
2011-10-17 20:24:29 -04:00
|
|
|
items.push_back (MenuElem (_("Rename..."), sigc::mem_fun(*this, &Editor::marker_menu_rename)));
|
2007-11-12 17:23:01 -05:00
|
|
|
|
2010-08-07 19:31:07 -04:00
|
|
|
items.push_back (CheckMenuElem (_("Lock")));
|
2013-07-11 15:32:31 -04:00
|
|
|
Gtk::CheckMenuItem* lock_item = static_cast<Gtk::CheckMenuItem*> (&items.back());
|
2010-08-07 19:31:07 -04:00
|
|
|
if (loc->locked ()) {
|
|
|
|
lock_item->set_active ();
|
|
|
|
}
|
|
|
|
lock_item->signal_activate().connect (sigc::mem_fun (*this, &Editor::toggle_marker_menu_lock));
|
2010-08-09 12:40:31 -04:00
|
|
|
|
|
|
|
items.push_back (CheckMenuElem (_("Glue to Bars and Beats")));
|
2013-07-11 15:32:31 -04:00
|
|
|
Gtk::CheckMenuItem* glue_item = static_cast<Gtk::CheckMenuItem*> (&items.back());
|
2010-08-09 12:40:31 -04:00
|
|
|
if (loc->position_lock_style() == MusicTime) {
|
|
|
|
glue_item->set_active ();
|
|
|
|
}
|
|
|
|
glue_item->signal_activate().connect (sigc::mem_fun (*this, &Editor::toggle_marker_menu_glue));
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2007-11-12 17:23:01 -05:00
|
|
|
items.push_back (SeparatorElem());
|
2006-01-23 11:02:48 -05:00
|
|
|
|
2009-12-11 18:29:48 -05:00
|
|
|
items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &Editor::marker_menu_remove)));
|
2006-01-23 11:02:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-10-16 17:58:29 -04:00
|
|
|
Editor::build_range_marker_menu (bool loop_or_punch, bool session)
|
2006-01-23 11:02:48 -05:00
|
|
|
{
|
|
|
|
using namespace Menu_Helpers;
|
|
|
|
|
2011-10-16 17:58:29 -04:00
|
|
|
bool const loop_or_punch_or_session = loop_or_punch | session;
|
|
|
|
|
2007-01-08 12:12:29 -05:00
|
|
|
Menu *markerMenu = new Menu;
|
2011-01-03 20:40:47 -05:00
|
|
|
if (loop_or_punch_or_session) {
|
2007-01-08 12:12:29 -05:00
|
|
|
transport_marker_menu = markerMenu;
|
|
|
|
} else {
|
|
|
|
range_marker_menu = markerMenu;
|
|
|
|
}
|
|
|
|
MenuList& items = markerMenu->items();
|
|
|
|
markerMenu->set_name ("ArdourContextMenu");
|
2006-01-23 11:02:48 -05:00
|
|
|
|
2009-12-11 18:29:48 -05:00
|
|
|
items.push_back (MenuElem (_("Play Range"), sigc::mem_fun(*this, &Editor::marker_menu_play_range)));
|
2013-01-10 09:07:46 -05:00
|
|
|
items.push_back (MenuElem (_("Locate to Marker"), sigc::mem_fun(*this, &Editor::marker_menu_set_playhead)));
|
|
|
|
items.push_back (MenuElem (_("Play from Marker"), sigc::mem_fun(*this, &Editor::marker_menu_play_from)));
|
|
|
|
items.push_back (MenuElem (_("Loop Range"), sigc::mem_fun(*this, &Editor::marker_menu_loop_range)));
|
|
|
|
|
|
|
|
items.push_back (MenuElem (_("Set Marker from Playhead"), sigc::mem_fun(*this, &Editor::marker_menu_set_from_playhead)));
|
2008-01-10 16:20:59 -05:00
|
|
|
if (!Profile->get_sae()) {
|
2013-01-10 09:07:46 -05:00
|
|
|
items.push_back (MenuElem (_("Set Range from Selection"), sigc::bind (sigc::mem_fun(*this, &Editor::marker_menu_set_from_selection), false)));
|
2008-01-10 16:20:59 -05:00
|
|
|
}
|
2006-01-23 11:02:48 -05:00
|
|
|
|
2012-03-22 12:41:44 -04:00
|
|
|
items.push_back (MenuElem (_("Zoom to Range"), sigc::mem_fun (*this, &Editor::marker_menu_zoom_to_range)));
|
|
|
|
|
2008-09-10 11:03:30 -04:00
|
|
|
items.push_back (SeparatorElem());
|
2011-10-17 20:24:29 -04:00
|
|
|
items.push_back (MenuElem (_("Export Range..."), sigc::mem_fun(*this, &Editor::export_range)));
|
2006-01-23 11:02:48 -05:00
|
|
|
items.push_back (SeparatorElem());
|
|
|
|
|
2011-01-03 20:40:47 -05:00
|
|
|
if (!loop_or_punch_or_session) {
|
2009-12-11 18:29:48 -05:00
|
|
|
items.push_back (MenuElem (_("Hide Range"), sigc::mem_fun(*this, &Editor::marker_menu_hide)));
|
2011-10-17 20:24:29 -04:00
|
|
|
items.push_back (MenuElem (_("Rename Range..."), sigc::mem_fun(*this, &Editor::marker_menu_rename)));
|
2011-10-16 17:58:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!session) {
|
2009-12-11 18:29:48 -05:00
|
|
|
items.push_back (MenuElem (_("Remove Range"), sigc::mem_fun(*this, &Editor::marker_menu_remove)));
|
2007-01-08 12:12:29 -05:00
|
|
|
}
|
2006-01-23 11:02:48 -05:00
|
|
|
|
2012-03-22 12:42:21 -04:00
|
|
|
if (!loop_or_punch_or_session || !session) {
|
2011-10-16 17:58:29 -04:00
|
|
|
items.push_back (SeparatorElem());
|
|
|
|
}
|
|
|
|
|
2009-12-11 18:29:48 -05:00
|
|
|
items.push_back (MenuElem (_("Separate Regions in Range"), sigc::mem_fun(*this, &Editor::marker_menu_separate_regions_using_location)));
|
|
|
|
items.push_back (MenuElem (_("Select All in Range"), sigc::mem_fun(*this, &Editor::marker_menu_select_all_selectables_using_range)));
|
2008-01-10 16:20:59 -05:00
|
|
|
if (!Profile->get_sae()) {
|
2009-12-11 18:29:48 -05:00
|
|
|
items.push_back (MenuElem (_("Select Range"), sigc::mem_fun(*this, &Editor::marker_menu_select_using_range)));
|
2008-01-10 16:20:59 -05:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-05-02 19:14:43 -04:00
|
|
|
Editor::build_tempo_or_meter_marker_menu (bool can_remove)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
using namespace Menu_Helpers;
|
|
|
|
|
2010-05-02 19:14:43 -04:00
|
|
|
tempo_or_meter_marker_menu = new Menu;
|
|
|
|
MenuList& items = tempo_or_meter_marker_menu->items();
|
|
|
|
tempo_or_meter_marker_menu->set_name ("ArdourContextMenu");
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2011-04-19 06:18:34 -04:00
|
|
|
items.push_back (MenuElem (_("Edit..."), sigc::mem_fun(*this, &Editor::marker_menu_edit)));
|
2009-12-11 18:29:48 -05:00
|
|
|
items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &Editor::marker_menu_remove)));
|
2010-05-02 19:14:43 -04:00
|
|
|
|
|
|
|
items.back().set_sensitive (can_remove);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::build_new_transport_marker_menu ()
|
|
|
|
{
|
|
|
|
using namespace Menu_Helpers;
|
|
|
|
|
|
|
|
new_transport_marker_menu = new Menu;
|
|
|
|
MenuList& items = new_transport_marker_menu->items();
|
|
|
|
new_transport_marker_menu->set_name ("ArdourContextMenu");
|
|
|
|
|
2009-12-11 18:29:48 -05:00
|
|
|
items.push_back (MenuElem (_("Set Loop Range"), sigc::mem_fun(*this, &Editor::new_transport_marker_menu_set_loop)));
|
|
|
|
items.push_back (MenuElem (_("Set Punch Range"), sigc::mem_fun(*this, &Editor::new_transport_marker_menu_set_punch)));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-12-11 18:29:48 -05:00
|
|
|
new_transport_marker_menu->signal_unmap().connect ( sigc::mem_fun(*this, &Editor::new_transport_marker_menu_popdown));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::marker_menu_hide ()
|
|
|
|
{
|
|
|
|
Marker* marker;
|
|
|
|
|
2005-11-28 17:36:26 -05:00
|
|
|
if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
|
|
|
Location* l;
|
|
|
|
bool is_start;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if ((l = find_location_from_marker (marker, is_start)) != 0) {
|
|
|
|
l->set_hidden (true, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-11 09:07:51 -04:00
|
|
|
void
|
|
|
|
Editor::marker_menu_select_using_range ()
|
|
|
|
{
|
|
|
|
Marker* marker;
|
|
|
|
|
|
|
|
if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
|
|
|
|
fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
|
|
|
Location* l;
|
|
|
|
bool is_start;
|
|
|
|
|
|
|
|
if (((l = find_location_from_marker (marker, is_start)) != 0) && (l->end() > l->start())) {
|
|
|
|
set_selection_from_range (*l);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-23 11:02:48 -05:00
|
|
|
void
|
2006-02-15 07:15:29 -05:00
|
|
|
Editor::marker_menu_select_all_selectables_using_range ()
|
2006-01-23 11:02:48 -05:00
|
|
|
{
|
|
|
|
Marker* marker;
|
|
|
|
|
|
|
|
if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
|
|
|
|
fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
2006-02-15 07:15:29 -05:00
|
|
|
|
2006-01-23 11:02:48 -05:00
|
|
|
Location* l;
|
|
|
|
bool is_start;
|
|
|
|
|
2006-02-15 07:15:29 -05:00
|
|
|
if (((l = find_location_from_marker (marker, is_start)) != 0) && (l->end() > l->start())) {
|
2010-08-09 21:52:49 -04:00
|
|
|
select_all_within (l->start(), l->end() - 1, 0, DBL_MAX, track_views, Selection::Set, false);
|
2006-03-31 19:21:25 -05:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-03-31 19:21:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::marker_menu_separate_regions_using_location ()
|
|
|
|
{
|
|
|
|
Marker* marker;
|
|
|
|
|
|
|
|
if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
|
|
|
|
fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
|
|
|
Location* l;
|
|
|
|
bool is_start;
|
|
|
|
|
|
|
|
if (((l = find_location_from_marker (marker, is_start)) != 0) && (l->end() > l->start())) {
|
|
|
|
separate_regions_using_location (*l);
|
2006-01-23 11:02:48 -05:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-01-23 11:02:48 -05:00
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Editor::marker_menu_play_from ()
|
|
|
|
{
|
|
|
|
Marker* marker;
|
|
|
|
|
2005-11-28 17:36:26 -05:00
|
|
|
if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
|
|
|
Location* l;
|
|
|
|
bool is_start;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if ((l = find_location_from_marker (marker, is_start)) != 0) {
|
|
|
|
|
|
|
|
if (l->is_mark()) {
|
2009-12-17 13:24:23 -05:00
|
|
|
_session->request_locate (l->start(), true);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
else {
|
2009-12-17 13:24:23 -05:00
|
|
|
//_session->request_bounded_roll (l->start(), l->end());
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (is_start) {
|
2009-12-17 13:24:23 -05:00
|
|
|
_session->request_locate (l->start(), true);
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2009-12-17 13:24:23 -05:00
|
|
|
_session->request_locate (l->end(), true);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::marker_menu_set_playhead ()
|
|
|
|
{
|
|
|
|
Marker* marker;
|
|
|
|
|
2005-11-28 17:36:26 -05:00
|
|
|
if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
|
|
|
Location* l;
|
|
|
|
bool is_start;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if ((l = find_location_from_marker (marker, is_start)) != 0) {
|
|
|
|
|
|
|
|
if (l->is_mark()) {
|
2009-12-17 13:24:23 -05:00
|
|
|
_session->request_locate (l->start(), false);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (is_start) {
|
2009-12-17 13:24:23 -05:00
|
|
|
_session->request_locate (l->start(), false);
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2009-12-17 13:24:23 -05:00
|
|
|
_session->request_locate (l->end(), false);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-10 11:03:30 -04:00
|
|
|
void
|
|
|
|
Editor::marker_menu_range_to_next ()
|
|
|
|
{
|
|
|
|
Marker* marker;
|
2009-12-17 13:24:23 -05:00
|
|
|
if (!_session) {
|
2008-09-10 11:03:30 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
|
|
|
|
fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
|
|
|
Location* l;
|
|
|
|
bool is_start;
|
|
|
|
|
|
|
|
if ((l = find_location_from_marker (marker, is_start)) == 0) {
|
|
|
|
return;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-09-17 14:20:37 -04:00
|
|
|
framepos_t start;
|
|
|
|
framepos_t end;
|
2009-12-17 13:24:23 -05:00
|
|
|
_session->locations()->marks_either_side (marker->position(), start, end);
|
2008-09-10 11:03:30 -04:00
|
|
|
|
2010-09-17 12:24:22 -04:00
|
|
|
if (end != max_framepos) {
|
2008-09-10 11:03:30 -04:00
|
|
|
string range_name = l->name();
|
|
|
|
range_name += "-range";
|
|
|
|
|
2010-08-09 12:40:31 -04:00
|
|
|
Location* newrange = new Location (*_session, marker->position(), end, range_name, Location::IsRangeMarker);
|
2009-12-17 13:24:23 -05:00
|
|
|
_session->locations()->add (newrange);
|
2008-09-10 11:03:30 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Editor::marker_menu_set_from_playhead ()
|
|
|
|
{
|
|
|
|
Marker* marker;
|
|
|
|
|
2005-11-28 17:36:26 -05:00
|
|
|
if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
|
|
|
Location* l;
|
|
|
|
bool is_start;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if ((l = find_location_from_marker (marker, is_start)) != 0) {
|
|
|
|
|
|
|
|
if (l->is_mark()) {
|
2009-12-17 13:24:23 -05:00
|
|
|
l->set_start (_session->audible_frame ());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (is_start) {
|
2009-12-17 13:24:23 -05:00
|
|
|
l->set_start (_session->audible_frame ());
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2009-12-17 13:24:23 -05:00
|
|
|
l->set_end (_session->audible_frame ());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-01-10 09:07:46 -05:00
|
|
|
Editor::marker_menu_set_from_selection (bool /*force_regions*/)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
Marker* marker;
|
|
|
|
|
2005-11-28 17:36:26 -05:00
|
|
|
if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
|
|
|
Location* l;
|
|
|
|
bool is_start;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if ((l = find_location_from_marker (marker, is_start)) != 0) {
|
|
|
|
|
|
|
|
if (l->is_mark()) {
|
|
|
|
|
2013-01-10 09:07:46 -05:00
|
|
|
// nothing for now
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2013-01-10 09:07:46 -05:00
|
|
|
} else {
|
|
|
|
|
|
|
|
if (!selection->time.empty()) {
|
|
|
|
l->set (selection->time.start(), selection->time.end_frame());
|
|
|
|
} else if (!selection->regions.empty()) {
|
|
|
|
l->set (selection->regions.start(), selection->regions.end_frame());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-02 16:25:37 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
Editor::marker_menu_play_range ()
|
|
|
|
{
|
|
|
|
Marker* marker;
|
|
|
|
|
|
|
|
if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
|
|
|
|
fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
|
|
|
Location* l;
|
|
|
|
bool is_start;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-02 16:25:37 -05:00
|
|
|
if ((l = find_location_from_marker (marker, is_start)) != 0) {
|
|
|
|
|
|
|
|
if (l->is_mark()) {
|
2009-12-17 13:24:23 -05:00
|
|
|
_session->request_locate (l->start(), true);
|
2007-01-02 16:25:37 -05:00
|
|
|
}
|
|
|
|
else {
|
2009-12-17 13:24:23 -05:00
|
|
|
_session->request_bounded_roll (l->start(), l->end());
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-02 16:25:37 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Editor::marker_menu_loop_range ()
|
|
|
|
{
|
|
|
|
Marker* marker;
|
|
|
|
|
2005-11-28 17:36:26 -05:00
|
|
|
if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
|
|
|
Location* l;
|
|
|
|
bool is_start;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if ((l = find_location_from_marker (marker, is_start)) != 0) {
|
|
|
|
Location* l2;
|
|
|
|
if ((l2 = transport_loop_location()) != 0) {
|
|
|
|
l2->set (l->start(), l->end());
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
// enable looping, reposition and start rolling
|
2009-12-17 13:24:23 -05:00
|
|
|
_session->request_play_loop(true);
|
|
|
|
_session->request_locate (l2->start(), true);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-22 12:41:44 -04:00
|
|
|
/** Temporal zoom to the range of the marker_menu_item (plus 5% either side) */
|
|
|
|
void
|
|
|
|
Editor::marker_menu_zoom_to_range ()
|
|
|
|
{
|
|
|
|
Marker* marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"));
|
|
|
|
assert (marker);
|
|
|
|
|
|
|
|
bool is_start;
|
|
|
|
Location* l = find_location_from_marker (marker, is_start);
|
|
|
|
if (l == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
framecnt_t const extra = l->length() * 0.05;
|
|
|
|
framepos_t a = l->start ();
|
|
|
|
if (a >= extra) {
|
|
|
|
a -= extra;
|
|
|
|
}
|
|
|
|
|
|
|
|
framepos_t b = l->end ();
|
|
|
|
if (b < (max_framepos - extra)) {
|
|
|
|
b += extra;
|
|
|
|
}
|
|
|
|
|
|
|
|
temporal_zoom_by_frame (a, b);
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2010-05-02 19:14:43 -04:00
|
|
|
Editor::dynamic_cast_marker_object (void* p, MeterMarker** m, TempoMarker** t) const
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2010-05-02 19:14:43 -04:00
|
|
|
Marker* marker = reinterpret_cast<Marker*> (p);
|
|
|
|
if (!marker) {
|
2005-09-25 14:42:24 -04:00
|
|
|
fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
2010-05-02 19:14:43 -04:00
|
|
|
*m = dynamic_cast<MeterMarker*> (marker);
|
|
|
|
*t = dynamic_cast<TempoMarker*> (marker);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-05-02 19:14:43 -04:00
|
|
|
Editor::marker_menu_edit ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
MeterMarker* mm;
|
|
|
|
TempoMarker* tm;
|
2010-05-02 19:14:43 -04:00
|
|
|
dynamic_cast_marker_object (marker_menu_item->get_data ("marker"), &mm, &tm);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2010-05-02 19:14:43 -04:00
|
|
|
if (mm) {
|
|
|
|
edit_meter_section (&mm->meter());
|
|
|
|
} else if (tm) {
|
|
|
|
edit_tempo_section (&tm->tempo());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2010-05-02 19:14:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::marker_menu_remove ()
|
|
|
|
{
|
|
|
|
MeterMarker* mm;
|
|
|
|
TempoMarker* tm;
|
|
|
|
dynamic_cast_marker_object (marker_menu_item->get_data ("marker"), &mm, &tm);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2010-05-02 19:14:43 -04:00
|
|
|
if (mm) {
|
2005-09-25 14:42:24 -04:00
|
|
|
remove_meter_marker (marker_menu_item);
|
2010-05-02 19:14:43 -04:00
|
|
|
} else if (tm) {
|
2005-09-25 14:42:24 -04:00
|
|
|
remove_tempo_marker (marker_menu_item);
|
|
|
|
} else {
|
2005-11-12 22:53:51 -05:00
|
|
|
remove_marker (*marker_menu_item, (GdkEvent*) 0);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-12 17:23:01 -05:00
|
|
|
void
|
2010-08-07 19:31:07 -04:00
|
|
|
Editor::toggle_marker_menu_lock ()
|
2007-11-12 17:23:01 -05:00
|
|
|
{
|
|
|
|
Marker* marker;
|
|
|
|
|
|
|
|
if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
|
|
|
|
fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
|
|
|
Location* loc;
|
|
|
|
bool ignored;
|
|
|
|
|
|
|
|
loc = find_location_from_marker (marker, ignored);
|
|
|
|
|
2010-08-07 19:31:07 -04:00
|
|
|
if (!loc) {
|
|
|
|
return;
|
|
|
|
}
|
2007-11-12 17:23:01 -05:00
|
|
|
|
2010-08-07 19:31:07 -04:00
|
|
|
if (loc->locked()) {
|
2007-11-12 17:23:01 -05:00
|
|
|
loc->unlock ();
|
2010-08-07 19:31:07 -04:00
|
|
|
} else {
|
|
|
|
loc->lock ();
|
2007-11-12 17:23:01 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Editor::marker_menu_rename ()
|
|
|
|
{
|
|
|
|
Marker* marker;
|
|
|
|
|
2005-11-28 17:36:26 -05:00
|
|
|
if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
2013-08-09 10:59:12 -04:00
|
|
|
|
|
|
|
rename_marker (marker);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::rename_marker(Marker *marker)
|
|
|
|
{
|
2005-09-25 14:42:24 -04:00
|
|
|
Location* loc;
|
|
|
|
bool is_start;
|
|
|
|
|
|
|
|
loc = find_location_from_marker (marker, is_start);
|
|
|
|
|
2013-08-09 11:24:24 -04:00
|
|
|
if (!loc)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (loc == transport_loop_location() || loc == transport_punch_location() || loc->is_session_range())
|
|
|
|
return;
|
2009-05-04 21:53:30 -04:00
|
|
|
|
2006-04-22 11:28:59 -04:00
|
|
|
ArdourPrompter dialog (true);
|
|
|
|
string txt;
|
|
|
|
|
|
|
|
dialog.set_prompt (_("New Name:"));
|
2007-04-11 09:07:51 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (loc->is_mark()) {
|
2009-10-19 13:25:37 -04:00
|
|
|
dialog.set_title (_("Rename Mark"));
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2009-10-19 13:25:37 -04:00
|
|
|
dialog.set_title (_("Rename Range"));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
dialog.set_name ("MarkRenameWindow");
|
2006-04-19 16:42:17 -04:00
|
|
|
dialog.set_size_request (250, -1);
|
2005-09-25 16:33:00 -04:00
|
|
|
dialog.set_position (Gtk::WIN_POS_MOUSE);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-04-19 16:42:17 -04:00
|
|
|
dialog.add_button (_("Rename"), RESPONSE_ACCEPT);
|
2006-04-22 11:28:59 -04:00
|
|
|
dialog.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
|
|
|
|
dialog.set_initial_text (loc->name());
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-04-22 11:28:59 -04:00
|
|
|
dialog.show ();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-12-12 15:54:55 -05:00
|
|
|
switch (dialog.run ()) {
|
|
|
|
case RESPONSE_ACCEPT:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2005-12-12 15:54:55 -05:00
|
|
|
|
2006-03-21 13:40:17 -05:00
|
|
|
begin_reversible_command ( _("rename marker") );
|
2009-12-17 13:24:23 -05:00
|
|
|
XMLNode &before = _session->locations()->get_state();
|
2006-03-21 13:40:17 -05:00
|
|
|
|
2006-04-22 11:28:59 -04:00
|
|
|
dialog.get_result(txt);
|
|
|
|
loc->set_name (txt);
|
2013-08-09 10:59:40 -04:00
|
|
|
_session->set_dirty ();
|
2009-05-04 21:53:30 -04:00
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
XMLNode &after = _session->locations()->get_state();
|
|
|
|
_session->add_command (new MementoCommand<Locations>(*(_session->locations()), &before, &after));
|
2006-03-21 13:40:17 -05:00
|
|
|
commit_reversible_command ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2008-10-11 13:51:15 -04:00
|
|
|
void
|
|
|
|
Editor::new_transport_marker_menu_popdown ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
// hide rects
|
2005-10-28 18:19:45 -04:00
|
|
|
transport_bar_drag_rect->hide();
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-05-05 18:09:07 -04:00
|
|
|
_drags->abort ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::new_transport_marker_menu_set_loop ()
|
|
|
|
{
|
2007-10-11 18:07:47 -04:00
|
|
|
set_loop_range (temp_location->start(), temp_location->end(), _("set loop range"));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::new_transport_marker_menu_set_punch ()
|
|
|
|
{
|
2007-10-11 18:07:47 -04:00
|
|
|
set_punch_range (temp_location->start(), temp_location->end(), _("set punch range"));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-01-27 21:27:13 -05:00
|
|
|
Editor::update_loop_range_view ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2009-12-17 13:24:23 -05:00
|
|
|
if (_session == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Location* tll;
|
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
if (_session->get_play_loop() && ((tll = transport_loop_location()) != 0)) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2013-04-12 11:15:45 -04:00
|
|
|
double x1 = sample_to_pixel (tll->start());
|
|
|
|
double x2 = sample_to_pixel (tll->end());
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
transport_loop_range_rect->set_x0 (x1);
|
|
|
|
transport_loop_range_rect->set_x1 (x2);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-01-27 21:27:13 -05:00
|
|
|
transport_loop_range_rect->show();
|
|
|
|
|
|
|
|
} else {
|
2005-10-28 18:19:45 -04:00
|
|
|
transport_loop_range_rect->hide();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-01-27 21:27:13 -05:00
|
|
|
Editor::update_punch_range_view ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2009-12-17 13:24:23 -05:00
|
|
|
if (_session == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Location* tpl;
|
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
if ((_session->config.get_punch_in() || _session->config.get_punch_out()) && ((tpl = transport_punch_location()) != 0)) {
|
2013-04-17 10:53:17 -04:00
|
|
|
ArdourCanvas::Rect const v = _track_canvas->visible_area ();
|
2014-01-27 21:27:13 -05:00
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
if (_session->config.get_punch_in()) {
|
2013-04-12 11:15:45 -04:00
|
|
|
transport_punch_range_rect->set_x0 (sample_to_pixel (tpl->start()));
|
|
|
|
transport_punch_range_rect->set_x1 (_session->config.get_punch_out() ? sample_to_pixel (tpl->end()) : sample_to_pixel (JACK_MAX_FRAMES));
|
2008-09-29 16:35:44 -04:00
|
|
|
} else {
|
2013-04-04 00:32:52 -04:00
|
|
|
transport_punch_range_rect->set_x0 (0);
|
2013-04-12 11:15:45 -04:00
|
|
|
transport_punch_range_rect->set_x1 (_session->config.get_punch_out() ? sample_to_pixel (tpl->end()) : v.width ());
|
2008-09-29 16:35:44 -04:00
|
|
|
}
|
2014-01-27 21:27:13 -05:00
|
|
|
|
|
|
|
transport_punch_range_rect->show();
|
|
|
|
|
|
|
|
} else {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-10-28 18:19:45 -04:00
|
|
|
transport_punch_range_rect->hide();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
2007-11-12 17:23:01 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
Editor::marker_selection_changed ()
|
|
|
|
{
|
2009-12-17 13:24:23 -05:00
|
|
|
if (_session && _session->deletion_in_progress()) {
|
2008-02-16 17:43:18 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-11-11 08:36:38 -05:00
|
|
|
for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) {
|
|
|
|
i->second->set_selected (false);
|
2007-11-12 17:23:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
for (MarkerSelection::iterator x = selection->markers.begin(); x != selection->markers.end(); ++x) {
|
2010-11-11 08:36:38 -05:00
|
|
|
(*x)->set_selected (true);
|
2007-11-12 17:23:01 -05:00
|
|
|
}
|
|
|
|
}
|
2008-01-10 16:20:59 -05:00
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
struct SortLocationsByPosition {
|
2008-01-10 16:20:59 -05:00
|
|
|
bool operator() (Location* a, Location* b) {
|
|
|
|
return a->start() < b->start();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::goto_nth_marker (int n)
|
|
|
|
{
|
2009-12-17 13:24:23 -05:00
|
|
|
if (!_session) {
|
2008-01-10 16:20:59 -05:00
|
|
|
return;
|
|
|
|
}
|
2009-12-17 13:24:23 -05:00
|
|
|
const Locations::LocationList& l (_session->locations()->list());
|
2008-01-10 16:20:59 -05:00
|
|
|
Locations::LocationList ordered;
|
|
|
|
ordered = l;
|
|
|
|
|
|
|
|
SortLocationsByPosition cmp;
|
|
|
|
ordered.sort (cmp);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
for (Locations::LocationList::iterator i = ordered.begin(); n >= 0 && i != ordered.end(); ++i) {
|
2010-04-18 17:29:48 -04:00
|
|
|
if ((*i)->is_mark() && !(*i)->is_hidden() && !(*i)->is_session_range()) {
|
2008-01-10 16:20:59 -05:00
|
|
|
if (n == 0) {
|
2009-12-17 13:24:23 -05:00
|
|
|
_session->request_locate ((*i)->start(), _session->transport_rolling());
|
2008-01-10 16:20:59 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
--n;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-08-09 12:40:31 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
Editor::toggle_marker_menu_glue ()
|
|
|
|
{
|
|
|
|
Marker* marker;
|
|
|
|
|
|
|
|
if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
|
|
|
|
fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
|
|
|
Location* loc;
|
|
|
|
bool ignored;
|
|
|
|
|
|
|
|
loc = find_location_from_marker (marker, ignored);
|
|
|
|
|
|
|
|
if (!loc) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (loc->position_lock_style() == MusicTime) {
|
|
|
|
loc->set_position_lock_style (AudioTime);
|
|
|
|
} else {
|
|
|
|
loc->set_position_lock_style (MusicTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2010-11-10 13:29:32 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
Editor::toggle_marker_lines ()
|
|
|
|
{
|
|
|
|
_show_marker_lines = !_show_marker_lines;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-11-10 13:29:32 -05:00
|
|
|
for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) {
|
2010-11-11 08:36:38 -05:00
|
|
|
i->second->set_show_lines (_show_marker_lines);
|
2010-11-10 13:29:32 -05:00
|
|
|
}
|
|
|
|
}
|
2010-11-14 18:47:09 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
Editor::remove_sorted_marker (Marker* m)
|
|
|
|
{
|
|
|
|
for (std::map<ArdourCanvas::Group *, std::list<Marker *> >::iterator i = _sorted_marker_lists.begin(); i != _sorted_marker_lists.end(); ++i) {
|
|
|
|
i->second.remove (m);
|
|
|
|
}
|
|
|
|
}
|
2011-10-19 20:05:31 -04:00
|
|
|
|
|
|
|
Marker *
|
|
|
|
Editor::find_marker_from_location_id (PBD::ID const & id, bool is_start) const
|
|
|
|
{
|
|
|
|
for (LocationMarkerMap::const_iterator i = location_markers.begin(); i != location_markers.end(); ++i) {
|
|
|
|
if (i->first->id() == id) {
|
|
|
|
return is_start ? i->second->start : i->second->end;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|