2005-11-28 17:40:22 -05:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2005-2017 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2006-2015 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2007-2017 Tim Mayberry <mojofunk@gmail.com>
|
|
|
|
* Copyright (C) 2007 Doug McLain <doug@nostar.net>
|
|
|
|
* Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2013-2019 Robin Gareus <robin@gareus.org>
|
|
|
|
* Copyright (C) 2014-2019 Ben Loftis <ben@harrisonconsoles.com>
|
|
|
|
* Copyright (C) 2015-2017 Nick Mainsbridge <mainsbridge@gmail.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-11-28 17:40:22 -05:00
|
|
|
|
2010-11-13 00:14:48 -05:00
|
|
|
#ifdef WAF_BUILD
|
|
|
|
#include "gtk2ardour-config.h"
|
|
|
|
#endif
|
|
|
|
|
2012-01-19 10:23:51 -05:00
|
|
|
#include "gtkmm2ext/utils.h"
|
2005-11-28 17:40:22 -05:00
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/profile.h"
|
2009-10-30 11:30:22 -04:00
|
|
|
#include "ardour/rc_configuration.h"
|
2013-03-29 14:09:03 -04:00
|
|
|
#include "ardour/smf_source.h"
|
2005-12-30 15:38:41 -05:00
|
|
|
|
2014-12-20 01:11:28 -05:00
|
|
|
#include "pbd/error.h"
|
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
#include "canvas/canvas.h"
|
|
|
|
#include "canvas/rectangle.h"
|
|
|
|
#include "canvas/pixbuf.h"
|
2014-05-20 23:08:15 -04:00
|
|
|
#include "canvas/scroll_group.h"
|
2013-04-04 00:32:52 -04:00
|
|
|
#include "canvas/text.h"
|
2013-04-15 10:38:12 -04:00
|
|
|
#include "canvas/debug.h"
|
2013-04-04 00:32:52 -04:00
|
|
|
|
2005-12-02 14:18:26 -05:00
|
|
|
#include "ardour_ui.h"
|
2014-06-18 10:24:59 -04:00
|
|
|
#include "automation_time_axis.h"
|
2005-11-28 17:40:22 -05:00
|
|
|
#include "editor.h"
|
|
|
|
#include "editing.h"
|
|
|
|
#include "rgb_macros.h"
|
|
|
|
#include "utils.h"
|
2005-12-29 19:34:21 -05:00
|
|
|
#include "audio_time_axis.h"
|
2009-05-30 14:25:59 -04:00
|
|
|
#include "editor_drag.h"
|
2009-06-08 15:28:51 -04:00
|
|
|
#include "region_view.h"
|
2009-06-20 10:13:34 -04:00
|
|
|
#include "editor_group_tabs.h"
|
2010-06-17 20:05:44 -04:00
|
|
|
#include "editor_summary.h"
|
2013-03-12 17:00:09 -04:00
|
|
|
#include "video_timeline.h"
|
2010-09-21 10:22:13 -04:00
|
|
|
#include "keyboard.h"
|
2010-11-16 09:53:16 -05:00
|
|
|
#include "editor_cursors.h"
|
|
|
|
#include "mouse_cursors.h"
|
2016-10-16 12:19:02 -04:00
|
|
|
#include "note_base.h"
|
2020-12-19 10:44:16 -05:00
|
|
|
#include "region_peak_cursor.h"
|
2015-01-02 09:44:54 -05:00
|
|
|
#include "ui_config.h"
|
2011-05-02 09:38:16 -04:00
|
|
|
#include "verbose_cursor.h"
|
2005-11-28 17:40:22 -05:00
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2005-11-28 17:40:22 -05:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace ARDOUR;
|
2014-06-25 15:27:37 -04:00
|
|
|
using namespace ARDOUR_UI_UTILS;
|
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-11-28 17:40:22 -05:00
|
|
|
using namespace Gtk;
|
|
|
|
using namespace Glib;
|
|
|
|
using namespace Gtkmm2ext;
|
|
|
|
using namespace Editing;
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::initialize_canvas ()
|
|
|
|
{
|
2013-04-13 07:29:49 -04:00
|
|
|
_track_canvas_viewport = new ArdourCanvas::GtkCanvasViewport (horizontal_adjustment, vertical_adjustment);
|
2013-04-04 00:32:52 -04:00
|
|
|
_track_canvas = _track_canvas_viewport->canvas ();
|
2014-05-20 23:08:15 -04:00
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
_track_canvas->set_background_color (UIConfiguration::instance().color ("arrange base"));
|
2017-03-21 00:38:10 -04:00
|
|
|
_track_canvas->use_nsglview ();
|
2014-11-10 10:36:32 -05:00
|
|
|
|
2014-06-24 09:56:08 -04:00
|
|
|
/* scroll group for items that should not automatically scroll
|
|
|
|
* (e.g verbose cursor). It shares the canvas coordinate space.
|
|
|
|
*/
|
|
|
|
no_scroll_group = new ArdourCanvas::Container (_track_canvas->root());
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
ArdourCanvas::ScrollGroup* hsg;
|
2014-05-21 19:15:08 -04:00
|
|
|
ArdourCanvas::ScrollGroup* hg;
|
2015-01-16 19:09:47 -05:00
|
|
|
ArdourCanvas::ScrollGroup* cg;
|
2014-05-21 10:25:28 -04:00
|
|
|
|
2015-01-12 01:02:37 -05:00
|
|
|
h_scroll_group = hg = new ArdourCanvas::ScrollGroup (_track_canvas->root(), ArdourCanvas::ScrollGroup::ScrollsHorizontally);
|
|
|
|
CANVAS_DEBUG_NAME (h_scroll_group, "canvas h scroll");
|
|
|
|
_track_canvas->add_scroller (*hg);
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
hv_scroll_group = hsg = new ArdourCanvas::ScrollGroup (_track_canvas->root(),
|
2014-05-21 10:25:28 -04:00
|
|
|
ArdourCanvas::ScrollGroup::ScrollSensitivity (ArdourCanvas::ScrollGroup::ScrollsVertically|
|
|
|
|
ArdourCanvas::ScrollGroup::ScrollsHorizontally));
|
2014-05-20 23:08:15 -04:00
|
|
|
CANVAS_DEBUG_NAME (hv_scroll_group, "canvas hv scroll");
|
2014-05-21 10:25:28 -04:00
|
|
|
_track_canvas->add_scroller (*hsg);
|
2008-10-10 20:04:33 -04:00
|
|
|
|
2015-01-16 22:06:10 -05:00
|
|
|
cursor_scroll_group = cg = new ArdourCanvas::ScrollGroup (_track_canvas->root(), ArdourCanvas::ScrollGroup::ScrollsHorizontally);
|
2015-01-16 19:09:47 -05:00
|
|
|
CANVAS_DEBUG_NAME (cursor_scroll_group, "canvas cursor scroll");
|
|
|
|
_track_canvas->add_scroller (*cg);
|
|
|
|
|
2011-05-02 09:38:16 -04:00
|
|
|
_verbose_cursor = new VerboseCursor (this);
|
2020-12-19 10:44:16 -05:00
|
|
|
_region_peak_cursor = new RegionPeakCursor (get_noscroll_group ());
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2014-01-26 14:04:23 -05:00
|
|
|
/*a group to hold global rects like punch/loop indicators */
|
2014-06-22 11:41:05 -04:00
|
|
|
global_rect_group = new ArdourCanvas::Container (hv_scroll_group);
|
2014-01-26 14:04:23 -05:00
|
|
|
CANVAS_DEBUG_NAME (global_rect_group, "global rect group");
|
2008-03-17 16:54:03 -04:00
|
|
|
|
2014-01-26 14:04:23 -05:00
|
|
|
transport_loop_range_rect = new ArdourCanvas::Rectangle (global_rect_group, ArdourCanvas::Rect (0.0, 0.0, 0.0, ArdourCanvas::COORD_MAX));
|
2013-11-03 10:07:00 -05:00
|
|
|
CANVAS_DEBUG_NAME (transport_loop_range_rect, "loop rect");
|
2008-09-17 15:04:16 -04:00
|
|
|
transport_loop_range_rect->hide();
|
|
|
|
|
2014-01-26 14:04:23 -05:00
|
|
|
transport_punch_range_rect = new ArdourCanvas::Rectangle (global_rect_group, ArdourCanvas::Rect (0.0, 0.0, 0.0, ArdourCanvas::COORD_MAX));
|
2013-11-03 10:07:00 -05:00
|
|
|
CANVAS_DEBUG_NAME (transport_punch_range_rect, "punch rect");
|
2008-09-29 16:35:44 -04:00
|
|
|
transport_punch_range_rect->hide();
|
|
|
|
|
2014-01-26 14:04:23 -05:00
|
|
|
/*a group to hold time (measure) lines */
|
2015-01-11 21:41:17 -05:00
|
|
|
time_line_group = new ArdourCanvas::Container (h_scroll_group);
|
2014-01-26 14:04:23 -05:00
|
|
|
CANVAS_DEBUG_NAME (time_line_group, "time line group");
|
|
|
|
|
2014-06-22 11:41:05 -04:00
|
|
|
_trackview_group = new ArdourCanvas::Container (hv_scroll_group);
|
2013-04-15 10:38:12 -04:00
|
|
|
CANVAS_DEBUG_NAME (_trackview_group, "Canvas TrackViews");
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-06-06 08:32:35 -04:00
|
|
|
// used as rubberband rect
|
|
|
|
rubberband_rect = new ArdourCanvas::Rectangle (hv_scroll_group, ArdourCanvas::Rect (0.0, 0.0, 0.0, 0.0));
|
|
|
|
rubberband_rect->hide();
|
|
|
|
|
2014-06-05 15:16:55 -04:00
|
|
|
/* a group to hold stuff while it gets dragged around. Must be the
|
|
|
|
* uppermost (last) group with hv_scroll_group as a parent
|
|
|
|
*/
|
2015-10-04 14:51:05 -04:00
|
|
|
_drag_motion_group = new ArdourCanvas::Container (hv_scroll_group);
|
2017-07-01 12:42:24 -04:00
|
|
|
CANVAS_DEBUG_NAME (_drag_motion_group, "Canvas Drag Motion");
|
2014-06-05 15:16:55 -04:00
|
|
|
|
2014-05-18 12:22:23 -04:00
|
|
|
/* TIME BAR CANVAS */
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-06-22 11:41:05 -04:00
|
|
|
_time_markers_group = new ArdourCanvas::Container (h_scroll_group);
|
2014-05-21 19:15:08 -04:00
|
|
|
CANVAS_DEBUG_NAME (_time_markers_group, "time bars");
|
2013-04-04 00:32:52 -04:00
|
|
|
|
2014-06-22 11:41:05 -04:00
|
|
|
cd_marker_group = new ArdourCanvas::Container (_time_markers_group, ArdourCanvas::Duple (0.0, 0.0));
|
2013-12-30 14:01:56 -05:00
|
|
|
CANVAS_DEBUG_NAME (cd_marker_group, "cd marker group");
|
2014-02-25 11:55:21 -05:00
|
|
|
/* the vide is temporarily placed a the same location as the
|
|
|
|
cd_marker_group, but is moved later.
|
|
|
|
*/
|
2014-06-22 11:41:05 -04:00
|
|
|
videotl_group = new ArdourCanvas::Container (_time_markers_group, ArdourCanvas::Duple(0.0, 0.0));
|
2013-12-30 14:01:56 -05:00
|
|
|
CANVAS_DEBUG_NAME (videotl_group, "videotl group");
|
2014-06-22 11:41:05 -04:00
|
|
|
marker_group = new ArdourCanvas::Container (_time_markers_group, ArdourCanvas::Duple (0.0, timebar_height + 1.0));
|
2014-02-25 11:55:21 -05:00
|
|
|
CANVAS_DEBUG_NAME (marker_group, "marker group");
|
2014-06-22 11:41:05 -04:00
|
|
|
transport_marker_group = new ArdourCanvas::Container (_time_markers_group, ArdourCanvas::Duple (0.0, (timebar_height * 2.0) + 1.0));
|
2014-02-25 11:55:21 -05:00
|
|
|
CANVAS_DEBUG_NAME (transport_marker_group, "transport marker group");
|
2014-06-22 11:41:05 -04:00
|
|
|
range_marker_group = new ArdourCanvas::Container (_time_markers_group, ArdourCanvas::Duple (0.0, (timebar_height * 3.0) + 1.0));
|
2014-02-25 11:55:21 -05:00
|
|
|
CANVAS_DEBUG_NAME (range_marker_group, "range marker group");
|
2014-06-22 11:41:05 -04:00
|
|
|
tempo_group = new ArdourCanvas::Container (_time_markers_group, ArdourCanvas::Duple (0.0, (timebar_height * 4.0) + 1.0));
|
2014-02-25 11:55:21 -05:00
|
|
|
CANVAS_DEBUG_NAME (tempo_group, "tempo group");
|
2014-06-22 11:41:05 -04:00
|
|
|
meter_group = new ArdourCanvas::Container (_time_markers_group, ArdourCanvas::Duple (0.0, (timebar_height * 5.0) + 1.0));
|
2014-02-25 11:55:21 -05:00
|
|
|
CANVAS_DEBUG_NAME (meter_group, "meter group");
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-05-21 19:15:08 -04:00
|
|
|
meter_bar = new ArdourCanvas::Rectangle (meter_group, ArdourCanvas::Rect (0.0, 0.0, ArdourCanvas::COORD_MAX, timebar_height));
|
|
|
|
CANVAS_DEBUG_NAME (meter_bar, "meter Bar");
|
|
|
|
meter_bar->set_outline_what (ArdourCanvas::Rectangle::BOTTOM);
|
|
|
|
|
|
|
|
tempo_bar = new ArdourCanvas::Rectangle (tempo_group, ArdourCanvas::Rect (0.0, 0.0, ArdourCanvas::COORD_MAX, timebar_height));
|
|
|
|
CANVAS_DEBUG_NAME (tempo_bar, "Tempo Bar");
|
|
|
|
tempo_bar->set_outline_what (ArdourCanvas::Rectangle::BOTTOM);
|
2013-03-12 17:00:09 -04:00
|
|
|
|
2014-05-21 19:15:08 -04:00
|
|
|
range_marker_bar = new ArdourCanvas::Rectangle (range_marker_group, ArdourCanvas::Rect (0.0, 0.0, ArdourCanvas::COORD_MAX, timebar_height));
|
|
|
|
CANVAS_DEBUG_NAME (range_marker_bar, "Range Marker Bar");
|
|
|
|
range_marker_bar->set_outline_what (ArdourCanvas::Rectangle::BOTTOM);
|
|
|
|
|
|
|
|
transport_marker_bar = new ArdourCanvas::Rectangle (transport_marker_group, ArdourCanvas::Rect (0.0, 0.0, ArdourCanvas::COORD_MAX, timebar_height));
|
|
|
|
CANVAS_DEBUG_NAME (transport_marker_bar, "transport Marker Bar");
|
|
|
|
transport_marker_bar->set_outline_what (ArdourCanvas::Rectangle::BOTTOM);
|
|
|
|
|
|
|
|
marker_bar = new ArdourCanvas::Rectangle (marker_group, ArdourCanvas::Rect (0.0, 0.0, ArdourCanvas::COORD_MAX, timebar_height));
|
|
|
|
CANVAS_DEBUG_NAME (marker_bar, "Marker Bar");
|
|
|
|
marker_bar->set_outline_what (ArdourCanvas::Rectangle::BOTTOM);
|
|
|
|
|
|
|
|
cd_marker_bar = new ArdourCanvas::Rectangle (cd_marker_group, ArdourCanvas::Rect (0.0, 0.0, ArdourCanvas::COORD_MAX, timebar_height));
|
|
|
|
CANVAS_DEBUG_NAME (cd_marker_bar, "CD Marker Bar");
|
2017-02-09 10:27:34 -05:00
|
|
|
cd_marker_bar->set_outline_what (ArdourCanvas::Rectangle::BOTTOM);
|
2014-05-21 19:15:08 -04:00
|
|
|
|
|
|
|
ARDOUR_UI::instance()->video_timeline = new VideoTimeLine(this, videotl_group, (timebar_height * videotl_bar_height));
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
cd_marker_bar_drag_rect = new ArdourCanvas::Rectangle (cd_marker_group, ArdourCanvas::Rect (0.0, 0.0, 100, timebar_height));
|
2013-12-30 14:01:56 -05:00
|
|
|
CANVAS_DEBUG_NAME (cd_marker_bar_drag_rect, "cd marker drag");
|
2013-04-04 00:32:52 -04:00
|
|
|
cd_marker_bar_drag_rect->set_outline (false);
|
2008-09-10 17:27:39 -04:00
|
|
|
cd_marker_bar_drag_rect->hide ();
|
|
|
|
|
2013-04-04 18:45:27 -04:00
|
|
|
range_bar_drag_rect = new ArdourCanvas::Rectangle (range_marker_group, ArdourCanvas::Rect (0.0, 0.0, 100, timebar_height));
|
2013-12-30 14:01:56 -05:00
|
|
|
CANVAS_DEBUG_NAME (range_bar_drag_rect, "range drag");
|
2013-04-04 00:32:52 -04:00
|
|
|
range_bar_drag_rect->set_outline (false);
|
2008-09-19 10:38:46 -04:00
|
|
|
range_bar_drag_rect->hide ();
|
2008-09-10 17:27:39 -04:00
|
|
|
|
2013-04-04 18:45:27 -04:00
|
|
|
transport_bar_drag_rect = new ArdourCanvas::Rectangle (transport_marker_group, ArdourCanvas::Rect (0.0, 0.0, 100, timebar_height));
|
2013-12-30 14:01:56 -05:00
|
|
|
CANVAS_DEBUG_NAME (transport_bar_drag_rect, "transport drag");
|
2013-04-04 00:32:52 -04:00
|
|
|
transport_bar_drag_rect->set_outline (false);
|
2008-09-10 17:27:39 -04:00
|
|
|
transport_bar_drag_rect->hide ();
|
|
|
|
|
2014-05-20 23:08:15 -04:00
|
|
|
transport_punchin_line = new ArdourCanvas::Line (hv_scroll_group);
|
2013-04-04 18:45:27 -04:00
|
|
|
transport_punchin_line->set_x0 (0);
|
|
|
|
transport_punchin_line->set_y0 (0);
|
2013-04-04 00:32:52 -04:00
|
|
|
transport_punchin_line->set_x1 (0);
|
2013-04-04 18:45:27 -04:00
|
|
|
transport_punchin_line->set_y1 (ArdourCanvas::COORD_MAX);
|
2005-11-28 17:40:22 -05:00
|
|
|
transport_punchin_line->hide ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-05-20 23:08:15 -04:00
|
|
|
transport_punchout_line = new ArdourCanvas::Line (hv_scroll_group);
|
2013-04-04 18:45:27 -04:00
|
|
|
transport_punchout_line->set_x0 (0);
|
|
|
|
transport_punchout_line->set_y0 (0);
|
2013-04-04 00:32:52 -04:00
|
|
|
transport_punchout_line->set_x1 (0);
|
2013-04-04 18:45:27 -04:00
|
|
|
transport_punchout_line->set_y1 (ArdourCanvas::COORD_MAX);
|
2005-11-28 17:40:22 -05:00
|
|
|
transport_punchout_line->hide();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2013-04-04 18:45:27 -04:00
|
|
|
tempo_bar->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_tempo_bar_event), tempo_bar));
|
|
|
|
meter_bar->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_meter_bar_event), meter_bar));
|
|
|
|
marker_bar->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_marker_bar_event), marker_bar));
|
|
|
|
cd_marker_bar->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_cd_marker_bar_event), cd_marker_bar));
|
2013-04-16 20:25:08 -04:00
|
|
|
videotl_group->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_videotl_bar_event), videotl_group));
|
2013-04-04 18:45:27 -04:00
|
|
|
range_marker_bar->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_range_marker_bar_event), range_marker_bar));
|
|
|
|
transport_marker_bar->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_transport_marker_bar_event), transport_marker_bar));
|
2007-03-18 02:07:08 -04:00
|
|
|
|
2021-07-27 14:10:10 -04:00
|
|
|
_playhead_cursor = new EditorCursor (*this, &Editor::canvas_playhead_cursor_event, X_("playhead"));
|
2006-09-18 23:29:16 -04:00
|
|
|
|
2021-07-27 14:10:10 -04:00
|
|
|
_snapped_cursor = new EditorCursor (*this, X_("snapped"));
|
2018-02-09 09:21:45 -05:00
|
|
|
|
2014-06-09 09:09:21 -04:00
|
|
|
_canvas_drop_zone = new ArdourCanvas::Rectangle (hv_scroll_group, ArdourCanvas::Rect (0.0, 0.0, ArdourCanvas::COORD_MAX, 0.0));
|
2014-04-16 04:16:56 -04:00
|
|
|
/* this thing is transparent */
|
2014-06-09 09:09:21 -04:00
|
|
|
_canvas_drop_zone->set_fill (false);
|
|
|
|
_canvas_drop_zone->set_outline (false);
|
|
|
|
_canvas_drop_zone->Event.connect (sigc::mem_fun (*this, &Editor::canvas_drop_zone_event));
|
2014-04-16 04:16:56 -04:00
|
|
|
|
2014-04-01 04:14:34 -04:00
|
|
|
/* these signals will initially be delivered to the canvas itself, but if they end up remaining unhandled, they are passed to Editor-level
|
|
|
|
handlers.
|
|
|
|
*/
|
2008-09-17 15:04:16 -04:00
|
|
|
|
2014-06-13 14:27:59 -04:00
|
|
|
_track_canvas->signal_scroll_event().connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_scroll_event), true));
|
2013-04-04 00:32:52 -04:00
|
|
|
_track_canvas->signal_motion_notify_event().connect (sigc::mem_fun (*this, &Editor::track_canvas_motion_notify_event));
|
|
|
|
_track_canvas->signal_button_press_event().connect (sigc::mem_fun (*this, &Editor::track_canvas_button_press_event));
|
|
|
|
_track_canvas->signal_button_release_event().connect (sigc::mem_fun (*this, &Editor::track_canvas_button_release_event));
|
|
|
|
_track_canvas->signal_drag_motion().connect (sigc::mem_fun (*this, &Editor::track_canvas_drag_motion));
|
|
|
|
_track_canvas->signal_key_press_event().connect (sigc::mem_fun (*this, &Editor::track_canvas_key_press));
|
|
|
|
_track_canvas->signal_key_release_event().connect (sigc::mem_fun (*this, &Editor::track_canvas_key_release));
|
2008-09-17 15:04:16 -04:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
_track_canvas->set_name ("EditorMainCanvas");
|
|
|
|
_track_canvas->add_events (Gdk::POINTER_MOTION_HINT_MASK | Gdk::SCROLL_MASK | Gdk::KEY_PRESS_MASK | Gdk::KEY_RELEASE_MASK);
|
|
|
|
_track_canvas->signal_leave_notify_event().connect (sigc::mem_fun(*this, &Editor::left_track_canvas), false);
|
|
|
|
_track_canvas->signal_enter_notify_event().connect (sigc::mem_fun(*this, &Editor::entered_track_canvas), false);
|
|
|
|
_track_canvas->set_flags (CAN_FOCUS);
|
2008-09-17 15:04:16 -04:00
|
|
|
|
2017-04-01 07:33:59 -04:00
|
|
|
_track_canvas->PreRender.connect (sigc::mem_fun(*this, &Editor::pre_render));
|
|
|
|
|
2008-09-17 15:04:16 -04:00
|
|
|
/* set up drag-n-drop */
|
|
|
|
|
|
|
|
vector<TargetEntry> target_table;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2018-11-15 10:30:22 -05:00
|
|
|
target_table.push_back (TargetEntry ("regions")); // DnD from the region list will generate this target
|
|
|
|
target_table.push_back (TargetEntry ("sources")); // DnD from the source list will generate this target
|
2008-09-17 15:04:16 -04:00
|
|
|
target_table.push_back (TargetEntry ("text/uri-list"));
|
2019-05-13 01:52:38 -04:00
|
|
|
target_table.push_back (TargetEntry ("text/plain"));
|
2008-09-17 15:04:16 -04:00
|
|
|
target_table.push_back (TargetEntry ("application/x-rootwin-drop"));
|
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
_track_canvas->drag_dest_set (target_table);
|
|
|
|
_track_canvas->signal_drag_data_received().connect (sigc::mem_fun(*this, &Editor::track_canvas_drag_data_received));
|
2008-09-17 15:04:16 -04:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
_track_canvas_viewport->signal_size_allocate().connect (sigc::mem_fun(*this, &Editor::track_canvas_viewport_allocate));
|
2008-09-17 15:04:16 -04:00
|
|
|
|
2014-06-12 01:06:25 -04:00
|
|
|
initialize_rulers ();
|
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
UIConfiguration::instance().ColorsChanged.connect (sigc::mem_fun (*this, &Editor::color_handler));
|
2007-06-15 18:08:27 -04:00
|
|
|
color_handler();
|
|
|
|
|
2005-11-28 17:40:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-04-04 00:32:52 -04:00
|
|
|
Editor::track_canvas_viewport_allocate (Gtk::Allocation alloc)
|
2005-11-28 17:40:22 -05:00
|
|
|
{
|
2013-04-04 00:32:52 -04:00
|
|
|
_canvas_viewport_allocation = alloc;
|
2014-04-16 02:55:08 -04:00
|
|
|
track_canvas_viewport_size_allocated ();
|
2006-11-19 11:45:16 -05:00
|
|
|
}
|
|
|
|
|
2014-04-16 02:55:08 -04:00
|
|
|
void
|
2013-04-04 00:32:52 -04:00
|
|
|
Editor::track_canvas_viewport_size_allocated ()
|
2006-11-19 11:45:16 -05:00
|
|
|
{
|
2013-04-04 00:32:52 -04:00
|
|
|
bool height_changed = _visible_canvas_height != _canvas_viewport_allocation.get_height();
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
_visible_canvas_width = _canvas_viewport_allocation.get_width ();
|
|
|
|
_visible_canvas_height = _canvas_viewport_allocation.get_height ();
|
2005-11-28 17:40:22 -05:00
|
|
|
|
2014-06-09 09:11:04 -04:00
|
|
|
_canvas_drop_zone->set_y1 (_canvas_drop_zone->y0() + (_visible_canvas_height - 20.0));
|
2014-06-09 09:09:21 -04:00
|
|
|
|
2013-04-12 18:01:44 -04:00
|
|
|
// SHOWTRACKS
|
2007-01-09 18:24:54 -05:00
|
|
|
|
2008-09-20 05:06:49 -04:00
|
|
|
if (height_changed) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
vertical_adjustment.set_page_size (_visible_canvas_height);
|
|
|
|
if ((vertical_adjustment.get_value() + _visible_canvas_height) >= vertical_adjustment.get_upper()) {
|
2009-10-14 12:10:01 -04:00
|
|
|
/*
|
2008-10-19 03:55:42 -04:00
|
|
|
We're increasing the size of the canvas while the bottom is visible.
|
|
|
|
We scroll down to keep in step with the controls layout.
|
|
|
|
*/
|
2013-04-04 00:32:52 -04:00
|
|
|
vertical_adjustment.set_value (_full_canvas_height - _visible_canvas_height);
|
2008-10-19 03:55:42 -04:00
|
|
|
}
|
2014-03-25 10:33:18 -04:00
|
|
|
|
|
|
|
set_visible_track_count (_visible_track_count);
|
2008-09-20 05:06:49 -04:00
|
|
|
}
|
2008-10-16 07:16:41 -04:00
|
|
|
|
2008-09-10 17:27:39 -04:00
|
|
|
update_fixed_rulers();
|
2021-02-20 19:41:32 -05:00
|
|
|
update_tempo_based_rulers ();
|
2018-02-09 10:59:39 -05:00
|
|
|
redisplay_grid (false);
|
2009-06-16 20:29:56 -04:00
|
|
|
_summary->set_overlays_dirty ();
|
2006-01-08 09:50:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-01-29 09:48:59 -05:00
|
|
|
Editor::reset_controls_layout_width ()
|
2006-01-08 09:50:41 -05:00
|
|
|
{
|
2014-11-18 02:37:30 -05:00
|
|
|
GtkRequisition req = { 0, 0 };
|
2011-07-07 09:15:53 -04:00
|
|
|
gint w;
|
|
|
|
|
|
|
|
edit_controls_vbox.size_request (req);
|
|
|
|
w = req.width;
|
2008-09-24 15:23:43 -04:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
if (_group_tabs->is_visible()) {
|
2011-07-07 09:15:53 -04:00
|
|
|
_group_tabs->size_request (req);
|
2017-07-01 12:42:24 -04:00
|
|
|
w += req.width;
|
|
|
|
}
|
2008-09-24 15:23:43 -04:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
/* the controls layout has no horizontal scrolling, its visible
|
|
|
|
width is always equal to the total width of its contents.
|
|
|
|
*/
|
2008-09-24 15:23:43 -04:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
controls_layout.property_width() = w;
|
|
|
|
controls_layout.property_width_request() = w;
|
2011-01-29 09:48:59 -05:00
|
|
|
}
|
2008-09-17 15:04:16 -04:00
|
|
|
|
2011-01-29 09:48:59 -05:00
|
|
|
void
|
|
|
|
Editor::reset_controls_layout_height (int32_t h)
|
|
|
|
{
|
2014-04-16 04:16:56 -04:00
|
|
|
/* ensure that the rect that represents the "bottom" of the canvas
|
|
|
|
* (the drag-n-drop zone) is, in fact, at the bottom.
|
|
|
|
*/
|
|
|
|
|
2014-06-09 09:09:21 -04:00
|
|
|
_canvas_drop_zone->set_position (ArdourCanvas::Duple (0, h));
|
2014-04-16 04:16:56 -04:00
|
|
|
|
|
|
|
/* track controls layout must span the full height of "h" (all tracks)
|
|
|
|
* plus the bottom rect.
|
|
|
|
*/
|
|
|
|
|
2014-06-09 09:09:21 -04:00
|
|
|
h += _canvas_drop_zone->height ();
|
2014-04-16 04:16:56 -04:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
/* set the height of the scrollable area (i.e. the sum of all contained widgets)
|
2014-04-16 04:16:56 -04:00
|
|
|
* for the controls layout. The size request is set elsewhere.
|
2017-07-01 12:42:24 -04:00
|
|
|
*/
|
2008-09-17 15:04:16 -04:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
controls_layout.property_height() = h;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2005-11-28 17:40:22 -05:00
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2005-11-28 23:41:15 -05:00
|
|
|
bool
|
2009-07-21 11:55:17 -04:00
|
|
|
Editor::track_canvas_map_handler (GdkEventAny* /*ev*/)
|
2005-11-28 23:41:15 -05:00
|
|
|
{
|
2014-12-20 01:11:28 -05:00
|
|
|
if (!_cursor_stack.empty()) {
|
|
|
|
set_canvas_cursor (get_canvas_cursor());
|
|
|
|
} else {
|
|
|
|
PBD::error << "cursor stack is empty" << endmsg;
|
2009-07-28 16:51:28 -04:00
|
|
|
}
|
2005-11-28 23:41:15 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-05-05 18:09:07 -04:00
|
|
|
/** This is called when something is dropped onto the track canvas */
|
2009-10-14 12:10:01 -04:00
|
|
|
void
|
2005-12-29 19:34:21 -05:00
|
|
|
Editor::track_canvas_drag_data_received (const RefPtr<Gdk::DragContext>& context,
|
2009-10-14 12:10:01 -04:00
|
|
|
int x, int y,
|
2005-12-29 19:34:21 -05:00
|
|
|
const SelectionData& data,
|
|
|
|
guint info, guint time)
|
2005-12-30 15:38:41 -05:00
|
|
|
{
|
2018-11-28 08:56:04 -05:00
|
|
|
if (!ARDOUR_UI_UTILS::engine_is_running ()) {
|
2018-11-27 18:01:50 -05:00
|
|
|
return;
|
|
|
|
}
|
2018-11-15 10:30:22 -05:00
|
|
|
if (data.get_target() == X_("regions")) {
|
|
|
|
drop_regions (context, x, y, data, info, time, true);
|
|
|
|
} else if (data.get_target() == X_("sources")) {
|
|
|
|
drop_regions (context, x, y, data, info, time, false);
|
2008-12-12 09:43:24 -05:00
|
|
|
} else {
|
2005-12-30 15:38:41 -05:00
|
|
|
drop_paths (context, x, y, data, info, time);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-12 09:43:24 -05:00
|
|
|
bool
|
2021-03-28 17:53:35 -04:00
|
|
|
Editor::idle_drop_paths (vector<string> paths, timepos_t pos, double ypos, bool copy)
|
2008-12-12 09:43:24 -05:00
|
|
|
{
|
2021-03-28 17:53:35 -04:00
|
|
|
drop_paths_part_two (paths, pos, ypos, copy);
|
2008-12-12 09:43:24 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-12-30 15:38:41 -05:00
|
|
|
void
|
2020-09-26 11:14:59 -04:00
|
|
|
Editor::drop_paths_part_two (const vector<string>& paths, timepos_t const & p, double ypos, bool copy)
|
2005-12-29 19:34:21 -05:00
|
|
|
{
|
2009-07-09 13:58:13 -04:00
|
|
|
RouteTimeAxisView* tv;
|
2020-09-26 11:14:59 -04:00
|
|
|
timepos_t pos (p);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-03-29 14:09:03 -04:00
|
|
|
/* MIDI files must always be imported, because we consider them
|
|
|
|
* writable. So split paths into two vectors, and follow the import
|
|
|
|
* path on the MIDI part.
|
|
|
|
*/
|
|
|
|
|
|
|
|
vector<string> midi_paths;
|
|
|
|
vector<string> audio_paths;
|
|
|
|
|
|
|
|
for (vector<string>::const_iterator i = paths.begin(); i != paths.end(); ++i) {
|
|
|
|
if (SMFSource::safe_midi_file_extension (*i)) {
|
|
|
|
midi_paths.push_back (*i);
|
|
|
|
} else {
|
|
|
|
audio_paths.push_back (*i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-19 13:45:05 -04:00
|
|
|
std::pair<TimeAxisView*, int> const tvp = trackview_by_y_position (ypos, false);
|
2009-01-05 22:18:09 -05:00
|
|
|
if (tvp.first == 0) {
|
2005-12-29 19:34:21 -05:00
|
|
|
|
2006-03-22 12:03:00 -05:00
|
|
|
/* drop onto canvas background: create new tracks */
|
2005-12-29 19:34:21 -05:00
|
|
|
|
2015-08-05 11:53:03 -04:00
|
|
|
InstrumentSelector is; // instantiation builds instrument-list and sets default.
|
2020-09-26 11:14:59 -04:00
|
|
|
do_import (midi_paths, Editing::ImportDistinctFiles, ImportAsTrack, SrcBest, SMFTrackName, SMFTempoIgnore, pos, is.selected_instrument(), false);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2015-10-26 15:17:42 -04:00
|
|
|
if (UIConfiguration::instance().get_only_copy_imported_files() || copy) {
|
2017-02-09 10:27:34 -05:00
|
|
|
do_import (audio_paths, Editing::ImportDistinctFiles, Editing::ImportAsTrack,
|
2020-09-26 11:14:59 -04:00
|
|
|
SrcBest, SMFTrackName, SMFTempoIgnore, pos);
|
2008-03-17 16:54:03 -04:00
|
|
|
} else {
|
2020-09-26 11:14:59 -04:00
|
|
|
do_embed (audio_paths, Editing::ImportDistinctFiles, ImportAsTrack, pos);
|
2008-03-17 16:54:03 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
} else if ((tv = dynamic_cast<RouteTimeAxisView*> (tvp.first)) != 0) {
|
2005-12-29 19:34:21 -05:00
|
|
|
|
2013-03-28 16:18:08 -04:00
|
|
|
/* check that its a track, not a bus */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-04-21 16:42:22 -04:00
|
|
|
if (tv->track()) {
|
2008-12-12 09:43:24 -05:00
|
|
|
/* select the track, then embed/import */
|
2009-07-09 13:58:13 -04:00
|
|
|
selection->set (tv);
|
2008-03-17 16:54:03 -04:00
|
|
|
|
2016-12-16 09:57:14 -05:00
|
|
|
do_import (midi_paths, Editing::ImportSerializeFiles, ImportToTrack,
|
2020-09-26 11:14:59 -04:00
|
|
|
SrcBest, SMFTrackName, SMFTempoIgnore, pos);
|
2013-03-29 14:09:03 -04:00
|
|
|
|
2015-10-26 15:17:42 -04:00
|
|
|
if (UIConfiguration::instance().get_only_copy_imported_files() || copy) {
|
2016-12-16 09:57:14 -05:00
|
|
|
do_import (audio_paths, Editing::ImportSerializeFiles, Editing::ImportToTrack,
|
2020-09-26 11:14:59 -04:00
|
|
|
SrcBest, SMFTrackName, SMFTempoIgnore, pos, boost::shared_ptr<PluginInfo>(), false);
|
2008-03-17 16:54:03 -04:00
|
|
|
} else {
|
2020-09-26 11:14:59 -04:00
|
|
|
do_embed (audio_paths, Editing::ImportSerializeFiles, ImportToTrack, pos);
|
2008-03-17 16:54:03 -04:00
|
|
|
}
|
2005-12-29 19:34:21 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-12-30 15:38:41 -05:00
|
|
|
void
|
2008-12-12 09:43:24 -05:00
|
|
|
Editor::drop_paths (const RefPtr<Gdk::DragContext>& context,
|
2009-10-14 12:10:01 -04:00
|
|
|
int x, int y,
|
2008-12-12 09:43:24 -05:00
|
|
|
const SelectionData& data,
|
|
|
|
guint info, guint time)
|
2005-12-30 15:38:41 -05:00
|
|
|
{
|
2010-09-14 11:45:21 -04:00
|
|
|
vector<string> paths;
|
2008-12-12 09:43:24 -05:00
|
|
|
GdkEvent ev;
|
|
|
|
double cy;
|
2005-12-30 15:38:41 -05:00
|
|
|
|
2021-12-13 16:50:04 -05:00
|
|
|
if (_session && convert_drop_to_paths (paths, data)) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2021-12-13 16:50:04 -05:00
|
|
|
/* D-n-D coordinates are window-relative, so convert to canvas coordinates */
|
2005-12-30 15:38:41 -05:00
|
|
|
|
2008-12-12 09:43:24 -05:00
|
|
|
ev.type = GDK_BUTTON_RELEASE;
|
2013-04-12 11:09:49 -04:00
|
|
|
ev.button.x = x;
|
|
|
|
ev.button.y = y;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2020-09-26 11:14:59 -04:00
|
|
|
timepos_t when (window_event_sample (&ev, 0, &cy));
|
2017-01-26 08:41:17 -05:00
|
|
|
snap_to (when);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2013-03-21 16:33:02 -04:00
|
|
|
bool copy = ((context->get_actions() & (Gdk::ACTION_COPY | Gdk::ACTION_LINK | Gdk::ACTION_MOVE)) == Gdk::ACTION_COPY);
|
2015-10-27 13:43:31 -04:00
|
|
|
#ifdef __APPLE__
|
2008-12-12 09:43:24 -05:00
|
|
|
/* We are not allowed to call recursive main event loops from within
|
|
|
|
the main event loop with GTK/Quartz. Since import/embed wants
|
|
|
|
to push up a progress dialog, defer all this till we go idle.
|
|
|
|
*/
|
2021-03-28 17:53:35 -04:00
|
|
|
Glib::signal_idle().connect (sigc::bind (sigc::mem_fun (*this, &Editor::idle_drop_paths), paths, when, cy, copy));
|
2008-12-12 09:43:24 -05:00
|
|
|
#else
|
2020-09-26 11:14:59 -04:00
|
|
|
drop_paths_part_two (paths, when, cy, copy);
|
2008-12-12 09:43:24 -05:00
|
|
|
#endif
|
2005-12-30 15:38:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
context->drag_finish (true, false, time);
|
|
|
|
}
|
2006-04-18 22:11:39 -04:00
|
|
|
|
2012-01-30 16:33:32 -05:00
|
|
|
/** @param allow_horiz true to allow horizontal autoscroll, otherwise false.
|
2013-07-10 19:10:06 -04:00
|
|
|
*
|
2012-01-30 16:33:32 -05:00
|
|
|
* @param allow_vert true to allow vertical autoscroll, otherwise false.
|
2013-07-10 19:10:06 -04:00
|
|
|
*
|
2012-01-30 16:33:32 -05:00
|
|
|
*/
|
2006-05-25 16:30:32 -04:00
|
|
|
void
|
2014-03-20 13:29:29 -04:00
|
|
|
Editor::maybe_autoscroll (bool allow_horiz, bool allow_vert, bool from_headers)
|
2006-05-25 16:30:32 -04:00
|
|
|
{
|
2015-07-07 22:12:21 -04:00
|
|
|
Gtk::Window* toplevel = dynamic_cast<Gtk::Window*>(contents().get_toplevel());
|
|
|
|
|
|
|
|
if (!toplevel) {
|
|
|
|
return;
|
|
|
|
}
|
2015-10-26 14:35:06 -04:00
|
|
|
|
2015-10-22 19:19:24 -04:00
|
|
|
if (!UIConfiguration::instance().get_autoscroll_editor () || autoscroll_active ()) {
|
2012-06-17 08:38:59 -04:00
|
|
|
return;
|
|
|
|
}
|
2011-11-20 14:38:37 -05:00
|
|
|
|
2014-06-17 08:08:07 -04:00
|
|
|
/* define a rectangular boundary for scrolling. If the mouse moves
|
|
|
|
* outside of this area and/or continue to be outside of this area,
|
|
|
|
* then we will continuously auto-scroll the canvas in the appropriate
|
|
|
|
* direction(s)
|
|
|
|
*
|
|
|
|
* the boundary is defined in coordinates relative to the toplevel
|
|
|
|
* window since that is what we're going to call ::get_pointer() on
|
|
|
|
* during autoscrolling to determine if we're still outside the
|
|
|
|
* boundary or not.
|
|
|
|
*/
|
|
|
|
|
2014-03-21 09:41:47 -04:00
|
|
|
ArdourCanvas::Rect scrolling_boundary;
|
|
|
|
Gtk::Allocation alloc;
|
2014-06-17 08:08:07 -04:00
|
|
|
|
2014-03-21 09:41:47 -04:00
|
|
|
if (from_headers) {
|
|
|
|
alloc = controls_layout.get_allocation ();
|
2017-02-09 10:27:16 -05:00
|
|
|
|
|
|
|
int wx, wy;
|
|
|
|
|
|
|
|
controls_layout.get_parent()->translate_coordinates (*toplevel,
|
|
|
|
alloc.get_x(), alloc.get_y(),
|
2019-04-13 11:48:27 -04:00
|
|
|
wx, wy);
|
2017-02-09 10:27:16 -05:00
|
|
|
|
|
|
|
scrolling_boundary = ArdourCanvas::Rect (wx, wy, wx + alloc.get_width(), wy + alloc.get_height());
|
|
|
|
|
|
|
|
|
2015-10-05 10:17:49 -04:00
|
|
|
} else {
|
2014-03-21 09:41:47 -04:00
|
|
|
alloc = _track_canvas_viewport->get_allocation ();
|
2014-06-17 08:08:07 -04:00
|
|
|
|
|
|
|
/* reduce height by the height of the timebars, which happens
|
|
|
|
to correspond to the position of the hv_scroll_group.
|
|
|
|
*/
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-06-17 08:08:07 -04:00
|
|
|
alloc.set_height (alloc.get_height() - hv_scroll_group->position().y);
|
|
|
|
alloc.set_y (alloc.get_y() + hv_scroll_group->position().y);
|
|
|
|
|
|
|
|
/* now reduce it again so that we start autoscrolling before we
|
|
|
|
* move off the top or bottom of the canvas
|
|
|
|
*/
|
|
|
|
|
|
|
|
alloc.set_height (alloc.get_height() - 20);
|
|
|
|
alloc.set_y (alloc.get_y() + 10);
|
|
|
|
|
2014-03-21 09:41:47 -04:00
|
|
|
/* the effective width of the autoscroll boundary so
|
|
|
|
that we start scrolling before we hit the edge.
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-03-21 09:41:47 -04:00
|
|
|
this helps when the window is slammed up against the
|
|
|
|
right edge of the screen, making it hard to scroll
|
|
|
|
effectively.
|
|
|
|
*/
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
if (alloc.get_width() > 20) {
|
2014-03-21 09:41:47 -04:00
|
|
|
alloc.set_width (alloc.get_width() - 20);
|
|
|
|
alloc.set_x (alloc.get_x() + 10);
|
2015-10-04 14:51:05 -04:00
|
|
|
}
|
2014-06-17 08:08:07 -04:00
|
|
|
|
2017-02-09 10:27:16 -05:00
|
|
|
int wx, wy;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2017-02-09 10:27:16 -05:00
|
|
|
_track_canvas_viewport->get_parent()->translate_coordinates (*toplevel,
|
|
|
|
alloc.get_x(), alloc.get_y(),
|
2017-07-01 12:42:24 -04:00
|
|
|
wx, wy);
|
2017-02-09 10:27:16 -05:00
|
|
|
|
|
|
|
scrolling_boundary = ArdourCanvas::Rect (wx, wy, wx + alloc.get_width(), wy + alloc.get_height());
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
int x, y;
|
|
|
|
Gdk::ModifierType mask;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2015-07-07 22:12:21 -04:00
|
|
|
toplevel->get_window()->get_pointer (x, y, mask);
|
2006-05-25 16:30:32 -04:00
|
|
|
|
2017-09-18 12:39:17 -04:00
|
|
|
if ((allow_horiz && ((x < scrolling_boundary.x0 && _leftmost_sample > 0) || x >= scrolling_boundary.x1)) ||
|
2014-06-13 18:43:16 -04:00
|
|
|
(allow_vert && ((y < scrolling_boundary.y0 && vertical_adjustment.get_value() > 0)|| y >= scrolling_boundary.y1))) {
|
2014-03-21 09:41:47 -04:00
|
|
|
start_canvas_autoscroll (allow_horiz, allow_vert, scrolling_boundary);
|
2014-03-20 21:59:37 -04:00
|
|
|
}
|
2006-05-25 16:30:32 -04:00
|
|
|
}
|
|
|
|
|
2019-11-08 19:35:55 -05:00
|
|
|
bool
|
|
|
|
Editor::drag_active () const
|
|
|
|
{
|
|
|
|
return _drags->active();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Editor::preview_video_drag_active () const
|
|
|
|
{
|
2019-11-08 23:03:38 -05:00
|
|
|
return _drags->preview_video ();
|
2019-11-08 19:35:55 -05:00
|
|
|
}
|
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
bool
|
|
|
|
Editor::autoscroll_active () const
|
2006-05-25 16:30:32 -04:00
|
|
|
{
|
2014-03-20 13:29:29 -04:00
|
|
|
return autoscroll_connection.connected ();
|
2006-05-25 16:30:32 -04:00
|
|
|
}
|
|
|
|
|
2020-09-26 11:14:59 -04:00
|
|
|
std::pair <timepos_t,timepos_t>
|
2018-02-24 07:54:15 -05:00
|
|
|
Editor::session_gui_extents (bool use_extra) const
|
2017-08-26 22:00:45 -04:00
|
|
|
{
|
2017-08-26 23:44:48 -04:00
|
|
|
if (!_session) {
|
2020-12-03 23:34:48 -05:00
|
|
|
return std::make_pair (timepos_t::max (Temporal::AudioTime), timepos_t (Temporal::AudioTime));
|
2017-08-26 23:44:48 -04:00
|
|
|
}
|
2018-02-24 07:54:15 -05:00
|
|
|
|
2020-09-26 11:14:59 -04:00
|
|
|
timepos_t session_extent_start (_session->current_start_sample());
|
|
|
|
timepos_t session_extent_end (_session->current_end_sample());
|
2017-08-26 22:00:45 -04:00
|
|
|
|
2018-02-24 07:54:15 -05:00
|
|
|
/* calculate the extents of all regions in every playlist
|
|
|
|
* NOTE: we should listen to playlists, and cache these values so we don't calculate them every time.
|
|
|
|
*/
|
2017-08-26 22:00:45 -04:00
|
|
|
{
|
|
|
|
boost::shared_ptr<RouteList> rl = _session->get_routes();
|
|
|
|
for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
|
|
|
|
boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (*r);
|
2020-09-26 11:14:59 -04:00
|
|
|
|
2021-01-05 17:23:22 -05:00
|
|
|
if (!tr) {
|
|
|
|
continue;
|
2017-08-26 22:00:45 -04:00
|
|
|
}
|
2021-01-05 17:23:22 -05:00
|
|
|
if (tr->presentation_info ().hidden ()) {
|
|
|
|
continue;
|
|
|
|
}
|
2020-09-26 11:14:59 -04:00
|
|
|
pair<timepos_t, timepos_t> e = tr->playlist()->get_extent ();
|
2021-01-05 17:23:22 -05:00
|
|
|
if (e.first == e.second) {
|
|
|
|
/* no regions present */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
session_extent_start = std::min (session_extent_start, e.first);
|
|
|
|
session_extent_end = std::max (session_extent_end, e.second);
|
2017-08-26 22:00:45 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-24 07:54:15 -05:00
|
|
|
/* ToDo: also incorporate automation regions (in case the session has no audio/midi but is just used for automating plugins or the like) */
|
2017-08-26 22:00:45 -04:00
|
|
|
|
2018-02-24 07:54:15 -05:00
|
|
|
/* add additional time to the ui extents (user-defined in config) */
|
2017-08-27 00:06:29 -04:00
|
|
|
if (use_extra) {
|
2020-12-02 00:33:09 -05:00
|
|
|
timecnt_t const extra ((samplepos_t) (UIConfiguration::instance().get_extra_ui_extents_time() * 60 * _session->nominal_sample_rate()));
|
|
|
|
session_extent_end += timepos_t (extra);
|
2020-09-26 11:14:59 -04:00
|
|
|
session_extent_start.shift_earlier (extra);
|
2017-08-27 00:06:29 -04:00
|
|
|
}
|
2018-02-24 07:54:15 -05:00
|
|
|
|
|
|
|
/* range-check */
|
2020-09-26 11:14:59 -04:00
|
|
|
if (session_extent_end >= timepos_t::max (Temporal::AudioTime)) {
|
|
|
|
session_extent_end = timepos_t::max (Temporal::AudioTime);
|
2017-08-26 23:44:48 -04:00
|
|
|
}
|
2021-12-11 09:51:31 -05:00
|
|
|
if (session_extent_start.is_negative()) {
|
2020-09-26 11:14:59 -04:00
|
|
|
session_extent_start = timepos_t (0);
|
2017-08-26 23:44:48 -04:00
|
|
|
}
|
2018-02-24 07:54:15 -05:00
|
|
|
|
2020-09-26 11:14:59 -04:00
|
|
|
return std::make_pair (session_extent_start, session_extent_end);
|
2017-08-26 22:00:45 -04:00
|
|
|
}
|
|
|
|
|
2006-09-18 23:29:16 -04:00
|
|
|
bool
|
2006-05-25 16:30:32 -04:00
|
|
|
Editor::autoscroll_canvas ()
|
|
|
|
{
|
2014-03-20 13:29:29 -04:00
|
|
|
int x, y;
|
|
|
|
Gdk::ModifierType mask;
|
2017-09-18 12:39:17 -04:00
|
|
|
sampleoffset_t dx = 0;
|
2014-03-20 13:29:29 -04:00
|
|
|
bool no_stop = false;
|
2015-07-07 22:12:21 -04:00
|
|
|
Gtk::Window* toplevel = dynamic_cast<Gtk::Window*>(contents().get_toplevel());
|
2014-03-20 13:29:29 -04:00
|
|
|
|
2015-07-07 22:12:21 -04:00
|
|
|
if (!toplevel) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
toplevel->get_window()->get_pointer (x, y, mask);
|
2014-03-20 13:29:29 -04:00
|
|
|
|
|
|
|
VisualChange vc;
|
2014-06-17 08:08:07 -04:00
|
|
|
bool vertical_motion = false;
|
2014-03-20 13:29:29 -04:00
|
|
|
|
|
|
|
if (autoscroll_horizontal_allowed) {
|
|
|
|
|
2017-09-18 12:39:17 -04:00
|
|
|
samplepos_t new_sample = _leftmost_sample;
|
2013-07-10 19:10:06 -04:00
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
/* horizontal */
|
2010-01-05 20:14:56 -05:00
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
if (x > autoscroll_boundary.x1) {
|
|
|
|
|
|
|
|
/* bring it back into view */
|
|
|
|
dx = x - autoscroll_boundary.x1;
|
|
|
|
dx += 10 + (2 * (autoscroll_cnt/2));
|
|
|
|
|
|
|
|
dx = pixel_to_sample (dx);
|
2018-02-24 07:54:15 -05:00
|
|
|
|
2017-08-26 23:19:04 -04:00
|
|
|
dx *= UIConfiguration::instance().get_draggable_playhead_speed();
|
2014-03-20 13:29:29 -04:00
|
|
|
|
2017-09-18 12:39:17 -04:00
|
|
|
if (_leftmost_sample < max_samplepos - dx) {
|
|
|
|
new_sample = _leftmost_sample + dx;
|
2014-03-20 13:29:29 -04:00
|
|
|
} else {
|
2017-09-18 12:39:17 -04:00
|
|
|
new_sample = max_samplepos;
|
2011-11-20 14:38:37 -05:00
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
no_stop = true;
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
} else if (x < autoscroll_boundary.x0) {
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
dx = autoscroll_boundary.x0 - x;
|
|
|
|
dx += 10 + (2 * (autoscroll_cnt/2));
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
dx = pixel_to_sample (dx);
|
|
|
|
|
2017-08-26 23:19:04 -04:00
|
|
|
dx *= UIConfiguration::instance().get_draggable_playhead_speed();
|
2017-08-26 22:00:45 -04:00
|
|
|
|
2017-09-18 12:39:17 -04:00
|
|
|
if (_leftmost_sample >= dx) {
|
|
|
|
new_sample = _leftmost_sample - dx;
|
2014-03-20 13:29:29 -04:00
|
|
|
} else {
|
2017-09-18 12:39:17 -04:00
|
|
|
new_sample = 0;
|
2014-03-20 13:29:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
no_stop = true;
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2017-09-18 12:39:17 -04:00
|
|
|
if (new_sample != _leftmost_sample) {
|
|
|
|
vc.time_origin = new_sample;
|
2014-03-20 13:29:29 -04:00
|
|
|
vc.add (VisualChange::TimeOrigin);
|
2008-12-12 09:43:24 -05:00
|
|
|
}
|
2008-10-04 06:38:20 -04:00
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
if (autoscroll_vertical_allowed) {
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-06-12 01:06:25 -04:00
|
|
|
// const double vertical_pos = vertical_adjustment.get_value();
|
2014-06-17 08:08:07 -04:00
|
|
|
const int speed_factor = 10;
|
2014-03-20 13:29:29 -04:00
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
/* vertical */
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
if (y < autoscroll_boundary.y0) {
|
|
|
|
|
|
|
|
/* scroll to make higher tracks visible */
|
|
|
|
|
2014-03-20 21:59:37 -04:00
|
|
|
if (autoscroll_cnt && (autoscroll_cnt % speed_factor == 0)) {
|
2014-08-31 17:45:20 -04:00
|
|
|
scroll_up_one_track ();
|
2014-06-17 08:08:07 -04:00
|
|
|
vertical_motion = true;
|
2014-03-20 13:29:29 -04:00
|
|
|
}
|
2016-03-19 09:40:27 -04:00
|
|
|
no_stop = true;
|
2014-03-20 13:29:29 -04:00
|
|
|
|
|
|
|
} else if (y > autoscroll_boundary.y1) {
|
|
|
|
|
2014-03-20 21:59:37 -04:00
|
|
|
if (autoscroll_cnt && (autoscroll_cnt % speed_factor == 0)) {
|
2014-08-31 17:45:20 -04:00
|
|
|
scroll_down_one_track ();
|
2014-06-17 08:08:07 -04:00
|
|
|
vertical_motion = true;
|
2014-03-20 21:59:37 -04:00
|
|
|
}
|
2016-03-19 09:40:27 -04:00
|
|
|
no_stop = true;
|
2008-04-11 10:06:50 -04:00
|
|
|
}
|
2014-03-20 21:59:37 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
}
|
|
|
|
|
2014-06-17 08:08:07 -04:00
|
|
|
if (vc.pending || vertical_motion) {
|
2008-04-11 10:06:50 -04:00
|
|
|
|
2014-03-20 21:59:37 -04:00
|
|
|
/* change horizontal first */
|
2008-04-11 10:06:50 -04:00
|
|
|
|
2014-03-21 09:41:47 -04:00
|
|
|
if (vc.pending) {
|
|
|
|
visual_changer (vc);
|
|
|
|
}
|
2008-04-11 10:06:50 -04:00
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
/* now send a motion event to notify anyone who cares
|
|
|
|
that we have moved to a new location (because we scrolled)
|
|
|
|
*/
|
2008-04-11 10:06:50 -04:00
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
GdkEventMotion ev;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
ev.type = GDK_MOTION_NOTIFY;
|
|
|
|
ev.state = Gdk::BUTTON1_MASK;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
/* the motion handler expects events in canvas coordinate space */
|
2006-05-25 16:30:32 -04:00
|
|
|
|
2014-06-17 08:08:07 -04:00
|
|
|
/* we asked for the mouse position above (::get_pointer()) via
|
2015-10-04 14:51:05 -04:00
|
|
|
* our own top level window (we being the Editor). Convert into
|
2014-06-17 08:08:07 -04:00
|
|
|
* coordinates within the canvas window.
|
2014-03-20 13:29:29 -04:00
|
|
|
*/
|
2006-05-25 16:30:32 -04:00
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
int cx;
|
|
|
|
int cy;
|
2008-09-10 17:27:39 -04:00
|
|
|
|
2015-07-07 22:12:21 -04:00
|
|
|
toplevel->translate_coordinates (*_track_canvas, x, y, cx, cy);
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2014-06-17 08:08:07 -04:00
|
|
|
/* clamp x and y to remain within the autoscroll boundary,
|
|
|
|
* which is defined in window coordinates
|
|
|
|
*/
|
2008-09-10 17:27:39 -04:00
|
|
|
|
2014-06-17 08:08:07 -04:00
|
|
|
x = min (max ((ArdourCanvas::Coord) cx, autoscroll_boundary.x0), autoscroll_boundary.x1);
|
|
|
|
y = min (max ((ArdourCanvas::Coord) cy, autoscroll_boundary.y0), autoscroll_boundary.y1);
|
|
|
|
|
|
|
|
/* now convert from Editor window coordinates to canvas
|
|
|
|
* window coordinates
|
|
|
|
*/
|
2013-04-15 13:50:05 -04:00
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
ArdourCanvas::Duple d = _track_canvas->window_to_canvas (ArdourCanvas::Duple (cx, cy));
|
|
|
|
ev.x = d.x;
|
|
|
|
ev.y = d.y;
|
2015-12-06 06:33:32 -05:00
|
|
|
ev.state = mask;
|
2008-09-10 17:27:39 -04:00
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
motion_handler (0, (GdkEvent*) &ev, true);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
} else if (no_stop) {
|
2006-05-25 16:30:32 -04:00
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
/* not changing visual state but pointer is outside the scrolling boundary
|
2015-10-04 14:51:05 -04:00
|
|
|
* so we still need to deliver a fake motion event
|
2014-03-20 13:29:29 -04:00
|
|
|
*/
|
2006-05-25 16:30:32 -04:00
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
GdkEventMotion ev;
|
2006-05-25 16:30:32 -04:00
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
ev.type = GDK_MOTION_NOTIFY;
|
|
|
|
ev.state = Gdk::BUTTON1_MASK;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
/* the motion handler expects events in canvas coordinate space */
|
|
|
|
|
|
|
|
/* first convert from Editor window coordinates to canvas
|
|
|
|
* window coordinates
|
|
|
|
*/
|
|
|
|
|
|
|
|
int cx;
|
|
|
|
int cy;
|
|
|
|
|
2014-03-21 09:41:47 -04:00
|
|
|
/* clamp x and y to remain within the visible area. except
|
|
|
|
* .. if horizontal scrolling is allowed, always allow us to
|
|
|
|
* move back to zero
|
|
|
|
*/
|
2014-03-20 13:29:29 -04:00
|
|
|
|
2014-03-21 09:41:47 -04:00
|
|
|
if (autoscroll_horizontal_allowed) {
|
|
|
|
x = min (max ((ArdourCanvas::Coord) x, 0.0), autoscroll_boundary.x1);
|
|
|
|
} else {
|
|
|
|
x = min (max ((ArdourCanvas::Coord) x, autoscroll_boundary.x0), autoscroll_boundary.x1);
|
|
|
|
}
|
2014-03-20 13:29:29 -04:00
|
|
|
y = min (max ((ArdourCanvas::Coord) y, autoscroll_boundary.y0), autoscroll_boundary.y1);
|
2015-10-26 14:35:06 -04:00
|
|
|
|
2015-07-07 22:12:21 -04:00
|
|
|
toplevel->translate_coordinates (*_track_canvas_viewport, x, y, cx, cy);
|
2014-03-20 13:29:29 -04:00
|
|
|
|
|
|
|
ArdourCanvas::Duple d = _track_canvas->window_to_canvas (ArdourCanvas::Duple (cx, cy));
|
|
|
|
ev.x = d.x;
|
|
|
|
ev.y = d.y;
|
2015-12-06 06:33:32 -05:00
|
|
|
ev.state = mask;
|
2006-09-18 23:29:16 -04:00
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
motion_handler (0, (GdkEvent*) &ev, true);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
} else {
|
|
|
|
stop_canvas_autoscroll ();
|
|
|
|
return false;
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2006-05-25 16:30:32 -04:00
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
autoscroll_cnt++;
|
|
|
|
|
|
|
|
return true; /* call me again */
|
2015-10-05 10:17:49 -04:00
|
|
|
}
|
2006-05-25 16:30:32 -04:00
|
|
|
|
|
|
|
void
|
2014-03-21 09:41:47 -04:00
|
|
|
Editor::start_canvas_autoscroll (bool allow_horiz, bool allow_vert, const ArdourCanvas::Rect& boundary)
|
2006-05-25 16:30:32 -04:00
|
|
|
{
|
2014-03-20 13:29:29 -04:00
|
|
|
if (!_session) {
|
2006-05-25 16:30:32 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
stop_canvas_autoscroll ();
|
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
autoscroll_horizontal_allowed = allow_horiz;
|
|
|
|
autoscroll_vertical_allowed = allow_vert;
|
2014-03-21 09:41:47 -04:00
|
|
|
autoscroll_boundary = boundary;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
/* do the first scroll right now
|
|
|
|
*/
|
2006-09-18 23:29:16 -04:00
|
|
|
|
2006-05-25 16:30:32 -04:00
|
|
|
autoscroll_canvas ();
|
2014-03-20 13:29:29 -04:00
|
|
|
|
|
|
|
/* scroll again at very very roughly 30FPS */
|
|
|
|
|
|
|
|
autoscroll_connection = Glib::signal_timeout().connect (sigc::mem_fun (*this, &Editor::autoscroll_canvas), 30);
|
2006-05-25 16:30:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::stop_canvas_autoscroll ()
|
|
|
|
{
|
2014-03-20 13:29:29 -04:00
|
|
|
autoscroll_connection.disconnect ();
|
2016-03-19 09:40:27 -04:00
|
|
|
autoscroll_cnt = 0;
|
2006-05-25 16:30:32 -04:00
|
|
|
}
|
|
|
|
|
2014-12-23 13:46:53 -05:00
|
|
|
Editor::EnterContext*
|
|
|
|
Editor::get_enter_context(ItemType type)
|
|
|
|
{
|
|
|
|
for (ssize_t i = _enter_stack.size() - 1; i >= 0; --i) {
|
|
|
|
if (_enter_stack[i].item_type == type) {
|
|
|
|
return &_enter_stack[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
bool
|
2017-02-15 13:00:28 -05:00
|
|
|
Editor::left_track_canvas (GdkEventCrossing* ev)
|
2006-05-25 16:30:32 -04:00
|
|
|
{
|
2017-02-15 13:00:28 -05:00
|
|
|
const bool was_within = within_track_canvas;
|
2010-11-25 15:37:39 -05:00
|
|
|
DropDownKeys ();
|
2012-03-09 12:15:25 -05:00
|
|
|
within_track_canvas = false;
|
2009-07-09 13:58:13 -04:00
|
|
|
set_entered_track (0);
|
2006-05-25 16:30:32 -04:00
|
|
|
set_entered_regionview (0);
|
2008-04-11 10:06:50 -04:00
|
|
|
reset_canvas_action_sensitivity (false);
|
2017-02-15 13:00:28 -05:00
|
|
|
|
|
|
|
if (was_within) {
|
|
|
|
if (ev->detail == GDK_NOTIFY_NONLINEAR ||
|
|
|
|
ev->detail == GDK_NOTIFY_NONLINEAR_VIRTUAL) {
|
|
|
|
/* context menu or something similar */
|
2017-02-15 13:50:51 -05:00
|
|
|
sensitize_the_right_region_actions (false);
|
2017-02-15 13:00:28 -05:00
|
|
|
} else {
|
2017-02-15 13:50:51 -05:00
|
|
|
sensitize_the_right_region_actions (true);
|
2017-02-15 13:00:28 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2017-02-15 13:00:28 -05:00
|
|
|
Editor::entered_track_canvas (GdkEventCrossing* ev)
|
2008-04-11 10:06:50 -04:00
|
|
|
{
|
2017-02-15 13:00:28 -05:00
|
|
|
const bool was_within = within_track_canvas;
|
2012-03-12 09:40:51 -04:00
|
|
|
within_track_canvas = true;
|
2008-04-11 10:06:50 -04:00
|
|
|
reset_canvas_action_sensitivity (true);
|
2017-02-15 13:00:28 -05:00
|
|
|
|
|
|
|
if (!was_within) {
|
2020-04-17 13:34:34 -04:00
|
|
|
|
|
|
|
if (internal_editing()) {
|
|
|
|
/* ensure that key events go here because there are
|
|
|
|
internal editing bindings associated only with the
|
|
|
|
canvas. if the focus is elsewhere, we cannot find them.
|
|
|
|
*/
|
|
|
|
_track_canvas->grab_focus ();
|
|
|
|
}
|
|
|
|
|
2017-02-15 13:00:28 -05:00
|
|
|
if (ev->detail == GDK_NOTIFY_NONLINEAR ||
|
|
|
|
ev->detail == GDK_NOTIFY_NONLINEAR_VIRTUAL) {
|
|
|
|
/* context menu or something similar */
|
2017-02-15 13:50:51 -05:00
|
|
|
sensitize_the_right_region_actions (false);
|
2017-02-15 13:00:28 -05:00
|
|
|
} else {
|
2017-02-15 13:50:51 -05:00
|
|
|
sensitize_the_right_region_actions (true);
|
2017-02-15 13:00:28 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2006-05-25 16:30:32 -04:00
|
|
|
}
|
|
|
|
|
2011-07-25 16:28:51 -04:00
|
|
|
void
|
2014-07-14 12:36:44 -04:00
|
|
|
Editor::ensure_time_axis_view_is_visible (TimeAxisView const & track, bool at_top)
|
2011-07-25 16:28:51 -04:00
|
|
|
{
|
2014-06-27 10:49:05 -04:00
|
|
|
if (track.hidden()) {
|
|
|
|
return;
|
2011-07-25 16:28:51 -04:00
|
|
|
}
|
2014-03-24 19:46:45 -04:00
|
|
|
|
2014-06-27 10:49:05 -04:00
|
|
|
/* compute visible area of trackview group, as offsets from top of
|
|
|
|
* trackview group.
|
2014-03-24 19:46:45 -04:00
|
|
|
*/
|
2014-06-27 10:49:05 -04:00
|
|
|
|
|
|
|
double const current_view_min_y = vertical_adjustment.get_value();
|
|
|
|
double const current_view_max_y = current_view_min_y + vertical_adjustment.get_page_size();
|
|
|
|
|
|
|
|
double const track_min_y = track.y_position ();
|
|
|
|
double const track_max_y = track.y_position () + track.effective_height ();
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
if (!at_top &&
|
2014-07-14 12:36:44 -04:00
|
|
|
(track_min_y >= current_view_min_y &&
|
|
|
|
track_max_y < current_view_max_y)) {
|
|
|
|
/* already visible, and caller did not ask to place it at the
|
|
|
|
* top of the track canvas
|
|
|
|
*/
|
2014-06-27 10:49:05 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
double new_value;
|
|
|
|
|
2014-07-14 12:36:44 -04:00
|
|
|
if (at_top) {
|
2014-06-27 10:49:05 -04:00
|
|
|
new_value = track_min_y;
|
|
|
|
} else {
|
2014-07-14 12:36:44 -04:00
|
|
|
if (track_min_y < current_view_min_y) {
|
|
|
|
// Track is above the current view
|
|
|
|
new_value = track_min_y;
|
|
|
|
} else if (track_max_y > current_view_max_y) {
|
|
|
|
// Track is below the current view
|
|
|
|
new_value = track.y_position () + track.effective_height() - vertical_adjustment.get_page_size();
|
|
|
|
} else {
|
|
|
|
new_value = track_min_y;
|
|
|
|
}
|
2014-03-24 19:46:45 -04:00
|
|
|
}
|
|
|
|
|
2014-06-27 10:49:05 -04:00
|
|
|
vertical_adjustment.set_value(new_value);
|
2011-07-25 16:28:51 -04:00
|
|
|
}
|
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
/** Called when the main vertical_adjustment has changed */
|
2008-01-12 18:45:50 -05:00
|
|
|
void
|
|
|
|
Editor::tie_vertical_scrolling ()
|
|
|
|
{
|
2009-06-13 13:52:51 -04:00
|
|
|
if (pending_visual_change.idle_handler_id < 0) {
|
2020-12-19 10:44:16 -05:00
|
|
|
_region_peak_cursor->hide ();
|
2009-06-16 20:29:56 -04:00
|
|
|
_summary->set_overlays_dirty ();
|
2009-06-13 13:52:51 -04:00
|
|
|
}
|
2008-09-10 17:27:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-05-08 21:33:11 -04:00
|
|
|
Editor::set_horizontal_position (double p)
|
2008-09-10 17:27:39 -04:00
|
|
|
{
|
2013-04-13 07:29:49 -04:00
|
|
|
horizontal_adjustment.set_value (p);
|
2008-09-10 17:27:39 -04:00
|
|
|
|
2017-09-18 12:39:17 -04:00
|
|
|
_leftmost_sample = (samplepos_t) floor (p * samples_per_pixel);
|
2008-09-10 17:27:39 -04:00
|
|
|
}
|
|
|
|
|
2007-06-15 18:08:27 -04:00
|
|
|
void
|
|
|
|
Editor::color_handler()
|
|
|
|
{
|
2017-07-17 12:34:35 -04:00
|
|
|
Gtkmm2ext::Color base = UIConfiguration::instance().color ("ruler base");
|
|
|
|
Gtkmm2ext::Color text = UIConfiguration::instance().color ("ruler text");
|
2014-06-12 01:06:25 -04:00
|
|
|
timecode_ruler->set_fill_color (base);
|
|
|
|
timecode_ruler->set_outline_color (text);
|
|
|
|
minsec_ruler->set_fill_color (base);
|
|
|
|
minsec_ruler->set_outline_color (text);
|
|
|
|
samples_ruler->set_fill_color (base);
|
|
|
|
samples_ruler->set_outline_color (text);
|
|
|
|
bbt_ruler->set_fill_color (base);
|
|
|
|
bbt_ruler->set_outline_color (text);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2021-01-05 15:58:28 -05:00
|
|
|
_playhead_cursor->set_color (UIConfiguration::instance().color ("play head"));
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
meter_bar->set_fill_color (UIConfiguration::instance().color_mod ("meter bar", "marker bar"));
|
|
|
|
meter_bar->set_outline_color (UIConfiguration::instance().color ("marker bar separator"));
|
2007-06-15 18:08:27 -04:00
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
tempo_bar->set_fill_color (UIConfiguration::instance().color_mod ("tempo bar", "marker bar"));
|
|
|
|
tempo_bar->set_outline_color (UIConfiguration::instance().color ("marker bar separator"));
|
2007-06-15 18:08:27 -04:00
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
marker_bar->set_fill_color (UIConfiguration::instance().color_mod ("marker bar", "marker bar"));
|
|
|
|
marker_bar->set_outline_color (UIConfiguration::instance().color ("marker bar separator"));
|
2007-06-15 18:08:27 -04:00
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
cd_marker_bar->set_fill_color (UIConfiguration::instance().color_mod ("cd marker bar", "marker bar"));
|
|
|
|
cd_marker_bar->set_outline_color (UIConfiguration::instance().color ("marker bar separator"));
|
2013-03-12 17:00:09 -04:00
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
range_marker_bar->set_fill_color (UIConfiguration::instance().color_mod ("range marker bar", "marker bar"));
|
|
|
|
range_marker_bar->set_outline_color (UIConfiguration::instance().color ("marker bar separator"));
|
2007-06-15 18:08:27 -04:00
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
transport_marker_bar->set_fill_color (UIConfiguration::instance().color_mod ("transport marker bar", "marker bar"));
|
|
|
|
transport_marker_bar->set_outline_color (UIConfiguration::instance().color ("marker bar separator"));
|
2007-06-15 18:08:27 -04:00
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
cd_marker_bar_drag_rect->set_fill_color (UIConfiguration::instance().color ("range drag bar rect"));
|
|
|
|
cd_marker_bar_drag_rect->set_outline_color (UIConfiguration::instance().color ("range drag bar rect"));
|
2008-02-16 17:43:18 -05:00
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
range_bar_drag_rect->set_fill_color (UIConfiguration::instance().color ("range drag bar rect"));
|
|
|
|
range_bar_drag_rect->set_outline_color (UIConfiguration::instance().color ("range drag bar rect"));
|
2007-06-15 18:08:27 -04:00
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
transport_bar_drag_rect->set_fill_color (UIConfiguration::instance().color ("transport drag rect"));
|
|
|
|
transport_bar_drag_rect->set_outline_color (UIConfiguration::instance().color ("transport drag rect"));
|
2007-06-15 18:08:27 -04:00
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
transport_loop_range_rect->set_fill_color (UIConfiguration::instance().color_mod ("transport loop rect", "loop rectangle"));
|
|
|
|
transport_loop_range_rect->set_outline_color (UIConfiguration::instance().color ("transport loop rect"));
|
2007-06-15 18:08:27 -04:00
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
transport_punch_range_rect->set_fill_color (UIConfiguration::instance().color ("transport punch rect"));
|
|
|
|
transport_punch_range_rect->set_outline_color (UIConfiguration::instance().color ("transport punch rect"));
|
2007-06-15 18:08:27 -04:00
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
transport_punchin_line->set_outline_color (UIConfiguration::instance().color ("punch line"));
|
|
|
|
transport_punchout_line->set_outline_color (UIConfiguration::instance().color ("punch line"));
|
2007-06-15 18:08:27 -04:00
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
rubberband_rect->set_outline_color (UIConfiguration::instance().color ("rubber band rect"));
|
|
|
|
rubberband_rect->set_fill_color (UIConfiguration::instance().color_mod ("rubber band rect", "selection rect"));
|
2007-06-15 18:08:27 -04:00
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
location_marker_color = UIConfiguration::instance().color ("location marker");
|
|
|
|
location_range_color = UIConfiguration::instance().color ("location range");
|
|
|
|
location_cd_marker_color = UIConfiguration::instance().color ("location cd marker");
|
|
|
|
location_loop_color = UIConfiguration::instance().color ("location loop");
|
|
|
|
location_punch_color = UIConfiguration::instance().color ("location punch");
|
2007-06-15 18:08:27 -04:00
|
|
|
|
|
|
|
refresh_location_display ();
|
2014-11-10 10:40:27 -05:00
|
|
|
|
2016-10-16 12:19:02 -04:00
|
|
|
NoteBase::set_colors ();
|
|
|
|
|
2015-01-07 01:23:13 -05:00
|
|
|
/* redraw the whole thing */
|
2015-01-02 09:44:54 -05:00
|
|
|
_track_canvas->set_background_color (UIConfiguration::instance().color ("arrange base"));
|
2015-01-07 01:23:13 -05:00
|
|
|
_track_canvas->queue_draw ();
|
2015-10-04 14:51:05 -04:00
|
|
|
|
2008-10-04 06:38:20 -04:00
|
|
|
/*
|
2018-02-09 10:59:39 -05:00
|
|
|
redisplay_grid (true);
|
2007-06-15 18:08:27 -04:00
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
if (_session)
|
|
|
|
_session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks); // redraw metric markers
|
2008-10-04 06:38:20 -04:00
|
|
|
*/
|
2007-06-15 18:08:27 -04:00
|
|
|
}
|
|
|
|
|
2010-05-09 16:48:21 -04:00
|
|
|
double
|
|
|
|
Editor::horizontal_position () const
|
|
|
|
{
|
2017-09-18 12:39:17 -04:00
|
|
|
return sample_to_pixel (_leftmost_sample);
|
2010-05-09 16:48:21 -04:00
|
|
|
}
|
2012-01-19 17:23:28 -05:00
|
|
|
|
2014-06-18 10:24:59 -04:00
|
|
|
bool
|
|
|
|
Editor::track_canvas_key_press (GdkEventKey*)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Editor::track_canvas_key_release (GdkEventKey*)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
double
|
|
|
|
Editor::clamp_verbose_cursor_x (double x)
|
|
|
|
{
|
|
|
|
if (x < 0) {
|
|
|
|
x = 0;
|
|
|
|
} else {
|
|
|
|
x = min (_visible_canvas_width - 200.0, x);
|
|
|
|
}
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
|
|
|
double
|
|
|
|
Editor::clamp_verbose_cursor_y (double y)
|
|
|
|
{
|
|
|
|
y = max (0.0, y);
|
|
|
|
y = min (_visible_canvas_height - 50, y);
|
|
|
|
return y;
|
|
|
|
}
|
|
|
|
|
|
|
|
ArdourCanvas::GtkCanvasViewport*
|
|
|
|
Editor::get_track_canvas() const
|
|
|
|
{
|
|
|
|
return _track_canvas_viewport;
|
|
|
|
}
|
|
|
|
|
2014-12-20 01:11:28 -05:00
|
|
|
Gdk::Cursor*
|
|
|
|
Editor::get_canvas_cursor () const
|
2010-09-21 11:15:06 -04:00
|
|
|
{
|
2014-12-20 01:11:28 -05:00
|
|
|
/* The top of the cursor stack is always the currently visible cursor. */
|
|
|
|
return _cursor_stack.back();
|
|
|
|
}
|
2010-09-22 11:21:06 -04:00
|
|
|
|
2014-12-20 01:11:28 -05:00
|
|
|
void
|
|
|
|
Editor::set_canvas_cursor (Gdk::Cursor* cursor)
|
|
|
|
{
|
2013-04-04 18:45:27 -04:00
|
|
|
Glib::RefPtr<Gdk::Window> win = _track_canvas->get_window();
|
2012-01-19 17:23:28 -05:00
|
|
|
|
2015-01-23 15:15:29 -05:00
|
|
|
if (win && !_cursors->is_invalid (cursor)) {
|
2015-01-24 12:26:58 -05:00
|
|
|
/* glibmm 2.4 doesn't allow null cursor pointer because it uses
|
|
|
|
a Gdk::Cursor& as the argument to Gdk::Window::set_cursor().
|
|
|
|
But a null pointer just means "use parent window cursor",
|
|
|
|
and so should be allowed. Gtkmm 3.x has fixed this API.
|
|
|
|
|
|
|
|
For now, drop down and use C API
|
|
|
|
*/
|
|
|
|
gdk_window_set_cursor (win->gobj(), cursor ? cursor->gobj() : 0);
|
2010-09-21 11:15:06 -04:00
|
|
|
}
|
|
|
|
}
|
2010-09-21 10:22:13 -04:00
|
|
|
|
2014-12-20 01:11:28 -05:00
|
|
|
size_t
|
2014-06-13 17:15:23 -04:00
|
|
|
Editor::push_canvas_cursor (Gdk::Cursor* cursor)
|
|
|
|
{
|
2015-01-23 15:15:29 -05:00
|
|
|
if (!_cursors->is_invalid (cursor)) {
|
2014-12-20 01:11:28 -05:00
|
|
|
_cursor_stack.push_back (cursor);
|
|
|
|
set_canvas_cursor (cursor);
|
2014-06-13 17:15:23 -04:00
|
|
|
}
|
2014-12-20 01:11:28 -05:00
|
|
|
return _cursor_stack.size() - 1;
|
2014-06-13 17:15:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::pop_canvas_cursor ()
|
|
|
|
{
|
2014-12-20 01:11:28 -05:00
|
|
|
while (true) {
|
|
|
|
if (_cursor_stack.size() <= 1) {
|
|
|
|
PBD::error << "attempt to pop default cursor" << endmsg;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_cursor_stack.pop_back();
|
|
|
|
if (_cursor_stack.back()) {
|
|
|
|
/* Popped to an existing cursor, we're done. Otherwise, the
|
|
|
|
context that created this cursor has been destroyed, so we need
|
|
|
|
to skip to the next down the stack. */
|
2014-12-23 13:36:25 -05:00
|
|
|
set_canvas_cursor (_cursor_stack.back());
|
2014-12-20 01:11:28 -05:00
|
|
|
return;
|
|
|
|
}
|
2014-06-13 17:15:23 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-18 10:24:59 -04:00
|
|
|
Gdk::Cursor*
|
|
|
|
Editor::which_trim_cursor (bool left) const
|
2010-09-21 10:22:13 -04:00
|
|
|
{
|
2014-06-18 10:24:59 -04:00
|
|
|
if (!entered_regionview) {
|
|
|
|
return 0;
|
2010-09-21 10:22:13 -04:00
|
|
|
}
|
|
|
|
|
2014-06-18 10:24:59 -04:00
|
|
|
Trimmable::CanTrim ct = entered_regionview->region()->can_trim ();
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-06-18 10:24:59 -04:00
|
|
|
if (left) {
|
|
|
|
if (ct & Trimmable::FrontTrimEarlier) {
|
|
|
|
return _cursors->left_side_trim;
|
|
|
|
} else {
|
|
|
|
return _cursors->left_side_trim_right_only;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (ct & Trimmable::EndTrimLater) {
|
|
|
|
return _cursors->right_side_trim;
|
|
|
|
} else {
|
|
|
|
return _cursors->right_side_trim_left_only;
|
|
|
|
}
|
|
|
|
}
|
2010-09-21 10:22:13 -04:00
|
|
|
}
|
2013-04-04 18:45:27 -04:00
|
|
|
|
2014-06-18 10:24:59 -04:00
|
|
|
Gdk::Cursor*
|
|
|
|
Editor::which_mode_cursor () const
|
2013-04-04 18:45:27 -04:00
|
|
|
{
|
2015-01-24 12:26:58 -05:00
|
|
|
Gdk::Cursor* mode_cursor = MouseCursors::invalid_cursor ();
|
2014-06-18 10:24:59 -04:00
|
|
|
|
|
|
|
switch (mouse_mode) {
|
|
|
|
case MouseRange:
|
|
|
|
mode_cursor = _cursors->selector;
|
|
|
|
break;
|
|
|
|
|
2014-07-07 06:27:01 -04:00
|
|
|
case MouseCut:
|
|
|
|
mode_cursor = _cursors->scissors;
|
|
|
|
break;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-06-18 10:24:59 -04:00
|
|
|
case MouseObject:
|
2014-12-08 23:00:00 -05:00
|
|
|
case MouseContent:
|
2014-06-18 10:24:59 -04:00
|
|
|
/* don't use mode cursor, pick a grabber cursor based on the item */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseDraw:
|
|
|
|
mode_cursor = _cursors->midi_pencil;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseTimeFX:
|
|
|
|
mode_cursor = _cursors->time_fx; // just use playhead
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseAudition:
|
|
|
|
mode_cursor = _cursors->speaker;
|
|
|
|
break;
|
2013-04-04 18:45:27 -04:00
|
|
|
}
|
2014-06-18 10:24:59 -04:00
|
|
|
|
|
|
|
/* up-down cursor as a cue that automation can be dragged up and down when in join object/range mode */
|
2014-12-08 23:00:00 -05:00
|
|
|
if (get_smart_mode()) {
|
2014-06-18 10:24:59 -04:00
|
|
|
|
|
|
|
double x, y;
|
|
|
|
get_pointer_position (x, y);
|
|
|
|
|
|
|
|
if (x >= 0 && y >= 0) {
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-06-18 10:24:59 -04:00
|
|
|
vector<ArdourCanvas::Item const *> items;
|
|
|
|
|
|
|
|
/* Note how we choose a specific scroll group to get
|
|
|
|
* items from. This could be problematic.
|
|
|
|
*/
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-06-18 10:24:59 -04:00
|
|
|
hv_scroll_group->add_items_at_point (ArdourCanvas::Duple (x,y), items);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
// first item will be the upper most
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-06-18 10:24:59 -04:00
|
|
|
if (!items.empty()) {
|
|
|
|
const ArdourCanvas::Item* i = items.front();
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-06-18 10:24:59 -04:00
|
|
|
if (i && i->parent() && i->parent()->get_data (X_("timeselection"))) {
|
|
|
|
pair<TimeAxisView*, int> tvp = trackview_by_y_position (_last_motion_y);
|
|
|
|
if (dynamic_cast<AutomationTimeAxisView*> (tvp.first)) {
|
|
|
|
mode_cursor = _cursors->up_down;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return mode_cursor;
|
2013-04-04 18:45:27 -04:00
|
|
|
}
|
|
|
|
|
2014-06-18 10:24:59 -04:00
|
|
|
Gdk::Cursor*
|
2014-06-18 21:03:25 -04:00
|
|
|
Editor::which_track_cursor () const
|
2013-04-04 18:45:27 -04:00
|
|
|
{
|
2015-01-24 12:26:58 -05:00
|
|
|
Gdk::Cursor* cursor = MouseCursors::invalid_cursor();
|
2014-06-18 10:24:59 -04:00
|
|
|
|
2014-12-08 23:00:00 -05:00
|
|
|
switch (_join_object_range_state) {
|
|
|
|
case JOIN_OBJECT_RANGE_NONE:
|
|
|
|
case JOIN_OBJECT_RANGE_OBJECT:
|
2018-02-09 10:59:39 -05:00
|
|
|
cursor = _cursors->grabber;
|
2014-12-08 23:00:00 -05:00
|
|
|
break;
|
|
|
|
case JOIN_OBJECT_RANGE_RANGE:
|
|
|
|
cursor = _cursors->selector;
|
|
|
|
break;
|
2014-06-18 10:24:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return cursor;
|
2013-04-04 18:45:27 -04:00
|
|
|
}
|
2013-04-15 16:10:13 -04:00
|
|
|
|
2014-12-23 13:46:53 -05:00
|
|
|
Gdk::Cursor*
|
|
|
|
Editor::which_canvas_cursor(ItemType type) const
|
2014-06-18 10:24:59 -04:00
|
|
|
{
|
2014-12-23 13:46:53 -05:00
|
|
|
Gdk::Cursor* cursor = which_mode_cursor ();
|
2014-06-18 10:24:59 -04:00
|
|
|
|
2015-06-28 01:52:49 -04:00
|
|
|
if (mouse_mode == MouseRange) {
|
|
|
|
switch (type) {
|
|
|
|
case StartSelectionTrimItem:
|
|
|
|
cursor = _cursors->left_side_trim;
|
|
|
|
break;
|
|
|
|
case EndSelectionTrimItem:
|
|
|
|
cursor = _cursors->right_side_trim;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-12-20 01:11:28 -05:00
|
|
|
if ((mouse_mode == MouseObject || get_smart_mode ()) ||
|
|
|
|
mouse_mode == MouseContent) {
|
2014-06-18 10:24:59 -04:00
|
|
|
|
|
|
|
/* find correct cursor to use in object/smart mode */
|
|
|
|
switch (type) {
|
|
|
|
case RegionItem:
|
2014-12-30 12:49:59 -05:00
|
|
|
/* We don't choose a cursor for these items on top of a region view,
|
|
|
|
because this would push a new context on the enter stack which
|
|
|
|
means switching the region context for things like smart mode
|
|
|
|
won't actualy change the cursor. */
|
|
|
|
// case WaveItem:
|
2014-06-18 21:03:25 -04:00
|
|
|
case StreamItem:
|
|
|
|
case AutomationTrackItem:
|
|
|
|
cursor = which_track_cursor ();
|
2014-06-18 10:24:59 -04:00
|
|
|
break;
|
|
|
|
case PlayheadCursorItem:
|
2018-02-09 10:59:39 -05:00
|
|
|
cursor = _cursors->grabber;
|
2014-06-18 10:24:59 -04:00
|
|
|
break;
|
|
|
|
case SelectionItem:
|
|
|
|
cursor = _cursors->selector;
|
|
|
|
break;
|
|
|
|
case ControlPointItem:
|
|
|
|
cursor = _cursors->fader;
|
|
|
|
break;
|
|
|
|
case GainLineItem:
|
2015-06-21 08:14:03 -04:00
|
|
|
cursor = _cursors->cross_hair;
|
2014-06-18 10:24:59 -04:00
|
|
|
break;
|
|
|
|
case AutomationLineItem:
|
|
|
|
cursor = _cursors->cross_hair;
|
|
|
|
break;
|
|
|
|
case StartSelectionTrimItem:
|
2014-06-18 21:03:25 -04:00
|
|
|
cursor = _cursors->left_side_trim;
|
2014-06-18 10:24:59 -04:00
|
|
|
break;
|
|
|
|
case EndSelectionTrimItem:
|
2014-06-18 21:03:25 -04:00
|
|
|
cursor = _cursors->right_side_trim;
|
2014-06-18 10:24:59 -04:00
|
|
|
break;
|
|
|
|
case FadeInItem:
|
|
|
|
cursor = _cursors->fade_in;
|
|
|
|
break;
|
|
|
|
case FadeInHandleItem:
|
|
|
|
cursor = _cursors->fade_in;
|
|
|
|
break;
|
|
|
|
case FadeInTrimHandleItem:
|
|
|
|
cursor = _cursors->fade_in;
|
|
|
|
break;
|
|
|
|
case FadeOutItem:
|
|
|
|
cursor = _cursors->fade_out;
|
|
|
|
break;
|
|
|
|
case FadeOutHandleItem:
|
|
|
|
cursor = _cursors->fade_out;
|
|
|
|
break;
|
|
|
|
case FadeOutTrimHandleItem:
|
|
|
|
cursor = _cursors->fade_out;
|
|
|
|
break;
|
|
|
|
case FeatureLineItem:
|
|
|
|
cursor = _cursors->cross_hair;
|
|
|
|
break;
|
|
|
|
case LeftFrameHandle:
|
2018-02-24 07:54:15 -05:00
|
|
|
if (effective_mouse_mode() == MouseObject) // (smart mode): if the user is in the btm half, show the trim cursor
|
2015-06-01 17:18:10 -04:00
|
|
|
cursor = which_trim_cursor (true);
|
|
|
|
else
|
2018-02-24 07:54:15 -05:00
|
|
|
cursor = _cursors->selector; // (smart mode): in the top half, just show the selection (range) cursor
|
2014-06-18 10:24:59 -04:00
|
|
|
break;
|
|
|
|
case RightFrameHandle:
|
2018-02-24 07:54:15 -05:00
|
|
|
if (effective_mouse_mode() == MouseObject) // see above
|
2014-07-07 15:46:05 -04:00
|
|
|
cursor = which_trim_cursor (false);
|
2015-06-01 17:18:10 -04:00
|
|
|
else
|
|
|
|
cursor = _cursors->selector;
|
2014-06-18 10:24:59 -04:00
|
|
|
break;
|
2019-09-26 13:44:22 -04:00
|
|
|
case RegionViewName:
|
|
|
|
case RegionViewNameHighlight:
|
|
|
|
/* the trim bar is used for trimming, but we have to determine if we are on the left or right side of the region */
|
|
|
|
cursor = MouseCursors::invalid_cursor ();
|
|
|
|
if (entered_regionview) {
|
|
|
|
samplepos_t where;
|
|
|
|
bool in_track_canvas;
|
|
|
|
if (mouse_sample (where, in_track_canvas)) {
|
|
|
|
samplepos_t start = entered_regionview->region()->first_sample();
|
|
|
|
samplepos_t end = entered_regionview->region()->last_sample();
|
|
|
|
cursor = which_trim_cursor ((where - start) < (end - where));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2014-06-18 10:24:59 -04:00
|
|
|
case StartCrossFadeItem:
|
|
|
|
cursor = _cursors->fade_in;
|
|
|
|
break;
|
|
|
|
case EndCrossFadeItem:
|
|
|
|
cursor = _cursors->fade_out;
|
|
|
|
break;
|
|
|
|
case CrossfadeViewItem:
|
|
|
|
cursor = _cursors->cross_hair;
|
|
|
|
break;
|
2014-12-23 13:46:53 -05:00
|
|
|
case NoteItem:
|
|
|
|
cursor = _cursors->grabber_note;
|
2014-06-18 10:24:59 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2014-10-21 11:50:06 -04:00
|
|
|
|
2014-12-07 19:53:46 -05:00
|
|
|
} else if (mouse_mode == MouseDraw) {
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-10-21 11:50:06 -04:00
|
|
|
/* ControlPointItem is not really specific to region gain mode
|
|
|
|
but it is the same cursor so don't worry about this for now.
|
|
|
|
The result is that we'll see the fader cursor if we enter
|
2014-12-07 19:53:46 -05:00
|
|
|
non-region-gain-line control points while in MouseDraw
|
2014-10-21 11:50:06 -04:00
|
|
|
mode, even though we can't edit them in this mode.
|
|
|
|
*/
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case GainLineItem:
|
|
|
|
case ControlPointItem:
|
|
|
|
cursor = _cursors->fader;
|
|
|
|
break;
|
2014-12-23 13:46:53 -05:00
|
|
|
case NoteItem:
|
|
|
|
cursor = _cursors->grabber_note;
|
2014-10-21 11:50:06 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2014-06-18 10:24:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
/* These items use the timebar cursor at all times */
|
|
|
|
case TimecodeRulerItem:
|
|
|
|
case MinsecRulerItem:
|
|
|
|
case BBTRulerItem:
|
|
|
|
case SamplesRulerItem:
|
|
|
|
cursor = _cursors->timebar;
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* These items use the grabber cursor at all times */
|
|
|
|
case MeterMarkerItem:
|
2021-02-10 16:34:30 -05:00
|
|
|
case BBTMarkerItem:
|
2014-06-18 10:24:59 -04:00
|
|
|
case TempoMarkerItem:
|
|
|
|
case MeterBarItem:
|
|
|
|
case TempoBarItem:
|
|
|
|
case MarkerItem:
|
|
|
|
case MarkerBarItem:
|
|
|
|
case RangeMarkerBarItem:
|
|
|
|
case CdMarkerBarItem:
|
|
|
|
case VideoBarItem:
|
|
|
|
case TransportMarkerBarItem:
|
2014-07-01 11:41:16 -04:00
|
|
|
case DropZoneItem:
|
2018-02-09 10:59:39 -05:00
|
|
|
cursor = _cursors->grabber;
|
2014-06-18 10:24:59 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-12-23 13:46:53 -05:00
|
|
|
return cursor;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::choose_canvas_cursor_on_entry (ItemType type)
|
|
|
|
{
|
|
|
|
if (_drags->active()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Gdk::Cursor* cursor = which_canvas_cursor(type);
|
|
|
|
|
2015-01-23 15:15:29 -05:00
|
|
|
if (!_cursors->is_invalid (cursor)) {
|
2014-12-23 13:46:53 -05:00
|
|
|
// Push a new enter context
|
|
|
|
const EnterContext ctx = { type, CursorContext::create(*this, cursor) };
|
|
|
|
_enter_stack.push_back(ctx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::update_all_enter_cursors ()
|
|
|
|
{
|
|
|
|
for (std::vector<EnterContext>::iterator i = _enter_stack.begin(); i != _enter_stack.end(); ++i) {
|
|
|
|
i->cursor_ctx->change(which_canvas_cursor(i->item_type));
|
2014-06-18 10:24:59 -04:00
|
|
|
}
|
2013-04-15 16:10:13 -04:00
|
|
|
}
|
2014-07-15 18:09:04 -04:00
|
|
|
|
|
|
|
double
|
|
|
|
Editor::trackviews_height() const
|
|
|
|
{
|
|
|
|
if (!_trackview_group) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return _visible_canvas_height - _trackview_group->canvas_origin().y;
|
|
|
|
}
|