2005-09-25 14:42:24 -04:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2005-2006 Taybin Rutkin <taybin@taybin.com>
|
|
|
|
* Copyright (C) 2005-2018 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2006-2015 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2006-2016 Tim Mayberry <mojofunk@gmail.com>
|
|
|
|
* Copyright (C) 2006 Sampo Savolainen <v2@iki.fi>
|
|
|
|
* Copyright (C) 2007-2012 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2007 Doug McLain <doug@nostar.net>
|
|
|
|
* Copyright (C) 2013-2014 Colin Fletcher <colin.m.fletcher@googlemail.com>
|
|
|
|
* Copyright (C) 2013-2019 Robin Gareus <robin@gareus.org>
|
|
|
|
* Copyright (C) 2014-2017 Nick Mainsbridge <mainsbridge@gmail.com>
|
|
|
|
* Copyright (C) 2014-2018 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.
|
|
|
|
*/
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
#include <cassert>
|
2005-09-25 14:42:24 -04:00
|
|
|
#include <cstdlib>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <cmath>
|
|
|
|
#include <set>
|
|
|
|
#include <string>
|
|
|
|
#include <algorithm>
|
2013-04-04 00:32:52 -04:00
|
|
|
#include <bitset>
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "pbd/error.h"
|
2009-07-28 16:51:28 -04:00
|
|
|
#include "pbd/enumwriter.h"
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "pbd/memento_command.h"
|
|
|
|
#include "pbd/basename.h"
|
2010-03-02 13:05:26 -05:00
|
|
|
#include "pbd/stateful_diff_command.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2011-03-03 22:10:48 -05:00
|
|
|
#include "gtkmm2ext/bindings.h"
|
|
|
|
#include "gtkmm2ext/utils.h"
|
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
#include "canvas/canvas.h"
|
|
|
|
|
2019-03-29 10:57:07 -04:00
|
|
|
#include "ardour/audioplaylist.h"
|
2013-04-04 00:32:52 -04:00
|
|
|
#include "ardour/audioregion.h"
|
|
|
|
#include "ardour/operations.h"
|
|
|
|
#include "ardour/playlist.h"
|
|
|
|
#include "ardour/profile.h"
|
|
|
|
#include "ardour/region_factory.h"
|
|
|
|
#include "ardour/route.h"
|
|
|
|
#include "ardour/session.h"
|
|
|
|
#include "ardour/types.h"
|
|
|
|
|
2017-07-16 23:18:48 -04:00
|
|
|
#include "widgets/prompter.h"
|
|
|
|
|
2009-07-28 16:51:28 -04:00
|
|
|
#include "actions.h"
|
2016-09-06 16:56:07 -04:00
|
|
|
#include "ardour_ui.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "editor.h"
|
|
|
|
#include "time_axis_view.h"
|
|
|
|
#include "audio_time_axis.h"
|
2006-08-01 13:19:38 -04:00
|
|
|
#include "audio_region_view.h"
|
2007-03-18 02:07:08 -04:00
|
|
|
#include "midi_region_view.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "marker.h"
|
|
|
|
#include "streamview.h"
|
|
|
|
#include "region_gain_line.h"
|
2018-02-09 10:59:39 -05:00
|
|
|
#include "rc_option_editor.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "automation_time_axis.h"
|
2007-07-06 23:19:04 -04:00
|
|
|
#include "control_point.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "selection.h"
|
|
|
|
#include "keyboard.h"
|
|
|
|
#include "editing.h"
|
|
|
|
#include "rgb_macros.h"
|
2008-12-18 12:46:28 -05:00
|
|
|
#include "control_point_dialog.h"
|
2009-05-30 14:25:59 -04:00
|
|
|
#include "editor_drag.h"
|
2010-08-04 11:41:55 -04:00
|
|
|
#include "automation_region_view.h"
|
2010-08-13 22:00:50 -04:00
|
|
|
#include "edit_note_dialog.h"
|
2010-11-16 09:53:16 -05:00
|
|
|
#include "mouse_cursors.h"
|
|
|
|
#include "editor_cursors.h"
|
2020-12-19 10:44:16 -05:00
|
|
|
#include "region_peak_cursor.h"
|
2011-05-02 09:38:16 -04:00
|
|
|
#include "verbose_cursor.h"
|
2013-04-04 00:32:52 -04:00
|
|
|
#include "note.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace ARDOUR;
|
Large nasty commit in the form of a 5000 line patch chock-full of completely
unecessary changes. (Sorry, doing a "sprint" based thing, this is the end of the first one)
Achieved MIDI track and bus creation, associated Jack port and diskstream creation, and minimal GUI stuff for creating them. Should be set to start work on actually recording and playing midi to/from disk now.
Relevant (significant) changes:
- Creation of a Buffer class. Base class is type agnostic so things can point to a buffer but not care what kind it is (otherwise it'd be a template). Derived into AudioBuffer and MidiBuffer, with a type tag because checking type is necessary in parts of the code where dynamic_cast wouldn't be wise. Originally I considered this a hack, but passing around a type proved to be a very good solution to all the other problems (below). There is a 1:1 mapping between jack port data types and ardour Buffer types (with a conversion function), but that's easily removed if it ever becomes necessary. Having the type scoped in the Buffer class is maybe not the best spot for it, but whatever (this is proof of concept kinda stuff right now...)
- IO now has a "default" port type (passed to the constructor and stored as a member), used by ensure_io (and similar) to create n ports. IO::register_***_port has a type argument that defaults to the default type if not passed. Rationale: previous IO API is identical, no changes needed to existing code, but path is paved for multiple port types in one IO, which we will need for eg synth plugin inserts, among other things. This is not quite ideal (best would be to only have the two port register functions and have them take a type), but the alternative is a lot of work (namely destroying the 'ensure' functions and everything that uses them) for very little gain. (I am convinced after quite a few tries at the whiteboard that subclassing IO in any way is not a feasible option, look at it's inheritance diagram in Doxygen and you can see why)
- AudioEngine::register_audio_input_port is now register_input_port and takes a type argument. Ditto for output.
- (Most significant change) AudioDiskstream abstracted into Distream, and sibling MidiDiskstream created. Very much still a work in progress, but Diskstream is there to switch references over to (most already are), which is the important part. It is still unclear what the MIDI diskstream's relation to channels is, but I'm pretty sure they will be single channel only (so SMF Type 0) since noone can come up with a reason otherwise.
- MidiTrack creation. Same thing as AudioTrack but with a different default type basically. No big deal here.
- Random cleanups and variable renamings etc. because I have OCD and can't help myself. :)
Known broken: Loading of sessions containing MIDI tracks.
git-svn-id: svn://localhost/ardour2/branches/midi@641 d708f5d6-7413-0410-9779-e7cbd77b26cf
2006-06-26 12:01:34 -04:00
|
|
|
using namespace PBD;
|
2005-09-25 14:42:24 -04:00
|
|
|
using namespace Gtk;
|
|
|
|
using namespace Editing;
|
2020-11-16 13:19:22 -05:00
|
|
|
using namespace Temporal;
|
|
|
|
|
2009-12-04 17:51:32 -05:00
|
|
|
using Gtkmm2ext::Keyboard;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-11-07 20:40:25 -05:00
|
|
|
bool
|
2017-09-18 12:39:17 -04:00
|
|
|
Editor::mouse_sample (samplepos_t& where, bool& in_track_canvas) const
|
2007-11-07 20:40:25 -05:00
|
|
|
{
|
2019-04-08 13:53:33 -04:00
|
|
|
/* gdk_window_get_pointer() has X11's XQueryPointer semantics in that it only
|
|
|
|
* pays attentions to subwindows. this means that menu windows are ignored, and
|
|
|
|
* if the pointer is in a menu, the return window from the call will be the
|
|
|
|
* the regular subwindow *under* the menu.
|
|
|
|
*
|
|
|
|
* this matters quite a lot if the pointer is moving around in a menu that overlaps
|
|
|
|
* the track canvas because we will believe that we are within the track canvas
|
|
|
|
* when we are not. therefore, we track enter/leave events for the track canvas
|
|
|
|
* and allow that to override the result of gdk_window_get_pointer().
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!within_track_canvas) {
|
2017-07-01 12:42:24 -04:00
|
|
|
return false;
|
2019-04-08 13:53:33 -04:00
|
|
|
}
|
2012-03-09 12:15:25 -05:00
|
|
|
|
2007-11-07 20:40:25 -05:00
|
|
|
int x, y;
|
2013-04-12 11:09:49 -04:00
|
|
|
Glib::RefPtr<Gdk::Window> canvas_window = const_cast<Editor*>(this)->_track_canvas->get_window();
|
2008-04-11 10:06:50 -04:00
|
|
|
|
|
|
|
if (!canvas_window) {
|
|
|
|
return false;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2013-04-12 11:09:49 -04:00
|
|
|
Glib::RefPtr<const Gdk::Window> pointer_window = Gdk::Display::get_default()->get_window_at_pointer (x, y);
|
2007-11-07 20:40:25 -05:00
|
|
|
|
2013-04-12 11:09:49 -04:00
|
|
|
if (!pointer_window) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-05-21 11:12:57 -04:00
|
|
|
if (pointer_window != canvas_window) {
|
2007-11-07 20:40:25 -05:00
|
|
|
in_track_canvas = false;
|
2013-04-04 00:32:52 -04:00
|
|
|
return false;
|
2007-11-07 20:40:25 -05:00
|
|
|
}
|
|
|
|
|
2013-04-12 11:09:49 -04:00
|
|
|
in_track_canvas = true;
|
|
|
|
|
2007-11-07 20:40:25 -05:00
|
|
|
GdkEvent event;
|
|
|
|
event.type = GDK_BUTTON_RELEASE;
|
2013-04-12 11:09:49 -04:00
|
|
|
event.button.x = x;
|
|
|
|
event.button.y = y;
|
|
|
|
|
2014-02-26 08:43:53 -05:00
|
|
|
where = window_event_sample (&event, 0, 0);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-11-07 20:40:25 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-09-18 12:39:17 -04:00
|
|
|
samplepos_t
|
2014-02-26 08:43:53 -05:00
|
|
|
Editor::window_event_sample (GdkEvent const * event, double* pcx, double* pcy) const
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2014-05-20 23:08:15 -04:00
|
|
|
ArdourCanvas::Duple d;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2014-05-20 23:08:15 -04:00
|
|
|
if (!gdk_event_get_coords (event, &d.x, &d.y)) {
|
2013-04-12 11:09:49 -04:00
|
|
|
return 0;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2013-04-12 11:09:49 -04:00
|
|
|
/* event coordinates are in window units, so convert to canvas
|
2013-04-11 20:19:22 -04:00
|
|
|
*/
|
2013-04-04 00:32:52 -04:00
|
|
|
|
2014-05-20 23:08:15 -04:00
|
|
|
d = _track_canvas->window_to_canvas (d);
|
2013-04-12 11:09:49 -04:00
|
|
|
|
|
|
|
if (pcx) {
|
2013-04-11 20:19:22 -04:00
|
|
|
*pcx = d.x;
|
2013-04-12 11:09:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pcy) {
|
2013-04-11 20:19:22 -04:00
|
|
|
*pcy = d.y;
|
2013-04-12 11:09:49 -04:00
|
|
|
}
|
|
|
|
|
2013-04-12 11:15:45 -04:00
|
|
|
return pixel_to_sample (d.x);
|
2013-04-12 11:09:49 -04:00
|
|
|
}
|
|
|
|
|
2021-01-18 22:13:13 -05:00
|
|
|
timepos_t
|
|
|
|
Editor::canvas_event_time (GdkEvent const * event, double* pcx, double* pcy) const
|
|
|
|
{
|
|
|
|
timepos_t pos (canvas_event_sample (event, pcx, pcy));
|
|
|
|
|
|
|
|
if (default_time_domain() == Temporal::AudioTime) {
|
|
|
|
cerr << "E::cet returns audio\n";
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
cerr << "E::cet returns beats\n";
|
|
|
|
return timepos_t (pos.beats());
|
|
|
|
}
|
|
|
|
|
2017-09-18 12:39:17 -04:00
|
|
|
samplepos_t
|
2014-02-26 08:43:53 -05:00
|
|
|
Editor::canvas_event_sample (GdkEvent const * event, double* pcx, double* pcy) const
|
2013-04-12 11:09:49 -04:00
|
|
|
{
|
|
|
|
double x;
|
|
|
|
double y;
|
|
|
|
|
|
|
|
/* event coordinates are already in canvas units */
|
|
|
|
|
|
|
|
if (!gdk_event_get_coords (event, &x, &y)) {
|
|
|
|
cerr << "!NO c COORDS for event type " << event->type << endl;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pcx) {
|
|
|
|
*pcx = x;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pcy) {
|
|
|
|
*pcy = y;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
/* note that pixel_to_sample_from_event() never returns less than zero, so even if the pixel
|
2005-09-25 14:42:24 -04:00
|
|
|
position is negative (as can be the case with motion events in particular),
|
2017-09-18 12:39:17 -04:00
|
|
|
the sample location is always positive.
|
2005-09-25 14:42:24 -04:00
|
|
|
*/
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
return pixel_to_sample_from_event (x);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2010-09-22 11:21:06 -04:00
|
|
|
void
|
|
|
|
Editor::set_current_trimmable (boost::shared_ptr<Trimmable> t)
|
|
|
|
{
|
2010-11-25 15:37:39 -05:00
|
|
|
boost::shared_ptr<Trimmable> st = _trimmable.lock();
|
2010-09-22 11:21:06 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
if (!st || st == t) {
|
|
|
|
_trimmable = t;
|
|
|
|
}
|
2010-09-22 11:21:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::set_current_movable (boost::shared_ptr<Movable> m)
|
|
|
|
{
|
2010-11-25 15:37:39 -05:00
|
|
|
boost::shared_ptr<Movable> sm = _movable.lock();
|
2010-09-22 11:21:06 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
if (!sm || sm != m) {
|
|
|
|
_movable = m;
|
2010-01-01 17:11:15 -05:00
|
|
|
}
|
2008-02-16 17:43:18 -05:00
|
|
|
}
|
|
|
|
|
2012-11-26 17:43:10 -05:00
|
|
|
void
|
|
|
|
Editor::mouse_mode_object_range_toggled()
|
|
|
|
{
|
2019-02-28 17:54:42 -05:00
|
|
|
set_mouse_mode (mouse_mode, true); /* updates set-mouse-mode-range */
|
2012-11-26 17:43:10 -05:00
|
|
|
}
|
|
|
|
|
2018-02-09 10:59:39 -05:00
|
|
|
bool
|
|
|
|
Editor::snap_mode_button_clicked (GdkEventButton* ev)
|
|
|
|
{
|
|
|
|
if (ev->button != 3) {
|
|
|
|
cycle_snap_mode();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
RCOptionEditor* rc_option_editor = ARDOUR_UI::instance()->get_rc_option_editor();
|
2018-02-24 07:54:15 -05:00
|
|
|
if (rc_option_editor) {
|
2018-02-09 10:59:39 -05:00
|
|
|
ARDOUR_UI::instance()->show_tabbable (rc_option_editor);
|
|
|
|
rc_option_editor->set_current_page (_("Editor/Snap"));
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-12-10 08:33:31 -05:00
|
|
|
Glib::RefPtr<Action>
|
|
|
|
Editor::get_mouse_mode_action(MouseMode m) const
|
2014-12-09 14:00:12 -05:00
|
|
|
{
|
|
|
|
switch (m) {
|
|
|
|
case MouseRange:
|
|
|
|
return ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-range"));
|
|
|
|
case MouseObject:
|
|
|
|
return ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-object"));
|
|
|
|
case MouseCut:
|
|
|
|
return ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-cut"));
|
|
|
|
case MouseDraw:
|
|
|
|
return ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-draw"));
|
|
|
|
case MouseTimeFX:
|
|
|
|
return ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-timefx"));
|
|
|
|
case MouseContent:
|
|
|
|
return ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-content"));
|
|
|
|
case MouseAudition:
|
|
|
|
return ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-audition"));
|
|
|
|
}
|
|
|
|
return Glib::RefPtr<Action>();
|
|
|
|
}
|
|
|
|
|
2008-02-16 17:43:18 -05:00
|
|
|
void
|
2009-07-28 16:51:28 -04:00
|
|
|
Editor::set_mouse_mode (MouseMode m, bool force)
|
2008-02-16 17:43:18 -05:00
|
|
|
{
|
2010-01-12 11:14:49 -05:00
|
|
|
if (_drags->active ()) {
|
2009-07-28 16:51:28 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!force && m == mouse_mode) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-11 16:41:28 -04:00
|
|
|
if (ARDOUR::Profile->get_mixbus()) {
|
2020-04-16 14:15:06 -04:00
|
|
|
if (m == MouseAudition) {
|
|
|
|
m = MouseRange;
|
|
|
|
}
|
2014-07-11 16:41:28 -04:00
|
|
|
}
|
|
|
|
|
2014-12-09 14:00:12 -05:00
|
|
|
Glib::RefPtr<Action> act = get_mouse_mode_action(m);
|
|
|
|
Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
|
2009-08-04 14:19:40 -04:00
|
|
|
|
|
|
|
/* go there and back to ensure that the toggled handler is called to set up mouse_mode */
|
|
|
|
tact->set_active (false);
|
2009-07-28 16:51:28 -04:00
|
|
|
tact->set_active (true);
|
2010-11-21 18:54:57 -05:00
|
|
|
|
2018-02-24 07:54:15 -05:00
|
|
|
/* NOTE: this will result in a call to mouse_mode_toggled which does the heavy lifting */
|
2008-02-16 17:43:18 -05:00
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2009-07-28 16:51:28 -04:00
|
|
|
Editor::mouse_mode_toggled (MouseMode m)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2014-07-11 16:41:28 -04:00
|
|
|
if (ARDOUR::Profile->get_mixbus()) {
|
2020-04-16 14:15:06 -04:00
|
|
|
if (m == MouseAudition) {
|
|
|
|
m = MouseRange;
|
|
|
|
}
|
2014-07-11 16:41:28 -04:00
|
|
|
}
|
|
|
|
|
2014-12-09 14:00:12 -05:00
|
|
|
Glib::RefPtr<Action> act = get_mouse_mode_action(m);
|
|
|
|
Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
|
2012-01-19 10:23:51 -05:00
|
|
|
|
|
|
|
if (!tact->get_active()) {
|
|
|
|
/* this was just the notification that the old mode has been
|
|
|
|
* left. we'll get called again with the new mode active in a
|
|
|
|
* jiffy.
|
|
|
|
*/
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-07-26 11:40:46 -04:00
|
|
|
if (_session && mouse_mode == MouseAudition) {
|
|
|
|
/* stop transport and reset default speed to avoid oddness with
|
|
|
|
auditioning */
|
2021-04-16 01:20:59 -04:00
|
|
|
_session->request_stop ();
|
2021-04-17 15:29:00 -04:00
|
|
|
_session->reset_transport_speed ();
|
2012-07-26 11:40:46 -04:00
|
|
|
}
|
2012-01-19 10:23:51 -05:00
|
|
|
|
2014-12-16 23:02:28 -05:00
|
|
|
const bool was_internal = internal_editing();
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
mouse_mode = m;
|
|
|
|
|
2021-11-15 18:36:05 -05:00
|
|
|
/* Ben ToDo: once we have a dedicated 'region edit panel', we can store
|
|
|
|
* one snap mode in the editor canvas and another one in the editor,
|
|
|
|
* relieving the complexity here */
|
|
|
|
|
2014-12-24 15:11:25 -05:00
|
|
|
/* Switch snap type/mode if we're moving to/from an internal tool. Note
|
|
|
|
this must toggle the actions and not call set_snap_*() directly,
|
|
|
|
otherwise things get out of sync and the combo box stops working. */
|
2019-04-08 13:53:33 -04:00
|
|
|
if (!UIConfiguration::instance().get_grid_follows_internal()) {
|
2018-07-26 14:53:36 -04:00
|
|
|
grid_type_action(pre_internal_grid_type)->set_active(true);
|
|
|
|
snap_mode_action(pre_internal_snap_mode)->set_active(true);
|
2019-04-08 13:53:33 -04:00
|
|
|
} else if (!was_internal && internal_editing()) {
|
2018-02-09 10:59:39 -05:00
|
|
|
grid_type_action(internal_grid_type)->set_active(true);
|
2014-12-24 15:11:25 -05:00
|
|
|
snap_mode_action(internal_snap_mode)->set_active(true);
|
2014-12-16 23:02:28 -05:00
|
|
|
} else if (was_internal && !internal_editing()) {
|
2018-02-09 10:59:39 -05:00
|
|
|
grid_type_action(pre_internal_grid_type)->set_active(true);
|
2014-12-24 15:11:25 -05:00
|
|
|
snap_mode_action(pre_internal_snap_mode)->set_active(true);
|
2014-12-16 23:02:28 -05:00
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
instant_save ();
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2014-07-07 07:54:41 -04:00
|
|
|
/* this should generate a new enter event which will
|
Fix typos in gtk2_ardour/ directory
Found via `codespell -q 3 -S *.po,./share/patchfiles,./libs -L ba,buss,busses,doubleclick,hsi,ontop,ro,seh,siz,sur,te,trough,ue`
2022-01-26 12:35:38 -05:00
|
|
|
trigger the appropriate cursor.
|
2014-07-07 07:54:41 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
if (_track_canvas) {
|
|
|
|
_track_canvas->re_enter ();
|
2010-11-25 15:37:39 -05:00
|
|
|
}
|
2014-07-07 07:54:41 -04:00
|
|
|
|
2012-05-29 14:30:10 -04:00
|
|
|
set_gain_envelope_visibility ();
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-02-26 10:50:51 -05:00
|
|
|
update_time_selection_display ();
|
2010-11-21 18:54:57 -05:00
|
|
|
|
2021-11-15 18:36:05 -05:00
|
|
|
if (mouse_mode == MouseDraw) {
|
2021-11-16 13:06:13 -05:00
|
|
|
draw_box.show();
|
2021-11-15 18:36:05 -05:00
|
|
|
} else {
|
2021-11-16 13:06:13 -05:00
|
|
|
draw_box.hide();
|
2021-11-15 18:36:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-05 19:58:32 -04:00
|
|
|
if (internal_editing()) {
|
2020-04-16 14:16:45 -04:00
|
|
|
|
|
|
|
/* reinstate any existing MIDI note (and by extension, MIDI
|
|
|
|
* region) selection for internal edit mode. This allows a user
|
|
|
|
* to enter/exit/enter this mode without losing a selection of
|
|
|
|
* notes.
|
|
|
|
*/
|
|
|
|
|
|
|
|
catch_up_on_midi_selection ();
|
|
|
|
|
|
|
|
/* ensure that the track canvas has focus, so that key events
|
|
|
|
will get directed to the correct place.
|
|
|
|
*/
|
|
|
|
_track_canvas->grab_focus ();
|
|
|
|
|
|
|
|
/* enable MIDI editing actions, which in turns enables their
|
|
|
|
bindings
|
|
|
|
*/
|
|
|
|
ActionManager::set_sensitive (_midi_actions, true);
|
|
|
|
|
|
|
|
/* mark "magic widget focus" so that we handle key events
|
|
|
|
* correctly
|
|
|
|
*/
|
|
|
|
Keyboard::magic_widget_grab_focus ();
|
|
|
|
} else {
|
|
|
|
/* undo some of the above actions, since we're not in internal
|
|
|
|
edit mode.
|
|
|
|
*/
|
|
|
|
ActionManager::set_sensitive (_midi_actions, false);
|
|
|
|
Keyboard::magic_widget_drop_focus ();
|
|
|
|
}
|
|
|
|
|
2020-05-01 19:37:27 -04:00
|
|
|
if (was_internal && !internal_editing()) {
|
|
|
|
/* drop any selected regions so that they in turn
|
|
|
|
* redraw any selected notes. This essentially the
|
|
|
|
* opposite of ::catch_up_on_midi_selection() called
|
|
|
|
* above.
|
|
|
|
*/
|
|
|
|
get_selection().clear_regions ();
|
|
|
|
}
|
|
|
|
|
2014-12-23 13:46:53 -05:00
|
|
|
update_all_enter_cursors ();
|
|
|
|
|
2010-11-21 18:54:57 -05:00
|
|
|
MouseModeChanged (); /* EMIT SIGNAL */
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2014-12-08 23:00:00 -05:00
|
|
|
bool
|
|
|
|
Editor::internal_editing() const
|
|
|
|
{
|
|
|
|
return mouse_mode == Editing::MouseContent || mouse_mode == Editing::MouseDraw;
|
|
|
|
}
|
|
|
|
|
2014-02-26 10:50:51 -05:00
|
|
|
void
|
|
|
|
Editor::update_time_selection_display ()
|
|
|
|
{
|
2015-01-13 14:33:42 -05:00
|
|
|
switch (mouse_mode) {
|
2015-01-13 23:30:37 -05:00
|
|
|
case MouseRange:
|
|
|
|
selection->clear_objects ();
|
2015-10-27 22:58:55 -04:00
|
|
|
selection->clear_midi_notes ();
|
2015-01-13 23:30:37 -05:00
|
|
|
break;
|
|
|
|
case MouseObject:
|
|
|
|
selection->clear_time ();
|
2015-10-27 22:58:55 -04:00
|
|
|
selection->clear_midi_notes ();
|
2015-01-13 23:30:37 -05:00
|
|
|
break;
|
|
|
|
case MouseDraw:
|
2015-01-14 08:06:16 -05:00
|
|
|
/* Clear regions, but not time or tracks, since that
|
|
|
|
would destroy the range selection rectangle, which we need to stick
|
2015-01-13 23:30:37 -05:00
|
|
|
around for AutomationRangeDrag. */
|
2015-01-14 08:06:16 -05:00
|
|
|
selection->clear_regions ();
|
2015-01-14 09:39:00 -05:00
|
|
|
selection->clear_playlists ();
|
2015-01-13 23:30:37 -05:00
|
|
|
break;
|
2015-01-14 09:39:00 -05:00
|
|
|
case MouseContent:
|
2015-01-14 08:06:16 -05:00
|
|
|
/* This handles internal edit.
|
2015-10-04 14:51:05 -04:00
|
|
|
Clear everything except points and notes.
|
2015-01-14 08:06:16 -05:00
|
|
|
*/
|
|
|
|
selection->clear_regions();
|
2015-01-14 09:39:00 -05:00
|
|
|
selection->clear_lines();
|
|
|
|
selection->clear_playlists ();
|
|
|
|
|
|
|
|
selection->clear_time ();
|
|
|
|
selection->clear_tracks ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseTimeFX:
|
|
|
|
/* We probably want to keep region selection */
|
|
|
|
selection->clear_points ();
|
|
|
|
selection->clear_lines();
|
|
|
|
selection->clear_playlists ();
|
|
|
|
|
|
|
|
selection->clear_time ();
|
|
|
|
selection->clear_tracks ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseAudition:
|
|
|
|
/*Don't lose lines or points if no action in this mode */
|
|
|
|
selection->clear_regions ();
|
|
|
|
selection->clear_playlists ();
|
|
|
|
selection->clear_time ();
|
|
|
|
selection->clear_tracks ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/*Clear everything */
|
|
|
|
selection->clear_objects();
|
2015-01-13 23:30:37 -05:00
|
|
|
selection->clear_time ();
|
|
|
|
selection->clear_tracks ();
|
|
|
|
break;
|
2014-02-26 10:50:51 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Editor::step_mouse_mode (bool next)
|
|
|
|
{
|
2014-12-08 23:00:00 -05:00
|
|
|
const int n_mouse_modes = (int)MouseContent + 1;
|
2014-12-07 19:04:33 -05:00
|
|
|
int current = (int)current_mouse_mode();
|
|
|
|
if (next) {
|
|
|
|
set_mouse_mode((MouseMode)((current + 1) % n_mouse_modes));
|
|
|
|
} else {
|
|
|
|
set_mouse_mode((MouseMode)((current + n_mouse_modes - 1) % n_mouse_modes));
|
2007-08-10 16:55:27 -04:00
|
|
|
}
|
2007-08-08 15:13:36 -04:00
|
|
|
}
|
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
void
|
2015-09-13 15:24:28 -04:00
|
|
|
Editor::button_selection (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2019-04-08 13:53:33 -04:00
|
|
|
/* in object/audition/timefx/gain-automation mode,
|
|
|
|
* any button press sets the selection if the object
|
|
|
|
* can be selected. this is a bit of hack, because
|
|
|
|
* we want to avoid this if the mouse operation is a
|
|
|
|
* region alignment.
|
|
|
|
*
|
|
|
|
* note: not dbl-click or triple-click
|
|
|
|
*
|
|
|
|
* Also note that there is no region selection in internal edit mode, otherwise
|
|
|
|
* for operations operating on the selection (e.g. cut) it is not obvious whether
|
|
|
|
* to cut notes or regions.
|
|
|
|
*/
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2014-06-30 09:17:03 -04:00
|
|
|
MouseMode eff_mouse_mode = effective_mouse_mode ();
|
2014-03-06 10:40:31 -05:00
|
|
|
|
2014-07-07 07:54:41 -04:00
|
|
|
if (eff_mouse_mode == MouseCut) {
|
|
|
|
/* never change selection in cut mode */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-03-06 10:40:31 -05:00
|
|
|
if (get_smart_mode() && eff_mouse_mode == MouseRange && event->button.button == 3 && item_type == RegionItem) {
|
|
|
|
/* context clicks are always about object properties, even if
|
2019-04-08 15:37:02 -04:00
|
|
|
* we're in range mode within smart mode.
|
|
|
|
*/
|
2014-03-06 10:40:31 -05:00
|
|
|
eff_mouse_mode = MouseObject;
|
|
|
|
}
|
|
|
|
|
2014-06-30 09:17:03 -04:00
|
|
|
/* special case: allow drag of region fade in/out in object mode with join object/range enabled */
|
|
|
|
if (get_smart_mode()) {
|
|
|
|
switch (item_type) {
|
2019-04-08 13:53:33 -04:00
|
|
|
case FadeInHandleItem:
|
|
|
|
case FadeInTrimHandleItem:
|
|
|
|
case FadeOutHandleItem:
|
|
|
|
case FadeOutTrimHandleItem:
|
|
|
|
eff_mouse_mode = MouseObject;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2014-06-30 09:17:03 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-13 08:39:14 -04:00
|
|
|
if (((mouse_mode != MouseObject) &&
|
2019-04-08 15:37:02 -04:00
|
|
|
(mouse_mode != MouseAudition || item_type != RegionItem) &&
|
|
|
|
(mouse_mode != MouseTimeFX || item_type != RegionItem) &&
|
|
|
|
(mouse_mode != MouseDraw) &&
|
|
|
|
(mouse_mode != MouseContent || item_type == RegionItem)) ||
|
|
|
|
((event->type != GDK_BUTTON_PRESS && event->type != GDK_BUTTON_RELEASE) || event->button.button > 3)) {
|
2006-06-13 03:27:52 -04:00
|
|
|
return;
|
|
|
|
}
|
2007-01-28 12:44:13 -05:00
|
|
|
|
|
|
|
if (event->type == GDK_BUTTON_PRESS || event->type == GDK_BUTTON_RELEASE) {
|
|
|
|
|
|
|
|
if ((event->button.state & Keyboard::RelevantModifierKeyMask) && event->button.button != 1) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-03-18 02:07:08 -04:00
|
|
|
/* almost no selection action on modified button-2 or button-3 events */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2015-10-31 14:22:55 -04:00
|
|
|
if ((item_type != RegionItem && event->button.button != 2)
|
2019-04-08 15:37:02 -04:00
|
|
|
/* for selection of control points prior to delete (shift-right click) */
|
|
|
|
&& !(item_type == ControlPointItem && event->button.button == 3 && event->type == GDK_BUTTON_PRESS)) {
|
2007-03-18 02:07:08 -04:00
|
|
|
return;
|
|
|
|
}
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2009-12-04 17:51:32 -05:00
|
|
|
Selection::Operation op = ArdourKeyboard::selection_type (event->button.state);
|
2006-06-13 03:27:52 -04:00
|
|
|
bool press = (event->type == GDK_BUTTON_PRESS);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2015-01-10 12:07:31 -05:00
|
|
|
if (press) {
|
|
|
|
_mouse_changed_selection = false;
|
|
|
|
}
|
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
switch (item_type) {
|
2019-04-08 13:53:33 -04:00
|
|
|
case RegionItem:
|
|
|
|
if (eff_mouse_mode == MouseDraw) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (press) {
|
|
|
|
if (eff_mouse_mode != MouseRange) {
|
|
|
|
_mouse_changed_selection = set_selected_regionview_from_click (press, op);
|
|
|
|
} else {
|
|
|
|
/* don't change the selection unless the
|
2019-04-08 18:27:05 -04:00
|
|
|
* clicked track is not currently selected. if
|
|
|
|
* so, "collapse" the selection to just this track
|
|
|
|
*/
|
2019-04-08 13:53:33 -04:00
|
|
|
if (!selection->selected (clicked_axisview)) {
|
|
|
|
set_selected_track_as_side_effect (Selection::Set);
|
|
|
|
}
|
|
|
|
}
|
2012-11-26 17:43:10 -05:00
|
|
|
} else {
|
2019-04-08 13:53:33 -04:00
|
|
|
if (eff_mouse_mode != MouseRange) {
|
|
|
|
_mouse_changed_selection |= set_selected_regionview_from_click (press, op);
|
2012-01-30 17:53:22 -05:00
|
|
|
}
|
|
|
|
}
|
2019-04-08 13:53:33 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RegionViewNameHighlight:
|
|
|
|
case RegionViewName:
|
|
|
|
case LeftFrameHandle:
|
|
|
|
case RightFrameHandle:
|
|
|
|
case FadeInHandleItem:
|
|
|
|
case FadeInTrimHandleItem:
|
|
|
|
case FadeInItem:
|
|
|
|
case FadeOutHandleItem:
|
|
|
|
case FadeOutTrimHandleItem:
|
|
|
|
case FadeOutItem:
|
|
|
|
case StartCrossFadeItem:
|
|
|
|
case EndCrossFadeItem:
|
|
|
|
if (get_smart_mode() || eff_mouse_mode != MouseRange) {
|
2015-01-17 13:25:23 -05:00
|
|
|
_mouse_changed_selection |= set_selected_regionview_from_click (press, op);
|
2019-04-08 13:53:33 -04:00
|
|
|
} else if (event->type == GDK_BUTTON_PRESS) {
|
|
|
|
set_selected_track_as_side_effect (op);
|
2014-03-06 10:40:31 -05:00
|
|
|
}
|
2019-04-08 13:53:33 -04:00
|
|
|
break;
|
2007-05-10 07:53:35 -04:00
|
|
|
|
2019-04-08 13:53:33 -04:00
|
|
|
case ControlPointItem:
|
|
|
|
/* for object/track exclusivity, we don't call set_selected_track_as_side_effect (op); */
|
2015-06-17 13:48:39 -04:00
|
|
|
|
2019-04-08 13:53:33 -04:00
|
|
|
if (eff_mouse_mode != MouseRange) {
|
|
|
|
if (event->button.button != 3) {
|
|
|
|
_mouse_changed_selection |= set_selected_control_point_from_click (press, op);
|
|
|
|
} else {
|
|
|
|
_mouse_changed_selection |= set_selected_control_point_from_click (press, Selection::Set);
|
|
|
|
}
|
2015-10-04 11:56:56 -04:00
|
|
|
}
|
2019-04-08 13:53:33 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2019-04-08 13:53:33 -04:00
|
|
|
case GainLineItem:
|
|
|
|
if (eff_mouse_mode != MouseRange) {
|
|
|
|
AutomationLine* argl = reinterpret_cast<AutomationLine*> (item->get_data ("line"));
|
2015-10-03 12:29:16 -04:00
|
|
|
|
2019-04-08 13:53:33 -04:00
|
|
|
std::list<Selectable*> selectables;
|
|
|
|
uint32_t before, after;
|
2020-10-19 14:37:54 -04:00
|
|
|
samplecnt_t const where = (samplecnt_t) floor (event->button.x * samples_per_pixel) - clicked_regionview->region ()->position_sample ();
|
2015-09-13 15:24:28 -04:00
|
|
|
|
2019-04-08 13:53:33 -04:00
|
|
|
if (!argl || !argl->control_points_adjacent (where, before, after)) {
|
|
|
|
break;
|
|
|
|
}
|
2015-09-13 15:24:28 -04:00
|
|
|
|
2019-04-08 13:53:33 -04:00
|
|
|
selectables.push_back (argl->nth (before));
|
|
|
|
selectables.push_back (argl->nth (after));
|
2015-10-03 12:29:16 -04:00
|
|
|
|
2019-04-08 13:53:33 -04:00
|
|
|
switch (op) {
|
|
|
|
case Selection::Set:
|
|
|
|
if (press) {
|
|
|
|
selection->set (selectables);
|
|
|
|
_mouse_changed_selection = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Selection::Add:
|
|
|
|
if (press) {
|
|
|
|
selection->add (selectables);
|
|
|
|
_mouse_changed_selection = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Selection::Toggle:
|
|
|
|
if (press) {
|
|
|
|
selection->toggle (selectables);
|
|
|
|
_mouse_changed_selection = true;
|
|
|
|
}
|
|
|
|
break;
|
2015-10-03 12:29:16 -04:00
|
|
|
|
2019-04-08 13:53:33 -04:00
|
|
|
case Selection::Extend:
|
|
|
|
/* XXX */
|
|
|
|
break;
|
|
|
|
}
|
2015-10-03 12:29:16 -04:00
|
|
|
}
|
2019-04-08 13:53:33 -04:00
|
|
|
break;
|
2015-10-03 12:29:16 -04:00
|
|
|
|
2019-04-08 13:53:33 -04:00
|
|
|
case AutomationLineItem:
|
|
|
|
if (eff_mouse_mode != MouseRange) {
|
|
|
|
AutomationLine* al = reinterpret_cast<AutomationLine*> (item->get_data ("line"));
|
|
|
|
std::list<Selectable*> selectables;
|
|
|
|
double mx = event->button.x;
|
|
|
|
double my = event->button.y;
|
2016-11-22 23:09:54 -05:00
|
|
|
|
2019-04-08 13:53:33 -04:00
|
|
|
al->grab_item().canvas_to_item (mx, my);
|
2016-11-22 23:09:54 -05:00
|
|
|
|
2019-04-08 13:53:33 -04:00
|
|
|
uint32_t before, after;
|
|
|
|
samplecnt_t const where = (samplecnt_t) floor (mx * samples_per_pixel);
|
2015-10-03 12:29:16 -04:00
|
|
|
|
2019-04-08 13:53:33 -04:00
|
|
|
if (!al || !al->control_points_adjacent (where, before, after)) {
|
|
|
|
break;
|
|
|
|
}
|
2015-09-13 15:24:28 -04:00
|
|
|
|
2019-04-08 13:53:33 -04:00
|
|
|
selectables.push_back (al->nth (before));
|
|
|
|
selectables.push_back (al->nth (after));
|
2015-09-13 15:24:28 -04:00
|
|
|
|
2019-04-08 13:53:33 -04:00
|
|
|
switch (op) {
|
|
|
|
case Selection::Set:
|
|
|
|
if (press) {
|
|
|
|
selection->set (selectables);
|
|
|
|
_mouse_changed_selection = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Selection::Add:
|
|
|
|
if (press) {
|
|
|
|
selection->add (selectables);
|
|
|
|
_mouse_changed_selection = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Selection::Toggle:
|
|
|
|
if (press) {
|
|
|
|
selection->toggle (selectables);
|
|
|
|
_mouse_changed_selection = true;
|
|
|
|
}
|
|
|
|
break;
|
2015-09-13 15:24:28 -04:00
|
|
|
|
2019-04-08 13:53:33 -04:00
|
|
|
case Selection::Extend:
|
|
|
|
/* XXX */
|
|
|
|
break;
|
|
|
|
}
|
2015-09-13 15:24:28 -04:00
|
|
|
}
|
2019-04-08 13:53:33 -04:00
|
|
|
break;
|
2015-09-13 15:24:28 -04:00
|
|
|
|
2019-04-08 13:53:33 -04:00
|
|
|
case StreamItem:
|
|
|
|
/* for context click, select track */
|
|
|
|
if (event->button.button == 3) {
|
|
|
|
selection->clear_tracks ();
|
|
|
|
set_selected_track_as_side_effect (op);
|
2015-01-17 13:25:23 -05:00
|
|
|
|
2019-04-08 13:53:33 -04:00
|
|
|
/* We won't get a release.*/
|
|
|
|
begin_reversible_selection_op (X_("Button 3 Menu Select"));
|
|
|
|
commit_reversible_selection_op ();
|
|
|
|
}
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2019-04-08 13:53:33 -04:00
|
|
|
case AutomationTrackItem:
|
|
|
|
if (eff_mouse_mode != MouseDraw && op == Selection::Set) {
|
|
|
|
set_selected_track_as_side_effect (op);
|
|
|
|
}
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2019-04-08 13:53:33 -04:00
|
|
|
case NoteItem:
|
|
|
|
if (press && event->button.button == 3) {
|
|
|
|
NoteBase* cnote = reinterpret_cast<NoteBase*> (item->get_data ("notebase"));
|
|
|
|
assert (cnote);
|
|
|
|
if (cnote->region_view().selection_size() == 0 || !cnote->selected()) {
|
|
|
|
selection->clear_points();
|
|
|
|
cnote->region_view().unique_select (cnote);
|
|
|
|
/* we won't get the release, so store the selection change now */
|
|
|
|
begin_reversible_selection_op (X_("Button 3 Note Selection"));
|
|
|
|
commit_reversible_selection_op ();
|
|
|
|
}
|
2015-10-31 14:22:55 -04:00
|
|
|
}
|
2019-04-08 13:53:33 -04:00
|
|
|
break;
|
2015-10-31 14:22:55 -04:00
|
|
|
|
2019-04-08 13:53:33 -04:00
|
|
|
default:
|
|
|
|
break;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2015-01-10 12:07:31 -05:00
|
|
|
|
|
|
|
if ((!press) && _mouse_changed_selection) {
|
2015-03-25 08:31:23 -04:00
|
|
|
begin_reversible_selection_op (X_("Button Selection"));
|
2015-01-10 12:07:31 -05:00
|
|
|
commit_reversible_selection_op ();
|
|
|
|
_mouse_changed_selection = false;
|
|
|
|
}
|
2006-06-13 03:27:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2009-08-04 14:21:09 -04:00
|
|
|
Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type)
|
2006-06-13 03:27:52 -04:00
|
|
|
{
|
2009-08-04 14:21:09 -04:00
|
|
|
/* single mouse clicks on any of these item types operate
|
2019-04-08 15:37:02 -04:00
|
|
|
* independent of mouse mode, mostly because they are
|
|
|
|
* not on the main track canvas or because we want
|
|
|
|
* them to be modeless.
|
|
|
|
*/
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-12-08 23:00:00 -05:00
|
|
|
NoteBase* note = NULL;
|
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
switch (item_type) {
|
|
|
|
case PlayheadCursorItem:
|
2021-01-05 15:58:28 -05:00
|
|
|
_drags->set (new CursorDrag (this, *_playhead_cursor, true), event);
|
2009-08-04 14:21:09 -04:00
|
|
|
return true;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
case MarkerItem:
|
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::ModifierMask(Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) {
|
|
|
|
hide_marker (item, event);
|
2008-09-10 11:03:30 -04:00
|
|
|
} else {
|
2021-05-24 14:28:19 -04:00
|
|
|
ArdourMarker* marker = static_cast<ArdourMarker*> (item->get_data ("marker"));
|
|
|
|
if (marker->type() == ArdourMarker::RegionCue) {
|
|
|
|
_drags->set (new RegionMarkerDrag (this, marker->region_view(), item), event);
|
|
|
|
} else {
|
|
|
|
_drags->set (new MarkerDrag (this, item), event);
|
|
|
|
}
|
2008-09-10 11:03:30 -04:00
|
|
|
}
|
2006-06-13 03:27:52 -04:00
|
|
|
return true;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
case TempoMarkerItem:
|
2011-09-08 13:49:36 -04:00
|
|
|
{
|
2017-02-25 13:07:51 -05:00
|
|
|
if (ArdourKeyboard::indicates_constraint (event->button.state)) {
|
2021-01-26 21:30:56 -05:00
|
|
|
_drags->set (new TempoEndDrag (this, item), event);
|
2017-02-25 13:07:51 -05:00
|
|
|
} else {
|
2021-01-26 21:30:56 -05:00
|
|
|
_drags->set (new TempoMarkerDrag (this, item, ArdourKeyboard::indicates_copy (event->button.state)), event);
|
2017-02-25 13:07:51 -05:00
|
|
|
}
|
|
|
|
|
2014-01-27 10:09:58 -05:00
|
|
|
return true;
|
2011-09-08 13:49:36 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
case MeterMarkerItem:
|
2011-09-08 13:49:36 -04:00
|
|
|
{
|
2014-01-27 10:09:58 -05:00
|
|
|
_drags->set (
|
|
|
|
new MeterMarkerDrag (
|
|
|
|
this,
|
|
|
|
item,
|
2016-08-13 11:50:51 -04:00
|
|
|
ArdourKeyboard::indicates_copy (event->button.state)
|
2014-01-27 10:09:58 -05:00
|
|
|
),
|
|
|
|
event
|
|
|
|
);
|
|
|
|
return true;
|
2011-09-08 13:49:36 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2013-03-12 17:00:09 -04:00
|
|
|
case VideoBarItem:
|
|
|
|
_drags->set (new VideoTimeLineDrag (this, item), event);
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
case MarkerBarItem:
|
|
|
|
case TempoBarItem:
|
2016-05-07 13:03:12 -04:00
|
|
|
case TempoCurveItem:
|
2009-08-04 14:21:09 -04:00
|
|
|
case MeterBarItem:
|
2014-06-12 16:06:31 -04:00
|
|
|
case TimecodeRulerItem:
|
|
|
|
case SamplesRulerItem:
|
|
|
|
case MinsecRulerItem:
|
|
|
|
case BBTRulerItem:
|
2016-05-07 13:03:12 -04:00
|
|
|
if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)
|
2019-04-08 15:37:02 -04:00
|
|
|
&& !ArdourKeyboard::indicates_constraint (event->button.state)) {
|
2021-01-05 15:58:28 -05:00
|
|
|
_drags->set (new CursorDrag (this, *_playhead_cursor, false), event);
|
2017-02-26 10:26:08 -05:00
|
|
|
} else if (ArdourKeyboard::indicates_constraint (event->button.state)
|
2019-04-08 15:37:02 -04:00
|
|
|
&& Keyboard::modifier_state_contains (event->button.state, Keyboard::PrimaryModifier)) {
|
2020-11-19 11:03:28 -05:00
|
|
|
// _drags->set (new TempoTwistDrag (this, item), event);
|
2016-08-13 11:50:51 -04:00
|
|
|
} else if (ArdourKeyboard::indicates_constraint (event->button.state)) {
|
2016-05-07 13:03:12 -04:00
|
|
|
_drags->set (new BBTRulerDrag (this, item), event);
|
2009-08-04 14:21:09 -04:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
break;
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
case RangeMarkerBarItem:
|
2014-09-17 10:59:19 -04:00
|
|
|
if (Keyboard::modifier_state_contains (event->button.state, Keyboard::TertiaryModifier)) {
|
|
|
|
_drags->set (new RangeMarkerBarDrag (this, item, RangeMarkerBarDrag::CreateSkipMarker), event);
|
|
|
|
} else if (Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new RangeMarkerBarDrag (this, item, RangeMarkerBarDrag::CreateRangeMarker), event);
|
2014-09-17 10:59:19 -04:00
|
|
|
} else {
|
2021-01-05 15:58:28 -05:00
|
|
|
_drags->set (new CursorDrag (this, *_playhead_cursor, false), event);
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2009-08-04 14:21:09 -04:00
|
|
|
return true;
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
case CdMarkerBarItem:
|
|
|
|
if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
|
2021-01-05 15:58:28 -05:00
|
|
|
_drags->set (new CursorDrag (this, *_playhead_cursor, false), event);
|
2009-08-04 14:21:09 -04:00
|
|
|
} else {
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new RangeMarkerBarDrag (this, item, RangeMarkerBarDrag::CreateCDMarker), event);
|
2009-08-04 14:21:09 -04:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2022-01-04 17:22:13 -05:00
|
|
|
case CueMarkerBarItem:
|
|
|
|
if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
|
|
|
|
_drags->set (new CursorDrag (this, *_playhead_cursor, false), event);
|
|
|
|
} else {
|
2022-01-04 18:08:10 -05:00
|
|
|
/* no range dragging on this ruler/bar */
|
2022-01-04 17:22:13 -05:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
case TransportMarkerBarItem:
|
|
|
|
if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
|
2021-01-05 15:58:28 -05:00
|
|
|
_drags->set (new CursorDrag (this, *_playhead_cursor, false), event);
|
2009-08-04 14:21:09 -04:00
|
|
|
} else {
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new RangeMarkerBarDrag (this, item, RangeMarkerBarDrag::CreateTransportMarker), event);
|
2009-08-04 14:21:09 -04:00
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2009-08-04 14:21:09 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
default:
|
|
|
|
break;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-01-01 20:19:47 -05:00
|
|
|
if (_join_object_range_state == JOIN_OBJECT_RANGE_OBJECT) {
|
|
|
|
/* special case: allow trim of range selections in joined object mode;
|
2019-04-08 15:37:02 -04:00
|
|
|
* in theory eff should equal MouseRange in this case, but it doesn't
|
|
|
|
* because entering the range selection canvas item results in entered_regionview
|
|
|
|
* being set to 0, so update_join_object_range_location acts as if we aren't
|
|
|
|
* over a region.
|
|
|
|
*/
|
2010-01-01 20:36:19 -05:00
|
|
|
if (item_type == StartSelectionTrimItem) {
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new SelectionDrag (this, item, SelectionDrag::SelectionStartTrim), event);
|
2010-01-01 20:36:19 -05:00
|
|
|
} else if (item_type == EndSelectionTrimItem) {
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new SelectionDrag (this, item, SelectionDrag::SelectionEndTrim), event);
|
2010-01-01 20:19:47 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-01 17:11:15 -05:00
|
|
|
Editing::MouseMode eff = effective_mouse_mode ();
|
|
|
|
|
2010-01-24 21:24:44 -05:00
|
|
|
/* special case: allow drag of region fade in/out in object mode with join object/range enabled */
|
2015-10-04 14:51:05 -04:00
|
|
|
if (get_smart_mode()) {
|
2014-06-30 09:17:03 -04:00
|
|
|
switch (item_type) {
|
|
|
|
case FadeInHandleItem:
|
|
|
|
case FadeInTrimHandleItem:
|
|
|
|
case FadeOutHandleItem:
|
|
|
|
case FadeOutTrimHandleItem:
|
|
|
|
eff = MouseObject;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2010-01-24 21:24:44 -05:00
|
|
|
}
|
|
|
|
|
2010-01-01 17:11:15 -05:00
|
|
|
switch (eff) {
|
2009-11-18 08:24:43 -05:00
|
|
|
case MouseRange:
|
2009-08-28 12:06:08 -04:00
|
|
|
switch (item_type) {
|
2009-11-18 08:24:43 -05:00
|
|
|
case StartSelectionTrimItem:
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new SelectionDrag (this, item, SelectionDrag::SelectionStartTrim), event);
|
2009-11-18 08:24:43 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EndSelectionTrimItem:
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new SelectionDrag (this, item, SelectionDrag::SelectionEndTrim), event);
|
2009-11-18 08:24:43 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SelectionItem:
|
2012-12-13 14:39:36 -05:00
|
|
|
if (Keyboard::modifier_state_contains (event->button.state, Keyboard::ModifierMask(Keyboard::PrimaryModifier|Keyboard::SecondaryModifier))) {
|
2009-11-18 08:24:43 -05:00
|
|
|
start_selection_grab (item, event);
|
2013-04-04 00:32:52 -04:00
|
|
|
return true;
|
2010-03-16 16:16:13 -04:00
|
|
|
} else if (Keyboard::modifier_state_equals (event->button.state, Keyboard::SecondaryModifier)) {
|
2009-11-18 08:24:43 -05:00
|
|
|
/* grab selection for moving */
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new SelectionDrag (this, item, SelectionDrag::SelectionMove), event);
|
2009-11-18 08:24:43 -05:00
|
|
|
} else {
|
2019-04-08 15:37:02 -04:00
|
|
|
/* this was debated, but decided the more common action was to make a new selection */
|
2014-08-05 16:42:06 -04:00
|
|
|
_drags->set (new SelectionDrag (this, item, SelectionDrag::CreateSelection), event);
|
2009-09-08 17:45:44 -04:00
|
|
|
}
|
|
|
|
break;
|
2009-11-18 08:24:43 -05:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
case StreamItem:
|
2014-12-08 23:00:00 -05:00
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::RangeSelectModifier)) {
|
|
|
|
_drags->set (new SelectionDrag (this, item, SelectionDrag::SelectionExtend), event);
|
2010-11-25 15:37:39 -05:00
|
|
|
} else {
|
2014-12-08 23:00:00 -05:00
|
|
|
_drags->set (new SelectionDrag (this, item, SelectionDrag::CreateSelection), event);
|
2010-06-21 21:28:49 -04:00
|
|
|
}
|
2014-12-08 23:00:00 -05:00
|
|
|
return true;
|
2010-11-25 15:37:39 -05:00
|
|
|
break;
|
2010-05-29 07:28:27 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
case RegionViewNameHighlight:
|
2011-02-09 09:02:49 -05:00
|
|
|
if (!clicked_regionview->region()->locked()) {
|
2013-06-10 12:51:59 -04:00
|
|
|
_drags->set (new TrimDrag (this, item, clicked_regionview, selection->regions.by_layer()), event);
|
2010-11-25 15:37:39 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
2010-05-30 16:13:29 -04:00
|
|
|
|
2009-08-28 12:06:08 -04:00
|
|
|
default:
|
2014-12-08 23:00:00 -05:00
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::RangeSelectModifier)) {
|
|
|
|
_drags->set (new SelectionDrag (this, item, SelectionDrag::SelectionExtend), event);
|
|
|
|
} else {
|
|
|
|
_drags->set (new SelectionDrag (this, item, SelectionDrag::CreateSelection), event);
|
2010-11-25 15:37:39 -05:00
|
|
|
}
|
2009-08-28 12:06:08 -04:00
|
|
|
}
|
2009-11-18 08:24:43 -05:00
|
|
|
return true;
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-07-07 07:05:27 -04:00
|
|
|
case MouseCut:
|
|
|
|
switch (item_type) {
|
|
|
|
case RegionItem:
|
|
|
|
case FadeInHandleItem:
|
|
|
|
case FadeOutHandleItem:
|
|
|
|
case LeftFrameHandle:
|
|
|
|
case RightFrameHandle:
|
|
|
|
case FeatureLineItem:
|
|
|
|
case RegionViewNameHighlight:
|
|
|
|
case RegionViewName:
|
2014-07-08 20:28:27 -04:00
|
|
|
case StreamItem:
|
2014-07-08 21:36:05 -04:00
|
|
|
case AutomationTrackItem:
|
2014-12-20 01:11:28 -05:00
|
|
|
_drags->set (new RegionCutDrag (this, item, canvas_event_sample (event)), event, get_canvas_cursor());
|
2014-07-07 07:54:41 -04:00
|
|
|
return true;
|
2014-07-07 07:05:27 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2014-12-08 23:00:00 -05:00
|
|
|
case MouseContent:
|
2009-11-18 08:24:43 -05:00
|
|
|
switch (item_type) {
|
|
|
|
case NoteItem:
|
2014-03-07 11:22:49 -05:00
|
|
|
/* Existing note: allow trimming/motion */
|
2014-12-08 23:00:00 -05:00
|
|
|
if ((note = reinterpret_cast<NoteBase*> (item->get_data ("notebase")))) {
|
|
|
|
if (note->big_enough_to_trim() && note->mouse_near_ends()) {
|
2014-12-20 01:11:28 -05:00
|
|
|
_drags->set (new NoteResizeDrag (this, item), event, get_canvas_cursor());
|
2010-11-25 15:37:39 -05:00
|
|
|
} else {
|
|
|
|
_drags->set (new NoteDrag (this, item), event);
|
|
|
|
}
|
2014-12-08 23:00:00 -05:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
|
2015-06-20 15:27:45 -04:00
|
|
|
case GainLineItem:
|
|
|
|
_drags->set (new LineDrag (this, item), event);
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
|
2014-12-08 23:00:00 -05:00
|
|
|
case ControlPointItem:
|
|
|
|
_drags->set (new ControlPointDrag (this, item), event);
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
|
2015-06-16 10:45:04 -04:00
|
|
|
case AutomationLineItem:
|
|
|
|
_drags->set (new LineDrag (this, item), event);
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
|
2014-12-08 23:00:00 -05:00
|
|
|
case StreamItem:
|
2018-02-24 07:54:15 -05:00
|
|
|
/* in the past, we created a new midi region here, but perhaps that is best left to the Draw mode */
|
2009-11-18 08:24:43 -05:00
|
|
|
break;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2014-12-08 23:00:00 -05:00
|
|
|
case AutomationTrackItem:
|
|
|
|
/* rubberband drag to select automation points */
|
|
|
|
_drags->set (new EditorRubberbandSelectDrag (this, item), event);
|
2015-01-10 12:07:31 -05:00
|
|
|
return true;
|
2014-12-08 23:00:00 -05:00
|
|
|
break;
|
|
|
|
|
2015-01-13 23:53:28 -05:00
|
|
|
case RegionItem:
|
|
|
|
if (dynamic_cast<AutomationRegionView*>(clicked_regionview)) {
|
|
|
|
/* rubberband drag to select automation points */
|
|
|
|
_drags->set (new EditorRubberbandSelectDrag (this, item), event);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-11-18 08:24:43 -05:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2014-12-08 23:00:00 -05:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-12-08 23:00:00 -05:00
|
|
|
case MouseObject:
|
2009-11-18 08:24:43 -05:00
|
|
|
if (Keyboard::modifier_state_contains (event->button.state, Keyboard::ModifierMask(Keyboard::PrimaryModifier|Keyboard::SecondaryModifier)) &&
|
|
|
|
event->type == GDK_BUTTON_PRESS) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2011-11-16 15:11:33 -05:00
|
|
|
_drags->set (new EditorRubberbandSelectDrag (this, item), event);
|
2009-11-18 08:24:43 -05:00
|
|
|
|
|
|
|
} else if (event->type == GDK_BUTTON_PRESS) {
|
|
|
|
|
|
|
|
switch (item_type) {
|
|
|
|
case FadeInHandleItem:
|
|
|
|
{
|
2013-06-10 12:51:59 -04:00
|
|
|
_drags->set (new FadeInDrag (this, item, reinterpret_cast<RegionView*> (item->get_data("regionview")), selection->regions), event, _cursors->fade_in);
|
2009-11-18 08:24:43 -05:00
|
|
|
return true;
|
2009-08-04 14:21:09 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-11-18 08:24:43 -05:00
|
|
|
case FadeOutHandleItem:
|
|
|
|
{
|
2013-06-10 12:51:59 -04:00
|
|
|
_drags->set (new FadeOutDrag (this, item, reinterpret_cast<RegionView*> (item->get_data("regionview")), selection->regions), event, _cursors->fade_out);
|
2009-11-18 08:24:43 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2012-05-09 19:04:18 -04:00
|
|
|
case StartCrossFadeItem:
|
|
|
|
case EndCrossFadeItem:
|
2018-02-24 07:54:15 -05:00
|
|
|
/* we might allow user to grab inside the fade to trim a region with preserve_fade_anchor.
|
|
|
|
* For not this is not fully implemented */
|
|
|
|
#if 0
|
|
|
|
if (!clicked_regionview->region()->locked()) {
|
|
|
|
_drags->set (new TrimDrag (this, item, clicked_regionview, selection->regions.by_layer(), true), event);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
2012-05-09 19:04:18 -04:00
|
|
|
break;
|
|
|
|
|
2010-07-06 07:33:27 -04:00
|
|
|
case FeatureLineItem:
|
2011-06-01 13:00:29 -04:00
|
|
|
{
|
2010-07-06 07:33:27 -04:00
|
|
|
if (Keyboard::modifier_state_contains (event->button.state, Keyboard::TertiaryModifier)) {
|
|
|
|
remove_transient(item);
|
|
|
|
return true;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-07-06 07:33:27 -04:00
|
|
|
_drags->set (new FeatureLineDrag (this, item), event);
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
case RegionItem:
|
2010-08-04 11:41:55 -04:00
|
|
|
if (dynamic_cast<AutomationRegionView*> (clicked_regionview)) {
|
|
|
|
/* click on an automation region view; do nothing here and let the ARV's signal handler
|
|
|
|
sort it out.
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
}
|
2010-09-18 16:22:03 -04:00
|
|
|
|
2010-08-04 11:41:55 -04:00
|
|
|
/* click on a normal region view */
|
2021-06-04 11:22:44 -04:00
|
|
|
|
2021-06-15 11:06:39 -04:00
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, ArdourKeyboard::slip_contents_modifier ())) {
|
2021-06-15 11:13:38 -04:00
|
|
|
if (!clicked_regionview->region()->locked() && (Config->get_edit_mode() != Lock)) {
|
|
|
|
_drags->add (new RegionSlipContentsDrag (this, item, clicked_regionview, selection->regions.by_layer()));
|
|
|
|
}
|
2021-06-15 10:06:28 -04:00
|
|
|
} else if (ArdourKeyboard::indicates_copy (event->button.state)) {
|
2021-06-18 15:54:44 -04:00
|
|
|
add_region_drag (item, event, clicked_regionview, true);
|
2011-03-02 12:00:54 -05:00
|
|
|
} else if (Keyboard::the_keyboard().key_is_down (GDK_b)) {
|
2010-01-12 11:14:49 -05:00
|
|
|
add_region_brush_drag (item, event, clicked_regionview);
|
2009-11-18 08:24:43 -05:00
|
|
|
} else {
|
2021-06-04 11:22:44 -04:00
|
|
|
add_region_drag (item, event, clicked_regionview, false);
|
2009-11-18 08:24:43 -05:00
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2012-01-30 17:53:22 -05:00
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->start_grab (event);
|
2013-04-04 00:32:52 -04:00
|
|
|
return true;
|
2009-08-04 14:21:09 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-11-18 08:24:43 -05:00
|
|
|
case RegionViewNameHighlight:
|
2010-06-17 08:45:51 -04:00
|
|
|
case LeftFrameHandle:
|
2014-05-30 21:53:59 -04:00
|
|
|
case RightFrameHandle:
|
2011-02-09 09:02:49 -05:00
|
|
|
if (!clicked_regionview->region()->locked()) {
|
2013-06-10 12:51:59 -04:00
|
|
|
_drags->set (new TrimDrag (this, item, clicked_regionview, selection->regions.by_layer()), event);
|
2010-07-21 22:12:28 -04:00
|
|
|
return true;
|
|
|
|
}
|
2009-11-18 08:24:43 -05:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-05-30 21:53:59 -04:00
|
|
|
case FadeInTrimHandleItem:
|
|
|
|
case FadeOutTrimHandleItem:
|
|
|
|
if (!clicked_regionview->region()->locked()) {
|
|
|
|
_drags->set (new TrimDrag (this, item, clicked_regionview, selection->regions.by_layer(), true), event);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-11-18 08:24:43 -05:00
|
|
|
case RegionViewName:
|
|
|
|
{
|
|
|
|
/* rename happens on edit clicks */
|
2014-06-08 11:23:00 -04:00
|
|
|
if (clicked_regionview->get_name_highlight()) {
|
|
|
|
_drags->set (new TrimDrag (this, clicked_regionview->get_name_highlight(), clicked_regionview, selection->regions.by_layer()), event);
|
|
|
|
return true;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
case ControlPointItem:
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new ControlPointDrag (this, item), event);
|
2009-11-18 08:24:43 -05:00
|
|
|
return true;
|
2009-08-04 14:21:09 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
case AutomationLineItem:
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new LineDrag (this, item), event);
|
2009-11-18 08:24:43 -05:00
|
|
|
return true;
|
2009-08-04 14:21:09 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-11-18 08:24:43 -05:00
|
|
|
case StreamItem:
|
2014-12-08 23:00:00 -05:00
|
|
|
_drags->set (new EditorRubberbandSelectDrag (this, item), event);
|
|
|
|
return true;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-11-18 08:24:43 -05:00
|
|
|
case AutomationTrackItem:
|
2011-07-13 08:34:11 -04:00
|
|
|
{
|
|
|
|
TimeAxisView* parent = clicked_axisview->get_parent ();
|
2011-09-07 09:45:52 -04:00
|
|
|
AutomationTimeAxisView* atv = dynamic_cast<AutomationTimeAxisView*> (clicked_axisview);
|
|
|
|
assert (atv);
|
|
|
|
if (parent && dynamic_cast<MidiTimeAxisView*> (parent) && atv->show_regions ()) {
|
2012-06-08 20:36:21 -04:00
|
|
|
|
|
|
|
RouteTimeAxisView* p = dynamic_cast<RouteTimeAxisView*> (parent);
|
|
|
|
assert (p);
|
|
|
|
boost::shared_ptr<Playlist> pl = p->track()->playlist ();
|
|
|
|
if (pl->n_regions() == 0) {
|
|
|
|
/* Parent has no regions; create one so that we have somewhere to put automation */
|
|
|
|
_drags->set (new RegionCreateDrag (this, item, parent), event);
|
|
|
|
} else {
|
|
|
|
/* See if there's a region before the click that we can extend, and extend it if so */
|
2020-10-19 14:37:54 -04:00
|
|
|
timepos_t const t (canvas_event_sample (event));
|
2012-06-08 20:36:21 -04:00
|
|
|
boost::shared_ptr<Region> prev = pl->find_next_region (t, End, -1);
|
|
|
|
if (!prev) {
|
|
|
|
_drags->set (new RegionCreateDrag (this, item, parent), event);
|
|
|
|
} else {
|
2020-11-30 12:59:17 -05:00
|
|
|
prev->set_length (prev->position ().distance (t));
|
2012-06-08 20:36:21 -04:00
|
|
|
}
|
|
|
|
}
|
2011-07-13 08:34:11 -04:00
|
|
|
} else {
|
|
|
|
/* rubberband drag to select automation points */
|
2011-11-16 15:11:33 -05:00
|
|
|
_drags->set (new EditorRubberbandSelectDrag (this, item), event);
|
2011-07-13 08:34:11 -04:00
|
|
|
}
|
2009-11-18 08:24:43 -05:00
|
|
|
break;
|
2011-07-13 08:34:11 -04:00
|
|
|
}
|
2009-11-18 08:24:43 -05:00
|
|
|
|
2010-01-01 17:11:15 -05:00
|
|
|
case SelectionItem:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-11-18 08:24:43 -05:00
|
|
|
case MarkerBarItem:
|
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2009-11-18 08:24:43 -05:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
|
2014-12-07 19:53:46 -05:00
|
|
|
case MouseDraw:
|
2009-11-18 08:24:43 -05:00
|
|
|
switch (item_type) {
|
|
|
|
case GainLineItem:
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new LineDrag (this, item), event);
|
2009-11-18 08:24:43 -05:00
|
|
|
return true;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-11-18 08:24:43 -05:00
|
|
|
case ControlPointItem:
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new ControlPointDrag (this, item), event);
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2012-03-22 12:41:23 -04:00
|
|
|
case SelectionItem:
|
2019-03-29 10:57:07 -04:00
|
|
|
{
|
|
|
|
if (selection->time.empty ()) {
|
|
|
|
/* nothing to do */
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
pair<TimeAxisView*, int> tvp = trackview_by_y_position (event->button.y, false);
|
|
|
|
if (!tvp.first) {
|
|
|
|
/* clicked outside of a track */
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
/* handle automation lanes first */
|
|
|
|
AutomationTimeAxisView* atv = dynamic_cast<AutomationTimeAxisView*> (tvp.first);
|
|
|
|
if (atv) {
|
|
|
|
/* smart "join" mode: drag automation */
|
|
|
|
_drags->set (new AutomationRangeDrag (this, atv, selection->time), event, _cursors->up_down);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (dynamic_cast<AutomationRegionView*>(clicked_regionview)) {
|
|
|
|
/* MIDI CC or similar -- TODO handle multiple? */
|
|
|
|
list<RegionView*> rvl;
|
|
|
|
rvl.push_back (clicked_regionview);
|
2019-03-29 20:19:47 -04:00
|
|
|
_drags->set (new AutomationRangeDrag (this, rvl, selection->time,
|
|
|
|
clicked_regionview->get_time_axis_view().y_position(),
|
|
|
|
clicked_regionview->get_time_axis_view().current_height()),
|
|
|
|
event, _cursors->up_down);
|
2019-03-29 10:57:07 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-03-29 20:19:47 -04:00
|
|
|
/* shift+drag: only apply to clicked_regionview (if any) */
|
|
|
|
if (Keyboard::modifier_state_contains (event->button.state, Keyboard::TertiaryModifier)) {
|
2019-03-29 10:57:07 -04:00
|
|
|
if (dynamic_cast<AudioRegionView*>(clicked_regionview) == 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
list<RegionView*> rvl;
|
|
|
|
rvl.push_back (clicked_regionview);
|
2019-03-29 20:19:47 -04:00
|
|
|
// TODO: handle layer_display() == Stacked
|
|
|
|
_drags->set (new AutomationRangeDrag (this, rvl, selection->time,
|
|
|
|
clicked_regionview->get_time_axis_view().y_position(),
|
|
|
|
clicked_regionview->get_time_axis_view().current_height()),
|
|
|
|
event, _cursors->up_down);
|
2019-03-29 10:57:07 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* collect all audio regions-views in the given range selection */
|
2019-03-27 18:23:33 -04:00
|
|
|
list<RegionView*> rvl;
|
|
|
|
TrackViewList ts = selection->tracks.filter_to_unique_playlists ();
|
|
|
|
for (TrackViewList::iterator i = ts.begin(); i != ts.end(); ++i) {
|
|
|
|
RouteTimeAxisView* tatv;
|
|
|
|
boost::shared_ptr<Playlist> playlist;
|
|
|
|
if ((tatv = dynamic_cast<RouteTimeAxisView*> (*i)) == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ((playlist = (*i)->playlist()) == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
2019-03-29 10:57:07 -04:00
|
|
|
if (boost::dynamic_pointer_cast<AudioPlaylist> (playlist) == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
2020-09-26 11:14:59 -04:00
|
|
|
for (list<TimelineRange>::const_iterator j = selection->time.begin(); j != selection->time.end(); ++j) {
|
2020-10-19 14:37:54 -04:00
|
|
|
boost::shared_ptr<RegionList> rl = playlist->regions_touched (j->start(), j->end());
|
2019-03-27 18:23:33 -04:00
|
|
|
for (RegionList::iterator ir = rl->begin(); ir != rl->end(); ++ir) {
|
|
|
|
RegionView* rv;
|
|
|
|
if ((rv = tatv->view()->find_view (*ir)) != 0) {
|
|
|
|
rvl.push_back (rv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-03-29 10:57:07 -04:00
|
|
|
/* region-gain drag */
|
|
|
|
if (!rvl.empty ()) {
|
2019-03-29 20:19:47 -04:00
|
|
|
double y_pos = tvp.first->y_position();
|
|
|
|
double height = tvp.first->current_height();
|
|
|
|
StreamView* cv = tvp.first->view ();
|
|
|
|
if (cv->layer_display() == Stacked && cv->layers() > 1) {
|
|
|
|
height /= cv->layers();
|
|
|
|
double yy = event->button.y - _trackview_group->canvas_origin().y;
|
|
|
|
y_pos += floor ((yy - y_pos) / height) * height;
|
|
|
|
}
|
|
|
|
_drags->set (new AutomationRangeDrag (this, rvl, selection->time, y_pos, height),
|
|
|
|
event, _cursors->up_down);
|
2014-08-05 16:42:06 -04:00
|
|
|
}
|
2019-03-29 10:57:07 -04:00
|
|
|
return true;
|
|
|
|
break;
|
2012-03-22 12:41:23 -04:00
|
|
|
}
|
|
|
|
|
2009-11-18 08:24:43 -05:00
|
|
|
case AutomationLineItem:
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new LineDrag (this, item), event);
|
2009-11-18 08:24:43 -05:00
|
|
|
break;
|
2014-12-07 19:53:46 -05:00
|
|
|
|
|
|
|
case NoteItem:
|
2014-12-08 23:00:00 -05:00
|
|
|
if ((note = reinterpret_cast<NoteBase*>(item->get_data ("notebase")))) {
|
|
|
|
if (note->big_enough_to_trim() && note->mouse_near_ends()) {
|
|
|
|
/* Note is big and pointer is near the end, trim */
|
2014-12-20 01:11:28 -05:00
|
|
|
_drags->set (new NoteResizeDrag (this, item), event, get_canvas_cursor());
|
2014-12-07 19:53:46 -05:00
|
|
|
} else {
|
2014-12-08 23:00:00 -05:00
|
|
|
/* Drag note */
|
2014-12-07 19:53:46 -05:00
|
|
|
_drags->set (new NoteDrag (this, item), event);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2014-12-08 23:00:00 -05:00
|
|
|
return true;
|
2014-12-07 19:53:46 -05:00
|
|
|
|
|
|
|
case StreamItem:
|
2014-12-08 23:00:00 -05:00
|
|
|
if (dynamic_cast<MidiTimeAxisView*> (clicked_axisview)) {
|
|
|
|
_drags->set (new RegionCreateDrag (this, item, clicked_axisview), event);
|
2014-12-07 19:53:46 -05:00
|
|
|
}
|
2014-12-08 23:00:00 -05:00
|
|
|
return true;
|
2014-12-07 19:53:46 -05:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2009-11-18 08:24:43 -05:00
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseTimeFX:
|
2014-12-08 23:00:00 -05:00
|
|
|
if (item_type == NoteItem) {
|
|
|
|
/* resize-drag notes */
|
|
|
|
if ((note = reinterpret_cast<NoteBase*>(item->get_data ("notebase")))) {
|
|
|
|
if (note->big_enough_to_trim()) {
|
2014-12-20 01:11:28 -05:00
|
|
|
_drags->set (new NoteResizeDrag (this, item), event, get_canvas_cursor());
|
2014-12-08 23:00:00 -05:00
|
|
|
}
|
2014-03-07 11:22:49 -05:00
|
|
|
}
|
2009-11-18 08:24:43 -05:00
|
|
|
return true;
|
2012-05-29 16:29:47 -04:00
|
|
|
} else if (clicked_regionview) {
|
|
|
|
/* do time-FX */
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new TimeFXDrag (this, item, clicked_regionview, selection->regions.by_layer()), event);
|
2009-11-18 08:24:43 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseAudition:
|
2014-12-20 01:11:28 -05:00
|
|
|
_drags->set (new ScrubDrag (this, item), event, _cursors->transparent);
|
2009-11-18 08:24:43 -05:00
|
|
|
scrub_reversals = 0;
|
|
|
|
scrub_reverse_distance = 0;
|
|
|
|
last_scrub_x = event->button.x;
|
|
|
|
scrubbing_direction = 0;
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2009-08-04 14:21:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Editor::button_press_handler_2 (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type)
|
|
|
|
{
|
2010-01-01 17:11:15 -05:00
|
|
|
Editing::MouseMode const eff = effective_mouse_mode ();
|
|
|
|
switch (eff) {
|
2009-08-04 14:21:09 -04:00
|
|
|
case MouseObject:
|
|
|
|
switch (item_type) {
|
|
|
|
case RegionItem:
|
2016-08-13 11:50:51 -04:00
|
|
|
if (ArdourKeyboard::indicates_copy (event->button.state)) {
|
2021-06-04 11:22:44 -04:00
|
|
|
add_region_drag (item, event, clicked_regionview, true);
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2021-06-04 11:22:44 -04:00
|
|
|
add_region_drag (item, event, clicked_regionview, false);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->start_grab (event);
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
2009-08-04 14:21:09 -04:00
|
|
|
case ControlPointItem:
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new ControlPointDrag (this, item), event);
|
2009-08-04 14:21:09 -04:00
|
|
|
return true;
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
switch (item_type) {
|
|
|
|
case RegionViewNameHighlight:
|
2014-05-30 21:53:59 -04:00
|
|
|
_drags->set (new TrimDrag (this, item, clicked_regionview, selection->regions.by_layer()), event);
|
|
|
|
return true;
|
|
|
|
break;
|
2011-02-09 09:02:49 -05:00
|
|
|
|
2014-05-30 21:53:59 -04:00
|
|
|
case LeftFrameHandle:
|
|
|
|
case RightFrameHandle:
|
2014-12-08 23:00:00 -05:00
|
|
|
_drags->set (new TrimDrag (this, item, clicked_regionview, selection->regions.by_layer()), event);
|
2009-08-04 14:21:09 -04:00
|
|
|
return true;
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
case RegionViewName:
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new TrimDrag (this, clicked_regionview->get_name_highlight(), clicked_regionview, selection->regions.by_layer()), event);
|
2009-08-04 14:21:09 -04:00
|
|
|
return true;
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
break;
|
|
|
|
|
2012-01-19 10:23:51 -05:00
|
|
|
case MouseDraw:
|
|
|
|
return false;
|
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
case MouseRange:
|
|
|
|
/* relax till release */
|
|
|
|
return true;
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
return false;
|
|
|
|
}
|
2015-10-04 14:51:05 -04:00
|
|
|
|
2012-01-19 10:23:51 -05:00
|
|
|
bool
|
|
|
|
Editor::button_press_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type)
|
|
|
|
{
|
2013-06-21 15:18:54 -04:00
|
|
|
if (event->type == GDK_2BUTTON_PRESS) {
|
|
|
|
_drags->mark_double_click ();
|
2014-01-27 10:09:58 -05:00
|
|
|
gdk_pointer_ungrab (GDK_CURRENT_TIME);
|
|
|
|
return true;
|
2013-06-21 15:18:54 -04:00
|
|
|
}
|
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
if (event->type != GDK_BUTTON_PRESS) {
|
|
|
|
return false;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
_track_canvas->grab_focus();
|
2009-08-04 14:21:09 -04:00
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
if (_session && _session->actively_recording()) {
|
2009-08-04 14:21:09 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-10 12:41:51 -04:00
|
|
|
button_selection (item, event, item_type);
|
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
if (!_drags->active () &&
|
2009-08-04 14:21:09 -04:00
|
|
|
(Keyboard::is_delete_event (&event->button) ||
|
|
|
|
Keyboard::is_context_menu_event (&event->button) ||
|
|
|
|
Keyboard::is_edit_event (&event->button))) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
/* handled by button release */
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-01-10 04:53:10 -05:00
|
|
|
/* not rolling, effectively in range mode, follow edits enabled (likely
|
|
|
|
* to start range drag), not in a fade handle (since that means we are
|
|
|
|
* not starting a range drag): locate the PH here
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ((item_type != FadeInHandleItem) &&
|
|
|
|
(item_type != FadeOutHandleItem) &&
|
2018-02-24 07:54:15 -05:00
|
|
|
!_drags->active () &&
|
|
|
|
_session &&
|
|
|
|
!_session->transport_rolling() &&
|
|
|
|
(effective_mouse_mode() == MouseRange) &&
|
|
|
|
UIConfiguration::instance().get_follow_edits() &&
|
2017-01-10 04:53:10 -05:00
|
|
|
!_session->config.get_external_sync()) {
|
|
|
|
|
2020-10-19 14:37:54 -04:00
|
|
|
timepos_t where (canvas_event_sample (event));
|
2017-01-26 08:41:17 -05:00
|
|
|
snap_to (where);
|
2020-10-19 14:37:54 -04:00
|
|
|
_session->request_locate (where.samples(), MustStop);
|
2012-11-20 14:43:43 -05:00
|
|
|
}
|
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
switch (event->button.button) {
|
|
|
|
case 1:
|
|
|
|
return button_press_handler_1 (item, event, item_type);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
return button_press_handler_2 (item, event, item_type);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2017-07-01 12:42:24 -04:00
|
|
|
return button_press_dispatch (&event->button);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
|
|
|
|
return false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2011-03-03 22:10:48 -05:00
|
|
|
bool
|
|
|
|
Editor::button_press_dispatch (GdkEventButton* ev)
|
|
|
|
{
|
2019-04-08 13:53:33 -04:00
|
|
|
/* this function is intended only for buttons 4 and above. */
|
2011-03-03 22:10:48 -05:00
|
|
|
|
2019-04-08 13:53:33 -04:00
|
|
|
Gtkmm2ext::MouseButton b (ev->state, ev->button);
|
|
|
|
return button_bindings->activate (b, Gtkmm2ext::Bindings::Press);
|
2011-03-03 22:10:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Editor::button_release_dispatch (GdkEventButton* ev)
|
|
|
|
{
|
2019-04-08 13:53:33 -04:00
|
|
|
/* this function is intended only for buttons 4 and above. */
|
2011-03-03 22:10:48 -05:00
|
|
|
|
2019-04-08 13:53:33 -04:00
|
|
|
Gtkmm2ext::MouseButton b (ev->state, ev->button);
|
|
|
|
return button_bindings->activate (b, Gtkmm2ext::Bindings::Release);
|
2011-03-03 22:10:48 -05:00
|
|
|
}
|
|
|
|
|
2005-11-22 00:10:12 -05:00
|
|
|
bool
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2021-01-18 22:13:37 -05:00
|
|
|
timepos_t where (canvas_event_time (event));
|
2009-07-09 13:58:13 -04:00
|
|
|
AutomationTimeAxisView* atv = 0;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-12-20 01:11:28 -05:00
|
|
|
_press_cursor_ctx.reset();
|
2010-09-22 11:21:06 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
/* no action if we're recording */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
if (_session && _session->actively_recording()) {
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
bool were_dragging = false;
|
2015-01-26 16:37:53 -05:00
|
|
|
|
|
|
|
if (!Keyboard::is_context_menu_event (&event->button)) {
|
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
/* see if we're finishing a drag */
|
2015-10-04 14:51:05 -04:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
if (_drags->active ()) {
|
|
|
|
bool const r = _drags->end_grab (event);
|
|
|
|
if (r) {
|
|
|
|
/* grab dragged, so do nothing else */
|
|
|
|
return true;
|
|
|
|
}
|
2015-10-04 14:51:05 -04:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
were_dragging = true;
|
|
|
|
}
|
2015-01-26 16:37:53 -05:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
update_region_layering_order_editor ();
|
|
|
|
}
|
2010-08-25 15:28:33 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
/* edit events get handled here */
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
if (!_drags->active () && Keyboard::is_edit_event (&event->button)) {
|
2005-09-25 14:42:24 -04:00
|
|
|
switch (item_type) {
|
|
|
|
case RegionItem:
|
2010-11-03 18:19:29 -04:00
|
|
|
show_region_properties ();
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
2014-01-27 10:09:58 -05:00
|
|
|
case TempoMarkerItem: {
|
2015-07-23 07:23:47 -04:00
|
|
|
ArdourMarker* marker;
|
2014-01-27 10:09:58 -05:00
|
|
|
TempoMarker* tempo_marker;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2015-07-23 07:23:47 -04:00
|
|
|
if ((marker = reinterpret_cast<ArdourMarker *> (item->get_data ("marker"))) == 0) {
|
2014-01-27 10:09:58 -05:00
|
|
|
fatal << _("programming error: tempo marker canvas item has no marker object pointer!") << endmsg;
|
2014-11-14 04:47:43 -05:00
|
|
|
abort(); /*NOTREACHED*/
|
2014-01-27 10:09:58 -05:00
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-01-27 10:09:58 -05:00
|
|
|
if ((tempo_marker = dynamic_cast<TempoMarker*> (marker)) == 0) {
|
|
|
|
fatal << _("programming error: marker for tempo is not a tempo marker!") << endmsg;
|
2014-11-14 04:47:43 -05:00
|
|
|
abort(); /*NOTREACHED*/
|
2014-01-27 10:09:58 -05:00
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-01-27 10:09:58 -05:00
|
|
|
edit_tempo_marker (*tempo_marker);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
2014-01-27 10:09:58 -05:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-01-27 10:09:58 -05:00
|
|
|
case MeterMarkerItem: {
|
2015-07-23 07:23:47 -04:00
|
|
|
ArdourMarker* marker;
|
2014-01-27 10:09:58 -05:00
|
|
|
MeterMarker* meter_marker;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2015-07-23 07:23:47 -04:00
|
|
|
if ((marker = reinterpret_cast<ArdourMarker *> (item->get_data ("marker"))) == 0) {
|
2014-01-27 10:09:58 -05:00
|
|
|
fatal << _("programming error: tempo marker canvas item has no marker object pointer!") << endmsg;
|
2014-11-14 04:47:43 -05:00
|
|
|
abort(); /*NOTREACHED*/
|
2014-01-27 10:09:58 -05:00
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-01-27 10:09:58 -05:00
|
|
|
if ((meter_marker = dynamic_cast<MeterMarker*> (marker)) == 0) {
|
|
|
|
fatal << _("programming error: marker for meter is not a meter marker!") << endmsg;
|
2014-11-14 04:47:43 -05:00
|
|
|
abort(); /*NOTREACHED*/
|
2014-01-27 10:09:58 -05:00
|
|
|
}
|
|
|
|
edit_meter_marker (*meter_marker);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
2014-01-27 10:09:58 -05:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
case RegionViewName:
|
2005-09-25 14:42:24 -04:00
|
|
|
if (clicked_regionview->name_active()) {
|
|
|
|
return mouse_rename_region (item, event);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2008-12-18 12:46:28 -05:00
|
|
|
case ControlPointItem:
|
|
|
|
edit_control_point (item);
|
|
|
|
break;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* context menu events get handled here */
|
|
|
|
if (Keyboard::is_context_menu_event (&event->button)) {
|
|
|
|
|
2011-12-26 18:18:24 -05:00
|
|
|
context_click_event = *event;
|
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
if (!_drags->active ()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* no matter which button pops up the context menu, tell the menu
|
|
|
|
widget to use button 1 to drive menu selection.
|
|
|
|
*/
|
|
|
|
|
|
|
|
switch (item_type) {
|
|
|
|
case FadeInItem:
|
|
|
|
case FadeInHandleItem:
|
2014-05-30 21:53:59 -04:00
|
|
|
case FadeInTrimHandleItem:
|
2012-05-10 15:14:11 -04:00
|
|
|
case StartCrossFadeItem:
|
2012-05-11 17:30:36 -04:00
|
|
|
popup_xfade_in_context_menu (1, event->button.time, item, item_type);
|
2012-05-10 15:14:11 -04:00
|
|
|
break;
|
|
|
|
|
2014-05-29 01:49:26 -04:00
|
|
|
case FadeOutItem:
|
|
|
|
case FadeOutHandleItem:
|
2014-05-30 21:53:59 -04:00
|
|
|
case FadeOutTrimHandleItem:
|
2012-05-10 15:14:11 -04:00
|
|
|
case EndCrossFadeItem:
|
2012-05-11 17:30:36 -04:00
|
|
|
popup_xfade_out_context_menu (1, event->button.time, item, item_type);
|
2012-05-10 15:14:11 -04:00
|
|
|
break;
|
|
|
|
|
2014-10-28 11:43:45 -04:00
|
|
|
case LeftFrameHandle:
|
|
|
|
case RightFrameHandle:
|
|
|
|
break;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case StreamItem:
|
2010-11-14 11:49:59 -05:00
|
|
|
popup_track_context_menu (1, event->button.time, item_type, false);
|
2007-10-11 18:07:47 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case RegionItem:
|
2006-07-23 08:03:19 -04:00
|
|
|
case RegionViewNameHighlight:
|
|
|
|
case RegionViewName:
|
2010-11-14 11:49:59 -05:00
|
|
|
popup_track_context_menu (1, event->button.time, item_type, false);
|
2007-10-11 18:07:47 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case SelectionItem:
|
2010-11-14 11:49:59 -05:00
|
|
|
popup_track_context_menu (1, event->button.time, item_type, true);
|
2007-10-11 18:07:47 -04:00
|
|
|
break;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case AutomationTrackItem:
|
2010-11-14 11:49:59 -05:00
|
|
|
popup_track_context_menu (1, event->button.time, item_type, false);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
case MarkerBarItem:
|
|
|
|
case RangeMarkerBarItem:
|
2008-01-10 16:20:59 -05:00
|
|
|
case TransportMarkerBarItem:
|
|
|
|
case CdMarkerBarItem:
|
2005-09-25 14:42:24 -04:00
|
|
|
case TempoBarItem:
|
2016-05-07 13:03:12 -04:00
|
|
|
case TempoCurveItem:
|
2005-09-25 14:42:24 -04:00
|
|
|
case MeterBarItem:
|
2013-03-12 17:00:09 -04:00
|
|
|
case VideoBarItem:
|
2014-06-12 16:06:31 -04:00
|
|
|
case TimecodeRulerItem:
|
|
|
|
case SamplesRulerItem:
|
|
|
|
case MinsecRulerItem:
|
|
|
|
case BBTRulerItem:
|
2021-01-19 15:21:04 -05:00
|
|
|
popup_ruler_menu (where, item_type);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
2022-01-05 15:27:39 -05:00
|
|
|
case CueMarkerBarItem:
|
|
|
|
snap_to (where, Temporal::RoundNearest, SnapToGrid_Scaled, true);
|
|
|
|
std::cerr << "cue marker will be at " << where << " beats = " << where.beats() << std::endl;
|
|
|
|
popup_ruler_menu (where, item_type);
|
|
|
|
break;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case MarkerItem:
|
|
|
|
marker_context_menu (&event->button, item);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TempoMarkerItem:
|
2010-05-02 19:14:43 -04:00
|
|
|
tempo_or_meter_marker_context_menu (&event->button, item);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case MeterMarkerItem:
|
2010-05-02 19:14:43 -04:00
|
|
|
tempo_or_meter_marker_context_menu (&event->button, item);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-12 18:45:50 -05:00
|
|
|
case CrossfadeViewItem:
|
2010-11-14 11:49:59 -05:00
|
|
|
popup_track_context_menu (1, event->button.time, item_type, false);
|
2008-01-12 18:45:50 -05:00
|
|
|
break;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2011-07-17 16:10:31 -04:00
|
|
|
case ControlPointItem:
|
|
|
|
popup_control_point_context_menu (item, event);
|
|
|
|
break;
|
|
|
|
|
2014-12-25 15:32:10 -05:00
|
|
|
case NoteItem:
|
|
|
|
if (internal_editing()) {
|
|
|
|
popup_note_context_menu (item, event);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* delete events get handled here */
|
|
|
|
|
2010-01-01 17:11:15 -05:00
|
|
|
Editing::MouseMode const eff = effective_mouse_mode ();
|
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
if (!_drags->active () && Keyboard::is_delete_event (&event->button)) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
switch (item_type) {
|
|
|
|
case TempoMarkerItem:
|
|
|
|
remove_tempo_marker (item);
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case MeterMarkerItem:
|
|
|
|
remove_meter_marker (item);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MarkerItem:
|
2021-05-18 18:50:55 -04:00
|
|
|
remove_marker (*item);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RegionItem:
|
2010-01-01 17:11:15 -05:00
|
|
|
if (eff == MouseObject) {
|
2005-09-25 14:42:24 -04:00
|
|
|
remove_clicked_region ();
|
|
|
|
}
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-06-30 14:41:50 -04:00
|
|
|
case ControlPointItem:
|
2011-07-17 16:10:31 -04:00
|
|
|
remove_control_point (item);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
2010-05-24 21:39:45 -04:00
|
|
|
case NoteItem:
|
|
|
|
remove_midi_note (item, event);
|
|
|
|
break;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (event->button.button) {
|
|
|
|
case 1:
|
|
|
|
|
|
|
|
switch (item_type) {
|
|
|
|
/* see comments in button_press_handler */
|
|
|
|
case PlayheadCursorItem:
|
|
|
|
case MarkerItem:
|
|
|
|
case GainLineItem:
|
2007-06-30 14:41:50 -04:00
|
|
|
case AutomationLineItem:
|
2005-09-25 14:42:24 -04:00
|
|
|
case StartSelectionTrimItem:
|
|
|
|
case EndSelectionTrimItem:
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
case MarkerBarItem:
|
2008-12-12 09:43:24 -05:00
|
|
|
if (!_dragging_playhead) {
|
2020-10-19 14:37:54 -04:00
|
|
|
snap_to_with_modifier (where, event, Temporal::RoundNearest, SnapToGrid_Scaled);
|
|
|
|
mouse_add_new_marker (where);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
case CdMarkerBarItem:
|
2008-12-12 09:43:24 -05:00
|
|
|
if (!_dragging_playhead) {
|
2018-02-24 07:54:15 -05:00
|
|
|
/* if we get here then a dragged range wasn't done */
|
2020-10-19 14:37:54 -04:00
|
|
|
snap_to_with_modifier (where, event, Temporal::RoundNearest, SnapToGrid_Scaled);
|
2022-01-04 17:22:13 -05:00
|
|
|
mouse_add_new_marker (where, Location::IsCDMarker);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case CueMarkerBarItem:
|
|
|
|
if (!_dragging_playhead) {
|
|
|
|
/* if we get here then a dragged range wasn't done */
|
2022-01-20 15:44:29 -05:00
|
|
|
snap_to_with_modifier (where, event, Temporal::RoundNearest, SnapToGrid_Scaled); //TODO: force to-measure?
|
2022-01-04 17:22:13 -05:00
|
|
|
mouse_add_new_marker (where, Location::IsCueMarker);
|
2008-01-10 16:20:59 -05:00
|
|
|
}
|
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
case TempoBarItem:
|
2016-05-07 13:03:12 -04:00
|
|
|
case TempoCurveItem:
|
2017-06-16 15:06:42 -04:00
|
|
|
if (!_dragging_playhead && Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
|
2009-08-24 16:26:34 -04:00
|
|
|
snap_to_with_modifier (where, event);
|
2020-10-19 14:37:54 -04:00
|
|
|
mouse_add_new_tempo_event (where);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case MeterBarItem:
|
2017-06-16 15:06:42 -04:00
|
|
|
if (!_dragging_playhead && Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
|
2020-10-19 14:37:54 -04:00
|
|
|
mouse_add_new_meter_event (timepos_t (pixel_to_sample (event->button.x)));
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
2014-06-12 16:06:31 -04:00
|
|
|
case TimecodeRulerItem:
|
|
|
|
case SamplesRulerItem:
|
|
|
|
case MinsecRulerItem:
|
|
|
|
case BBTRulerItem:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-01-01 17:11:15 -05:00
|
|
|
switch (eff) {
|
2014-12-07 00:26:00 -05:00
|
|
|
case MouseDraw:
|
2005-09-25 14:42:24 -04:00
|
|
|
switch (item_type) {
|
|
|
|
case RegionItem:
|
2010-05-26 21:08:37 -04:00
|
|
|
{
|
2008-12-12 09:43:24 -05:00
|
|
|
/* check that we didn't drag before releasing, since
|
|
|
|
its really annoying to create new control
|
|
|
|
points when doing this.
|
|
|
|
*/
|
2010-05-26 21:08:37 -04:00
|
|
|
AudioRegionView* arv = dynamic_cast<AudioRegionView*> (clicked_regionview);
|
2012-03-09 15:47:40 -05:00
|
|
|
if (!were_dragging && arv) {
|
2014-02-19 12:54:00 -05:00
|
|
|
bool with_guard_points = Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier);
|
2014-02-20 14:01:40 -05:00
|
|
|
arv->add_gain_point_event (item, event, with_guard_points);
|
2008-12-12 09:43:24 -05:00
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
2010-05-26 21:08:37 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-02-19 23:37:46 -05:00
|
|
|
case AutomationTrackItem: {
|
2014-02-19 12:54:00 -05:00
|
|
|
bool with_guard_points = Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier);
|
2014-12-07 19:53:46 -05:00
|
|
|
atv = dynamic_cast<AutomationTimeAxisView*>(clicked_axisview);
|
|
|
|
if (atv) {
|
2020-10-19 14:37:54 -04:00
|
|
|
atv->add_automation_event (event, where, event->button.y, with_guard_points);
|
2014-12-07 19:53:46 -05:00
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
2014-02-19 23:37:46 -05:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case MouseAudition:
|
2007-11-07 20:40:25 -05:00
|
|
|
if (scrubbing_direction == 0) {
|
2007-10-11 18:07:47 -04:00
|
|
|
/* no drag, just a click */
|
|
|
|
switch (item_type) {
|
|
|
|
case RegionItem:
|
2008-01-10 16:20:59 -05:00
|
|
|
play_selected_region ();
|
2007-10-11 18:07:47 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2015-03-17 12:01:50 -04:00
|
|
|
} else if (_session) {
|
2007-10-11 18:07:47 -04:00
|
|
|
/* make sure we stop */
|
2021-04-16 01:20:59 -04:00
|
|
|
_session->request_stop ();
|
2009-10-23 16:17:20 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
default:
|
|
|
|
break;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
/* do any (de)selection operations that should occur on button release */
|
2015-01-10 12:07:31 -05:00
|
|
|
button_selection (item, event, item_type);
|
2014-12-22 08:30:23 -05:00
|
|
|
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 2:
|
2010-01-01 17:11:15 -05:00
|
|
|
switch (eff) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
case MouseObject:
|
|
|
|
switch (item_type) {
|
|
|
|
case RegionItem:
|
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::TertiaryModifier)) {
|
|
|
|
raise_region ();
|
|
|
|
} else if (Keyboard::modifier_state_equals (event->button.state, Keyboard::ModifierMask (Keyboard::TertiaryModifier|Keyboard::SecondaryModifier))) {
|
|
|
|
lower_region ();
|
|
|
|
} else {
|
2018-02-24 07:54:15 -05:00
|
|
|
/* Button2 click is unused */
|
2008-01-10 16:20:59 -05:00
|
|
|
}
|
|
|
|
return true;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2012-01-19 10:23:51 -05:00
|
|
|
case MouseDraw:
|
2022-04-15 11:24:13 -04:00
|
|
|
if (item_type == NoteItem) {
|
|
|
|
remove_midi_note (item, event);
|
|
|
|
}
|
2012-01-19 10:23:51 -05:00
|
|
|
return true;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2022-04-15 11:24:13 -04:00
|
|
|
case MouseContent:
|
|
|
|
if (item_type == NoteItem) {
|
|
|
|
remove_midi_note (item, event);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case MouseRange:
|
|
|
|
// x_style_paste (where, 1.0);
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case 3:
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2011-03-08 07:45:23 -05:00
|
|
|
|
2006-03-07 21:50:53 -05:00
|
|
|
return false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-11-22 00:10:12 -05:00
|
|
|
bool
|
2010-01-01 17:11:15 -05:00
|
|
|
Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
ControlPoint* cp;
|
2015-07-23 07:23:47 -04:00
|
|
|
ArdourMarker * marker;
|
2016-08-19 14:36:52 -04:00
|
|
|
MeterMarker* m_marker = 0;
|
|
|
|
TempoMarker* t_marker = 0;
|
2005-09-25 14:42:24 -04:00
|
|
|
double fraction;
|
2017-07-01 12:42:24 -04:00
|
|
|
bool ret = true;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-06-18 10:24:59 -04:00
|
|
|
/* by the time we reach here, entered_regionview and entered trackview
|
2015-10-04 14:51:05 -04:00
|
|
|
* will have already been set as appropriate. Things are done this
|
2014-06-18 10:24:59 -04:00
|
|
|
* way because this method isn't passed a pointer to a variable type of
|
|
|
|
* thing that is entered (which may or may not be canvas item).
|
|
|
|
* (e.g. the actual entered regionview)
|
|
|
|
*/
|
|
|
|
|
2014-12-20 01:11:28 -05:00
|
|
|
choose_canvas_cursor_on_entry (item_type);
|
2014-06-18 10:24:59 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
switch (item_type) {
|
2007-06-30 14:41:50 -04:00
|
|
|
case ControlPointItem:
|
2015-10-03 14:29:45 -04:00
|
|
|
if (mouse_mode == MouseDraw || mouse_mode == MouseObject || mouse_mode == MouseContent) {
|
2007-03-18 02:07:08 -04:00
|
|
|
cp = static_cast<ControlPoint*>(item->get_data ("control_point"));
|
2013-12-31 11:55:30 -05:00
|
|
|
cp->show ();
|
2007-03-18 02:07:08 -04:00
|
|
|
|
2007-07-06 23:19:04 -04:00
|
|
|
fraction = 1.0 - (cp->get_y() / cp->line().height());
|
2007-03-18 02:07:08 -04:00
|
|
|
|
2014-06-26 15:07:29 -04:00
|
|
|
_verbose_cursor->set (cp->line().get_verbose_cursor_string (fraction));
|
2011-05-02 09:38:16 -04:00
|
|
|
_verbose_cursor->show ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
break;
|
2008-01-10 16:20:59 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case GainLineItem:
|
2014-12-07 19:53:46 -05:00
|
|
|
if (mouse_mode == MouseDraw) {
|
2005-11-27 17:35:04 -05:00
|
|
|
ArdourCanvas::Line *line = dynamic_cast<ArdourCanvas::Line *> (item);
|
2013-04-04 00:32:52 -04:00
|
|
|
if (line) {
|
2015-01-02 09:44:54 -05:00
|
|
|
line->set_outline_color (UIConfiguration::instance().color ("entered gain line"));
|
2013-04-04 00:32:52 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-06-30 14:41:50 -04:00
|
|
|
case AutomationLineItem:
|
2014-12-07 19:53:46 -05:00
|
|
|
if (mouse_mode == MouseDraw || mouse_mode == MouseObject) {
|
2012-01-30 17:53:22 -05:00
|
|
|
ArdourCanvas::Line *line = dynamic_cast<ArdourCanvas::Line *> (item);
|
|
|
|
if (line) {
|
2015-01-02 09:44:54 -05:00
|
|
|
line->set_outline_color (UIConfiguration::instance().color ("entered automation line"));
|
2007-03-18 02:07:08 -04:00
|
|
|
}
|
2010-06-17 08:45:51 -04:00
|
|
|
}
|
2014-05-30 21:53:59 -04:00
|
|
|
break;
|
2010-06-17 08:45:51 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case AutomationTrackItem:
|
2014-06-18 10:24:59 -04:00
|
|
|
AutomationTimeAxisView* atv;
|
|
|
|
if ((atv = static_cast<AutomationTimeAxisView*>(item->get_data ("trackview"))) != 0) {
|
|
|
|
clear_entered_track = false;
|
|
|
|
set_entered_track (atv);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MarkerItem:
|
2015-07-23 07:23:47 -04:00
|
|
|
if ((marker = static_cast<ArdourMarker *> (item->get_data ("marker"))) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
}
|
2007-11-12 17:23:01 -05:00
|
|
|
entered_marker = marker;
|
2021-05-18 16:46:25 -04:00
|
|
|
marker->set_entered (true);
|
2016-08-19 14:36:52 -04:00
|
|
|
break;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case MeterMarkerItem:
|
2016-08-19 14:36:52 -04:00
|
|
|
if ((m_marker = static_cast<MeterMarker *> (item->get_data ("marker"))) == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
entered_marker = m_marker;
|
2020-11-16 13:19:22 -05:00
|
|
|
if (m_marker->meter().map().time_domain() == BeatTime) {
|
2016-08-19 15:41:12 -04:00
|
|
|
m_marker->set_color_rgba (UIConfiguration::instance().color ("meter marker"));
|
|
|
|
} else {
|
|
|
|
m_marker->set_color_rgba (UIConfiguration::instance().color ("meter marker music"));
|
|
|
|
}
|
2016-08-19 14:36:52 -04:00
|
|
|
break;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case TempoMarkerItem:
|
2016-08-19 14:36:52 -04:00
|
|
|
if ((t_marker = static_cast<TempoMarker *> (item->get_data ("marker"))) == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
entered_marker = t_marker;
|
2020-11-16 13:19:22 -05:00
|
|
|
if (t_marker->tempo().map().time_domain() == BeatTime) {
|
2016-08-19 15:41:12 -04:00
|
|
|
t_marker->set_color_rgba (UIConfiguration::instance().color ("tempo marker"));
|
|
|
|
} else {
|
|
|
|
t_marker->set_color_rgba (UIConfiguration::instance().color ("tempo marker music"));
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
2010-06-17 18:09:07 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case FadeInHandleItem:
|
2014-05-31 08:04:41 -04:00
|
|
|
case FadeInTrimHandleItem:
|
2014-12-08 23:00:00 -05:00
|
|
|
if (mouse_mode == MouseObject) {
|
2014-05-31 08:04:41 -04:00
|
|
|
ArdourCanvas::Rectangle *rect = dynamic_cast<ArdourCanvas::Rectangle *> (item);
|
|
|
|
if (rect) {
|
|
|
|
RegionView* rv = static_cast<RegionView*>(item->get_data ("regionview"));
|
|
|
|
rect->set_fill_color (rv->get_fill_color());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case FadeOutHandleItem:
|
2014-05-31 08:04:41 -04:00
|
|
|
case FadeOutTrimHandleItem:
|
2014-12-08 23:00:00 -05:00
|
|
|
if (mouse_mode == MouseObject) {
|
2014-05-31 08:04:41 -04:00
|
|
|
ArdourCanvas::Rectangle *rect = dynamic_cast<ArdourCanvas::Rectangle *> (item);
|
|
|
|
if (rect) {
|
|
|
|
RegionView* rv = static_cast<RegionView*>(item->get_data ("regionview"));
|
|
|
|
rect->set_fill_color (rv->get_fill_color ());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-07-06 07:33:27 -04:00
|
|
|
case FeatureLineItem:
|
2013-04-04 00:32:52 -04:00
|
|
|
{
|
|
|
|
ArdourCanvas::Line *line = dynamic_cast<ArdourCanvas::Line *> (item);
|
|
|
|
line->set_outline_color (0xFF0000FF);
|
|
|
|
}
|
|
|
|
break;
|
2014-03-11 22:38:48 -04:00
|
|
|
|
2010-08-18 14:06:31 -04:00
|
|
|
case SelectionItem:
|
|
|
|
break;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2015-06-01 14:12:39 -04:00
|
|
|
case WaveItem:
|
|
|
|
{
|
|
|
|
if (entered_regionview) {
|
|
|
|
entered_regionview->entered();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-06-18 10:24:59 -04:00
|
|
|
/* third pass to handle entered track status in a comprehensible way.
|
2005-09-25 14:42:24 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
switch (item_type) {
|
|
|
|
case GainLineItem:
|
2007-06-30 14:41:50 -04:00
|
|
|
case AutomationLineItem:
|
|
|
|
case ControlPointItem:
|
2005-09-25 14:42:24 -04:00
|
|
|
/* these do not affect the current entered track state */
|
|
|
|
clear_entered_track = false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AutomationTrackItem:
|
|
|
|
/* handled above already */
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2014-06-18 10:24:59 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-05-30 16:13:29 -04:00
|
|
|
return ret;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-11-22 00:10:12 -05:00
|
|
|
bool
|
2011-09-30 13:55:14 -04:00
|
|
|
Editor::leave_handler (ArdourCanvas::Item* item, GdkEvent*, ItemType item_type)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
AutomationLine* al;
|
2015-07-23 07:23:47 -04:00
|
|
|
ArdourMarker *marker;
|
2016-08-19 14:36:52 -04:00
|
|
|
TempoMarker *t_marker;
|
|
|
|
MeterMarker *m_marker;
|
2010-11-25 15:37:39 -05:00
|
|
|
bool ret = true;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2014-12-27 12:26:55 -05:00
|
|
|
if (!_enter_stack.empty()) {
|
|
|
|
_enter_stack.pop_back();
|
|
|
|
}
|
2014-11-14 02:28:15 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
switch (item_type) {
|
2007-06-30 14:41:50 -04:00
|
|
|
case ControlPointItem:
|
2015-10-04 14:51:05 -04:00
|
|
|
_verbose_cursor->hide ();
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case GainLineItem:
|
2007-06-30 14:41:50 -04:00
|
|
|
case AutomationLineItem:
|
2005-11-28 17:36:26 -05:00
|
|
|
al = reinterpret_cast<AutomationLine*> (item->get_data ("line"));
|
2005-11-27 17:35:04 -05:00
|
|
|
{
|
|
|
|
ArdourCanvas::Line *line = dynamic_cast<ArdourCanvas::Line *> (item);
|
2013-04-04 00:32:52 -04:00
|
|
|
if (line) {
|
|
|
|
line->set_outline_color (al->get_line_color());
|
|
|
|
}
|
2005-11-27 17:35:04 -05:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case MarkerItem:
|
2015-07-23 07:23:47 -04:00
|
|
|
if ((marker = static_cast<ArdourMarker *> (item->get_data ("marker"))) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
}
|
2007-11-12 17:23:01 -05:00
|
|
|
entered_marker = 0;
|
2021-05-18 16:46:25 -04:00
|
|
|
marker->set_entered (false);
|
2016-08-19 14:36:52 -04:00
|
|
|
break;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case MeterMarkerItem:
|
2016-08-19 14:36:52 -04:00
|
|
|
if ((m_marker = static_cast<MeterMarker *> (item->get_data ("marker"))) == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
entered_marker = 0;
|
2020-11-16 13:19:22 -05:00
|
|
|
if (m_marker->meter().map().time_domain() == BeatTime) {
|
2016-08-19 15:41:12 -04:00
|
|
|
m_marker->set_color_rgba (UIConfiguration::instance().color ("meter marker music"));
|
|
|
|
} else {
|
|
|
|
m_marker->set_color_rgba (UIConfiguration::instance().color ("meter marker"));
|
|
|
|
}
|
2016-08-19 14:36:52 -04:00
|
|
|
break;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case TempoMarkerItem:
|
2016-08-19 14:36:52 -04:00
|
|
|
if ((t_marker = static_cast<TempoMarker *> (item->get_data ("marker"))) == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
entered_marker = 0;
|
2020-11-16 13:19:22 -05:00
|
|
|
if (t_marker->tempo().map().time_domain() == BeatTime) {
|
2016-08-19 15:41:12 -04:00
|
|
|
t_marker->set_color_rgba (UIConfiguration::instance().color ("tempo marker music"));
|
|
|
|
} else {
|
|
|
|
t_marker->set_color_rgba (UIConfiguration::instance().color ("tempo marker"));
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
2014-05-30 22:51:02 -04:00
|
|
|
case FadeInTrimHandleItem:
|
|
|
|
case FadeOutTrimHandleItem:
|
2005-09-25 14:42:24 -04:00
|
|
|
case FadeInHandleItem:
|
|
|
|
case FadeOutHandleItem:
|
2014-06-18 10:24:59 -04:00
|
|
|
{
|
|
|
|
ArdourCanvas::Rectangle *rect = dynamic_cast<ArdourCanvas::Rectangle *> (item);
|
|
|
|
if (rect) {
|
2015-01-02 09:44:54 -05:00
|
|
|
rect->set_fill_color (UIConfiguration::instance().color ("inactive fade handle"));
|
2005-11-27 17:35:04 -05:00
|
|
|
}
|
2014-06-18 10:24:59 -04:00
|
|
|
}
|
|
|
|
break;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
case AutomationTrackItem:
|
|
|
|
break;
|
2014-06-18 10:24:59 -04:00
|
|
|
|
2010-07-06 07:33:27 -04:00
|
|
|
case FeatureLineItem:
|
2014-06-18 10:24:59 -04:00
|
|
|
{
|
|
|
|
ArdourCanvas::Line *line = dynamic_cast<ArdourCanvas::Line *> (item);
|
2015-01-02 09:44:54 -05:00
|
|
|
line->set_outline_color (UIConfiguration::instance().color ("zero line"));
|
2014-06-18 10:24:59 -04:00
|
|
|
}
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-05-30 16:13:29 -04:00
|
|
|
return ret;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
void
|
2017-09-18 12:39:17 -04:00
|
|
|
Editor::scrub (samplepos_t sample, double current_x)
|
2008-04-11 10:06:50 -04:00
|
|
|
{
|
|
|
|
double delta;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
if (scrubbing_direction == 0) {
|
|
|
|
/* first move */
|
2020-01-17 17:26:01 -05:00
|
|
|
_session->request_locate (sample, MustStop);
|
2021-06-18 13:22:59 -04:00
|
|
|
_session->request_transport_speed (0.1);
|
2008-04-11 10:06:50 -04:00
|
|
|
scrubbing_direction = 1;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
} else {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
if (last_scrub_x > current_x) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
/* pointer moved to the left */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
if (scrubbing_direction > 0) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
/* we reversed direction to go backwards */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
scrub_reversals++;
|
2010-01-12 11:14:49 -05:00
|
|
|
scrub_reverse_distance += (int) (last_scrub_x - current_x);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
} else {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
/* still moving to the left (backwards) */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
scrub_reversals = 0;
|
|
|
|
scrub_reverse_distance = 0;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
delta = 0.01 * (last_scrub_x - current_x);
|
2021-06-18 13:22:59 -04:00
|
|
|
_session->request_transport_speed_nonzero (_session->actual_speed() - delta);
|
2008-04-11 10:06:50 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
} else {
|
|
|
|
/* pointer moved to the right */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
if (scrubbing_direction < 0) {
|
|
|
|
/* we reversed direction to go forward */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
scrub_reversals++;
|
2010-01-12 11:14:49 -05:00
|
|
|
scrub_reverse_distance += (int) (current_x - last_scrub_x);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
} else {
|
|
|
|
/* still moving to the right */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
scrub_reversals = 0;
|
|
|
|
scrub_reverse_distance = 0;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
delta = 0.01 * (current_x - last_scrub_x);
|
2021-06-18 13:22:59 -04:00
|
|
|
_session->request_transport_speed_nonzero (_session->actual_speed() + delta);
|
2008-04-11 10:06:50 -04:00
|
|
|
}
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
/* if there have been more than 2 opposite motion moves detected, or one that moves
|
|
|
|
back more than 10 pixels, reverse direction
|
|
|
|
*/
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
if (scrub_reversals >= 2 || scrub_reverse_distance > 10) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
if (scrubbing_direction > 0) {
|
|
|
|
/* was forwards, go backwards */
|
2021-06-18 13:22:59 -04:00
|
|
|
_session->request_transport_speed (-0.1);
|
2008-04-11 10:06:50 -04:00
|
|
|
scrubbing_direction = -1;
|
|
|
|
} else {
|
|
|
|
/* was backwards, go forwards */
|
2021-06-18 13:22:59 -04:00
|
|
|
_session->request_transport_speed (0.1);
|
2008-04-11 10:06:50 -04:00
|
|
|
scrubbing_direction = 1;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
scrub_reverse_distance = 0;
|
|
|
|
scrub_reversals = 0;
|
|
|
|
}
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
last_scrub_x = current_x;
|
2008-04-11 10:06:50 -04:00
|
|
|
}
|
|
|
|
|
2005-11-22 00:10:12 -05:00
|
|
|
bool
|
2009-07-21 11:55:17 -04:00
|
|
|
Editor::motion_handler (ArdourCanvas::Item* /*item*/, GdkEvent* event, bool from_autoscroll)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2010-08-18 14:06:31 -04:00
|
|
|
_last_motion_y = event->motion.y;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
if (event->motion.is_hint) {
|
|
|
|
gint x, y;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
/* We call this so that MOTION_NOTIFY events continue to be
|
2019-04-08 15:37:02 -04:00
|
|
|
* delivered to the canvas. We need to do this because we set
|
|
|
|
* Gdk::POINTER_MOTION_HINT_MASK on the canvas. This reduces
|
|
|
|
* the density of the events, at the expense of a round-trip
|
|
|
|
* to the server. Given that this will mostly occur on cases
|
|
|
|
* where DISPLAY = :0.0, and given the cost of what the motion
|
|
|
|
* event might do, its a good tradeoff.
|
|
|
|
*/
|
2008-09-10 17:27:39 -04:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
_track_canvas->get_pointer (x, y);
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2008-09-10 11:03:30 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (current_stepping_trackview) {
|
|
|
|
/* don't keep the persistent stepped trackview if the mouse moves */
|
2009-07-09 13:58:13 -04:00
|
|
|
current_stepping_trackview = 0;
|
2005-09-25 14:42:24 -04:00
|
|
|
step_timeout.disconnect ();
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
if (_session && _session->actively_recording()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
/* Sorry. no dragging stuff around while we record */
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-06-18 10:24:59 -04:00
|
|
|
update_join_object_range_location (event->motion.y);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
if (_drags->active ()) {
|
2018-08-10 11:43:38 -04:00
|
|
|
//drags change the snapped_cursor location, because we are snapping the thing being dragged, not the actual mouse cursor
|
2019-04-13 11:48:27 -04:00
|
|
|
return _drags->motion_handler (event, from_autoscroll);
|
2018-08-10 11:43:38 -04:00
|
|
|
} else {
|
|
|
|
bool ignored;
|
2020-12-19 10:44:16 -05:00
|
|
|
bool peaks_visible = false;
|
2021-01-03 19:39:29 -05:00
|
|
|
samplepos_t where;
|
2020-10-19 14:37:54 -04:00
|
|
|
if (mouse_sample (where, ignored)) {
|
2020-12-19 10:44:16 -05:00
|
|
|
|
|
|
|
/* display peaks */
|
|
|
|
if (mouse_mode == MouseContent || ArdourKeyboard::indicates_snap (event->motion.state)) {
|
|
|
|
AudioRegionView* arv = dynamic_cast<AudioRegionView*>(entered_regionview);
|
|
|
|
if (arv) {
|
2020-10-19 14:37:54 -04:00
|
|
|
_region_peak_cursor->set (arv, where, samples_per_pixel);
|
2020-12-19 10:44:16 -05:00
|
|
|
peaks_visible = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the snapped_cursor shows where an operation (like Split) is going to occur */
|
2020-10-19 14:37:54 -04:00
|
|
|
timepos_t t (where);
|
|
|
|
snap_to_with_modifier (t, event);
|
2021-01-03 19:39:29 -05:00
|
|
|
set_snapped_cursor_position (t);
|
2018-08-10 11:43:38 -04:00
|
|
|
}
|
2020-12-19 10:44:16 -05:00
|
|
|
|
|
|
|
if (!peaks_visible) {
|
|
|
|
_region_peak_cursor->hide ();
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2014-06-26 15:07:29 -04:00
|
|
|
return false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2011-07-17 16:10:31 -04:00
|
|
|
bool
|
|
|
|
Editor::can_remove_control_point (ArdourCanvas::Item* item)
|
2008-04-11 10:06:50 -04:00
|
|
|
{
|
2009-05-30 14:25:59 -04:00
|
|
|
ControlPoint* control_point;
|
2008-04-11 10:06:50 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if ((control_point = reinterpret_cast<ControlPoint *> (item->get_data ("control_point"))) == 0) {
|
|
|
|
fatal << _("programming error: control point canvas item has no control point object pointer!") << endmsg;
|
2014-11-14 04:47:43 -05:00
|
|
|
abort(); /*NOTREACHED*/
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
2008-04-11 10:06:50 -04:00
|
|
|
|
2011-07-17 16:10:31 -04:00
|
|
|
AutomationLine& line = control_point->line ();
|
|
|
|
if (dynamic_cast<AudioRegionGainLine*> (&line)) {
|
|
|
|
/* we shouldn't remove the first or last gain point in region gain lines */
|
|
|
|
if (line.is_last_point(*control_point) || line.is_first_point(*control_point)) {
|
|
|
|
return false;
|
|
|
|
}
|
2008-04-11 10:06:50 -04:00
|
|
|
}
|
|
|
|
|
2011-07-17 16:10:31 -04:00
|
|
|
return true;
|
2008-04-11 10:06:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-07-17 16:10:31 -04:00
|
|
|
Editor::remove_control_point (ArdourCanvas::Item* item)
|
2008-04-11 10:06:50 -04:00
|
|
|
{
|
2011-07-17 16:10:31 -04:00
|
|
|
if (!can_remove_control_point (item)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
ControlPoint* control_point;
|
2008-04-11 10:06:50 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if ((control_point = reinterpret_cast<ControlPoint *> (item->get_data ("control_point"))) == 0) {
|
|
|
|
fatal << _("programming error: control point canvas item has no control point object pointer!") << endmsg;
|
2014-11-14 04:47:43 -05:00
|
|
|
abort(); /*NOTREACHED*/
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
control_point->line().remove_point (*control_point);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
void
|
2009-05-30 14:25:59 -04:00
|
|
|
Editor::edit_control_point (ArdourCanvas::Item* item)
|
2006-06-13 03:27:52 -04:00
|
|
|
{
|
2009-05-30 14:25:59 -04:00
|
|
|
ControlPoint* p = reinterpret_cast<ControlPoint *> (item->get_data ("control_point"));
|
2006-06-13 03:27:52 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (p == 0) {
|
|
|
|
fatal << _("programming error: control point canvas item has no control point object pointer!") << endmsg;
|
2014-11-14 04:47:43 -05:00
|
|
|
abort(); /*NOTREACHED*/
|
2006-06-13 03:27:52 -04:00
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
ControlPointDialog d (p);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (d.run () != RESPONSE_ACCEPT) {
|
|
|
|
return;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
p->line().modify_point_y (*p, d.get_y_fraction ());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2010-08-13 22:00:50 -04:00
|
|
|
void
|
2014-12-25 15:32:10 -05:00
|
|
|
Editor::edit_notes (MidiRegionView* mrv)
|
2010-08-13 22:00:50 -04:00
|
|
|
{
|
2013-05-02 15:16:56 -04:00
|
|
|
MidiRegionView::Selection const & s = mrv->selection();
|
|
|
|
|
2012-06-08 21:51:34 -04:00
|
|
|
if (s.empty ()) {
|
|
|
|
return;
|
|
|
|
}
|
2014-06-18 10:24:59 -04:00
|
|
|
|
2014-12-25 15:32:10 -05:00
|
|
|
EditNoteDialog* d = new EditNoteDialog (mrv, s);
|
2014-06-18 10:24:59 -04:00
|
|
|
d->show_all ();
|
2010-08-13 22:00:50 -04:00
|
|
|
|
2014-06-18 10:24:59 -04:00
|
|
|
d->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &Editor::note_edit_done), d));
|
2010-08-13 22:00:50 -04:00
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2013-05-02 18:13:35 -04:00
|
|
|
void
|
|
|
|
Editor::note_edit_done (int r, EditNoteDialog* d)
|
|
|
|
{
|
2014-06-18 10:24:59 -04:00
|
|
|
d->done (r);
|
|
|
|
delete d;
|
2010-08-13 22:00:50 -04:00
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2016-12-12 21:02:57 -05:00
|
|
|
void
|
|
|
|
Editor::edit_region (RegionView* rv)
|
|
|
|
{
|
|
|
|
if (UIConfiguration::instance().get_use_double_click_to_zoom_to_selection()) {
|
2016-12-13 02:10:30 -05:00
|
|
|
temporal_zoom_selection (Both);
|
2016-12-12 21:02:57 -05:00
|
|
|
} else {
|
|
|
|
rv->show_region_editor ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-12 09:43:24 -05:00
|
|
|
void
|
2009-05-30 14:25:59 -04:00
|
|
|
Editor::visible_order_range (int* low, int* high) const
|
2008-12-12 09:43:24 -05:00
|
|
|
{
|
2009-05-30 14:25:59 -04:00
|
|
|
*low = TimeAxisView::max_order ();
|
|
|
|
*high = 0;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
for (TrackViewList::const_iterator i = track_views.begin(); i != track_views.end(); ++i) {
|
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*i);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2016-06-02 08:42:58 -04:00
|
|
|
if (rtv && !rtv->hidden()) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (*high < rtv->order()) {
|
|
|
|
*high = rtv->order ();
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (*low > rtv->order()) {
|
|
|
|
*low = rtv->order ();
|
|
|
|
}
|
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2009-05-30 14:25:59 -04:00
|
|
|
Editor::region_view_item_click (AudioRegionView& rv, GdkEventButton* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2009-05-30 14:25:59 -04:00
|
|
|
/* Either add to or set the set the region selection, unless
|
2019-04-08 15:37:02 -04:00
|
|
|
* this is an alignment click (control used)
|
|
|
|
*/
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (Keyboard::modifier_state_contains (event->state, Keyboard::PrimaryModifier)) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2020-10-19 14:37:54 -04:00
|
|
|
timepos_t where = get_preferred_edit_position();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2021-12-11 09:51:31 -05:00
|
|
|
if (where.is_negative()) {
|
2020-10-19 14:37:54 -04:00
|
|
|
return;
|
|
|
|
}
|
2008-09-10 11:03:30 -04:00
|
|
|
|
2020-10-19 14:37:54 -04:00
|
|
|
if (Keyboard::modifier_state_equals (event->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::SecondaryModifier))) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2020-10-19 14:37:54 -04:00
|
|
|
align_region (rv.region(), SyncPoint, where);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2020-10-19 14:37:54 -04:00
|
|
|
} else if (Keyboard::modifier_state_equals (event->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2020-10-19 14:37:54 -04:00
|
|
|
align_region (rv.region(), End, where);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2020-10-19 14:37:54 -04:00
|
|
|
} else {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2020-10-19 14:37:54 -04:00
|
|
|
align_region (rv.region(), Start, where);
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
void
|
|
|
|
Editor::collect_new_region_view (RegionView* rv)
|
|
|
|
{
|
|
|
|
latest_regionviews.push_back (rv);
|
|
|
|
}
|
2009-04-20 17:02:46 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
void
|
|
|
|
Editor::collect_and_select_new_region_view (RegionView* rv)
|
|
|
|
{
|
2014-06-18 10:24:59 -04:00
|
|
|
selection->add(rv);
|
2009-05-30 14:25:59 -04:00
|
|
|
latest_regionviews.push_back (rv);
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
void
|
|
|
|
Editor::cancel_selection ()
|
|
|
|
{
|
|
|
|
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
|
|
|
|
(*i)->hide_selection ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
selection->clear ();
|
|
|
|
clicked_selection = 0;
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2012-11-20 14:43:43 -05:00
|
|
|
void
|
|
|
|
Editor::cancel_time_selection ()
|
|
|
|
{
|
2014-06-18 10:24:59 -04:00
|
|
|
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
|
2012-11-20 14:43:43 -05:00
|
|
|
(*i)->hide_selection ();
|
|
|
|
}
|
|
|
|
selection->time.clear ();
|
|
|
|
clicked_selection = 0;
|
2015-10-05 10:17:49 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
void
|
2020-10-15 01:09:22 -04:00
|
|
|
Editor::point_trim (GdkEvent* event, timepos_t const & new_bound)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
RegionView* rv = clicked_regionview;
|
2009-04-20 17:02:46 -04:00
|
|
|
|
Fix typos in gtk2_ardour/ directory
Found via `codespell -q 3 -S *.po,./share/patchfiles,./libs -L ba,buss,busses,doubleclick,hsi,ontop,ro,seh,siz,sur,te,trough,ue`
2022-01-26 12:35:38 -05:00
|
|
|
/* Choose action dependent on which button was pressed */
|
2005-09-25 14:42:24 -04:00
|
|
|
switch (event->button.button) {
|
|
|
|
case 1:
|
2010-09-14 20:33:33 -04:00
|
|
|
begin_reversible_command (_("start point trim"));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
if (selection->selected (rv)) {
|
2006-07-23 08:03:19 -04:00
|
|
|
for (list<RegionView*>::const_iterator i = selection->regions.by_layer().begin();
|
|
|
|
i != selection->regions.by_layer().end(); ++i)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-08-29 17:21:48 -04:00
|
|
|
if (!(*i)->region()->locked()) {
|
2010-08-25 13:32:08 -04:00
|
|
|
(*i)->region()->clear_changes ();
|
2011-05-30 09:54:44 -04:00
|
|
|
(*i)->region()->trim_front (new_bound);
|
2010-03-02 13:05:26 -05:00
|
|
|
_session->add_command(new StatefulDiffCommand ((*i)->region()));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2006-08-29 17:21:48 -04:00
|
|
|
if (!rv->region()->locked()) {
|
2010-08-25 13:32:08 -04:00
|
|
|
rv->region()->clear_changes ();
|
2011-05-30 09:54:44 -04:00
|
|
|
rv->region()->trim_front (new_bound);
|
2010-03-02 13:05:26 -05:00
|
|
|
_session->add_command(new StatefulDiffCommand (rv->region()));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
commit_reversible_command();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
case 2:
|
2015-10-30 08:43:09 -04:00
|
|
|
begin_reversible_command (_("end point trim"));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
if (selection->selected (rv)) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
for (list<RegionView*>::const_iterator i = selection->regions.by_layer().begin(); i != selection->regions.by_layer().end(); ++i)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-08-29 17:21:48 -04:00
|
|
|
if (!(*i)->region()->locked()) {
|
2010-08-25 13:32:08 -04:00
|
|
|
(*i)->region()->clear_changes();
|
2011-05-30 09:54:44 -04:00
|
|
|
(*i)->region()->trim_end (new_bound);
|
2010-03-02 13:05:26 -05:00
|
|
|
_session->add_command(new StatefulDiffCommand ((*i)->region()));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
} else {
|
2006-06-13 03:27:52 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (!rv->region()->locked()) {
|
2010-08-25 13:32:08 -04:00
|
|
|
rv->region()->clear_changes ();
|
2011-05-30 09:54:44 -04:00
|
|
|
rv->region()->trim_end (new_bound);
|
2010-03-02 13:05:26 -05:00
|
|
|
_session->add_command (new StatefulDiffCommand (rv->region()));
|
2006-06-13 03:27:52 -04:00
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
commit_reversible_command();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-07-21 11:55:17 -04:00
|
|
|
Editor::hide_marker (ArdourCanvas::Item* item, GdkEvent* /*event*/)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2015-07-23 07:23:47 -04:00
|
|
|
ArdourMarker* marker;
|
2009-05-30 14:25:59 -04:00
|
|
|
bool is_start;
|
|
|
|
|
2015-07-23 07:23:47 -04:00
|
|
|
if ((marker = static_cast<ArdourMarker *> (item->get_data ("marker"))) == 0) {
|
2009-05-30 14:25:59 -04:00
|
|
|
fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
|
2014-11-14 04:47:43 -05:00
|
|
|
abort(); /*NOTREACHED*/
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
Location* location = find_location_from_marker (marker, is_start);
|
2009-05-30 14:25:59 -04:00
|
|
|
location->set_hidden (true, this);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
2009-07-21 11:55:17 -04:00
|
|
|
Editor::mouse_rename_region (ArdourCanvas::Item* /*item*/, GdkEvent* /*event*/)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-09-25 16:33:00 -04:00
|
|
|
using namespace Gtkmm2ext;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2017-07-16 23:18:48 -04:00
|
|
|
ArdourWidgets::Prompter prompter (false);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
prompter.set_prompt (_("Name for region:"));
|
2006-08-29 17:21:48 -04:00
|
|
|
prompter.set_initial_text (clicked_regionview->region()->name());
|
2006-04-19 16:42:17 -04:00
|
|
|
prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
|
2006-04-22 11:28:59 -04:00
|
|
|
prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
|
2005-09-25 14:42:24 -04:00
|
|
|
prompter.show_all ();
|
2005-10-26 21:10:36 -04:00
|
|
|
switch (prompter.run ()) {
|
2006-01-13 14:48:55 -05:00
|
|
|
case Gtk::RESPONSE_ACCEPT:
|
2007-08-10 16:55:27 -04:00
|
|
|
string str;
|
2005-10-26 21:10:36 -04:00
|
|
|
prompter.get_result(str);
|
|
|
|
if (str.length()) {
|
2007-04-29 13:23:11 -04:00
|
|
|
clicked_regionview->region()->set_name (str);
|
2005-10-26 21:10:36 -04:00
|
|
|
}
|
|
|
|
break;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2020-10-15 01:09:22 -04:00
|
|
|
Editor::mouse_brush_insert_region (RegionView* rv, timepos_t const & pos)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2018-02-09 10:59:39 -05:00
|
|
|
/* no brushing without a useful quantize setting */
|
|
|
|
if (_grid_type == GridTypeNone)
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* don't brush a copy over the original */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2020-11-30 12:59:17 -05:00
|
|
|
if (pos == rv->region()->position()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&rv->get_time_axis_view());
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2016-06-02 08:42:58 -04:00
|
|
|
if (!rtv || !rtv->is_track()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-18 02:07:08 -04:00
|
|
|
boost::shared_ptr<Playlist> playlist = rtv->playlist();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
playlist->clear_changes ();
|
2011-02-14 16:49:43 -05:00
|
|
|
boost::shared_ptr<Region> new_region (RegionFactory::create (rv->region(), true));
|
2017-04-17 06:12:49 -04:00
|
|
|
playlist->add_region (new_region, pos);
|
2010-03-02 13:05:26 -05:00
|
|
|
_session->add_command (new StatefulDiffCommand (playlist));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2018-02-24 07:54:15 -05:00
|
|
|
/* playlist is frozen, so we have to update manually XXX this is disgusting */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2015-06-16 10:45:04 -04:00
|
|
|
//playlist->RegionAdded (new_region); /* EMIT SIGNAL */
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
Editor::track_height_step_timeout ()
|
|
|
|
{
|
2008-09-10 11:03:30 -04:00
|
|
|
if (get_microseconds() - last_track_height_step_timestamp < 250000) {
|
2009-07-09 13:58:13 -04:00
|
|
|
current_stepping_trackview = 0;
|
2006-03-07 21:50:53 -05:00
|
|
|
return false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2007-10-11 18:07:47 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
void
|
2021-06-04 11:22:44 -04:00
|
|
|
Editor::add_region_drag (ArdourCanvas::Item* item, GdkEvent*, RegionView* region_view, bool copy)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
|
|
|
assert (region_view);
|
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
if (!region_view->region()->playlist()) {
|
|
|
|
return;
|
|
|
|
}
|
2010-09-16 17:58:54 -04:00
|
|
|
|
2021-06-18 15:54:44 -04:00
|
|
|
_drags->add (new RegionMoveDrag (this, item, region_view, selection->regions.by_layer(), copy));
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-09-30 13:55:14 -04:00
|
|
|
Editor::add_region_brush_drag (ArdourCanvas::Item* item, GdkEvent*, RegionView* region_view)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
|
|
|
assert (region_view);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
if (!region_view->region()->playlist()) {
|
|
|
|
return;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2021-06-04 10:03:21 -04:00
|
|
|
if (should_ripple()) {
|
2009-05-30 14:25:59 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-06-15 17:09:24 -04:00
|
|
|
std::list<RegionView*> empty;
|
|
|
|
_drags->add (new RegionBrushDrag (this, item, region_view, empty));
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Start a grab where a time range is selected, track(s) are selected, and the
|
|
|
|
* user clicks and drags a region with a modifier in order to create a new region containing
|
|
|
|
* the section of the clicked region that lies within the time range.
|
|
|
|
*/
|
|
|
|
void
|
2009-07-21 11:55:17 -04:00
|
|
|
Editor::start_selection_grab (ArdourCanvas::Item* /*item*/, GdkEvent* event)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
|
|
|
if (clicked_regionview == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* lets try to create new Region for the selection */
|
|
|
|
|
|
|
|
vector<boost::shared_ptr<Region> > new_regions;
|
|
|
|
create_region_from_selection (new_regions);
|
|
|
|
|
|
|
|
if (new_regions.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX fix me one day to use all new regions */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
boost::shared_ptr<Region> region (new_regions.front());
|
|
|
|
|
|
|
|
/* add it to the current stream/playlist.
|
2019-04-08 15:37:02 -04:00
|
|
|
*
|
|
|
|
* tricky: the streamview for the track will add a new regionview. we will
|
|
|
|
* catch the signal it sends when it creates the regionview to
|
|
|
|
* set the regionview we want to then drag.
|
|
|
|
*/
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
latest_regionviews.clear();
|
2009-12-11 18:29:48 -05:00
|
|
|
sigc::connection c = clicked_routeview->view()->RegionViewAdded.connect (sigc::mem_fun(*this, &Editor::collect_new_region_view));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
|
|
|
/* A selection grab currently creates two undo/redo operations, one for
|
2019-04-08 15:37:02 -04:00
|
|
|
* creating the new region and another for moving it.
|
|
|
|
*/
|
2011-01-19 12:38:56 -05:00
|
|
|
begin_reversible_command (Operations::selection_grab);
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
boost::shared_ptr<Playlist> playlist = clicked_axisview->playlist();
|
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
playlist->clear_changes ();
|
2020-10-19 14:37:54 -04:00
|
|
|
clicked_routeview->playlist()->add_region (region, selection->time[clicked_selection].start());
|
2010-03-02 13:05:26 -05:00
|
|
|
_session->add_command(new StatefulDiffCommand (playlist));
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
c.disconnect ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (latest_regionviews.empty()) {
|
|
|
|
/* something went wrong */
|
2015-06-16 10:45:04 -04:00
|
|
|
abort_reversible_command ();
|
2009-05-30 14:25:59 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we need to deselect all other regionviews, and select this one
|
2019-04-08 15:37:02 -04:00
|
|
|
* i'm ignoring undo stuff, because the region creation will take care of it
|
|
|
|
*/
|
2014-12-14 08:13:38 -05:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
selection->set (latest_regionviews);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-12-14 08:13:38 -05:00
|
|
|
commit_reversible_command ();
|
|
|
|
|
2021-06-15 17:09:24 -04:00
|
|
|
_drags->set (new RegionMoveDrag (this, latest_regionviews.front()->get_canvas_group(), latest_regionviews.front(), latest_regionviews, false), event);
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2010-01-07 20:28:15 -05:00
|
|
|
void
|
|
|
|
Editor::escape ()
|
|
|
|
{
|
2010-01-12 11:14:49 -05:00
|
|
|
if (_drags->active ()) {
|
2010-05-05 18:09:07 -04:00
|
|
|
_drags->abort ();
|
2019-02-26 14:08:56 -05:00
|
|
|
} else if (_session) {
|
2020-04-16 14:16:45 -04:00
|
|
|
|
|
|
|
midi_action (&MidiRegionView::clear_note_selection);
|
|
|
|
|
2010-01-07 20:28:15 -05:00
|
|
|
selection->clear ();
|
2018-02-24 07:54:15 -05:00
|
|
|
|
|
|
|
/* if session is playing a range, cancel that */
|
2018-02-11 10:39:45 -05:00
|
|
|
if (_session->get_play_range()) {
|
|
|
|
_session->request_cancel_play_range();
|
|
|
|
}
|
|
|
|
|
2018-02-24 07:54:15 -05:00
|
|
|
if (_session->solo_selection_active()) {
|
2018-02-11 10:39:45 -05:00
|
|
|
StripableList sl;
|
2018-02-24 07:54:15 -05:00
|
|
|
_session->solo_selection (sl, false);
|
2018-02-11 10:39:45 -05:00
|
|
|
}
|
2010-01-07 20:28:15 -05:00
|
|
|
}
|
2014-09-16 11:09:12 -04:00
|
|
|
|
2016-09-06 16:56:07 -04:00
|
|
|
ARDOUR_UI::instance()->reset_focus (&contents());
|
2010-01-07 20:28:15 -05:00
|
|
|
}
|
|
|
|
|
2014-06-18 10:24:59 -04:00
|
|
|
/** Update _join_object_range_state which indicate whether we are over the top
|
|
|
|
* or bottom half of a route view, used by the `join object/range' tool
|
|
|
|
* mode. Coordinates in canvas space.
|
2010-01-01 17:11:15 -05:00
|
|
|
*/
|
|
|
|
void
|
2014-06-18 10:24:59 -04:00
|
|
|
Editor::update_join_object_range_location (double y)
|
2010-01-01 17:11:15 -05:00
|
|
|
{
|
2014-12-08 23:00:00 -05:00
|
|
|
if (!get_smart_mode()) {
|
2010-01-01 17:11:15 -05:00
|
|
|
_join_object_range_state = JOIN_OBJECT_RANGE_NONE;
|
|
|
|
return;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2014-06-18 10:24:59 -04:00
|
|
|
JoinObjectRangeState const old = _join_object_range_state;
|
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
if (mouse_mode == MouseObject) {
|
|
|
|
_join_object_range_state = JOIN_OBJECT_RANGE_OBJECT;
|
|
|
|
} else if (mouse_mode == MouseRange) {
|
|
|
|
_join_object_range_state = JOIN_OBJECT_RANGE_RANGE;
|
|
|
|
}
|
2010-01-01 20:19:47 -05:00
|
|
|
|
2014-06-18 10:24:59 -04:00
|
|
|
if (entered_regionview) {
|
2010-01-01 17:11:15 -05:00
|
|
|
|
2018-02-24 07:54:15 -05:00
|
|
|
/* TODO: there is currently a bug here(?)
|
|
|
|
* when we are inside a region fade handle, it acts as though we are in range mode because it is in the top half of the region
|
|
|
|
* can it be fixed here?
|
|
|
|
*/
|
2016-12-19 13:22:39 -05:00
|
|
|
|
2014-06-18 10:24:59 -04:00
|
|
|
ArdourCanvas::Duple const item_space = entered_regionview->get_canvas_group()->canvas_to_item (ArdourCanvas::Duple (0, y));
|
|
|
|
double const c = item_space.y / entered_regionview->height();
|
2014-12-30 12:49:59 -05:00
|
|
|
|
2014-06-18 10:24:59 -04:00
|
|
|
_join_object_range_state = c <= 0.5 ? JOIN_OBJECT_RANGE_RANGE : JOIN_OBJECT_RANGE_OBJECT;
|
2014-12-23 13:46:53 -05:00
|
|
|
|
|
|
|
Editor::EnterContext* ctx = get_enter_context(RegionItem);
|
|
|
|
if (_join_object_range_state != old && ctx) {
|
|
|
|
ctx->cursor_ctx->change(which_track_cursor());
|
2014-06-18 10:24:59 -04:00
|
|
|
}
|
2010-01-12 11:14:49 -05:00
|
|
|
|
2014-06-18 10:24:59 -04:00
|
|
|
} else if (entered_track) {
|
2010-09-21 19:26:18 -04:00
|
|
|
|
2014-06-18 10:24:59 -04:00
|
|
|
RouteTimeAxisView* entered_route_view = dynamic_cast<RouteTimeAxisView*> (entered_track);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-06-18 10:24:59 -04:00
|
|
|
if (entered_route_view) {
|
2014-07-02 16:23:46 -04:00
|
|
|
|
|
|
|
double cx = 0;
|
|
|
|
double cy = y;
|
|
|
|
|
|
|
|
entered_route_view->canvas_display()->canvas_to_item (cx, cy);
|
|
|
|
|
|
|
|
double track_height = entered_route_view->view()->child_height();
|
2015-01-02 09:44:54 -05:00
|
|
|
if (UIConfiguration::instance().get_show_name_highlight()) {
|
2014-07-02 16:23:46 -04:00
|
|
|
track_height -= TimeAxisViewItem::NAME_HIGHLIGHT_SIZE;
|
|
|
|
}
|
|
|
|
double const c = cy / track_height;
|
|
|
|
|
|
|
|
|
|
|
|
if (c <= 0.5) {
|
|
|
|
_join_object_range_state = JOIN_OBJECT_RANGE_RANGE;
|
|
|
|
} else {
|
|
|
|
_join_object_range_state = JOIN_OBJECT_RANGE_OBJECT;
|
2014-06-18 10:24:59 -04:00
|
|
|
}
|
2014-07-02 16:23:46 -04:00
|
|
|
|
2014-06-18 10:24:59 -04:00
|
|
|
} else {
|
|
|
|
/* Other kinds of tracks use object mode */
|
|
|
|
_join_object_range_state = JOIN_OBJECT_RANGE_OBJECT;
|
2014-07-02 16:23:46 -04:00
|
|
|
}
|
|
|
|
|
2014-12-23 13:46:53 -05:00
|
|
|
Editor::EnterContext* ctx = get_enter_context(StreamItem);
|
|
|
|
if (_join_object_range_state != old && ctx) {
|
|
|
|
ctx->cursor_ctx->change(which_track_cursor());
|
2010-01-01 17:11:15 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Editing::MouseMode
|
|
|
|
Editor::effective_mouse_mode () const
|
|
|
|
{
|
|
|
|
if (_join_object_range_state == JOIN_OBJECT_RANGE_OBJECT) {
|
|
|
|
return MouseObject;
|
|
|
|
} else if (_join_object_range_state == JOIN_OBJECT_RANGE_RANGE) {
|
|
|
|
return MouseRange;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mouse_mode;
|
|
|
|
}
|
2010-05-24 21:39:45 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
Editor::remove_midi_note (ArdourCanvas::Item* item, GdkEvent *)
|
|
|
|
{
|
2013-04-04 00:32:52 -04:00
|
|
|
NoteBase* e = reinterpret_cast<NoteBase*> (item->get_data ("notebase"));
|
2010-05-24 21:39:45 -04:00
|
|
|
assert (e);
|
|
|
|
|
|
|
|
e->region_view().delete_note (e->note ());
|
|
|
|
}
|
2010-11-15 14:00:31 -05:00
|
|
|
|
2013-04-04 18:45:27 -04:00
|
|
|
/** Obtain the pointer position in canvas coordinates */
|
2011-05-02 09:38:16 -04:00
|
|
|
void
|
|
|
|
Editor::get_pointer_position (double& x, double& y) const
|
|
|
|
{
|
|
|
|
int px, py;
|
2013-04-04 18:45:27 -04:00
|
|
|
_track_canvas->get_pointer (px, py);
|
2013-04-17 10:53:17 -04:00
|
|
|
_track_canvas->window_to_canvas (px, py, x, y);
|
2011-05-02 09:38:16 -04:00
|
|
|
}
|