Fix some evil "tabs".

Switch canvas cursor for MIDI tools.
Fix delete tool bug (touch delete always on).


git-svn-id: svn://localhost/ardour2/trunk@2287 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
David Robillard 2007-08-10 20:55:27 +00:00
parent 1ead67fbd7
commit f32a6d0f04
5 changed files with 87 additions and 63 deletions

View file

@ -152,7 +152,9 @@ Gdk::Cursor* Editor::zoom_cursor = 0;
Gdk::Cursor* Editor::time_fx_cursor = 0; Gdk::Cursor* Editor::time_fx_cursor = 0;
Gdk::Cursor* Editor::fader_cursor = 0; Gdk::Cursor* Editor::fader_cursor = 0;
Gdk::Cursor* Editor::speaker_cursor = 0; Gdk::Cursor* Editor::speaker_cursor = 0;
Gdk::Cursor* Editor::note_cursor = 0; Gdk::Cursor* Editor::midi_select_cursor = 0;
Gdk::Cursor* Editor::midi_pencil_cursor = 0;
Gdk::Cursor* Editor::midi_erase_cursor = 0;
Gdk::Cursor* Editor::wait_cursor = 0; Gdk::Cursor* Editor::wait_cursor = 0;
Gdk::Cursor* Editor::timebar_cursor = 0; Gdk::Cursor* Editor::timebar_cursor = 0;
@ -326,8 +328,8 @@ Editor::Editor ()
range_marker_drag_rect = 0; range_marker_drag_rect = 0;
marker_drag_line = 0; marker_drag_line = 0;
set_mouse_mode (MouseObject, true);
set_midi_edit_mode (MidiEditSelect, true); set_midi_edit_mode (MidiEditSelect, true);
set_mouse_mode (MouseObject, true);
frames_per_unit = 2048; /* too early to use reset_zoom () */ frames_per_unit = 2048; /* too early to use reset_zoom () */
reset_hscrollbar_stepping (); reset_hscrollbar_stepping ();
@ -1236,7 +1238,9 @@ Editor::build_cursors ()
time_fx_cursor = new Gdk::Cursor (SIZING); time_fx_cursor = new Gdk::Cursor (SIZING);
wait_cursor = new Gdk::Cursor (WATCH); wait_cursor = new Gdk::Cursor (WATCH);
timebar_cursor = new Gdk::Cursor(LEFT_PTR); timebar_cursor = new Gdk::Cursor(LEFT_PTR);
note_cursor = new Gdk::Cursor (PENCIL); midi_select_cursor = new Gdk::Cursor (CENTER_PTR);
midi_pencil_cursor = new Gdk::Cursor (PENCIL);
midi_erase_cursor = new Gdk::Cursor (DRAPED_BOX);
} }
/** Pop up a context menu for when the user clicks on a fade in or fade out */ /** Pop up a context menu for when the user clicks on a fade in or fade out */

View file

@ -143,6 +143,7 @@ class Editor : public PublicEditor
void step_mouse_mode (bool next); void step_mouse_mode (bool next);
Editing::MouseMode current_mouse_mode () const { return mouse_mode; } Editing::MouseMode current_mouse_mode () const { return mouse_mode; }
void set_midi_edit_cursor (Editing::MidiEditMode);
void set_midi_edit_mode (Editing::MidiEditMode, bool force=true); void set_midi_edit_mode (Editing::MidiEditMode, bool force=true);
Editing::MidiEditMode current_midi_edit_mode () const { return midi_edit_mode; } Editing::MidiEditMode current_midi_edit_mode () const { return midi_edit_mode; }
@ -813,7 +814,9 @@ class Editor : public PublicEditor
static Gdk::Cursor* time_fx_cursor; static Gdk::Cursor* time_fx_cursor;
static Gdk::Cursor* fader_cursor; static Gdk::Cursor* fader_cursor;
static Gdk::Cursor* speaker_cursor; static Gdk::Cursor* speaker_cursor;
static Gdk::Cursor* note_cursor; static Gdk::Cursor* midi_select_cursor;
static Gdk::Cursor* midi_pencil_cursor;
static Gdk::Cursor* midi_erase_cursor;
static Gdk::Cursor* wait_cursor; static Gdk::Cursor* wait_cursor;
static Gdk::Cursor* timebar_cursor; static Gdk::Cursor* timebar_cursor;

View file

@ -253,7 +253,7 @@ Editor::set_mouse_mode (MouseMode m, bool force)
case MouseNote: case MouseNote:
mouse_note_button.set_active (true); mouse_note_button.set_active (true);
current_canvas_cursor = note_cursor; set_midi_edit_cursor (current_midi_edit_mode());
break; break;
} }
@ -265,7 +265,7 @@ Editor::set_mouse_mode (MouseMode m, bool force)
ignore_mouse_mode_toggle = false; ignore_mouse_mode_toggle = false;
if (is_drawable()) { if (is_drawable()) {
track_canvas.get_window()->set_cursor(*current_canvas_cursor); track_canvas.get_window()->set_cursor(*current_canvas_cursor);
} }
} }
@ -339,6 +339,8 @@ Editor::midi_edit_mode_toggled (MidiEditMode m)
default: default:
break; break;
} }
set_midi_edit_cursor(m);
} }
@ -362,17 +364,14 @@ Editor::set_midi_edit_mode (MidiEditMode m, bool force)
switch (midi_edit_mode) { switch (midi_edit_mode) {
case MidiEditSelect: case MidiEditSelect:
midi_tool_select_button.set_active (true); midi_tool_select_button.set_active (true);
//current_canvas_cursor = selector_cursor;
break; break;
case MidiEditPencil: case MidiEditPencil:
midi_tool_pencil_button.set_active (true); midi_tool_pencil_button.set_active (true);
//current_canvas_cursor = selector_cursor;
break; break;
case MidiEditErase: case MidiEditErase:
midi_tool_erase_button.set_active (true); midi_tool_erase_button.set_active (true);
//current_canvas_cursor = selector_cursor;
break; break;
} }
@ -383,9 +382,27 @@ Editor::set_midi_edit_mode (MidiEditMode m, bool force)
ignore_midi_edit_mode_toggle = false; ignore_midi_edit_mode_toggle = false;
/*if (is_drawable()) { set_midi_edit_cursor (current_midi_edit_mode());
if (is_drawable()) {
track_canvas.get_window()->set_cursor(*current_canvas_cursor); track_canvas.get_window()->set_cursor(*current_canvas_cursor);
}*/ }
}
void
Editor::set_midi_edit_cursor (MidiEditMode m)
{
switch (midi_edit_mode) {
case MidiEditSelect:
current_canvas_cursor = midi_select_cursor;
break;
case MidiEditPencil:
current_canvas_cursor = midi_pencil_cursor;
break;
case MidiEditErase:
current_canvas_cursor = midi_erase_cursor;
break;
}
} }
void void
@ -1200,7 +1217,7 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_
case AutomationTrackItem: case AutomationTrackItem:
if (is_drawable()) { if (is_drawable()) {
Gdk::Cursor *cursor; Gdk::Cursor *cursor;
switch (mouse_mode) { switch (mouse_mode) {
case MouseRange: case MouseRange:
cursor = selector_cursor; cursor = selector_cursor;
@ -1544,7 +1561,7 @@ Editor::start_grab (GdkEvent* event, Gdk::Cursor *cursor)
cursor = grabber_cursor; cursor = grabber_cursor;
} }
// if dragging with button2, the motion is x constrained, with Alt-button2 it is y constrained // if dragging with button2, the motion is x constrained, with Alt-button2 it is y constrained
if (event->button.button == 2) { if (event->button.button == 2) {
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::Alt)) { if (Keyboard::modifier_state_equals (event->button.state, Keyboard::Alt)) {
@ -1994,7 +2011,7 @@ Editor::update_marker_drag_item (Location *location)
double x2 = frame_to_pixel (location->end()); double x2 = frame_to_pixel (location->end());
if (location->is_mark()) { if (location->is_mark()) {
marker_drag_line_points.front().set_x(x1); marker_drag_line_points.front().set_x(x1);
marker_drag_line_points.back().set_x(x1); marker_drag_line_points.back().set_x(x1);
marker_drag_line->property_points() = marker_drag_line_points; marker_drag_line->property_points() = marker_drag_line_points;
} }
@ -2272,12 +2289,12 @@ Editor::meter_marker_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent*
if (drag_info.copy == true) { if (drag_info.copy == true) {
begin_reversible_command (_("copy meter mark")); begin_reversible_command (_("copy meter mark"));
XMLNode &before = map.get_state(); XMLNode &before = map.get_state();
map.add_meter (marker->meter(), when); map.add_meter (marker->meter(), when);
XMLNode &after = map.get_state(); XMLNode &after = map.get_state();
session->add_command(new MementoCommand<TempoMap>(map, &before, &after)); session->add_command(new MementoCommand<TempoMap>(map, &before, &after));
commit_reversible_command (); commit_reversible_command ();
// delete the dummy marker we used for visual representation of copying. // delete the dummy marker we used for visual representation of copying.
// a new visual marker will show up automatically. // a new visual marker will show up automatically.
delete marker; delete marker;
@ -2286,7 +2303,7 @@ Editor::meter_marker_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent*
XMLNode &before = map.get_state(); XMLNode &before = map.get_state();
map.move_meter (marker->meter(), when); map.move_meter (marker->meter(), when);
XMLNode &after = map.get_state(); XMLNode &after = map.get_state();
session->add_command(new MementoCommand<TempoMap>(map, &before, &after)); session->add_command(new MementoCommand<TempoMap>(map, &before, &after));
commit_reversible_command (); commit_reversible_command ();
} }
} }
@ -2415,10 +2432,10 @@ Editor::tempo_marker_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent*
delete marker; delete marker;
} else { } else {
begin_reversible_command (_("move tempo mark")); begin_reversible_command (_("move tempo mark"));
XMLNode &before = map.get_state(); XMLNode &before = map.get_state();
map.move_tempo (marker->tempo(), when); map.move_tempo (marker->tempo(), when);
XMLNode &after = map.get_state(); XMLNode &after = map.get_state();
session->add_command (new MementoCommand<TempoMap>(map, &before, &after)); session->add_command (new MementoCommand<TempoMap>(map, &before, &after));
commit_reversible_command (); commit_reversible_command ();
} }
} }
@ -2820,7 +2837,7 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
original_pointer_order = drag_info.last_trackview->order; original_pointer_order = drag_info.last_trackview->order;
/************************************************************ /************************************************************
Y-Delta Computation Y-Delta Computation
************************************************************/ ************************************************************/
if (drag_info.brushing) { if (drag_info.brushing) {
@ -2975,7 +2992,7 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
} }
/************************************************************ /************************************************************
X DELTA COMPUTATION X DELTA COMPUTATION
************************************************************/ ************************************************************/
/* compute the amount of pointer motion in frames, and where /* compute the amount of pointer motion in frames, and where
@ -3043,7 +3060,7 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
} }
/************************************************************* /*************************************************************
PREPARE TO MOVE PREPARE TO MOVE
************************************************************/ ************************************************************/
if (x_delta == 0 && (pointer_y_span == 0)) { if (x_delta == 0 && (pointer_y_span == 0)) {
@ -3073,7 +3090,7 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
} }
/************************************************************* /*************************************************************
MOTION MOTION
************************************************************/ ************************************************************/
bool do_move; bool do_move;
@ -3720,7 +3737,7 @@ Editor::start_selection_grab (ArdourCanvas::Item* item, GdkEvent* event)
void void
Editor::cancel_selection () Editor::cancel_selection ()
{ {
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
(*i)->hide_selection (); (*i)->hide_selection ();
} }
begin_reversible_command (_("cancel selection")); begin_reversible_command (_("cancel selection"));
@ -4053,7 +4070,7 @@ Editor::trim_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
boost::shared_ptr<Playlist> pl = (*i)->region()->playlist(); boost::shared_ptr<Playlist> pl = (*i)->region()->playlist();
insert_result = motion_frozen_playlists.insert (pl); insert_result = motion_frozen_playlists.insert (pl);
if (insert_result.second) { if (insert_result.second) {
session->add_command(new MementoCommand<Playlist>(*pl, &pl->get_state(), 0)); session->add_command(new MementoCommand<Playlist>(*pl, &pl->get_state(), 0));
} }
} }
} }
@ -4068,7 +4085,7 @@ Editor::trim_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
case StartTrim: case StartTrim:
if ((left_direction == false) && (drag_info.current_pointer_frame <= rv->region()->first_frame()/speed)) { if ((left_direction == false) && (drag_info.current_pointer_frame <= rv->region()->first_frame()/speed)) {
break; break;
} else { } else {
for (list<RegionView*>::const_iterator i = selection->regions.by_layer().begin(); i != selection->regions.by_layer().end(); ++i) { for (list<RegionView*>::const_iterator i = selection->regions.by_layer().begin(); i != selection->regions.by_layer().end(); ++i) {
single_start_trim (**i, frame_delta, left_direction, obey_snap); single_start_trim (**i, frame_delta, left_direction, obey_snap);
} }
@ -4244,8 +4261,8 @@ Editor::trim_finished_callback (ArdourCanvas::Item* item, GdkEvent* event)
for (set<boost::shared_ptr<Playlist> >::iterator p = motion_frozen_playlists.begin(); p != motion_frozen_playlists.end(); ++p) { for (set<boost::shared_ptr<Playlist> >::iterator p = motion_frozen_playlists.begin(); p != motion_frozen_playlists.end(); ++p) {
//(*p)->thaw (); //(*p)->thaw ();
session->add_command (new MementoCommand<Playlist>(*(*p).get(), 0, &(*p)->get_state())); session->add_command (new MementoCommand<Playlist>(*(*p).get(), 0, &(*p)->get_state()));
} }
motion_frozen_playlists.clear (); motion_frozen_playlists.clear ();
@ -4279,10 +4296,10 @@ Editor::point_trim (GdkEvent* event)
{ {
if (!(*i)->region()->locked()) { if (!(*i)->region()->locked()) {
boost::shared_ptr<Playlist> pl = (*i)->region()->playlist(); boost::shared_ptr<Playlist> pl = (*i)->region()->playlist();
XMLNode &before = pl->get_state(); XMLNode &before = pl->get_state();
(*i)->region()->trim_front (new_bound, this); (*i)->region()->trim_front (new_bound, this);
XMLNode &after = pl->get_state(); XMLNode &after = pl->get_state();
session->add_command(new MementoCommand<Playlist>(*pl.get(), &before, &after)); session->add_command(new MementoCommand<Playlist>(*pl.get(), &before, &after));
} }
} }
@ -4292,7 +4309,7 @@ Editor::point_trim (GdkEvent* event)
boost::shared_ptr<Playlist> pl = rv->region()->playlist(); boost::shared_ptr<Playlist> pl = rv->region()->playlist();
XMLNode &before = pl->get_state(); XMLNode &before = pl->get_state();
rv->region()->trim_front (new_bound, this); rv->region()->trim_front (new_bound, this);
XMLNode &after = pl->get_state(); XMLNode &after = pl->get_state();
session->add_command(new MementoCommand<Playlist>(*pl.get(), &before, &after)); session->add_command(new MementoCommand<Playlist>(*pl.get(), &before, &after));
} }
} }
@ -4323,7 +4340,7 @@ Editor::point_trim (GdkEvent* event)
boost::shared_ptr<Playlist> pl = rv->region()->playlist(); boost::shared_ptr<Playlist> pl = rv->region()->playlist();
XMLNode &before = pl->get_state(); XMLNode &before = pl->get_state();
rv->region()->trim_end (new_bound, this); rv->region()->trim_end (new_bound, this);
XMLNode &after = pl->get_state(); XMLNode &after = pl->get_state();
session->add_command (new MementoCommand<Playlist>(*pl.get(), &before, &after)); session->add_command (new MementoCommand<Playlist>(*pl.get(), &before, &after));
} }
} }
@ -4346,7 +4363,7 @@ Editor::thaw_region_after_trim (RegionView& rv)
} }
region->thaw (_("trimmed region")); region->thaw (_("trimmed region"));
XMLNode &after = region->playlist()->get_state(); XMLNode &after = region->playlist()->get_state();
session->add_command (new MementoCommand<Playlist>(*(region->playlist()), 0, &after)); session->add_command (new MementoCommand<Playlist>(*(region->playlist()), 0, &after));
AudioRegionView* arv = dynamic_cast<AudioRegionView*>(&rv); AudioRegionView* arv = dynamic_cast<AudioRegionView*>(&rv);
@ -4489,11 +4506,11 @@ Editor::end_range_markerbar_op (ArdourCanvas::Item* item, GdkEvent* event)
case CreateRangeMarker: case CreateRangeMarker:
{ {
begin_reversible_command (_("new range marker")); begin_reversible_command (_("new range marker"));
XMLNode &before = session->locations()->get_state(); XMLNode &before = session->locations()->get_state();
session->locations()->next_available_name(rangename,"unnamed"); session->locations()->next_available_name(rangename,"unnamed");
newloc = new Location(temp_location->start(), temp_location->end(), rangename, Location::IsRangeMarker); newloc = new Location(temp_location->start(), temp_location->end(), rangename, Location::IsRangeMarker);
session->locations()->add (newloc, true); session->locations()->add (newloc, true);
XMLNode &after = session->locations()->get_state(); XMLNode &after = session->locations()->get_state();
session->add_command(new MementoCommand<Locations>(*(session->locations()), &before, &after)); session->add_command(new MementoCommand<Locations>(*(session->locations()), &before, &after));
commit_reversible_command (); commit_reversible_command ();
@ -4767,7 +4784,7 @@ Editor::mouse_rename_region (ArdourCanvas::Item* item, GdkEvent* event)
prompter.show_all (); prompter.show_all ();
switch (prompter.run ()) { switch (prompter.run ()) {
case Gtk::RESPONSE_ACCEPT: case Gtk::RESPONSE_ACCEPT:
string str; string str;
prompter.get_result(str); prompter.get_result(str);
if (str.length()) { if (str.length()) {
clicked_regionview->region()->set_name (str); clicked_regionview->region()->set_name (str);
@ -4872,9 +4889,9 @@ Editor::mouse_brush_insert_region (RegionView* rv, nframes_t pos)
boost::shared_ptr<Playlist> playlist = rtv->playlist(); boost::shared_ptr<Playlist> playlist = rtv->playlist();
double speed = rtv->get_diskstream()->speed(); double speed = rtv->get_diskstream()->speed();
XMLNode &before = playlist->get_state(); XMLNode &before = playlist->get_state();
playlist->add_region (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (arv->audio_region())), (nframes_t) (pos * speed)); playlist->add_region (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (arv->audio_region())), (nframes_t) (pos * speed));
XMLNode &after = playlist->get_state(); XMLNode &after = playlist->get_state();
session->add_command(new MementoCommand<Playlist>(*playlist.get(), &before, &after)); session->add_command(new MementoCommand<Playlist>(*playlist.get(), &before, &after));
// playlist is frozen, so we have to update manually // playlist is frozen, so we have to update manually

View file

@ -241,11 +241,6 @@ MidiRegionView::canvas_event(GdkEvent* ev)
_mouse_state = AddDragging; _mouse_state = AddDragging;
return true; return true;
// Eraser drag start
} else if (trackview.editor.current_midi_edit_mode() == MidiEditErase) {
_mouse_state = EraseTouchDragging;
return false; // Don't ask me...
} }
return false; return false;
@ -729,6 +724,7 @@ MidiRegionView::move_selection(double dx, double dy)
(*i)->item()->move(dx, dy); (*i)->item()->move(dx, dy);
} }
void void
MidiRegionView::note_dropped(CanvasMidiEvent* ev, double dt, uint8_t dnote) MidiRegionView::note_dropped(CanvasMidiEvent* ev, double dt, uint8_t dnote)
{ {
@ -748,4 +744,18 @@ MidiRegionView::note_dropped(CanvasMidiEvent* ev, double dt, uint8_t dnote)
apply_command(); apply_command();
} }
} }
void
MidiRegionView::note_entered(ArdourCanvas::CanvasMidiEvent* ev)
{
cerr << "NOTE ENTERED: " << _mouse_state << endl;
if (ev->note() && _mouse_state == EraseTouchDragging) {
start_delta_command();
ev->selected(true);
_delta_command->remove(*ev->note());
} else if (_mouse_state == SelectTouchDragging) {
note_selected(ev, true);
}
}

View file

@ -97,6 +97,11 @@ class MidiRegionView : public RegionView
if (!_delta_command) if (!_delta_command)
_delta_command = _model->new_delta_command(); _delta_command = _model->new_delta_command();
} }
void command_add_note(ARDOUR::MidiModel::Note& note) {
if (_delta_command)
_delta_command->add(note);
}
void command_remove_note(ArdourCanvas::CanvasMidiEvent* ev) { void command_remove_note(ArdourCanvas::CanvasMidiEvent* ev) {
if (_delta_command && ev->note()) { if (_delta_command && ev->note()) {
@ -104,22 +109,6 @@ class MidiRegionView : public RegionView
ev->selected(true); ev->selected(true);
} }
} }
void command_add_note(ARDOUR::MidiModel::Note& note) {
if (_delta_command) {
_delta_command->add(note);
}
}
void note_entered(ArdourCanvas::CanvasMidiEvent* ev) {
if (ev->note() && _mouse_state == EraseTouchDragging) {
start_delta_command();
ev->selected(true);
_delta_command->remove(*ev->note());
} else if (_mouse_state == SelectTouchDragging) {
note_selected(ev, true);
}
}
void abort_command() { void abort_command() {
delete _delta_command; delete _delta_command;
@ -134,7 +123,8 @@ class MidiRegionView : public RegionView
} }
midi_view()->midi_track()->diskstream()->playlist_modified(); midi_view()->midi_track()->diskstream()->playlist_modified();
} }
void note_entered(ArdourCanvas::CanvasMidiEvent* ev);
void unique_select(ArdourCanvas::CanvasMidiEvent* ev); void unique_select(ArdourCanvas::CanvasMidiEvent* ev);
void note_selected(ArdourCanvas::CanvasMidiEvent* ev, bool add); void note_selected(ArdourCanvas::CanvasMidiEvent* ev, bool add);
void note_deselected(ArdourCanvas::CanvasMidiEvent* ev, bool add); void note_deselected(ArdourCanvas::CanvasMidiEvent* ev, bool add);