2005-09-25 14:42:24 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2004 Paul Davis
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <ardour/audioregion.h>
|
2006-01-23 16:55:30 -05:00
|
|
|
#include <ardour/playlist.h>
|
2006-07-28 23:17:11 -04:00
|
|
|
#include <pbd/memento_command.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#include "editor.h"
|
2006-08-03 22:18:45 -04:00
|
|
|
#include "region_view.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "selection.h"
|
|
|
|
|
2006-01-23 16:55:30 -05:00
|
|
|
#include "i18n.h"
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2005-09-25 17:19:23 -04:00
|
|
|
Editor::kbd_driver (sigc::slot<void,GdkEvent*> theslot, bool use_track_canvas, bool use_time_canvas, bool can_select)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
gint x, y;
|
2005-12-29 19:34:21 -05:00
|
|
|
double worldx, worldy;
|
2005-09-25 14:42:24 -04:00
|
|
|
GdkEvent ev;
|
2005-11-12 22:53:51 -05:00
|
|
|
Gdk::ModifierType mask;
|
|
|
|
Glib::RefPtr<Gdk::Window> evw = track_canvas.get_window()->get_pointer (x, y, mask);
|
2005-09-25 14:42:24 -04:00
|
|
|
bool doit = false;
|
|
|
|
|
2005-11-12 22:53:51 -05:00
|
|
|
if (use_track_canvas && track_canvas_event_box.get_window()->get_pointer(x, y, mask) != 0) {
|
2005-11-12 17:07:07 -05:00
|
|
|
doit = true;
|
2005-11-12 22:53:51 -05:00
|
|
|
} else if (use_time_canvas && time_canvas_event_box.get_window()->get_pointer(x, y, mask)!= 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
doit = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (doit) {
|
|
|
|
|
|
|
|
if (entered_regionview && can_select) {
|
|
|
|
selection->set (entered_regionview);
|
|
|
|
}
|
|
|
|
|
2005-12-29 19:34:21 -05:00
|
|
|
track_canvas.window_to_world (x, y, worldx, worldy);
|
2006-01-02 15:27:51 -05:00
|
|
|
worldx += horizontal_adjustment.get_value();
|
|
|
|
worldy += vertical_adjustment.get_value();
|
2005-12-29 19:34:21 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
ev.type = GDK_BUTTON_PRESS;
|
2005-12-29 19:34:21 -05:00
|
|
|
ev.button.x = worldx;
|
|
|
|
ev.button.y = worldy;
|
2005-09-25 14:42:24 -04:00
|
|
|
ev.button.state = 0; /* XXX correct? */
|
|
|
|
|
|
|
|
theslot (&ev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::kbd_set_playhead_cursor ()
|
|
|
|
{
|
2005-09-25 17:19:23 -04:00
|
|
|
kbd_driver (mem_fun(*this, &Editor::set_playhead_cursor), true, true, false);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::kbd_set_edit_cursor ()
|
|
|
|
{
|
2005-09-25 17:19:23 -04:00
|
|
|
kbd_driver (mem_fun(*this, &Editor::set_edit_cursor), true, true, false);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::kbd_do_split (GdkEvent* ev)
|
|
|
|
{
|
2006-09-28 13:23:52 -04:00
|
|
|
nframes_t where = event_frame (ev);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (entered_regionview) {
|
2006-08-03 22:18:45 -04:00
|
|
|
if (selection->regions.find (entered_regionview) != selection->regions.end()) {
|
|
|
|
split_regions_at (where, selection->regions);
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2006-08-03 22:18:45 -04:00
|
|
|
RegionSelection s;
|
2005-09-25 14:42:24 -04:00
|
|
|
s.add (entered_regionview);
|
|
|
|
split_regions_at (where, s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::kbd_split ()
|
|
|
|
{
|
2005-09-25 17:19:23 -04:00
|
|
|
kbd_driver (mem_fun(*this, &Editor::kbd_do_split), true, true, false);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2006-01-22 10:46:30 -05:00
|
|
|
void
|
|
|
|
Editor::kbd_mute_unmute_region ()
|
|
|
|
{
|
|
|
|
if (entered_regionview) {
|
2006-01-23 16:55:30 -05:00
|
|
|
begin_reversible_command (_("mute region"));
|
2006-08-24 21:07:15 -04:00
|
|
|
XMLNode &before = entered_regionview->region()->playlist()->get_state();
|
2006-01-23 16:55:30 -05:00
|
|
|
|
2006-08-24 21:07:15 -04:00
|
|
|
entered_regionview->region()->set_muted (!entered_regionview->region()->muted());
|
2006-01-23 16:55:30 -05:00
|
|
|
|
2006-08-24 21:07:15 -04:00
|
|
|
XMLNode &after = entered_regionview->region()->playlist()->get_state();
|
|
|
|
session->add_command (new MementoCommand<ARDOUR::Playlist>(*(entered_regionview->region()->playlist()), &before, &after));
|
2006-01-23 16:55:30 -05:00
|
|
|
commit_reversible_command();
|
2006-01-22 10:46:30 -05:00
|
|
|
}
|
|
|
|
}
|
2006-01-22 08:29:08 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
Editor::kbd_set_sync_position ()
|
|
|
|
{
|
|
|
|
kbd_driver (mem_fun(*this, &Editor::kbd_do_set_sync_position), true, true, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::kbd_do_set_sync_position (GdkEvent* ev)
|
|
|
|
{
|
2006-09-28 13:23:52 -04:00
|
|
|
nframes_t where = event_frame (ev);
|
2006-01-22 08:29:08 -05:00
|
|
|
snap_to (where);
|
|
|
|
|
|
|
|
if (entered_regionview) {
|
2006-08-03 22:18:45 -04:00
|
|
|
set_a_regions_sync_position (entered_regionview->region(), where);
|
2006-01-22 08:29:08 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Editor::kbd_do_align (GdkEvent* ev, ARDOUR::RegionPoint what)
|
|
|
|
{
|
|
|
|
align (what);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::kbd_align (ARDOUR::RegionPoint what)
|
|
|
|
{
|
2005-09-25 17:19:23 -04:00
|
|
|
kbd_driver (bind (mem_fun(*this, &Editor::kbd_do_align), what));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::kbd_do_align_relative (GdkEvent* ev, ARDOUR::RegionPoint what)
|
|
|
|
{
|
|
|
|
align (what);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::kbd_align_relative (ARDOUR::RegionPoint what)
|
|
|
|
{
|
2005-09-25 17:19:23 -04:00
|
|
|
kbd_driver (bind (mem_fun(*this, &Editor::kbd_do_align), what), true, true, false);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::kbd_do_brush (GdkEvent *ev)
|
|
|
|
{
|
|
|
|
brush (event_frame (ev, 0, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::kbd_brush ()
|
|
|
|
{
|
2005-09-25 17:19:23 -04:00
|
|
|
kbd_driver (mem_fun(*this, &Editor::kbd_do_brush), true, true, false);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::kbd_do_audition (GdkEvent *ignored)
|
|
|
|
{
|
|
|
|
audition_selected_region ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::kbd_audition ()
|
|
|
|
{
|
2005-09-25 17:19:23 -04:00
|
|
|
kbd_driver (mem_fun(*this, &Editor::kbd_do_audition), true, false, true);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|