From fbfbc19c586d11488435277c3794dac117590fde Mon Sep 17 00:00:00 2001 From: paul Date: Thu, 17 Jun 2010 12:45:51 +0000 Subject: [PATCH] add left/right side trim cursors and use them for region trimming, as appropriate git-svn-id: http://subversion.ardour.org/svn/ardour2/ardour2/branches/3.0@7268 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor.cc | 8 ++++++++ gtk2_ardour/editor.h | 2 ++ gtk2_ardour/editor_canvas_events.cc | 16 ++++++++++++---- gtk2_ardour/editor_drag.cc | 16 +++++++++------- gtk2_ardour/editor_items.h | 2 ++ gtk2_ardour/editor_mouse.cc | 24 ++++++++++++++++++++++++ gtk2_ardour/region_view.cc | 2 ++ 7 files changed, 59 insertions(+), 11 deletions(-) diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index b059723cd..92d3239e8 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -209,6 +209,8 @@ static const gchar *_rb_opt_strings[] = { Gdk::Cursor* Editor::cross_hair_cursor = 0; Gdk::Cursor* Editor::selector_cursor = 0; Gdk::Cursor* Editor::trimmer_cursor = 0; +Gdk::Cursor* Editor::left_side_trim_cursor = 0; +Gdk::Cursor* Editor::right_side_trim_cursor = 0; Gdk::Cursor* Editor::grabber_cursor = 0; Gdk::Cursor* Editor::grabber_edit_point_cursor = 0; Gdk::Cursor* Editor::zoom_cursor = 0; @@ -1240,6 +1242,8 @@ Editor::build_cursors () cross_hair_cursor = new Gdk::Cursor (CROSSHAIR); trimmer_cursor = new Gdk::Cursor (SB_H_DOUBLE_ARROW); + left_side_trim_cursor = new Gdk::Cursor (SB_LEFT_ARROW); + right_side_trim_cursor = new Gdk::Cursor (SB_RIGHT_ARROW); selector_cursor = new Gdk::Cursor (XTERM); time_fx_cursor = new Gdk::Cursor (SIZING); wait_cursor = new Gdk::Cursor (WATCH); @@ -1334,6 +1338,8 @@ Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type, case RegionItem: case RegionViewName: case RegionViewNameHighlight: + case LeftFrameHandle: + case RightFrameHandle: if (with_selection) { build_menu_function = &Editor::build_track_selection_context_menu; } else { @@ -1375,6 +1381,8 @@ Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type, case RegionItem: case RegionViewName: case RegionViewNameHighlight: + case LeftFrameHandle: + case RightFrameHandle: if (!with_selection) { if (region_edit_menu_split_item) { if (clicked_regionview && clicked_regionview->region()->covers (get_preferred_edit_position())) { diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index feecd81fd..d11bb309f 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -988,6 +988,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD static Gdk::Cursor* cross_hair_cursor; static Gdk::Cursor* trimmer_cursor; + static Gdk::Cursor* right_side_trim_cursor; + static Gdk::Cursor* left_side_trim_cursor; static Gdk::Cursor* selector_cursor; static Gdk::Cursor* grabber_cursor; static Gdk::Cursor* grabber_edit_point_cursor; diff --git a/gtk2_ardour/editor_canvas_events.cc b/gtk2_ardour/editor_canvas_events.cc index e879f460f..bf84eb20e 100644 --- a/gtk2_ardour/editor_canvas_events.cc +++ b/gtk2_ardour/editor_canvas_events.cc @@ -768,6 +768,14 @@ Editor::canvas_frame_handle_event (GdkEvent* event, ArdourCanvas::Item* item, Re perspective. XXX change this ?? */ + ItemType type; + + if (item->get_data ("isleft")) { + type = LeftFrameHandle; + } else { + type = RightFrameHandle; + } + switch (event->type) { case GDK_BUTTON_PRESS: case GDK_2BUTTON_PRESS: @@ -776,20 +784,20 @@ Editor::canvas_frame_handle_event (GdkEvent* event, ArdourCanvas::Item* item, Re clicked_control_point = 0; clicked_axisview = &clicked_regionview->get_time_axis_view(); clicked_routeview = dynamic_cast(clicked_axisview); - ret = button_press_handler (item, event, RegionViewNameHighlight); + ret = button_press_handler (item, event, type); break; case GDK_BUTTON_RELEASE: - ret = button_release_handler (item, event, RegionViewNameHighlight); + ret = button_release_handler (item, event, type); break; case GDK_MOTION_NOTIFY: ret = motion_handler (item, event); break; case GDK_ENTER_NOTIFY: - ret = enter_handler (item, event, RegionViewNameHighlight); + ret = enter_handler (item, event, type); break; case GDK_LEAVE_NOTIFY: - ret = leave_handler (item, event, RegionViewNameHighlight); + ret = leave_handler (item, event, type); break; default: diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 30211049c..d978029d2 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -215,8 +215,8 @@ Drag::start_grab (GdkEvent* event, Gdk::Cursor *cursor) _last_pointer_y = _grab_y; _item->grab (Gdk::POINTER_MOTION_MASK|Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK, - *cursor, - event->button.time); + *cursor, + event->button.time); if (_editor->session() && _editor->session()->transport_rolling()) { _was_rolling = true; @@ -1703,21 +1703,23 @@ TrimDrag::start_grab (GdkEvent* event, Gdk::Cursor *) nframes64_t region_end = (nframes64_t) (_primary->region()->last_frame() / speed); nframes64_t region_length = (nframes64_t) (_primary->region()->length() / speed); - Drag::start_grab (event, _editor->trimmer_cursor); nframes64_t const pf = adjusted_current_frame (event); if (Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) { _operation = ContentsTrim; + Drag::start_grab (event, _editor->trimmer_cursor); } else { /* These will get overridden for a point trim.*/ if (pf < (region_start + region_length/2)) { /* closer to start */ _operation = StartTrim; - } else if (pf > (region_end - region_length/2)) { + Drag::start_grab (event, _editor->left_side_trim_cursor); + } else { /* closer to end */ _operation = EndTrim; - } + Drag::start_grab (event, _editor->right_side_trim_cursor); + } } switch (_operation) { @@ -3164,7 +3166,7 @@ SelectionDrag::start_grab (GdkEvent* event, Gdk::Cursor*) if (_editor->clicked_axisview) { _editor->clicked_axisview->order_selection_trims (_item, true); } - Drag::start_grab (event, _editor->trimmer_cursor); + Drag::start_grab (event, _editor->left_side_trim_cursor); start = _editor->selection->time[_editor->clicked_selection].start; _pointer_frame_offset = grab_frame() - start; break; @@ -3173,7 +3175,7 @@ SelectionDrag::start_grab (GdkEvent* event, Gdk::Cursor*) if (_editor->clicked_axisview) { _editor->clicked_axisview->order_selection_trims (_item, false); } - Drag::start_grab (event, _editor->trimmer_cursor); + Drag::start_grab (event, _editor->right_side_trim_cursor); end = _editor->selection->time[_editor->clicked_selection].end; _pointer_frame_offset = grab_frame() - end; break; diff --git a/gtk2_ardour/editor_items.h b/gtk2_ardour/editor_items.h index 44765ffe9..08013e30a 100644 --- a/gtk2_ardour/editor_items.h +++ b/gtk2_ardour/editor_items.h @@ -47,6 +47,8 @@ enum ItemType { FadeOutItem, FadeOutHandleItem, NoteItem, + LeftFrameHandle, + RightFrameHandle, #ifdef WITH_CMT MarkerViewItem, diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index 2cbf0c1a8..8aef3f9a5 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -472,6 +472,8 @@ Editor::button_selection (ArdourCanvas::Item* /*item*/, GdkEvent* event, ItemTyp case RegionViewNameHighlight: case RegionViewName: + case LeftFrameHandle: + case RightFrameHandle: if (mouse_mode != MouseRange || internal_editing() || _join_object_range_state == JOIN_OBJECT_RANGE_OBJECT) { set_selected_regionview_from_click (press, op, true); } else if (event->type == GDK_BUTTON_PRESS) { @@ -669,6 +671,8 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT break; case RegionViewNameHighlight: + case LeftFrameHandle: + case RightFrameHandle: { RegionSelection s = get_equivalent_regions (selection->regions, Properties::edit.property_id); _drags->set (new TrimDrag (this, item, clicked_regionview, s.by_layer()), event); @@ -736,6 +740,8 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT break; case RegionViewNameHighlight: + case LeftFrameHandle: + case RightFrameHandle: { RegionSelection s = get_equivalent_regions (selection->regions, Properties::edit.property_id); _drags->set (new TrimDrag (this, item, clicked_regionview, s.by_layer()), event); @@ -962,6 +968,8 @@ Editor::button_press_handler_2 (ArdourCanvas::Item* item, GdkEvent* event, ItemT switch (item_type) { case RegionViewNameHighlight: + case LeftFrameHandle: + case RightFrameHandle: _drags->set (new TrimDrag (this, item, clicked_regionview, selection->regions.by_layer()), event); return true; break; @@ -1144,6 +1152,8 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT case RegionItem: case RegionViewNameHighlight: + case LeftFrameHandle: + case RightFrameHandle: case RegionViewName: popup_track_context_menu (1, event->button.time, item_type, false, where); break; @@ -1474,6 +1484,18 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_ } break; + case LeftFrameHandle: + if (is_drawable() && (mouse_mode == MouseObject || (internal_editing() && mouse_mode == MouseRange))) { + track_canvas->get_window()->set_cursor (*left_side_trim_cursor); + } + break; + + case RightFrameHandle: + if (is_drawable() && (mouse_mode == MouseObject || (internal_editing() && mouse_mode == MouseRange))) { + track_canvas->get_window()->set_cursor (*right_side_trim_cursor); + } + break; + case StartSelectionTrimItem: case EndSelectionTrimItem: @@ -1630,6 +1652,8 @@ Editor::leave_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_ break; case RegionViewNameHighlight: + case LeftFrameHandle: + case RightFrameHandle: case StartSelectionTrimItem: case EndSelectionTrimItem: case PlayheadCursorItem: diff --git a/gtk2_ardour/region_view.cc b/gtk2_ardour/region_view.cc index aeae3acc9..be564d3dc 100644 --- a/gtk2_ardour/region_view.cc +++ b/gtk2_ardour/region_view.cc @@ -158,9 +158,11 @@ RegionView::init (Gdk::Color const & basic_color, bool wfd) name_highlight->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_region_view_name_highlight_event), name_highlight, this)); frame_handle_start->set_data ("regionview", this); + frame_handle_start->set_data ("isleft", (void*) 1); frame_handle_start->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_frame_handle_event), frame_handle_start, this)); frame_handle_end->set_data ("regionview", this); + frame_handle_end->set_data ("isleft", (void*) 0); frame_handle_end->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_frame_handle_event), frame_handle_end, this)); frame_handle_start->raise_to_top(); -- 2.11.4.GIT