From 68a8330afc09f75305f927caf4814e3c80148367 Mon Sep 17 00:00:00 2001 From: nick_m Date: Sat, 16 May 2015 04:15:52 +1000 Subject: Relative snap --- gtk2_ardour/ardour.menus.in | 3 + gtk2_ardour/editing.cc | 22 ++++++ gtk2_ardour/editing.h | 14 ++++ gtk2_ardour/editing_syms.h | 3 + gtk2_ardour/editor.cc | 61 ++++++++++++++++ gtk2_ardour/editor.h | 9 +++ gtk2_ardour/editor_actions.cc | 51 +++++++++++++- gtk2_ardour/editor_drag.cc | 153 ++++++++++++++++++++++++++++++++-------- gtk2_ardour/editor_drag.h | 14 +++- gtk2_ardour/enums.cc | 5 ++ gtk2_ardour/midi_region_view.cc | 76 ++++++++++++++------ gtk2_ardour/midi_region_view.h | 10 ++- gtk2_ardour/public_editor.h | 3 + 13 files changed, 367 insertions(+), 57 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/ardour.menus.in b/gtk2_ardour/ardour.menus.in index 85680ac7b0..4cc9ea900d 100644 --- a/gtk2_ardour/ardour.menus.in +++ b/gtk2_ardour/ardour.menus.in @@ -222,6 +222,9 @@ + + + diff --git a/gtk2_ardour/editing.cc b/gtk2_ardour/editing.cc index 486808065e..b6894ed2f5 100644 --- a/gtk2_ardour/editing.cc +++ b/gtk2_ardour/editing.cc @@ -29,6 +29,7 @@ using namespace std; // This involves some cpp magic. --taybin #define SNAPTYPE(a) /*empty*/ +#define SNAPDELTA(a) /*empty*/ #define SNAPMODE(a) /*empty*/ #define REGIONLISTSORTTYPE(a) /*empty*/ #define MOUSEMODE(a) /*empty*/ @@ -57,6 +58,27 @@ const char *snaptypestrs[] = { #undef SNAPTYPE #define SNAPTYPE(a) /*empty*/ + +// SNAPDELTA +#undef SNAPDELTA +#define SNAPDELTA(s) if (!strcmp(type, #s)) {return s;} +SnapDelta +str2snapdelta (const string & str) { + const char* type = str.c_str(); + #include "editing_syms.h" + return SnapAbsolute; +} + +#undef SNAPDELTA +#define SNAPDELTA(s) N_(#s), +const char *snapdeltastrs[] = { + #include "editing_syms.h" + 0 +}; +#undef SNAPDELTA +#define SNAPDELTA(a) /*empty*/ + + // SNAPMODE #undef SNAPMODE #define SNAPMODE(s) if (!strcmp(type, #s)) {return s;} diff --git a/gtk2_ardour/editing.h b/gtk2_ardour/editing.h index 8dd6f2ed6c..38b8c5ed1f 100644 --- a/gtk2_ardour/editing.h +++ b/gtk2_ardour/editing.h @@ -28,6 +28,7 @@ #define SNAPTYPE(a) /*empty*/ #define SNAPMODE(a) /*empty*/ +#define SNAPDELTA(a) /*empty*/ #define REGIONLISTSORTTYPE(a) /*empty*/ #define MOUSEMODE(a) /*empty*/ #define MIDIEDITMODE(a) /*empty*/ @@ -71,6 +72,19 @@ SnapMode str2snapmode(const std::string &); #undef SNAPMODE #define SNAPMODE(a) /*empty*/ +// SNAPDELTA +#undef SNAPDELTA +#define SNAPDELTA(a) a, +enum SnapDelta { + #include "editing_syms.h" +}; +extern const char *snapdeltastrs[]; +inline const char* enum2str(SnapDelta m) {return snapdeltastrs[m];} +SnapDelta str2snapdelta(const std::string &); + +#undef SNAPDELTA +#define SNAPDELTA(a) /*empty*/ + // REGIONLISTSORTTYPE #undef REGIONLISTSORTTYPE #define REGIONLISTSORTTYPE(a) a, diff --git a/gtk2_ardour/editing_syms.h b/gtk2_ardour/editing_syms.h index a958776305..2769b06b6a 100644 --- a/gtk2_ardour/editing_syms.h +++ b/gtk2_ardour/editing_syms.h @@ -54,6 +54,9 @@ SNAPMODE(SnapOff) SNAPMODE(SnapNormal) SNAPMODE(SnapMagnetic) +SNAPDELTA(SnapAbsolute) +SNAPDELTA(SnapRelative) + REGIONLISTSORTTYPE(ByEndInFile) REGIONLISTSORTTYPE(ByLength) REGIONLISTSORTTYPE(ByName) diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index df1421b6ce..60aa58dbb0 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -177,6 +177,12 @@ static const gchar *_snap_type_strings[] = { 0 }; +static const gchar *_snap_delta_strings[] = { + N_("Absolute"), + N_("Relative"), + 0 +}; + static const gchar *_snap_mode_strings[] = { N_("No Grid"), N_("Grid"), @@ -329,6 +335,7 @@ Editor::Editor () tempo_lines = 0; snap_type_strings = I18N (_snap_type_strings); + snap_delta_strings = I18N (_snap_delta_strings); snap_mode_strings = I18N (_snap_mode_strings); zoom_focus_strings = I18N (_zoom_focus_strings); edit_mode_strings = I18N (_edit_mode_strings); @@ -341,6 +348,7 @@ Editor::Editor () build_edit_mode_menu(); build_zoom_focus_menu(); build_track_count_menu(); + build_snap_delta_menu(); build_snap_mode_menu(); build_snap_type_menu(); build_edit_point_menu(); @@ -678,6 +686,8 @@ Editor::Editor () set_visible_track_count (_visible_track_count); _snap_type = SnapToBeat; set_snap_to (_snap_type); + _snap_delta = SnapAbsolute; + set_snap_delta (_snap_delta); _snap_mode = SnapOff; set_snap_mode (_snap_mode); set_mouse_mode (MouseObject, true); @@ -2036,6 +2046,12 @@ Editor::snap_type() const return _snap_type; } +SnapDelta +Editor::snap_delta() const +{ + return _snap_delta; +} + SnapMode Editor::snap_mode() const { @@ -2114,6 +2130,20 @@ Editor::set_snap_to (SnapType st) SnapChanged (); /* EMIT SIGNAL */ } +void +Editor::set_snap_delta (SnapDelta delta) +{ + string str = snap_delta_strings[(int)delta]; + + _snap_delta = delta; + + if (str != snap_delta_selector.get_text ()) { + snap_delta_selector.set_text (str); + } + + instant_save (); +} + void Editor::set_snap_mode (SnapMode mode) { @@ -2133,6 +2163,7 @@ Editor::set_snap_mode (SnapMode mode) instant_save (); } + void Editor::set_edit_point_preference (EditPoint ep, bool force) { @@ -2272,6 +2303,10 @@ Editor::set_state (const XMLNode& node, int /*version*/) snap_type_selection_done ((SnapType) string_2_enum (prop->value(), _snap_type)); } + if ((prop = node.property ("snap-delta"))) { + snap_delta_selection_done((SnapDelta) string_2_enum (prop->value(), _snap_delta)); + } + if ((prop = node.property ("snap-mode"))) { snap_mode_selection_done((SnapMode) string_2_enum (prop->value(), _snap_mode)); } @@ -2497,6 +2532,7 @@ Editor::get_state () snprintf (buf, sizeof(buf), "%" PRId64, samples_per_pixel); node->add_property ("zoom", buf); node->add_property ("snap-to", enum_2_string (_snap_type)); + node->add_property ("snap-delta", enum_2_string (_snap_delta)); node->add_property ("snap-mode", enum_2_string (_snap_mode)); node->add_property ("internal-snap-to", enum_2_string (internal_snap_type)); node->add_property ("internal-snap-mode", enum_2_string (internal_snap_mode)); @@ -2906,6 +2942,7 @@ Editor::setup_toolbar () mouse_mode_size_group->add_widget (visible_tracks_selector); mouse_mode_size_group->add_widget (snap_type_selector); + mouse_mode_size_group->add_widget (snap_delta_selector); mouse_mode_size_group->add_widget (snap_mode_selector); mouse_mode_size_group->add_widget (edit_point_selector); @@ -3058,10 +3095,12 @@ Editor::setup_toolbar () snap_type_selector.set_name ("mouse mode button"); + snap_delta_selector.set_name ("mouse mode button"); snap_mode_selector.set_name ("mouse mode button"); edit_point_selector.set_name ("mouse mode button"); + snap_box.pack_start (snap_delta_selector, false, false); snap_box.pack_start (snap_mode_selector, false, false); snap_box.pack_start (snap_type_selector, false, false); snap_box.pack_start (edit_point_selector, false, false); @@ -3161,6 +3200,17 @@ Editor::build_edit_mode_menu () set_size_request_to_display_given_text (edit_mode_selector, edit_mode_strings, COMBO_TRIANGLE_WIDTH, 2); } +void +Editor::build_snap_delta_menu () +{ + using namespace Menu_Helpers; + + snap_delta_selector.AddMenuElem (MenuElem ( snap_delta_strings[(int)SnapAbsolute], sigc::bind (sigc::mem_fun(*this, &Editor::snap_delta_selection_done), (SnapDelta) SnapAbsolute))); + snap_delta_selector.AddMenuElem (MenuElem ( snap_delta_strings[(int)SnapRelative], sigc::bind (sigc::mem_fun(*this, &Editor::snap_delta_selection_done), (SnapDelta) SnapRelative))); + + set_size_request_to_display_given_text (snap_delta_selector, snap_delta_strings, COMBO_TRIANGLE_WIDTH, 2); +} + void Editor::build_snap_mode_menu () { @@ -3236,6 +3286,7 @@ Editor::setup_tooltips () ARDOUR_UI::instance()->set_tip (tav_shrink_button, _("Shrink Tracks")); ARDOUR_UI::instance()->set_tip (visible_tracks_selector, _("Number of visible tracks")); ARDOUR_UI::instance()->set_tip (snap_type_selector, _("Snap/Grid Units")); + ARDOUR_UI::instance()->set_tip (snap_delta_selector, _("Relative Snap Mode")); ARDOUR_UI::instance()->set_tip (snap_mode_selector, _("Snap/Grid Mode")); ARDOUR_UI::instance()->set_tip (edit_point_selector, _("Edit point")); ARDOUR_UI::instance()->set_tip (edit_mode_selector, _("Edit Mode")); @@ -3632,6 +3683,16 @@ Editor::snap_type_selection_done (SnapType snaptype) } } +void +Editor::snap_delta_selection_done (SnapDelta delta) +{ + RefPtr ract = snap_delta_action (delta); + + if (ract) { + ract->set_active (true); + } +} + void Editor::snap_mode_selection_done (SnapMode mode) { diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index eaa9132e86..0e1661aca9 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -162,9 +162,11 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void prev_snap_choice_music_only (); void prev_snap_choice_music_and_time (); void set_snap_to (Editing::SnapType); + void set_snap_delta (Editing::SnapDelta); void set_snap_mode (Editing::SnapMode); void set_snap_threshold (double pixel_distance) {snap_threshold = pixel_distance;} + Editing::SnapDelta snap_delta () const; Editing::SnapMode snap_mode () const; Editing::SnapType snap_type () const; @@ -1471,6 +1473,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void move_range_selection_start_or_end_to_region_boundary (bool, bool); Editing::SnapType _snap_type; + Editing::SnapDelta _snap_delta; Editing::SnapMode _snap_mode; /// Snap threshold in pixels @@ -1751,19 +1754,25 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD ArdourDropdown snap_type_selector; void build_snap_type_menu (); + ArdourDropdown snap_delta_selector; ArdourDropdown snap_mode_selector; + void build_snap_delta_menu (); void build_snap_mode_menu (); Gtk::HBox snap_box; std::vector snap_type_strings; + std::vector snap_delta_strings; std::vector snap_mode_strings; void snap_type_selection_done (Editing::SnapType); + void snap_delta_selection_done (Editing::SnapDelta); void snap_mode_selection_done (Editing::SnapMode); + void snap_delta_chosen (Editing::SnapDelta); void snap_mode_chosen (Editing::SnapMode); void snap_type_chosen (Editing::SnapType); Glib::RefPtr snap_type_action (Editing::SnapType); + Glib::RefPtr snap_delta_action (Editing::SnapDelta); Glib::RefPtr snap_mode_action (Editing::SnapMode); //zoom focus meu stuff diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc index baebda73af..eeb3c2aac4 100644 --- a/gtk2_ardour/editor_actions.cc +++ b/gtk2_ardour/editor_actions.cc @@ -512,9 +512,13 @@ Editor::register_actions () ActionManager::register_action (editor_actions, "set-edit-lock", S_("EditMode|Lock"), sigc::bind (sigc::mem_fun (*this, &Editor::set_edit_mode), Lock)); ActionManager::register_action (editor_actions, "cycle-edit-mode", _("Cycle Edit Mode"), sigc::mem_fun (*this, &Editor::cycle_edit_mode)); + ActionManager::register_action (editor_actions, X_("SnapDelta"), _("Snap Delta")); + RadioAction::Group snap_delta_group; + ActionManager::register_radio_action (editor_actions, snap_delta_group, X_("snap-absolute"), _("Absolute"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_delta_chosen), Editing::SnapAbsolute))); + ActionManager::register_radio_action (editor_actions, snap_delta_group, X_("snap-relative"), _("Relative"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_delta_chosen), Editing::SnapRelative))); + ActionManager::register_action (editor_actions, X_("SnapTo"), _("Snap to")); ActionManager::register_action (editor_actions, X_("SnapMode"), _("Snap Mode")); - RadioAction::Group snap_mode_group; ActionManager::register_radio_action (editor_actions, snap_mode_group, X_("snap-off"), _("No Grid"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_mode_chosen), Editing::SnapOff))); ActionManager::register_radio_action (editor_actions, snap_mode_group, X_("snap-normal"), _("Grid"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_mode_chosen), Editing::SnapNormal))); @@ -1463,6 +1467,36 @@ Editor::snap_type_chosen (SnapType type) } } +RefPtr +Editor::snap_delta_action (SnapDelta delta) +{ + const char* action = 0; + RefPtr act; + + switch (delta) { + case Editing::SnapAbsolute: + action = X_("snap-absolute"); + break; + case Editing::SnapRelative: + action = X_("snap-relative"); + break; + default: + fatal << string_compose (_("programming error: %1: %2"), "Editor: impossible snap delta type", (int) delta) << endmsg; + abort(); /*NOTREACHED*/ + } + + act = ActionManager::get_action (X_("Editor"), action); + + if (act) { + RefPtr ract = RefPtr::cast_dynamic(act); + return ract; + + } else { + error << string_compose (_("programming error: %1: %2"), "Editor::snap_delta_chosen could not find action to match mode.", action) << endmsg; + return RefPtr (); + } +} + RefPtr Editor::snap_mode_action (SnapMode mode) { @@ -1512,6 +1546,21 @@ Editor::cycle_snap_mode () } } +void +Editor::snap_delta_chosen (SnapDelta rel) +{ + /* this is driven by a toggle on a radio group, and so is invoked twice, + once for the item that became inactive and once for the one that became + active. + */ + + RefPtr ract = snap_delta_action (rel); + + if (ract && ract->get_active()) { + set_snap_delta (rel); + } +} + void Editor::snap_mode_chosen (SnapMode mode) { diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 9fbf2efce8..b2f84fe638 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -264,6 +264,7 @@ Drag::start_grab (GdkEvent* event, Gdk::Cursor *cursor) } _raw_grab_frame = _editor->canvas_event_sample (event, &_grab_x, &_grab_y); + setup_pointer_frame_offset (); _grab_frame = adjusted_frame (_raw_grab_frame, event); _last_pointer_frame = _grab_frame; @@ -559,6 +560,7 @@ RegionMotionDrag::RegionMotionDrag (Editor* e, ArdourCanvas::Item* i, RegionView , _ndropzone (0) , _pdropzone (0) , _ddropzone (0) + , _snap_delta (0) { DEBUG_TRACE (DEBUG::Drags, "New RegionMotionDrag\n"); } @@ -568,6 +570,12 @@ RegionMotionDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor) { Drag::start_grab (event, cursor); + if (_editor->snap_delta () == SnapRelative) { + framepos_t temp = _last_frame_position; + _editor->snap_to_with_modifier (temp, event, RoundUpMaybe); + _snap_delta = temp - _last_frame_position; + } + if (Keyboard::modifier_state_contains (event->button.state, Keyboard::TertiaryModifier)) { _single_axis = true; } @@ -588,7 +596,7 @@ RegionMotionDrag::compute_x_delta (GdkEvent const * event, framepos_t* pending_r /* compute the amount of pointer motion in frames, and where the region would be if we moved it by that much. */ - *pending_region_position = adjusted_current_frame (event); + *pending_region_position = adjusted_frame (_drags->current_pointer_frame () + _snap_delta, event, true); framepos_t sync_frame; framecnt_t sync_offset; @@ -600,11 +608,11 @@ RegionMotionDrag::compute_x_delta (GdkEvent const * event, framepos_t* pending_r */ if (sync_dir >= 0 || (sync_dir < 0 && *pending_region_position >= sync_offset)) { - sync_frame = *pending_region_position + (sync_dir*sync_offset); + sync_frame = *pending_region_position + (sync_dir * sync_offset); _editor->snap_to_with_modifier (sync_frame, event); - *pending_region_position = _primary->region()->adjust_to_sync (sync_frame); + *pending_region_position = _primary->region()->adjust_to_sync (sync_frame) - _snap_delta; } else { *pending_region_position = _last_frame_position; @@ -2318,6 +2326,7 @@ RegionCreateDrag::aborted (bool) NoteResizeDrag::NoteResizeDrag (Editor* e, ArdourCanvas::Item* i) : Drag (e, i) , region (0) + , _snap_delta (0) { DEBUG_TRACE (DEBUG::Drags, "New NoteResizeDrag\n"); } @@ -2342,6 +2351,21 @@ NoteResizeDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*ignored*/) region = &cnote->region_view(); + if (_editor->snap_delta () == SnapRelative) { + double temp; + temp = region->snap_to_pixel(cnote->x0 ()); + _snap_delta = temp - cnote->x0 (); + /* + if (at_front) { + temp = region->snap_to_pixel(cnote->x0 ()); + _snap_delta = temp - cnote->x0 (); + } else { + temp = region->snap_to_pixel(cnote->x1 ()); + _snap_delta = temp - cnote->x1 (); + } + */ + } + _item->grab (); if (event->motion.state & Keyboard::PrimaryModifier) { @@ -2385,7 +2409,7 @@ NoteResizeDrag::motion (GdkEvent* /*event*/, bool /*first_move*/) assert (nb); MidiRegionView* mrv = dynamic_cast(*r); if (mrv) { - mrv->update_resizing (nb, at_front, _drags->current_pointer_x() - grab_x(), relative); + mrv->update_resizing (nb, at_front, _drags->current_pointer_x() - grab_x(), relative, _snap_delta); } } } @@ -2399,7 +2423,7 @@ NoteResizeDrag::finished (GdkEvent*, bool /*movement_occurred*/) assert (nb); MidiRegionView* mrv = dynamic_cast(*r); if (mrv) { - mrv->commit_resizing (nb, at_front, _drags->current_pointer_x() - grab_x(), relative); + mrv->commit_resizing (nb, at_front, _drags->current_pointer_x() - grab_x(), relative, _snap_delta); } } @@ -2577,6 +2601,7 @@ TrimDrag::TrimDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, listsnap_delta () == SnapRelative) { + framepos_t temp = region_start; + _editor->snap_to_with_modifier (temp, event, RoundUpMaybe); + _snap_delta = temp - region_start; + } + if (Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) { /* Move the contents of the region around without changing the region bounds */ _operation = ContentsTrim; @@ -2636,7 +2667,7 @@ TrimDrag::start_grab (GdkEvent* event, Gdk::Cursor*) } break; case EndTrim: - show_verbose_cursor_time (region_end); + show_verbose_cursor_duration (region_start, region_end); break; case ContentsTrim: show_verbose_cursor_time (pf); @@ -2662,8 +2693,8 @@ TrimDrag::motion (GdkEvent* event, bool first_move) if (tv && tv->is_track()) { speed = tv->track()->speed(); } - - framecnt_t dt = adjusted_current_frame (event) - raw_grab_frame () + _pointer_frame_offset; + framecnt_t adj_frame = adjusted_frame (_drags->current_pointer_frame () + _snap_delta, event, true); + framecnt_t dt = adj_frame - raw_grab_frame () + _pointer_frame_offset - _snap_delta; if (first_move) { @@ -2769,7 +2800,7 @@ TrimDrag::motion (GdkEvent* event, bool first_move) if (arv) { boost::shared_ptr ar (arv->audio_region()); framecnt_t len = ar->fade_out()->back()->when; - framecnt_t diff = 1 + ar->last_frame() - i->initial_end; + framecnt_t diff = ar->last_frame() - i->initial_end; framepos_t new_length = len + diff; i->anchored_fade_length = min (ar->length(), new_length); //i->anchored_fade_length = ar->verify_xfade_bounds (new_length, false /*END*/ ); @@ -2795,7 +2826,7 @@ TrimDrag::motion (GdkEvent* event, bool first_move) show_verbose_cursor_time ((framepos_t) (rv->region()->position() / speed)); break; case EndTrim: - show_verbose_cursor_time ((framepos_t) (rv->region()->last_frame() / speed)); + show_verbose_cursor_duration ((framepos_t) rv->region()->position() / speed, (framepos_t) rv->region()->last_frame() / speed); break; case ContentsTrim: // show_verbose_cursor_time (frame_delta); @@ -3213,6 +3244,7 @@ CursorDrag::CursorDrag (Editor* e, EditorCursor& c, bool s) : Drag (e, &c.track_canvas_item(), false) , _cursor (c) , _stop (s) + , _snap_delta (0) { DEBUG_TRACE (DEBUG::Drags, "New CursorDrag\n"); } @@ -3248,9 +3280,15 @@ CursorDrag::start_grab (GdkEvent* event, Gdk::Cursor* c) { Drag::start_grab (event, c); + if (_editor->snap_delta () == SnapRelative) { + framepos_t temp = _editor->playhead_cursor->current_frame (); + _editor->snap_to_with_modifier (temp, event); + _snap_delta = temp - _editor->playhead_cursor->current_frame (); + } + _grab_zoom = _editor->samples_per_pixel; - framepos_t where = _editor->canvas_event_sample (event); + framepos_t where = _editor->canvas_event_sample (event) + _snap_delta; _editor->snap_to_with_modifier (where, event); @@ -3288,15 +3326,16 @@ CursorDrag::start_grab (GdkEvent* event, Gdk::Cursor* c) } } - fake_locate (where); + fake_locate (where - _snap_delta); } void CursorDrag::motion (GdkEvent* event, bool) { - framepos_t const adjusted_frame = adjusted_current_frame (event); - if (adjusted_frame != last_pointer_frame()) { - fake_locate (adjusted_frame); + framepos_t where = _editor->canvas_event_sample (event) + _snap_delta; + _editor->snap_to_with_modifier (where, event); + if (where != last_pointer_frame()) { + fake_locate (where - _snap_delta); } } @@ -3336,6 +3375,7 @@ CursorDrag::aborted (bool) FadeInDrag::FadeInDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, list const & v) : RegionDrag (e, i, p, v) + , _snap_delta (0) { DEBUG_TRACE (DEBUG::Drags, "New FadeInDrag\n"); } @@ -3348,6 +3388,12 @@ FadeInDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor) AudioRegionView* arv = dynamic_cast (_primary); boost::shared_ptr const r = arv->audio_region (); + if (_editor->snap_delta () == SnapRelative) { + framepos_t temp = r->position(); + _editor->snap_to_with_modifier (temp, event); + _snap_delta = temp - r->position(); + } + show_verbose_cursor_duration (r->position(), r->position() + r->fade_in()->back()->when, 32); } @@ -3363,7 +3409,11 @@ void FadeInDrag::motion (GdkEvent* event, bool) { framecnt_t fade_length; - framepos_t const pos = adjusted_current_frame (event); + + framepos_t pos = _editor->canvas_event_sample (event) + _snap_delta; + _editor->snap_to_with_modifier (pos, event); + pos -= _snap_delta; + boost::shared_ptr region = boost::dynamic_pointer_cast (_primary->region ()); if (pos < (region->position() + 64)) { @@ -3396,8 +3446,9 @@ FadeInDrag::finished (GdkEvent* event, bool movement_occurred) } framecnt_t fade_length; - - framepos_t const pos = adjusted_current_frame (event); + framepos_t pos = _editor->canvas_event_sample (event) + _snap_delta; + _editor->snap_to_with_modifier (pos, event); + pos -= _snap_delta; boost::shared_ptr region = boost::dynamic_pointer_cast (_primary->region ()); @@ -3460,6 +3511,12 @@ FadeOutDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor) AudioRegionView* arv = dynamic_cast (_primary); boost::shared_ptr r = arv->audio_region (); + if (_editor->snap_delta () == SnapRelative) { + framepos_t temp = r->last_frame (); + _editor->snap_to_with_modifier (temp, event); + _snap_delta = temp - r->last_frame(); + } + show_verbose_cursor_duration (r->last_frame() - r->fade_out()->back()->when, r->last_frame()); } @@ -3476,7 +3533,9 @@ FadeOutDrag::motion (GdkEvent* event, bool) { framecnt_t fade_length; - framepos_t const pos = adjusted_current_frame (event); + framepos_t pos = _editor->canvas_event_sample (event) + _snap_delta; + _editor->snap_to_with_modifier (pos, event); + pos -= _snap_delta; boost::shared_ptr region = boost::dynamic_pointer_cast (_primary->region ()); @@ -3511,7 +3570,9 @@ FadeOutDrag::finished (GdkEvent* event, bool movement_occurred) framecnt_t fade_length; - framepos_t const pos = adjusted_current_frame (event); + framepos_t pos = _editor->canvas_event_sample (event) + _snap_delta; + _editor->snap_to_with_modifier (pos, event); + pos -= _snap_delta; boost::shared_ptr region = boost::dynamic_pointer_cast (_primary->region ()); @@ -3965,6 +4026,16 @@ ControlPointDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*cursor*/) _fixed_grab_x = _point->get_x(); _fixed_grab_y = _point->get_y(); + framepos_t pos = _editor->pixel_to_sample (_fixed_grab_x); + + if (_editor->snap_delta () == SnapRelative) { + framepos_t temp = pos; + if (!_x_constrained) { + _editor->snap_to_with_modifier (temp, event); + } + _snap_delta = temp - pos; + } + float const fraction = 1 - (_point->get_y() / _point->line().height()); _point->line().start_drag_single (_point, _fixed_grab_x, fraction); @@ -4017,12 +4088,13 @@ ControlPointDrag::motion (GdkEvent* event, bool) cy = max (0.0, cy); cy = min ((double) _point->line().height(), cy); - framepos_t cx_frames = _editor->pixel_to_sample (cx); + framepos_t cx_frames = _editor->pixel_to_sample (cx) + _snap_delta; if (!_x_constrained) { _editor->snap_to_with_modifier (cx_frames, event); } + cx_frames -= _snap_delta; cx_frames = min (cx_frames, _point->line().maximum_time()); float const fraction = 1.0 - (cy / _point->line().height()); @@ -4070,9 +4142,9 @@ ControlPointDrag::active (Editing::MouseMode m) } LineDrag::LineDrag (Editor* e, ArdourCanvas::Item* i) - : Drag (e, i), - _line (0), - _cumulative_y_drag (0) + : Drag (e, i) + , _line (0) + , _cumulative_y_drag (0) { DEBUG_TRACE (DEBUG::Drags, "New LineDrag\n"); } @@ -4423,6 +4495,7 @@ RubberbandSelectDrag::aborted (bool) TimeFXDrag::TimeFXDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, std::list const & v) : RegionDrag (e, i, p, v) + , _snap_delta (0) { DEBUG_TRACE (DEBUG::Drags, "New TimeFXDrag\n"); } @@ -4432,7 +4505,16 @@ TimeFXDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor) { Drag::start_grab (event, cursor); - show_verbose_cursor_time (adjusted_current_frame (event)); + _editor->get_selection().add (_primary); + + framepos_t where = _primary->region()->position(); + if (_editor->snap_delta () == SnapRelative) { + framepos_t temp = where; + _editor->snap_to_with_modifier (temp, event); + _snap_delta = temp - where; + } + + show_verbose_cursor_duration (where, adjusted_current_frame (event), 0); } void @@ -4444,14 +4526,15 @@ TimeFXDrag::motion (GdkEvent* event, bool) pair const tv = _editor->trackview_by_y_position (grab_y()); int layer = tv.first->layer_display() == Overlaid ? 0 : tv.second; int layers = tv.first->layer_display() == Overlaid ? 1 : cv->layers(); - - framepos_t const pf = adjusted_current_frame (event); + framepos_t pf = _editor->canvas_event_sample (event) + _snap_delta; + _editor->snap_to_with_modifier (pf, event); + pf -= _snap_delta; if (pf > rv->region()->position()) { rv->get_time_axis_view().show_timestretch (rv->region()->position(), pf, layers, layer); } - show_verbose_cursor_time (pf); + show_verbose_cursor_duration (_primary->region()->position(), pf, 0); } void @@ -5117,6 +5200,7 @@ NoteDrag::NoteDrag (Editor* e, ArdourCanvas::Item* i) : Drag (e, i) , _cumulative_dx (0) , _cumulative_dy (0) + , _snap_delta (0) { DEBUG_TRACE (DEBUG::Drags, "New NoteDrag\n"); @@ -5131,6 +5215,13 @@ NoteDrag::start_grab (GdkEvent* event, Gdk::Cursor *) { Drag::start_grab (event); + if (_editor->snap_delta () == SnapRelative) { + framepos_t where = _region->source_beats_to_absolute_frames (_primary->note()->time ()); + framepos_t temp = where; + _editor->snap_to_with_modifier (temp, event); + _snap_delta = temp - where; + } + if (!(_was_selected = _primary->selected())) { /* tertiary-click means extend selection - we'll do that on button release, @@ -5166,7 +5257,7 @@ NoteDrag::total_dx () const frameoffset_t const n = _region->source_beats_to_absolute_frames (_primary->note()->time ()); /* new time of the primary note in session frames */ - frameoffset_t st = n + dx; + frameoffset_t st = n + dx + _snap_delta; framepos_t const rp = _region->region()->position (); @@ -5174,7 +5265,7 @@ NoteDrag::total_dx () const st = max (st, rp); /* snap and return corresponding delta */ - return _region->snap_frame_to_frame (st - rp) + rp - n; + return _region->snap_frame_to_frame (st - rp) + rp - n - _snap_delta; } /** @return Current total drag y change in note number */ @@ -5880,7 +5971,7 @@ RegionCutDrag::RegionCutDrag (Editor* e, ArdourCanvas::Item* item, framepos_t po , line (new EditorCursor (*e)) { line->set_position (pos); - line->show (); + line->how (); } RegionCutDrag::~RegionCutDrag () diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index e6f800cb52..e5eecbb3ed 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -213,7 +213,7 @@ protected: return _last_pointer_y; } - double last_pointer_frame () const { + ARDOUR::framepos_t last_pointer_frame () const { return _last_pointer_frame; } @@ -341,6 +341,7 @@ private: uint32_t _ndropzone; uint32_t _pdropzone; uint32_t _ddropzone; + int32_t _snap_delta; ///< delta between the initial position and next snap point }; @@ -503,6 +504,7 @@ private: MidiRegionView* region; bool relative; bool at_front; + double _snap_delta; }; /** Drags to move MIDI notes */ @@ -527,6 +529,7 @@ class NoteDrag : public Drag double _cumulative_dy; bool _was_selected; double _note_height; + int32_t _snap_delta; }; class NoteCreateDrag : public Drag @@ -646,6 +649,7 @@ private: bool _preserve_fade_anchor; bool _jump_position_when_done; + int32_t _snap_delta; }; /** Meter marker drag */ @@ -728,6 +732,7 @@ private: EditorCursor& _cursor; bool _stop; ///< true to stop the transport on starting the drag, otherwise false double _grab_zoom; ///< editor frames per unit when our grab started + int32_t _snap_delta; }; /** Region fade-in drag */ @@ -746,6 +751,8 @@ public: } void setup_pointer_frame_offset (); +private: + int32_t _snap_delta; }; /** Region fade-out drag */ @@ -764,6 +771,8 @@ public: } void setup_pointer_frame_offset (); +private: + int32_t _snap_delta; }; /** Marker drag */ @@ -827,6 +836,7 @@ private: double _cumulative_y_drag; bool _pushing; uint32_t _final_index; + int32_t _snap_delta; static double _zero_gain_fraction; }; @@ -951,6 +961,8 @@ public: void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); void aborted (bool); +private: + int32_t _snap_delta; }; /** Scrub drag in audition mode */ diff --git a/gtk2_ardour/enums.cc b/gtk2_ardour/enums.cc index 4cae1f5db4..956db79dd4 100644 --- a/gtk2_ardour/enums.cc +++ b/gtk2_ardour/enums.cc @@ -43,6 +43,7 @@ setup_gtk_ardour_enums () LayerDisplay layer_display; RegionListSortType region_list_sort_type; SnapType snap_type; + SnapDelta snap_delta; SnapMode snap_mode; ZoomFocus zoom_focus; ItemType item_type; @@ -90,6 +91,10 @@ setup_gtk_ardour_enums () REGISTER_ENUM (ByTimestamp); REGISTER (region_list_sort_type); + REGISTER_ENUM (SnapAbsolute); + REGISTER_ENUM (SnapRelative); + REGISTER (snap_delta); + REGISTER_ENUM (SnapToCDFrame); REGISTER_ENUM (SnapToTimecodeFrame); REGISTER_ENUM (SnapToTimecodeSeconds); diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index eed9017d0d..97a71003eb 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -104,6 +104,7 @@ MidiRegionView::MidiRegionView (ArdourCanvas::Container* parent, , _current_range_max(0) , _region_relative_time_converter(r->session().tempo_map(), r->position()) , _source_relative_time_converter(r->session().tempo_map(), r->position() - r->start()) + , _region_relative_time_converter_double(r->session().tempo_map(), r->position()) , _active_notes(0) , _note_group (new ArdourCanvas::Container (group)) , _note_diff_command (0) @@ -151,6 +152,7 @@ MidiRegionView::MidiRegionView (ArdourCanvas::Container* parent, , _current_range_max(0) , _region_relative_time_converter(r->session().tempo_map(), r->position()) , _source_relative_time_converter(r->session().tempo_map(), r->position() - r->start()) + , _region_relative_time_converter_double(r->session().tempo_map(), r->position()) , _active_notes(0) , _note_group (new ArdourCanvas::Container (group)) , _note_diff_command (0) @@ -203,6 +205,7 @@ MidiRegionView::MidiRegionView (const MidiRegionView& other) , _current_range_max(0) , _region_relative_time_converter(other.region_relative_time_converter()) , _source_relative_time_converter(other.source_relative_time_converter()) + , _region_relative_time_converter_double(other.region_relative_time_converter_double()) , _active_notes(0) , _note_group (new ArdourCanvas::Container (get_canvas_group())) , _note_diff_command (0) @@ -234,6 +237,7 @@ MidiRegionView::MidiRegionView (const MidiRegionView& other, boost::shared_ptrposition()); + _region_relative_time_converter_double.set_origin_b(_region->position()); set_duration(_region->length(), 0); if (_enable_display) { redisplay_model(); @@ -2685,6 +2690,12 @@ MidiRegionView::region_frames_to_region_beats(framepos_t frames) const return _region_relative_time_converter.from(frames); } +double +MidiRegionView::region_frames_to_region_beats_double(framepos_t frames) const +{ + return _region_relative_time_converter_double.from(frames); +} + void MidiRegionView::begin_resizing (bool /*at_front*/) { @@ -2733,9 +2744,10 @@ MidiRegionView::begin_resizing (bool /*at_front*/) * a difference when multiple notes are being resized; in relative mode, each note's length is changed by the * amount of the drag. In non-relative mode, all selected notes are set to have the same start or end point * as the \a primary note. + * @param snap_delta snap offset of the primary note in pixels. used in SnapRelative SnapDelta mode. */ void -MidiRegionView::update_resizing (NoteBase* primary, bool at_front, double delta_x, bool relative) +MidiRegionView::update_resizing (NoteBase* primary, bool at_front, double delta_x, bool relative, double snap_delta) { bool cursor_set = false; @@ -2746,15 +2758,15 @@ MidiRegionView::update_resizing (NoteBase* primary, bool at_front, double delta_ if (at_front) { if (relative) { - current_x = canvas_note->x0() + delta_x; + current_x = canvas_note->x0() + delta_x + snap_delta; } else { - current_x = primary->x0() + delta_x; + current_x = primary->x0() + delta_x + snap_delta; } } else { if (relative) { - current_x = canvas_note->x1() + delta_x; + current_x = canvas_note->x1() + delta_x + snap_delta; } else { - current_x = primary->x1() + delta_x; + current_x = primary->x1() + delta_x + snap_delta; } } @@ -2768,26 +2780,38 @@ MidiRegionView::update_resizing (NoteBase* primary, bool at_front, double delta_ } if (at_front) { - resize_rect->set_x0 (snap_to_pixel(current_x)); + resize_rect->set_x0 (snap_to_pixel(current_x) - snap_delta); resize_rect->set_x1 (canvas_note->x1()); } else { - resize_rect->set_x1 (snap_to_pixel(current_x)); + resize_rect->set_x1 (snap_to_pixel(current_x) - snap_delta); resize_rect->set_x0 (canvas_note->x0()); } if (!cursor_set) { + /* snap delta is in pixels (sigh) */ + framepos_t delta_samps = trackview.editor().pixel_to_sample (snap_delta); + double delta_beats; + int sign = 1; + /* negative beat offsets aren't allowed */ + if (delta_samps > 0) { + delta_beats = _region_relative_time_converter_double.from(delta_samps); + } else if (delta_samps < 0) { + delta_beats = _region_relative_time_converter_double.from( - delta_samps); + sign = -1; + } + const double snapped_x = snap_pixel_to_sample (current_x); Evoral::Beats beats = region_frames_to_region_beats (snapped_x); Evoral::Beats len = Evoral::Beats(); if (at_front) { if (beats < canvas_note->note()->end_time()) { - len = canvas_note->note()->time() - beats; + len = canvas_note->note()->time() - beats + (sign * delta_beats); len += canvas_note->note()->length(); } } else { if (beats >= canvas_note->note()->time()) { - len = beats - canvas_note->note()->time(); + len = beats - canvas_note->note()->time() - (sign * delta_beats); } } @@ -2808,10 +2832,9 @@ MidiRegionView::update_resizing (NoteBase* primary, bool at_front, double delta_ * Parameters the same as for \a update_resizing(). */ void -MidiRegionView::commit_resizing (NoteBase* primary, bool at_front, double delta_x, bool relative) +MidiRegionView::commit_resizing (NoteBase* primary, bool at_front, double delta_x, bool relative, double snap_delta) { _note_diff_command = _model->new_note_diff_command (_("resize notes")); - for (std::vector::iterator i = _resize_data.begin(); i != _resize_data.end(); ++i) { Note* canvas_note = (*i)->note; ArdourCanvas::Rectangle* resize_rect = (*i)->resize_rect; @@ -2824,15 +2847,15 @@ MidiRegionView::commit_resizing (NoteBase* primary, bool at_front, double delta_ if (at_front) { if (relative) { - current_x = canvas_note->x0() + delta_x; + current_x = canvas_note->x0() + delta_x + snap_delta; } else { - current_x = primary->x0() + delta_x; + current_x = primary->x0() + delta_x + snap_delta; } } else { if (relative) { - current_x = canvas_note->x1() + delta_x; + current_x = canvas_note->x1() + delta_x + snap_delta; } else { - current_x = primary->x1() + delta_x; + current_x = primary->x1() + delta_x + snap_delta; } } @@ -2842,17 +2865,26 @@ MidiRegionView::commit_resizing (NoteBase* primary, bool at_front, double delta_ if (current_x > trackview.editor().sample_to_pixel(_region->length())) { current_x = trackview.editor().sample_to_pixel(_region->length()); } + framepos_t delta_samps = trackview.editor().pixel_to_sample (snap_delta); + double delta_beats; + int sign = 1; + if (delta_samps > 0) { + delta_beats = _region_relative_time_converter_double.from(delta_samps); + } else if (delta_samps < 0) { + delta_beats = _region_relative_time_converter_double.from( - delta_samps); + sign = -1; + } /* Convert that to a frame within the source */ - current_x = snap_pixel_to_sample (current_x) + _region->start (); - + framepos_t current_fr = snap_pixel_to_sample (current_x) + _region->start (); + double one_frame = region_frames_to_region_beats_double (current_fr) - region_frames_to_region_beats_double (current_fr - 1); + cerr << "commit one frame in beats : " << one_frame << endl; /* and then to beats */ - const Evoral::Beats x_beats = region_frames_to_region_beats (current_x); - + const Evoral::Beats x_beats = region_frames_to_region_beats (current_fr); if (at_front && x_beats < canvas_note->note()->end_time()) { - note_diff_add_change (canvas_note, MidiModel::NoteDiffCommand::StartTime, x_beats); + note_diff_add_change (canvas_note, MidiModel::NoteDiffCommand::StartTime, x_beats - (sign * delta_beats)); - Evoral::Beats len = canvas_note->note()->time() - x_beats; + Evoral::Beats len = canvas_note->note()->time() - x_beats + (sign * delta_beats); len += canvas_note->note()->length(); if (!!len) { @@ -2862,7 +2894,7 @@ MidiRegionView::commit_resizing (NoteBase* primary, bool at_front, double delta_ if (!at_front) { const Evoral::Beats len = std::max(Evoral::Beats(1 / 512.0), - x_beats - canvas_note->note()->time()); + x_beats - canvas_note->note()->time() - (sign * delta_beats) - one_frame); note_diff_add_change (canvas_note, MidiModel::NoteDiffCommand::Length, len); } diff --git a/gtk2_ardour/midi_region_view.h b/gtk2_ardour/midi_region_view.h index 776543041c..cfdb50a99c 100644 --- a/gtk2_ardour/midi_region_view.h +++ b/gtk2_ardour/midi_region_view.h @@ -223,8 +223,8 @@ public: */ void begin_resizing(bool at_front); - void update_resizing (NoteBase*, bool, double, bool); - void commit_resizing (NoteBase*, bool, double, bool); + void update_resizing (NoteBase*, bool, double, bool, double); + void commit_resizing (NoteBase*, bool, double, bool, double); void abort_resizing (); /** Change the channel of the selection. @@ -268,6 +268,7 @@ public: } /** Convert a timestamp in frames to beats (both relative to region position) */ Evoral::Beats region_frames_to_region_beats(framepos_t) const; + double region_frames_to_region_beats_double(framepos_t) const; /** Convert a timestamp in beats measured from source start into absolute frames */ framepos_t source_beats_to_absolute_frames(Evoral::Beats beats) const; @@ -286,6 +287,10 @@ public: return _source_relative_time_converter; } + ARDOUR::DoubleBeatsFramesConverter const & region_relative_time_converter_double () const { + return _region_relative_time_converter_double; + } + void goto_previous_note (bool add_to_selection); void goto_next_note (bool add_to_selection); void change_note_lengths (bool, bool, Evoral::Beats beats, bool start, bool end); @@ -400,6 +405,7 @@ private: ARDOUR::BeatsFramesConverter _region_relative_time_converter; ARDOUR::BeatsFramesConverter _source_relative_time_converter; + ARDOUR::DoubleBeatsFramesConverter _region_relative_time_converter_double; boost::shared_ptr _model; Events _events; diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index cf68f35fb9..a8ecbb5f40 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -129,8 +129,11 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible, publi virtual void set_snap_to (Editing::SnapType t) = 0; virtual Editing::SnapType snap_type () const = 0; + virtual Editing::SnapDelta snap_delta () const = 0; virtual Editing::SnapMode snap_mode () const = 0; + virtual void set_snap_delta (Editing::SnapDelta m) = 0; + /** Set the snap mode. * @param m Snap mode (defined in editing_syms.h) */ -- cgit v1.2.3 From c8303c8b7ee25e453f3374e37c022ccc0c16a3f1 Mon Sep 17 00:00:00 2001 From: nick_m Date: Sat, 16 May 2015 04:50:37 +1000 Subject: Revert incorrect region_length() definition. --- gtk2_ardour/editor_drag.cc | 2 +- libs/ardour/ardour/region.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index b2f84fe638..799d441b16 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -2800,7 +2800,7 @@ TrimDrag::motion (GdkEvent* event, bool first_move) if (arv) { boost::shared_ptr ar (arv->audio_region()); framecnt_t len = ar->fade_out()->back()->when; - framecnt_t diff = ar->last_frame() - i->initial_end; + framecnt_t diff = 1 + ar->last_frame() - i->initial_end; framepos_t new_length = len + diff; i->anchored_fade_length = min (ar->length(), new_length); //i->anchored_fade_length = ar->verify_xfade_bounds (new_length, false /*END*/ ); diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h index 071cae9127..54cfd57fea 100644 --- a/libs/ardour/ardour/region.h +++ b/libs/ardour/ardour/region.h @@ -139,7 +139,7 @@ class LIBARDOUR_API Region /* first_frame() is an alias; last_frame() just hides some math */ framepos_t first_frame () const { return _position; } - framepos_t last_frame () const { return _position + _length; } + framepos_t last_frame () const { return _position + _length - 1; } /** Return the earliest possible value of _position given the * value of _start within the region's sources @@ -151,7 +151,7 @@ class LIBARDOUR_API Region framepos_t latest_possible_frame () const; Evoral::Range last_range () const { - return Evoral::Range (_last_position, _last_position + _last_length); + return Evoral::Range (_last_position, _last_position + _last_length - 1); } Evoral::Range range () const { -- cgit v1.2.3 From 6831d8a5aa9fc236cd7d80b34a493cbe5563b22f Mon Sep 17 00:00:00 2001 From: nick_m Date: Sat, 16 May 2015 06:10:02 +1000 Subject: Fix typo. --- gtk2_ardour/editor_drag.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 799d441b16..065eecbf7d 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -5971,7 +5971,7 @@ RegionCutDrag::RegionCutDrag (Editor* e, ArdourCanvas::Item* item, framepos_t po , line (new EditorCursor (*e)) { line->set_position (pos); - line->how (); + line->show (); } RegionCutDrag::~RegionCutDrag () -- cgit v1.2.3 From bbafb8f137bd9f8a18a7242e2628d309a1f8f991 Mon Sep 17 00:00:00 2001 From: nick_m Date: Sun, 17 May 2015 00:23:25 +1000 Subject: Cleanup relative snap code. --- gtk2_ardour/editor_drag.cc | 128 +++++++++++++++------------------------------ gtk2_ardour/editor_drag.h | 23 ++++---- 2 files changed, 53 insertions(+), 98 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 065eecbf7d..f7f4cd2873 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -226,6 +226,7 @@ Drag::Drag (Editor* e, ArdourCanvas::Item* i, bool trackview_only) , _raw_grab_frame (0) , _grab_frame (0) , _last_pointer_frame (0) + , _snap_delta (0) { } @@ -360,6 +361,16 @@ Drag::current_pointer_y () const return _drags->current_pointer_y () - _editor->get_trackview_group()->canvas_origin().y; } +void +Drag::setup_snap_delta (framepos_t pos) +{ + if (_editor->snap_delta () == SnapRelative) { + framepos_t temp = pos; + _editor->snap_to (temp); + _snap_delta = temp - pos; + } +} + bool Drag::motion_handler (GdkEvent* event, bool from_autoscroll) { @@ -560,7 +571,6 @@ RegionMotionDrag::RegionMotionDrag (Editor* e, ArdourCanvas::Item* i, RegionView , _ndropzone (0) , _pdropzone (0) , _ddropzone (0) - , _snap_delta (0) { DEBUG_TRACE (DEBUG::Drags, "New RegionMotionDrag\n"); } @@ -569,12 +579,7 @@ void RegionMotionDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor) { Drag::start_grab (event, cursor); - - if (_editor->snap_delta () == SnapRelative) { - framepos_t temp = _last_frame_position; - _editor->snap_to_with_modifier (temp, event, RoundUpMaybe); - _snap_delta = temp - _last_frame_position; - } + setup_snap_delta (_last_frame_position); if (Keyboard::modifier_state_contains (event->button.state, Keyboard::TertiaryModifier)) { _single_axis = true; @@ -596,7 +601,7 @@ RegionMotionDrag::compute_x_delta (GdkEvent const * event, framepos_t* pending_r /* compute the amount of pointer motion in frames, and where the region would be if we moved it by that much. */ - *pending_region_position = adjusted_frame (_drags->current_pointer_frame () + _snap_delta, event, true); + *pending_region_position = adjusted_frame (_drags->current_pointer_frame () + snap_delta (), event, true); framepos_t sync_frame; framecnt_t sync_offset; @@ -612,7 +617,7 @@ RegionMotionDrag::compute_x_delta (GdkEvent const * event, framepos_t* pending_r _editor->snap_to_with_modifier (sync_frame, event); - *pending_region_position = _primary->region()->adjust_to_sync (sync_frame) - _snap_delta; + *pending_region_position = _primary->region()->adjust_to_sync (sync_frame) - snap_delta (); } else { *pending_region_position = _last_frame_position; @@ -2355,15 +2360,6 @@ NoteResizeDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*ignored*/) double temp; temp = region->snap_to_pixel(cnote->x0 ()); _snap_delta = temp - cnote->x0 (); - /* - if (at_front) { - temp = region->snap_to_pixel(cnote->x0 ()); - _snap_delta = temp - cnote->x0 (); - } else { - temp = region->snap_to_pixel(cnote->x1 ()); - _snap_delta = temp - cnote->x1 (); - } - */ } _item->grab (); @@ -2601,7 +2597,6 @@ TrimDrag::TrimDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, listregion()->length() / speed); framepos_t const pf = adjusted_current_frame (event); - - if (_editor->snap_delta () == SnapRelative) { - framepos_t temp = region_start; - _editor->snap_to_with_modifier (temp, event, RoundUpMaybe); - _snap_delta = temp - region_start; - } + setup_snap_delta (region_start); if (Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) { /* Move the contents of the region around without changing the region bounds */ @@ -2693,8 +2683,8 @@ TrimDrag::motion (GdkEvent* event, bool first_move) if (tv && tv->is_track()) { speed = tv->track()->speed(); } - framecnt_t adj_frame = adjusted_frame (_drags->current_pointer_frame () + _snap_delta, event, true); - framecnt_t dt = adj_frame - raw_grab_frame () + _pointer_frame_offset - _snap_delta; + framecnt_t adj_frame = adjusted_frame (_drags->current_pointer_frame () + snap_delta (), event, true); + framecnt_t dt = adj_frame - raw_grab_frame () + _pointer_frame_offset - snap_delta (); if (first_move) { @@ -3244,7 +3234,6 @@ CursorDrag::CursorDrag (Editor* e, EditorCursor& c, bool s) : Drag (e, &c.track_canvas_item(), false) , _cursor (c) , _stop (s) - , _snap_delta (0) { DEBUG_TRACE (DEBUG::Drags, "New CursorDrag\n"); } @@ -3279,16 +3268,11 @@ void CursorDrag::start_grab (GdkEvent* event, Gdk::Cursor* c) { Drag::start_grab (event, c); - - if (_editor->snap_delta () == SnapRelative) { - framepos_t temp = _editor->playhead_cursor->current_frame (); - _editor->snap_to_with_modifier (temp, event); - _snap_delta = temp - _editor->playhead_cursor->current_frame (); - } + setup_snap_delta (_editor->playhead_cursor->current_frame ()); _grab_zoom = _editor->samples_per_pixel; - framepos_t where = _editor->canvas_event_sample (event) + _snap_delta; + framepos_t where = _editor->canvas_event_sample (event) + snap_delta (); _editor->snap_to_with_modifier (where, event); @@ -3326,16 +3310,16 @@ CursorDrag::start_grab (GdkEvent* event, Gdk::Cursor* c) } } - fake_locate (where - _snap_delta); + fake_locate (where - snap_delta ()); } void CursorDrag::motion (GdkEvent* event, bool) { - framepos_t where = _editor->canvas_event_sample (event) + _snap_delta; + framepos_t where = _editor->canvas_event_sample (event) + snap_delta (); _editor->snap_to_with_modifier (where, event); if (where != last_pointer_frame()) { - fake_locate (where - _snap_delta); + fake_locate (where - snap_delta ()); } } @@ -3375,7 +3359,6 @@ CursorDrag::aborted (bool) FadeInDrag::FadeInDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, list const & v) : RegionDrag (e, i, p, v) - , _snap_delta (0) { DEBUG_TRACE (DEBUG::Drags, "New FadeInDrag\n"); } @@ -3387,12 +3370,7 @@ FadeInDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor) AudioRegionView* arv = dynamic_cast (_primary); boost::shared_ptr const r = arv->audio_region (); - - if (_editor->snap_delta () == SnapRelative) { - framepos_t temp = r->position(); - _editor->snap_to_with_modifier (temp, event); - _snap_delta = temp - r->position(); - } + setup_snap_delta (r->position ()); show_verbose_cursor_duration (r->position(), r->position() + r->fade_in()->back()->when, 32); } @@ -3410,9 +3388,9 @@ FadeInDrag::motion (GdkEvent* event, bool) { framecnt_t fade_length; - framepos_t pos = _editor->canvas_event_sample (event) + _snap_delta; + framepos_t pos = _editor->canvas_event_sample (event) + snap_delta (); _editor->snap_to_with_modifier (pos, event); - pos -= _snap_delta; + pos -= snap_delta (); boost::shared_ptr region = boost::dynamic_pointer_cast (_primary->region ()); @@ -3446,9 +3424,9 @@ FadeInDrag::finished (GdkEvent* event, bool movement_occurred) } framecnt_t fade_length; - framepos_t pos = _editor->canvas_event_sample (event) + _snap_delta; + framepos_t pos = _editor->canvas_event_sample (event) + snap_delta (); _editor->snap_to_with_modifier (pos, event); - pos -= _snap_delta; + pos -= snap_delta (); boost::shared_ptr region = boost::dynamic_pointer_cast (_primary->region ()); @@ -3510,12 +3488,7 @@ FadeOutDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor) AudioRegionView* arv = dynamic_cast (_primary); boost::shared_ptr r = arv->audio_region (); - - if (_editor->snap_delta () == SnapRelative) { - framepos_t temp = r->last_frame (); - _editor->snap_to_with_modifier (temp, event); - _snap_delta = temp - r->last_frame(); - } + setup_snap_delta (r->last_frame ()); show_verbose_cursor_duration (r->last_frame() - r->fade_out()->back()->when, r->last_frame()); } @@ -3533,9 +3506,9 @@ FadeOutDrag::motion (GdkEvent* event, bool) { framecnt_t fade_length; - framepos_t pos = _editor->canvas_event_sample (event) + _snap_delta; + framepos_t pos = _editor->canvas_event_sample (event) + snap_delta (); _editor->snap_to_with_modifier (pos, event); - pos -= _snap_delta; + pos -= snap_delta (); boost::shared_ptr region = boost::dynamic_pointer_cast (_primary->region ()); @@ -3570,9 +3543,9 @@ FadeOutDrag::finished (GdkEvent* event, bool movement_occurred) framecnt_t fade_length; - framepos_t pos = _editor->canvas_event_sample (event) + _snap_delta; + framepos_t pos = _editor->canvas_event_sample (event) + snap_delta (); _editor->snap_to_with_modifier (pos, event); - pos -= _snap_delta; + pos -= snap_delta (); boost::shared_ptr region = boost::dynamic_pointer_cast (_primary->region ()); @@ -4027,14 +4000,7 @@ ControlPointDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*cursor*/) _fixed_grab_y = _point->get_y(); framepos_t pos = _editor->pixel_to_sample (_fixed_grab_x); - - if (_editor->snap_delta () == SnapRelative) { - framepos_t temp = pos; - if (!_x_constrained) { - _editor->snap_to_with_modifier (temp, event); - } - _snap_delta = temp - pos; - } + setup_snap_delta (pos); float const fraction = 1 - (_point->get_y() / _point->line().height()); @@ -4088,13 +4054,13 @@ ControlPointDrag::motion (GdkEvent* event, bool) cy = max (0.0, cy); cy = min ((double) _point->line().height(), cy); - framepos_t cx_frames = _editor->pixel_to_sample (cx) + _snap_delta; + framepos_t cx_frames = _editor->pixel_to_sample (cx) + snap_delta (); if (!_x_constrained) { _editor->snap_to_with_modifier (cx_frames, event); } - cx_frames -= _snap_delta; + cx_frames -= snap_delta (); cx_frames = min (cx_frames, _point->line().maximum_time()); float const fraction = 1.0 - (cy / _point->line().height()); @@ -4495,7 +4461,6 @@ RubberbandSelectDrag::aborted (bool) TimeFXDrag::TimeFXDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, std::list const & v) : RegionDrag (e, i, p, v) - , _snap_delta (0) { DEBUG_TRACE (DEBUG::Drags, "New TimeFXDrag\n"); } @@ -4508,11 +4473,7 @@ TimeFXDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor) _editor->get_selection().add (_primary); framepos_t where = _primary->region()->position(); - if (_editor->snap_delta () == SnapRelative) { - framepos_t temp = where; - _editor->snap_to_with_modifier (temp, event); - _snap_delta = temp - where; - } + setup_snap_delta (where); show_verbose_cursor_duration (where, adjusted_current_frame (event), 0); } @@ -4526,9 +4487,9 @@ TimeFXDrag::motion (GdkEvent* event, bool) pair const tv = _editor->trackview_by_y_position (grab_y()); int layer = tv.first->layer_display() == Overlaid ? 0 : tv.second; int layers = tv.first->layer_display() == Overlaid ? 1 : cv->layers(); - framepos_t pf = _editor->canvas_event_sample (event) + _snap_delta; + framepos_t pf = _editor->canvas_event_sample (event) + snap_delta (); _editor->snap_to_with_modifier (pf, event); - pf -= _snap_delta; + pf -= snap_delta (); if (pf > rv->region()->position()) { rv->get_time_axis_view().show_timestretch (rv->region()->position(), pf, layers, layer); @@ -5200,7 +5161,6 @@ NoteDrag::NoteDrag (Editor* e, ArdourCanvas::Item* i) : Drag (e, i) , _cumulative_dx (0) , _cumulative_dy (0) - , _snap_delta (0) { DEBUG_TRACE (DEBUG::Drags, "New NoteDrag\n"); @@ -5214,13 +5174,7 @@ void NoteDrag::start_grab (GdkEvent* event, Gdk::Cursor *) { Drag::start_grab (event); - - if (_editor->snap_delta () == SnapRelative) { - framepos_t where = _region->source_beats_to_absolute_frames (_primary->note()->time ()); - framepos_t temp = where; - _editor->snap_to_with_modifier (temp, event); - _snap_delta = temp - where; - } + setup_snap_delta (_region->source_beats_to_absolute_frames (_primary->note()->time ())); if (!(_was_selected = _primary->selected())) { @@ -5257,7 +5211,7 @@ NoteDrag::total_dx () const frameoffset_t const n = _region->source_beats_to_absolute_frames (_primary->note()->time ()); /* new time of the primary note in session frames */ - frameoffset_t st = n + dx + _snap_delta; + frameoffset_t st = n + dx + snap_delta (); framepos_t const rp = _region->region()->position (); @@ -5265,7 +5219,7 @@ NoteDrag::total_dx () const st = max (st, rp); /* snap and return corresponding delta */ - return _region->snap_frame_to_frame (st - rp) + rp - n - _snap_delta; + return _region->snap_frame_to_frame (st - rp) + rp - n - snap_delta (); } /** @return Current total drag y change in note number */ diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index e5eecbb3ed..5fb183671f 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -217,9 +217,16 @@ protected: return _last_pointer_frame; } + framecnt_t snap_delta () const { + return _snap_delta; + } + double current_pointer_x () const; double current_pointer_y () const; + /* sets snap delta from unsnapped pos */ + void setup_snap_delta (framepos_t pos); + boost::shared_ptr add_midi_region (MidiTimeAxisView*); void show_verbose_cursor_time (framepos_t); @@ -248,6 +255,11 @@ private: ARDOUR::framepos_t _raw_grab_frame; ///< unsnapped frame that the mouse was at when start_grab was called, or 0 ARDOUR::framepos_t _grab_frame; ///< adjusted_frame that the mouse was at when start_grab was called, or 0 ARDOUR::framepos_t _last_pointer_frame; ///< adjusted_frame the last time a motion occurred + + /* difference between some key position's snapped and unsnapped + * framepos. used for relative snap. + */ + framecnt_t _snap_delta; CursorContext::Handle _cursor_ctx; ///< cursor change context }; @@ -341,7 +353,6 @@ private: uint32_t _ndropzone; uint32_t _pdropzone; uint32_t _ddropzone; - int32_t _snap_delta; ///< delta between the initial position and next snap point }; @@ -529,7 +540,6 @@ class NoteDrag : public Drag double _cumulative_dy; bool _was_selected; double _note_height; - int32_t _snap_delta; }; class NoteCreateDrag : public Drag @@ -649,7 +659,6 @@ private: bool _preserve_fade_anchor; bool _jump_position_when_done; - int32_t _snap_delta; }; /** Meter marker drag */ @@ -732,7 +741,6 @@ private: EditorCursor& _cursor; bool _stop; ///< true to stop the transport on starting the drag, otherwise false double _grab_zoom; ///< editor frames per unit when our grab started - int32_t _snap_delta; }; /** Region fade-in drag */ @@ -751,8 +759,6 @@ public: } void setup_pointer_frame_offset (); -private: - int32_t _snap_delta; }; /** Region fade-out drag */ @@ -771,8 +777,6 @@ public: } void setup_pointer_frame_offset (); -private: - int32_t _snap_delta; }; /** Marker drag */ @@ -836,7 +840,6 @@ private: double _cumulative_y_drag; bool _pushing; uint32_t _final_index; - int32_t _snap_delta; static double _zero_gain_fraction; }; @@ -961,8 +964,6 @@ public: void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); void aborted (bool); -private: - int32_t _snap_delta; }; /** Scrub drag in audition mode */ -- cgit v1.2.3 From 91a34c596d1bb72f33ccaa17d6ebfa3a435f629c Mon Sep 17 00:00:00 2001 From: nick_m Date: Sun, 17 May 2015 04:26:05 +1000 Subject: Relative snap - support magnetic mode (hackishly for now) --- gtk2_ardour/editor.cc | 16 +++++++++++++++- gtk2_ardour/editor.h | 7 ++++++- gtk2_ardour/editor_drag.cc | 4 ++-- gtk2_ardour/editor_drag.h | 4 ++-- gtk2_ardour/midi_region_view.cc | 29 ++++++++++++++++++++++++----- gtk2_ardour/midi_region_view.h | 12 ++++++++++++ gtk2_ardour/public_editor.h | 4 ++++ gtk2_ardour/region_view.cc | 26 ++++++++++++++++++++++++++ gtk2_ardour/region_view.h | 1 + 9 files changed, 92 insertions(+), 11 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 60aa58dbb0..a45e243da5 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -2653,6 +2653,16 @@ Editor::snap_to (framepos_t& start, RoundMode direction, bool for_mark) snap_to_internal (start, direction, for_mark); } +void +Editor::snap_to_no_magnets (framepos_t& start, RoundMode direction, bool for_mark) +{ + if (!_session || _snap_mode == SnapOff) { + return; + } + + snap_to_internal (start, direction, for_mark, true); +} + void Editor::timecode_snap_to_internal (framepos_t& start, RoundMode direction, bool /*for_mark*/) { @@ -2720,7 +2730,7 @@ Editor::timecode_snap_to_internal (framepos_t& start, RoundMode direction, bool } void -Editor::snap_to_internal (framepos_t& start, RoundMode direction, bool for_mark) +Editor::snap_to_internal (framepos_t& start, RoundMode direction, bool for_mark, bool no_magnets) { const framepos_t one_second = _session->frame_rate(); const framepos_t one_minute = _session->frame_rate() * 60; @@ -2890,6 +2900,10 @@ Editor::snap_to_internal (framepos_t& start, RoundMode direction, bool for_mark) case SnapMagnetic: + if (no_magnets) { + return; + } + if (presnap > start) { if (presnap > (start + pixel_to_sample(snap_threshold))) { start = presnap; diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 0e1661aca9..988d20efd2 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -440,6 +440,10 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD ARDOUR::RoundMode direction = ARDOUR::RoundNearest, bool for_mark = false); + void snap_to_no_magnets (framepos_t& first, + ARDOUR::RoundMode direction = ARDOUR::RoundNearest, + bool for_mark = false); + void snap_to_with_modifier (framepos_t& first, GdkEvent const * ev, ARDOUR::RoundMode direction = ARDOUR::RoundNearest, @@ -2140,7 +2144,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void snap_to_internal (framepos_t& first, ARDOUR::RoundMode direction = ARDOUR::RoundNearest, - bool for_mark = false); + bool for_mark = false, + bool no_magnets = false); void timecode_snap_to_internal (framepos_t& first, ARDOUR::RoundMode direction = ARDOUR::RoundNearest, diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index f7f4cd2873..966ab7002f 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -366,7 +366,7 @@ Drag::setup_snap_delta (framepos_t pos) { if (_editor->snap_delta () == SnapRelative) { framepos_t temp = pos; - _editor->snap_to (temp); + _editor->snap_to_no_magnets (temp); _snap_delta = temp - pos; } } @@ -2358,7 +2358,7 @@ NoteResizeDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*ignored*/) if (_editor->snap_delta () == SnapRelative) { double temp; - temp = region->snap_to_pixel(cnote->x0 ()); + temp = region->snap_to_pixel_no_magnets (cnote->x0 ()); _snap_delta = temp - cnote->x0 (); } diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index 5fb183671f..a58d95dfa1 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -217,7 +217,7 @@ protected: return _last_pointer_frame; } - framecnt_t snap_delta () const { + ARDOUR::frameoffset_t snap_delta () const { return _snap_delta; } @@ -259,7 +259,7 @@ private: /* difference between some key position's snapped and unsnapped * framepos. used for relative snap. */ - framecnt_t _snap_delta; + ARDOUR::frameoffset_t _snap_delta; CursorContext::Handle _cursor_ctx; ///< cursor change context }; diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 97a71003eb..3ecadc4775 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -2633,6 +2633,16 @@ MidiRegionView::snap_pixel_to_sample(double x) return snap_frame_to_frame (editor.pixel_to_sample (x)); } +/** @param x Pixel relative to the region position explicitly (no magnetic snap) + * @return Snapped frame relative to the region position. + */ +framepos_t +MidiRegionView::snap_pixel_to_sample_no_magnets (double x) +{ + PublicEditor& editor (trackview.editor()); + return snap_frame_to_frame_no_magnets (editor.pixel_to_sample (x)); +} + /** @param x Pixel relative to the region position. * @return Snapped pixel relative to the region position. */ @@ -2642,6 +2652,15 @@ MidiRegionView::snap_to_pixel(double x) return (double) trackview.editor().sample_to_pixel(snap_pixel_to_sample(x)); } +/** @param x Pixel relative to the region position. + * @return Explicitly snapped pixel relative to the region position (no magnetic snap). + */ +double +MidiRegionView::snap_to_pixel_no_magnets (double x) +{ + return (double) trackview.editor().sample_to_pixel(snap_pixel_to_sample_no_magnets(x)); +} + double MidiRegionView::get_position_pixels() { @@ -2691,7 +2710,7 @@ MidiRegionView::region_frames_to_region_beats(framepos_t frames) const } double -MidiRegionView::region_frames_to_region_beats_double(framepos_t frames) const +MidiRegionView::region_frames_to_region_beats_double (framepos_t frames) const { return _region_relative_time_converter_double.from(frames); } @@ -2794,9 +2813,9 @@ MidiRegionView::update_resizing (NoteBase* primary, bool at_front, double delta_ int sign = 1; /* negative beat offsets aren't allowed */ if (delta_samps > 0) { - delta_beats = _region_relative_time_converter_double.from(delta_samps); + delta_beats = region_frames_to_region_beats_double (delta_samps); } else if (delta_samps < 0) { - delta_beats = _region_relative_time_converter_double.from( - delta_samps); + delta_beats = region_frames_to_region_beats_double ( - delta_samps); sign = -1; } @@ -2869,9 +2888,9 @@ MidiRegionView::commit_resizing (NoteBase* primary, bool at_front, double delta_ double delta_beats; int sign = 1; if (delta_samps > 0) { - delta_beats = _region_relative_time_converter_double.from(delta_samps); + delta_beats = region_frames_to_region_beats_double (delta_samps); } else if (delta_samps < 0) { - delta_beats = _region_relative_time_converter_double.from( - delta_samps); + delta_beats = region_frames_to_region_beats_double ( - delta_samps); sign = -1; } diff --git a/gtk2_ardour/midi_region_view.h b/gtk2_ardour/midi_region_view.h index cfdb50a99c..7329c6facc 100644 --- a/gtk2_ardour/midi_region_view.h +++ b/gtk2_ardour/midi_region_view.h @@ -254,12 +254,24 @@ public: */ double snap_to_pixel(double x); + /** Snap a region relative pixel coordinate to pixel units explicitly (no magnetic snap). + * @param x a pixel coordinate relative to region start + * @return the explicitly snapped pixel coordinate relative to region start + */ + double snap_to_pixel_no_magnets (double x); + /** Snap a region relative pixel coordinate to frame units. * @param x a pixel coordinate relative to region start * @return the snapped framepos_t coordinate relative to region start */ framepos_t snap_pixel_to_sample(double x); + /** Explicitly snap a region relative pixel coordinate to frame units (no magnetic snap). + * @param x a pixel coordinate relative to region start + * @return the explicitly snapped framepos_t coordinate relative to region start + */ + framepos_t snap_pixel_to_sample_no_magnets (double x); + /** Convert a timestamp in beats into frames (both relative to region position) */ framepos_t region_beats_to_region_frames(Evoral::Beats beats) const; /** Convert a timestamp in beats into absolute frames */ diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index a8ecbb5f40..dc845e6f89 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -148,6 +148,10 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible, publi virtual void snap_to (framepos_t& first, ARDOUR::RoundMode direction = ARDOUR::RoundNearest, bool for_mark = false) = 0; + /** Snap a value according to the current snap setting. */ + virtual void snap_to_no_magnets (framepos_t& first, + ARDOUR::RoundMode direction = ARDOUR::RoundNearest, + bool for_mark = false) = 0; /** Undo some transactions. * @param n Number of transactions to undo. diff --git a/gtk2_ardour/region_view.cc b/gtk2_ardour/region_view.cc index be96cd4058..cd83154a9f 100644 --- a/gtk2_ardour/region_view.cc +++ b/gtk2_ardour/region_view.cc @@ -962,3 +962,29 @@ RegionView::snap_frame_to_frame (frameoffset_t x) const /* back to region relative */ return frame - _region->position(); } + +/** Snap a frame offset within our region using the current snap settings. + * @param x Frame offset from this region's position. + * @return Snapped frame offset from this region's position. + */ +frameoffset_t +RegionView::snap_frame_to_frame_no_magnets (frameoffset_t x) const +{ + PublicEditor& editor = trackview.editor(); + + /* x is region relative, convert it to global absolute frames */ + framepos_t const session_frame = x + _region->position(); + + /* try a snap in either direction */ + framepos_t frame = session_frame; + editor.snap_to_no_magnets (frame, RoundNearest); + + /* if we went off the beginning of the region, snap forwards */ + if (frame < _region->position ()) { + frame = session_frame; + editor.snap_to_no_magnets (frame, RoundUpAlways); + } + + /* back to region relative */ + return frame - _region->position(); +} diff --git a/gtk2_ardour/region_view.h b/gtk2_ardour/region_view.h index 92006c556c..77abb5e2a9 100644 --- a/gtk2_ardour/region_view.h +++ b/gtk2_ardour/region_view.h @@ -122,6 +122,7 @@ class RegionView : public TimeAxisViewItem }; ARDOUR::frameoffset_t snap_frame_to_frame (ARDOUR::frameoffset_t) const; + ARDOUR::frameoffset_t snap_frame_to_frame_no_magnets (ARDOUR::frameoffset_t) const; protected: -- cgit v1.2.3 From c359f881a1fbcbcbeeed3fadfe3b9df19418998a Mon Sep 17 00:00:00 2001 From: nick_m Date: Sun, 17 May 2015 23:47:01 +1000 Subject: Relative Snap -make it activated by the tertiary modifier during drag. Disabled/enabled with the shift key. no config stuff at all now. Move existing (strange) trim feature to primary + tertiary modifiers. --- gtk2_ardour/ardour.menus.in | 3 -- gtk2_ardour/editing.cc | 22 -------- gtk2_ardour/editing.h | 14 ----- gtk2_ardour/editing_syms.h | 3 -- gtk2_ardour/editor.cc | 60 ---------------------- gtk2_ardour/editor.h | 9 ---- gtk2_ardour/editor_actions.cc | 51 +----------------- gtk2_ardour/editor_drag.cc | 111 ++++++++++++++++++++++------------------ gtk2_ardour/editor_drag.h | 6 +-- gtk2_ardour/enums.cc | 5 -- gtk2_ardour/midi_region_view.cc | 5 +- gtk2_ardour/public_editor.h | 3 -- 12 files changed, 66 insertions(+), 226 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/ardour.menus.in b/gtk2_ardour/ardour.menus.in index 4cc9ea900d..85680ac7b0 100644 --- a/gtk2_ardour/ardour.menus.in +++ b/gtk2_ardour/ardour.menus.in @@ -222,9 +222,6 @@ - - - diff --git a/gtk2_ardour/editing.cc b/gtk2_ardour/editing.cc index b6894ed2f5..486808065e 100644 --- a/gtk2_ardour/editing.cc +++ b/gtk2_ardour/editing.cc @@ -29,7 +29,6 @@ using namespace std; // This involves some cpp magic. --taybin #define SNAPTYPE(a) /*empty*/ -#define SNAPDELTA(a) /*empty*/ #define SNAPMODE(a) /*empty*/ #define REGIONLISTSORTTYPE(a) /*empty*/ #define MOUSEMODE(a) /*empty*/ @@ -58,27 +57,6 @@ const char *snaptypestrs[] = { #undef SNAPTYPE #define SNAPTYPE(a) /*empty*/ - -// SNAPDELTA -#undef SNAPDELTA -#define SNAPDELTA(s) if (!strcmp(type, #s)) {return s;} -SnapDelta -str2snapdelta (const string & str) { - const char* type = str.c_str(); - #include "editing_syms.h" - return SnapAbsolute; -} - -#undef SNAPDELTA -#define SNAPDELTA(s) N_(#s), -const char *snapdeltastrs[] = { - #include "editing_syms.h" - 0 -}; -#undef SNAPDELTA -#define SNAPDELTA(a) /*empty*/ - - // SNAPMODE #undef SNAPMODE #define SNAPMODE(s) if (!strcmp(type, #s)) {return s;} diff --git a/gtk2_ardour/editing.h b/gtk2_ardour/editing.h index 38b8c5ed1f..8dd6f2ed6c 100644 --- a/gtk2_ardour/editing.h +++ b/gtk2_ardour/editing.h @@ -28,7 +28,6 @@ #define SNAPTYPE(a) /*empty*/ #define SNAPMODE(a) /*empty*/ -#define SNAPDELTA(a) /*empty*/ #define REGIONLISTSORTTYPE(a) /*empty*/ #define MOUSEMODE(a) /*empty*/ #define MIDIEDITMODE(a) /*empty*/ @@ -72,19 +71,6 @@ SnapMode str2snapmode(const std::string &); #undef SNAPMODE #define SNAPMODE(a) /*empty*/ -// SNAPDELTA -#undef SNAPDELTA -#define SNAPDELTA(a) a, -enum SnapDelta { - #include "editing_syms.h" -}; -extern const char *snapdeltastrs[]; -inline const char* enum2str(SnapDelta m) {return snapdeltastrs[m];} -SnapDelta str2snapdelta(const std::string &); - -#undef SNAPDELTA -#define SNAPDELTA(a) /*empty*/ - // REGIONLISTSORTTYPE #undef REGIONLISTSORTTYPE #define REGIONLISTSORTTYPE(a) a, diff --git a/gtk2_ardour/editing_syms.h b/gtk2_ardour/editing_syms.h index 2769b06b6a..a958776305 100644 --- a/gtk2_ardour/editing_syms.h +++ b/gtk2_ardour/editing_syms.h @@ -54,9 +54,6 @@ SNAPMODE(SnapOff) SNAPMODE(SnapNormal) SNAPMODE(SnapMagnetic) -SNAPDELTA(SnapAbsolute) -SNAPDELTA(SnapRelative) - REGIONLISTSORTTYPE(ByEndInFile) REGIONLISTSORTTYPE(ByLength) REGIONLISTSORTTYPE(ByName) diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index a45e243da5..ff9d480a35 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -177,12 +177,6 @@ static const gchar *_snap_type_strings[] = { 0 }; -static const gchar *_snap_delta_strings[] = { - N_("Absolute"), - N_("Relative"), - 0 -}; - static const gchar *_snap_mode_strings[] = { N_("No Grid"), N_("Grid"), @@ -335,7 +329,6 @@ Editor::Editor () tempo_lines = 0; snap_type_strings = I18N (_snap_type_strings); - snap_delta_strings = I18N (_snap_delta_strings); snap_mode_strings = I18N (_snap_mode_strings); zoom_focus_strings = I18N (_zoom_focus_strings); edit_mode_strings = I18N (_edit_mode_strings); @@ -348,7 +341,6 @@ Editor::Editor () build_edit_mode_menu(); build_zoom_focus_menu(); build_track_count_menu(); - build_snap_delta_menu(); build_snap_mode_menu(); build_snap_type_menu(); build_edit_point_menu(); @@ -686,8 +678,6 @@ Editor::Editor () set_visible_track_count (_visible_track_count); _snap_type = SnapToBeat; set_snap_to (_snap_type); - _snap_delta = SnapAbsolute; - set_snap_delta (_snap_delta); _snap_mode = SnapOff; set_snap_mode (_snap_mode); set_mouse_mode (MouseObject, true); @@ -2046,12 +2036,6 @@ Editor::snap_type() const return _snap_type; } -SnapDelta -Editor::snap_delta() const -{ - return _snap_delta; -} - SnapMode Editor::snap_mode() const { @@ -2130,20 +2114,6 @@ Editor::set_snap_to (SnapType st) SnapChanged (); /* EMIT SIGNAL */ } -void -Editor::set_snap_delta (SnapDelta delta) -{ - string str = snap_delta_strings[(int)delta]; - - _snap_delta = delta; - - if (str != snap_delta_selector.get_text ()) { - snap_delta_selector.set_text (str); - } - - instant_save (); -} - void Editor::set_snap_mode (SnapMode mode) { @@ -2303,10 +2273,6 @@ Editor::set_state (const XMLNode& node, int /*version*/) snap_type_selection_done ((SnapType) string_2_enum (prop->value(), _snap_type)); } - if ((prop = node.property ("snap-delta"))) { - snap_delta_selection_done((SnapDelta) string_2_enum (prop->value(), _snap_delta)); - } - if ((prop = node.property ("snap-mode"))) { snap_mode_selection_done((SnapMode) string_2_enum (prop->value(), _snap_mode)); } @@ -2532,7 +2498,6 @@ Editor::get_state () snprintf (buf, sizeof(buf), "%" PRId64, samples_per_pixel); node->add_property ("zoom", buf); node->add_property ("snap-to", enum_2_string (_snap_type)); - node->add_property ("snap-delta", enum_2_string (_snap_delta)); node->add_property ("snap-mode", enum_2_string (_snap_mode)); node->add_property ("internal-snap-to", enum_2_string (internal_snap_type)); node->add_property ("internal-snap-mode", enum_2_string (internal_snap_mode)); @@ -2956,7 +2921,6 @@ Editor::setup_toolbar () mouse_mode_size_group->add_widget (visible_tracks_selector); mouse_mode_size_group->add_widget (snap_type_selector); - mouse_mode_size_group->add_widget (snap_delta_selector); mouse_mode_size_group->add_widget (snap_mode_selector); mouse_mode_size_group->add_widget (edit_point_selector); @@ -3109,12 +3073,10 @@ Editor::setup_toolbar () snap_type_selector.set_name ("mouse mode button"); - snap_delta_selector.set_name ("mouse mode button"); snap_mode_selector.set_name ("mouse mode button"); edit_point_selector.set_name ("mouse mode button"); - snap_box.pack_start (snap_delta_selector, false, false); snap_box.pack_start (snap_mode_selector, false, false); snap_box.pack_start (snap_type_selector, false, false); snap_box.pack_start (edit_point_selector, false, false); @@ -3214,17 +3176,6 @@ Editor::build_edit_mode_menu () set_size_request_to_display_given_text (edit_mode_selector, edit_mode_strings, COMBO_TRIANGLE_WIDTH, 2); } -void -Editor::build_snap_delta_menu () -{ - using namespace Menu_Helpers; - - snap_delta_selector.AddMenuElem (MenuElem ( snap_delta_strings[(int)SnapAbsolute], sigc::bind (sigc::mem_fun(*this, &Editor::snap_delta_selection_done), (SnapDelta) SnapAbsolute))); - snap_delta_selector.AddMenuElem (MenuElem ( snap_delta_strings[(int)SnapRelative], sigc::bind (sigc::mem_fun(*this, &Editor::snap_delta_selection_done), (SnapDelta) SnapRelative))); - - set_size_request_to_display_given_text (snap_delta_selector, snap_delta_strings, COMBO_TRIANGLE_WIDTH, 2); -} - void Editor::build_snap_mode_menu () { @@ -3300,7 +3251,6 @@ Editor::setup_tooltips () ARDOUR_UI::instance()->set_tip (tav_shrink_button, _("Shrink Tracks")); ARDOUR_UI::instance()->set_tip (visible_tracks_selector, _("Number of visible tracks")); ARDOUR_UI::instance()->set_tip (snap_type_selector, _("Snap/Grid Units")); - ARDOUR_UI::instance()->set_tip (snap_delta_selector, _("Relative Snap Mode")); ARDOUR_UI::instance()->set_tip (snap_mode_selector, _("Snap/Grid Mode")); ARDOUR_UI::instance()->set_tip (edit_point_selector, _("Edit point")); ARDOUR_UI::instance()->set_tip (edit_mode_selector, _("Edit Mode")); @@ -3697,16 +3647,6 @@ Editor::snap_type_selection_done (SnapType snaptype) } } -void -Editor::snap_delta_selection_done (SnapDelta delta) -{ - RefPtr ract = snap_delta_action (delta); - - if (ract) { - ract->set_active (true); - } -} - void Editor::snap_mode_selection_done (SnapMode mode) { diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 988d20efd2..8362b00551 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -162,11 +162,9 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void prev_snap_choice_music_only (); void prev_snap_choice_music_and_time (); void set_snap_to (Editing::SnapType); - void set_snap_delta (Editing::SnapDelta); void set_snap_mode (Editing::SnapMode); void set_snap_threshold (double pixel_distance) {snap_threshold = pixel_distance;} - Editing::SnapDelta snap_delta () const; Editing::SnapMode snap_mode () const; Editing::SnapType snap_type () const; @@ -1477,7 +1475,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void move_range_selection_start_or_end_to_region_boundary (bool, bool); Editing::SnapType _snap_type; - Editing::SnapDelta _snap_delta; Editing::SnapMode _snap_mode; /// Snap threshold in pixels @@ -1758,25 +1755,19 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD ArdourDropdown snap_type_selector; void build_snap_type_menu (); - ArdourDropdown snap_delta_selector; ArdourDropdown snap_mode_selector; - void build_snap_delta_menu (); void build_snap_mode_menu (); Gtk::HBox snap_box; std::vector snap_type_strings; - std::vector snap_delta_strings; std::vector snap_mode_strings; void snap_type_selection_done (Editing::SnapType); - void snap_delta_selection_done (Editing::SnapDelta); void snap_mode_selection_done (Editing::SnapMode); - void snap_delta_chosen (Editing::SnapDelta); void snap_mode_chosen (Editing::SnapMode); void snap_type_chosen (Editing::SnapType); Glib::RefPtr snap_type_action (Editing::SnapType); - Glib::RefPtr snap_delta_action (Editing::SnapDelta); Glib::RefPtr snap_mode_action (Editing::SnapMode); //zoom focus meu stuff diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc index eeb3c2aac4..baebda73af 100644 --- a/gtk2_ardour/editor_actions.cc +++ b/gtk2_ardour/editor_actions.cc @@ -512,13 +512,9 @@ Editor::register_actions () ActionManager::register_action (editor_actions, "set-edit-lock", S_("EditMode|Lock"), sigc::bind (sigc::mem_fun (*this, &Editor::set_edit_mode), Lock)); ActionManager::register_action (editor_actions, "cycle-edit-mode", _("Cycle Edit Mode"), sigc::mem_fun (*this, &Editor::cycle_edit_mode)); - ActionManager::register_action (editor_actions, X_("SnapDelta"), _("Snap Delta")); - RadioAction::Group snap_delta_group; - ActionManager::register_radio_action (editor_actions, snap_delta_group, X_("snap-absolute"), _("Absolute"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_delta_chosen), Editing::SnapAbsolute))); - ActionManager::register_radio_action (editor_actions, snap_delta_group, X_("snap-relative"), _("Relative"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_delta_chosen), Editing::SnapRelative))); - ActionManager::register_action (editor_actions, X_("SnapTo"), _("Snap to")); ActionManager::register_action (editor_actions, X_("SnapMode"), _("Snap Mode")); + RadioAction::Group snap_mode_group; ActionManager::register_radio_action (editor_actions, snap_mode_group, X_("snap-off"), _("No Grid"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_mode_chosen), Editing::SnapOff))); ActionManager::register_radio_action (editor_actions, snap_mode_group, X_("snap-normal"), _("Grid"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_mode_chosen), Editing::SnapNormal))); @@ -1467,36 +1463,6 @@ Editor::snap_type_chosen (SnapType type) } } -RefPtr -Editor::snap_delta_action (SnapDelta delta) -{ - const char* action = 0; - RefPtr act; - - switch (delta) { - case Editing::SnapAbsolute: - action = X_("snap-absolute"); - break; - case Editing::SnapRelative: - action = X_("snap-relative"); - break; - default: - fatal << string_compose (_("programming error: %1: %2"), "Editor: impossible snap delta type", (int) delta) << endmsg; - abort(); /*NOTREACHED*/ - } - - act = ActionManager::get_action (X_("Editor"), action); - - if (act) { - RefPtr ract = RefPtr::cast_dynamic(act); - return ract; - - } else { - error << string_compose (_("programming error: %1: %2"), "Editor::snap_delta_chosen could not find action to match mode.", action) << endmsg; - return RefPtr (); - } -} - RefPtr Editor::snap_mode_action (SnapMode mode) { @@ -1546,21 +1512,6 @@ Editor::cycle_snap_mode () } } -void -Editor::snap_delta_chosen (SnapDelta rel) -{ - /* this is driven by a toggle on a radio group, and so is invoked twice, - once for the item that became inactive and once for the one that became - active. - */ - - RefPtr ract = snap_delta_action (rel); - - if (ract && ract->get_active()) { - set_snap_delta (rel); - } -} - void Editor::snap_mode_chosen (SnapMode mode) { diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 966ab7002f..d5460b063c 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -345,6 +345,16 @@ Drag::adjusted_current_frame (GdkEvent const * event, bool snap) const return adjusted_frame (_drags->current_pointer_frame (), event, snap); } +frameoffset_t +Drag::snap_delta (GdkEvent const * event) const +{ + if (Keyboard::modifier_state_contains (event->button.state, Keyboard::TertiaryModifier)) { + return _snap_delta; + } else { + return 0; + } +} + double Drag::current_pointer_x() const { @@ -364,11 +374,9 @@ Drag::current_pointer_y () const void Drag::setup_snap_delta (framepos_t pos) { - if (_editor->snap_delta () == SnapRelative) { - framepos_t temp = pos; - _editor->snap_to_no_magnets (temp); - _snap_delta = temp - pos; - } + framepos_t temp = pos; + _editor->snap_to_no_magnets (temp); + _snap_delta = temp - pos; } bool @@ -581,7 +589,7 @@ RegionMotionDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor) Drag::start_grab (event, cursor); setup_snap_delta (_last_frame_position); - if (Keyboard::modifier_state_contains (event->button.state, Keyboard::TertiaryModifier)) { + if (Keyboard::modifier_state_equals (event->button.state, Keyboard::ModifierMask (Keyboard::PrimaryModifier | Keyboard::TertiaryModifier))) { _single_axis = true; } @@ -601,7 +609,7 @@ RegionMotionDrag::compute_x_delta (GdkEvent const * event, framepos_t* pending_r /* compute the amount of pointer motion in frames, and where the region would be if we moved it by that much. */ - *pending_region_position = adjusted_frame (_drags->current_pointer_frame () + snap_delta (), event, true); + *pending_region_position = adjusted_frame (_drags->current_pointer_frame () + snap_delta (event), event, true); framepos_t sync_frame; framecnt_t sync_offset; @@ -617,7 +625,7 @@ RegionMotionDrag::compute_x_delta (GdkEvent const * event, framepos_t* pending_r _editor->snap_to_with_modifier (sync_frame, event); - *pending_region_position = _primary->region()->adjust_to_sync (sync_frame) - snap_delta (); + *pending_region_position = _primary->region()->adjust_to_sync (sync_frame) - snap_delta (event); } else { *pending_region_position = _last_frame_position; @@ -2356,11 +2364,9 @@ NoteResizeDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*ignored*/) region = &cnote->region_view(); - if (_editor->snap_delta () == SnapRelative) { - double temp; - temp = region->snap_to_pixel_no_magnets (cnote->x0 ()); - _snap_delta = temp - cnote->x0 (); - } + double temp; + temp = region->snap_to_pixel_no_magnets (cnote->x0 ()); + _snap_delta = temp - cnote->x0 (); _item->grab (); @@ -2397,7 +2403,7 @@ NoteResizeDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*ignored*/) } void -NoteResizeDrag::motion (GdkEvent* /*event*/, bool /*first_move*/) +NoteResizeDrag::motion (GdkEvent* event, bool /*first_move*/) { MidiRegionSelection& ms (_editor->get_selection().midi_regions); for (MidiRegionSelection::iterator r = ms.begin(); r != ms.end(); ++r) { @@ -2405,21 +2411,29 @@ NoteResizeDrag::motion (GdkEvent* /*event*/, bool /*first_move*/) assert (nb); MidiRegionView* mrv = dynamic_cast(*r); if (mrv) { - mrv->update_resizing (nb, at_front, _drags->current_pointer_x() - grab_x(), relative, _snap_delta); + double sd = 0.0; + if (Keyboard::modifier_state_contains (event->button.state, Keyboard::TertiaryModifier)) { + sd = _snap_delta; + } + mrv->update_resizing (nb, at_front, _drags->current_pointer_x() - grab_x(), relative, sd); } } } void -NoteResizeDrag::finished (GdkEvent*, bool /*movement_occurred*/) +NoteResizeDrag::finished (GdkEvent* event, bool /*movement_occurred*/) { MidiRegionSelection& ms (_editor->get_selection().midi_regions); for (MidiRegionSelection::iterator r = ms.begin(); r != ms.end(); ++r) { NoteBase* nb = reinterpret_cast (_item->get_data ("notebase")); assert (nb); MidiRegionView* mrv = dynamic_cast(*r); + double sd = 0.0; + if (Keyboard::modifier_state_contains (event->button.state, Keyboard::TertiaryModifier)) { + sd = _snap_delta; + } if (mrv) { - mrv->commit_resizing (nb, at_front, _drags->current_pointer_x() - grab_x(), relative, _snap_delta); + mrv->commit_resizing (nb, at_front, _drags->current_pointer_x() - grab_x(), relative, sd); } } @@ -2628,8 +2642,7 @@ TrimDrag::start_grab (GdkEvent* event, Gdk::Cursor*) if (pf < (region_start + region_length/2)) { /* closer to front */ _operation = StartTrim; - - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::TertiaryModifier)) { + if (Keyboard::modifier_state_equals (event->button.state, Keyboard::ModifierMask (Keyboard::PrimaryModifier | Keyboard::TertiaryModifier))) { Drag::start_grab (event, _editor->cursors()->anchored_left_side_trim); } else { Drag::start_grab (event, _editor->cursors()->left_side_trim); @@ -2637,15 +2650,15 @@ TrimDrag::start_grab (GdkEvent* event, Gdk::Cursor*) } else { /* closer to end */ _operation = EndTrim; - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::TertiaryModifier)) { + if (Keyboard::modifier_state_equals (event->button.state, Keyboard::ModifierMask (Keyboard::PrimaryModifier | Keyboard::TertiaryModifier))) { Drag::start_grab (event, _editor->cursors()->anchored_right_side_trim); } else { Drag::start_grab (event, _editor->cursors()->right_side_trim); } } } - - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::TertiaryModifier)) { + /* XXX this "feature" gives the user no clue as to what is going to happen. */ + if (Keyboard::modifier_state_equals (event->button.state, Keyboard::ModifierMask (Keyboard::PrimaryModifier | Keyboard::TertiaryModifier))) { _jump_position_when_done = true; } @@ -2683,8 +2696,8 @@ TrimDrag::motion (GdkEvent* event, bool first_move) if (tv && tv->is_track()) { speed = tv->track()->speed(); } - framecnt_t adj_frame = adjusted_frame (_drags->current_pointer_frame () + snap_delta (), event, true); - framecnt_t dt = adj_frame - raw_grab_frame () + _pointer_frame_offset - snap_delta (); + framecnt_t adj_frame = adjusted_frame (_drags->current_pointer_frame () + snap_delta (event), event, true); + framecnt_t dt = adj_frame - raw_grab_frame () + _pointer_frame_offset - snap_delta (event); if (first_move) { @@ -2730,7 +2743,7 @@ TrimDrag::motion (GdkEvent* event, bool first_move) bool non_overlap_trim = false; - if (event && Keyboard::modifier_state_equals (event->button.state, Keyboard::TertiaryModifier)) { + if (event && Keyboard::modifier_state_equals (event->button.state, Keyboard::ModifierMask (Keyboard::PrimaryModifier | Keyboard::TertiaryModifier))) { non_overlap_trim = true; } @@ -2824,7 +2837,6 @@ TrimDrag::motion (GdkEvent* event, bool first_move) } } - void TrimDrag::finished (GdkEvent* event, bool movement_occurred) { @@ -3272,7 +3284,7 @@ CursorDrag::start_grab (GdkEvent* event, Gdk::Cursor* c) _grab_zoom = _editor->samples_per_pixel; - framepos_t where = _editor->canvas_event_sample (event) + snap_delta (); + framepos_t where = _editor->canvas_event_sample (event) + snap_delta (event); _editor->snap_to_with_modifier (where, event); @@ -3310,16 +3322,16 @@ CursorDrag::start_grab (GdkEvent* event, Gdk::Cursor* c) } } - fake_locate (where - snap_delta ()); + fake_locate (where - snap_delta (event)); } void CursorDrag::motion (GdkEvent* event, bool) { - framepos_t where = _editor->canvas_event_sample (event) + snap_delta (); + framepos_t where = _editor->canvas_event_sample (event) + snap_delta (event); _editor->snap_to_with_modifier (where, event); if (where != last_pointer_frame()) { - fake_locate (where - snap_delta ()); + fake_locate (where - snap_delta (event)); } } @@ -3388,9 +3400,9 @@ FadeInDrag::motion (GdkEvent* event, bool) { framecnt_t fade_length; - framepos_t pos = _editor->canvas_event_sample (event) + snap_delta (); + framepos_t pos = _editor->canvas_event_sample (event) + snap_delta (event); _editor->snap_to_with_modifier (pos, event); - pos -= snap_delta (); + pos -= snap_delta (event); boost::shared_ptr region = boost::dynamic_pointer_cast (_primary->region ()); @@ -3424,9 +3436,9 @@ FadeInDrag::finished (GdkEvent* event, bool movement_occurred) } framecnt_t fade_length; - framepos_t pos = _editor->canvas_event_sample (event) + snap_delta (); + framepos_t pos = _editor->canvas_event_sample (event) + snap_delta (event); _editor->snap_to_with_modifier (pos, event); - pos -= snap_delta (); + pos -= snap_delta (event); boost::shared_ptr region = boost::dynamic_pointer_cast (_primary->region ()); @@ -3506,9 +3518,9 @@ FadeOutDrag::motion (GdkEvent* event, bool) { framecnt_t fade_length; - framepos_t pos = _editor->canvas_event_sample (event) + snap_delta (); + framepos_t pos = _editor->canvas_event_sample (event) + snap_delta (event); _editor->snap_to_with_modifier (pos, event); - pos -= snap_delta (); + pos -= snap_delta (event); boost::shared_ptr region = boost::dynamic_pointer_cast (_primary->region ()); @@ -3543,9 +3555,9 @@ FadeOutDrag::finished (GdkEvent* event, bool movement_occurred) framecnt_t fade_length; - framepos_t pos = _editor->canvas_event_sample (event) + snap_delta (); + framepos_t pos = _editor->canvas_event_sample (event) + snap_delta (event); _editor->snap_to_with_modifier (pos, event); - pos -= snap_delta (); + pos -= snap_delta (event); boost::shared_ptr region = boost::dynamic_pointer_cast (_primary->region ()); @@ -4054,13 +4066,13 @@ ControlPointDrag::motion (GdkEvent* event, bool) cy = max (0.0, cy); cy = min ((double) _point->line().height(), cy); - framepos_t cx_frames = _editor->pixel_to_sample (cx) + snap_delta (); + framepos_t cx_frames = _editor->pixel_to_sample (cx) + snap_delta (event); if (!_x_constrained) { _editor->snap_to_with_modifier (cx_frames, event); } - cx_frames -= snap_delta (); + cx_frames -= snap_delta (event); cx_frames = min (cx_frames, _point->line().maximum_time()); float const fraction = 1.0 - (cy / _point->line().height()); @@ -4076,8 +4088,7 @@ ControlPointDrag::finished (GdkEvent* event, bool movement_occurred) if (!movement_occurred) { /* just a click */ - - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::TertiaryModifier)) { + if (Keyboard::modifier_state_equals (event->button.state, Keyboard::ModifierMask (Keyboard::PrimaryModifier | Keyboard::TertiaryModifier))) { _editor->reset_point_selection (); } @@ -4487,9 +4498,9 @@ TimeFXDrag::motion (GdkEvent* event, bool) pair const tv = _editor->trackview_by_y_position (grab_y()); int layer = tv.first->layer_display() == Overlaid ? 0 : tv.second; int layers = tv.first->layer_display() == Overlaid ? 1 : cv->layers(); - framepos_t pf = _editor->canvas_event_sample (event) + snap_delta (); + framepos_t pf = _editor->canvas_event_sample (event) + snap_delta (event); _editor->snap_to_with_modifier (pf, event); - pf -= snap_delta (); + pf -= snap_delta (event); if (pf > rv->region()->position()) { rv->get_time_axis_view().show_timestretch (rv->region()->position(), pf, layers, layer); @@ -5202,7 +5213,7 @@ NoteDrag::start_grab (GdkEvent* event, Gdk::Cursor *) /** @return Current total drag x change in frames */ frameoffset_t -NoteDrag::total_dx () const +NoteDrag::total_dx (GdkEvent const * event) const { /* dx in frames */ frameoffset_t const dx = _editor->pixel_to_sample (_drags->current_pointer_x() - grab_x()); @@ -5211,7 +5222,7 @@ NoteDrag::total_dx () const frameoffset_t const n = _region->source_beats_to_absolute_frames (_primary->note()->time ()); /* new time of the primary note in session frames */ - frameoffset_t st = n + dx + snap_delta (); + frameoffset_t st = n + dx + snap_delta (event); framepos_t const rp = _region->region()->position (); @@ -5219,7 +5230,7 @@ NoteDrag::total_dx () const st = max (st, rp); /* snap and return corresponding delta */ - return _region->snap_frame_to_frame (st - rp) + rp - n - snap_delta (); + return _region->snap_frame_to_frame (st - rp) + rp - n - snap_delta (event); } /** @return Current total drag y change in note number */ @@ -5238,10 +5249,10 @@ NoteDrag::total_dy () const } void -NoteDrag::motion (GdkEvent *, bool) +NoteDrag::motion (GdkEvent * event, bool) { /* Total change in x and y since the start of the drag */ - frameoffset_t const dx = total_dx (); + frameoffset_t const dx = total_dx (event); int8_t const dy = total_dy (); /* Now work out what we have to do to the note canvas items to set this new drag delta */ @@ -5310,7 +5321,7 @@ NoteDrag::finished (GdkEvent* ev, bool moved) } } } else { - _region->note_dropped (_primary, total_dx(), total_dy()); + _region->note_dropped (_primary, total_dx (ev), total_dy()); } } diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index a58d95dfa1..67b549bac2 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -217,9 +217,7 @@ protected: return _last_pointer_frame; } - ARDOUR::frameoffset_t snap_delta () const { - return _snap_delta; - } + ARDOUR::frameoffset_t snap_delta (GdkEvent const *) const; double current_pointer_x () const; double current_pointer_y () const; @@ -531,7 +529,7 @@ class NoteDrag : public Drag private: - ARDOUR::frameoffset_t total_dx () const; + ARDOUR::frameoffset_t total_dx (GdkEvent const *) const; int8_t total_dy () const; MidiRegionView* _region; diff --git a/gtk2_ardour/enums.cc b/gtk2_ardour/enums.cc index 956db79dd4..4cae1f5db4 100644 --- a/gtk2_ardour/enums.cc +++ b/gtk2_ardour/enums.cc @@ -43,7 +43,6 @@ setup_gtk_ardour_enums () LayerDisplay layer_display; RegionListSortType region_list_sort_type; SnapType snap_type; - SnapDelta snap_delta; SnapMode snap_mode; ZoomFocus zoom_focus; ItemType item_type; @@ -91,10 +90,6 @@ setup_gtk_ardour_enums () REGISTER_ENUM (ByTimestamp); REGISTER (region_list_sort_type); - REGISTER_ENUM (SnapAbsolute); - REGISTER_ENUM (SnapRelative); - REGISTER (snap_delta); - REGISTER_ENUM (SnapToCDFrame); REGISTER_ENUM (SnapToTimecodeFrame); REGISTER_ENUM (SnapToTimecodeSeconds); diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 3ecadc4775..be280001d2 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -2896,8 +2896,7 @@ MidiRegionView::commit_resizing (NoteBase* primary, bool at_front, double delta_ /* Convert that to a frame within the source */ framepos_t current_fr = snap_pixel_to_sample (current_x) + _region->start (); - double one_frame = region_frames_to_region_beats_double (current_fr) - region_frames_to_region_beats_double (current_fr - 1); - cerr << "commit one frame in beats : " << one_frame << endl; + /* and then to beats */ const Evoral::Beats x_beats = region_frames_to_region_beats (current_fr); if (at_front && x_beats < canvas_note->note()->end_time()) { @@ -2913,7 +2912,7 @@ MidiRegionView::commit_resizing (NoteBase* primary, bool at_front, double delta_ if (!at_front) { const Evoral::Beats len = std::max(Evoral::Beats(1 / 512.0), - x_beats - canvas_note->note()->time() - (sign * delta_beats) - one_frame); + x_beats - canvas_note->note()->time() - (sign * delta_beats)); note_diff_add_change (canvas_note, MidiModel::NoteDiffCommand::Length, len); } diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index dc845e6f89..a89993a479 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -129,11 +129,8 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible, publi virtual void set_snap_to (Editing::SnapType t) = 0; virtual Editing::SnapType snap_type () const = 0; - virtual Editing::SnapDelta snap_delta () const = 0; virtual Editing::SnapMode snap_mode () const = 0; - virtual void set_snap_delta (Editing::SnapDelta m) = 0; - /** Set the snap mode. * @param m Snap mode (defined in editing_syms.h) */ -- cgit v1.2.3 From a0bd6975d2857becd68e85d5dff0e7023016068d Mon Sep 17 00:00:00 2001 From: nick_m Date: Mon, 18 May 2015 01:43:44 +1000 Subject: Clean up drag modifiers. Button 2 drag now is constrained to initial move axis, removing all modifiers from this op. Remove Jump after trim mode. TrimDrag now has: Primary for trim anchored to fade. Secondary for contents trim (as before) Primary & Tertiary for "non overlap" trim All drags have Tertiary for relative snap --- gtk2_ardour/editor_drag.cc | 57 ++++++++++++---------------------------------- gtk2_ardour/editor_drag.h | 3 --- 2 files changed, 14 insertions(+), 46 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index d5460b063c..df1987f3c0 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -251,18 +251,9 @@ Drag::start_grab (GdkEvent* event, Gdk::Cursor *cursor) { // if dragging with button2, the motion is x constrained, with Alt-button2 it is y constrained - if (Keyboard::is_button2_event (&event->button)) { - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::SecondaryModifier)) { - _y_constrained = true; - _x_constrained = false; - } else { - _y_constrained = false; - _x_constrained = true; - } - } else { - _x_constrained = false; - _y_constrained = false; - } + /* we set up x/y dragging constraints on first move */ + _x_constrained = false; + _y_constrained = false; _raw_grab_frame = _editor->canvas_event_sample (event, &_grab_x, &_grab_y); @@ -410,8 +401,16 @@ Drag::motion_handler (GdkEvent* event, bool from_autoscroll) /* just changed */ if (fabs (current_pointer_y() - _grab_y) > fabs (current_pointer_x() - _grab_x)) { + if (event->motion.state & Gdk::BUTTON2_MASK) { + _x_constrained = true; + _y_constrained = false; + } _initially_vertical = true; } else { + if (event->motion.state & Gdk::BUTTON2_MASK) { + _x_constrained = false; + _y_constrained = true; + } _initially_vertical = false; } } @@ -575,7 +574,6 @@ RegionMotionDrag::RegionMotionDrag (Editor* e, ArdourCanvas::Item* i, RegionView , _total_x_delta (0) , _last_pointer_time_axis_view (0) , _last_pointer_layer (0) - , _single_axis (false) , _ndropzone (0) , _pdropzone (0) , _ddropzone (0) @@ -589,10 +587,6 @@ RegionMotionDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor) Drag::start_grab (event, cursor); setup_snap_delta (_last_frame_position); - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::ModifierMask (Keyboard::PrimaryModifier | Keyboard::TertiaryModifier))) { - _single_axis = true; - } - show_verbose_cursor_time (_last_frame_position); pair const tv = _editor->trackview_by_y_position (current_pointer_y ()); @@ -771,18 +765,6 @@ RegionMotionDrag::motion (GdkEvent* event, bool first_move) assert (!_views.empty ()); - if (first_move) { - if (_single_axis) { - if (initially_vertical()) { - _y_constrained = false; - _x_constrained = true; - } else { - _y_constrained = true; - _x_constrained = false; - } - } - } - /* Note: time axis views in this method are often expressed as an index into the _time_axis_views vector */ /* Find the TimeAxisView that the pointer is now over */ @@ -2610,7 +2592,6 @@ VideoTimeLineDrag::aborted (bool) TrimDrag::TrimDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, list const & v, bool preserve_fade_anchor) : RegionDrag (e, i, p, v) , _preserve_fade_anchor (preserve_fade_anchor) - , _jump_position_when_done (false) { DEBUG_TRACE (DEBUG::Drags, "New TrimDrag\n"); } @@ -2633,7 +2614,7 @@ TrimDrag::start_grab (GdkEvent* event, Gdk::Cursor*) framepos_t const pf = adjusted_current_frame (event); setup_snap_delta (region_start); - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) { + if (Keyboard::modifier_state_equals (event->button.state, Keyboard::SecondaryModifier)) { /* Move the contents of the region around without changing the region bounds */ _operation = ContentsTrim; Drag::start_grab (event, _editor->cursors()->trimmer); @@ -2642,7 +2623,7 @@ TrimDrag::start_grab (GdkEvent* event, Gdk::Cursor*) if (pf < (region_start + region_length/2)) { /* closer to front */ _operation = StartTrim; - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::ModifierMask (Keyboard::PrimaryModifier | Keyboard::TertiaryModifier))) { + if (Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) { Drag::start_grab (event, _editor->cursors()->anchored_left_side_trim); } else { Drag::start_grab (event, _editor->cursors()->left_side_trim); @@ -2650,17 +2631,13 @@ TrimDrag::start_grab (GdkEvent* event, Gdk::Cursor*) } else { /* closer to end */ _operation = EndTrim; - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::ModifierMask (Keyboard::PrimaryModifier | Keyboard::TertiaryModifier))) { + if (Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) { Drag::start_grab (event, _editor->cursors()->anchored_right_side_trim); } else { Drag::start_grab (event, _editor->cursors()->right_side_trim); } } } - /* XXX this "feature" gives the user no clue as to what is going to happen. */ - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::ModifierMask (Keyboard::PrimaryModifier | Keyboard::TertiaryModifier))) { - _jump_position_when_done = true; - } switch (_operation) { case StartTrim: @@ -2861,9 +2838,6 @@ TrimDrag::finished (GdkEvent* event, bool movement_occurred) ar->set_fade_in_active(true); } } - if (_jump_position_when_done) { - i->view->region()->set_position (i->initial_position); - } } } else if (_operation == EndTrim) { for (list::const_iterator i = _views.begin(); i != _views.end(); ++i) { @@ -2876,9 +2850,6 @@ TrimDrag::finished (GdkEvent* event, bool movement_occurred) ar->set_fade_out_active(true); } } - if (_jump_position_when_done) { - i->view->region()->set_position (i->initial_end - i->view->region()->length()); - } } } diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index 67b549bac2..4ed77999bf 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -345,8 +345,6 @@ protected: double _total_x_delta; int _last_pointer_time_axis_view; double _last_pointer_layer; - bool _single_axis; - private: uint32_t _ndropzone; uint32_t _pdropzone; @@ -656,7 +654,6 @@ private: Operation _operation; bool _preserve_fade_anchor; - bool _jump_position_when_done; }; /** Meter marker drag */ -- cgit v1.2.3 From 799e619690e17f96a65c8fc2933cff041991ec34 Mon Sep 17 00:00:00 2001 From: nick_m Date: Mon, 18 May 2015 03:15:22 +1000 Subject: Relative snap now always on - disabled with Tertiary modifier (shift) --- gtk2_ardour/editor_drag.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index df1987f3c0..c21622dd4a 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -340,9 +340,9 @@ frameoffset_t Drag::snap_delta (GdkEvent const * event) const { if (Keyboard::modifier_state_contains (event->button.state, Keyboard::TertiaryModifier)) { - return _snap_delta; - } else { return 0; + } else { + return _snap_delta; } } -- cgit v1.2.3 From aac167a19f32accfbd867f3c72cec13f374f9199 Mon Sep 17 00:00:00 2001 From: nick_m Date: Mon, 18 May 2015 06:25:36 +1000 Subject: "Lock" mode is now "Constrained", make snap absolute modifier configurable. - user can abs/rel modifier key in prefs->user interaction suggested for linux - absolute->alt ignore snap->alt-shift - Constrained mode works the same as button 2 drag (initial move sets constraint axis). --- gtk2_ardour/editor.cc | 10 +++++----- gtk2_ardour/editor_actions.cc | 2 +- gtk2_ardour/editor_drag.cc | 23 +++++++++------------- gtk2_ardour/editor_ops.cc | 6 +++--- gtk2_ardour/rc_option_editor.cc | 38 +++++++++++++++++++++++++++++++++---- libs/ardour/ardour/types.h | 2 +- libs/ardour/enums.cc | 2 +- libs/ardour/utils.cc | 8 ++++---- libs/gtkmm2ext/gtkmm2ext/keyboard.h | 7 +++++++ libs/gtkmm2ext/keyboard.cc | 15 +++++++++++++++ 10 files changed, 80 insertions(+), 33 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index ff9d480a35..e785db3de7 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -195,7 +195,7 @@ static const gchar *_edit_mode_strings[] = { N_("Slide"), N_("Splice"), N_("Ripple"), - N_("Lock"), + N_("Constrained"), 0 }; @@ -3171,7 +3171,7 @@ Editor::build_edit_mode_menu () edit_mode_selector.AddMenuElem (MenuElem ( edit_mode_strings[(int)Slide], sigc::bind (sigc::mem_fun(*this, &Editor::edit_mode_selection_done), (EditMode) Slide))); // edit_mode_selector.AddMenuElem (MenuElem ( edit_mode_strings[(int)Splice], sigc::bind (sigc::mem_fun(*this, &Editor::edit_mode_selection_done), (EditMode) Splice))); edit_mode_selector.AddMenuElem (MenuElem ( edit_mode_strings[(int)Ripple], sigc::bind (sigc::mem_fun(*this, &Editor::edit_mode_selection_done), (EditMode) Ripple))); - edit_mode_selector.AddMenuElem (MenuElem ( edit_mode_strings[(int)Lock], sigc::bind (sigc::mem_fun(*this, &Editor::edit_mode_selection_done), (EditMode) Lock))); + edit_mode_selector.AddMenuElem (MenuElem ( edit_mode_strings[(int)Constrained], sigc::bind (sigc::mem_fun(*this, &Editor::edit_mode_selection_done), (EditMode) Constrained))); set_size_request_to_display_given_text (edit_mode_selector, edit_mode_strings, COMBO_TRIANGLE_WIDTH, 2); } @@ -3617,16 +3617,16 @@ Editor::cycle_edit_mode () switch (Config->get_edit_mode()) { case Slide: if (Profile->get_sae()) { - Config->set_edit_mode (Lock); + Config->set_edit_mode (Constrained); } else { Config->set_edit_mode (Ripple); } break; case Splice: case Ripple: - Config->set_edit_mode (Lock); + Config->set_edit_mode (Constrained); break; - case Lock: + case Constrained: Config->set_edit_mode (Slide); break; } diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc index baebda73af..f1cf70fd89 100644 --- a/gtk2_ardour/editor_actions.cc +++ b/gtk2_ardour/editor_actions.cc @@ -509,7 +509,7 @@ Editor::register_actions () // ActionManager::register_action (editor_actions, "set-edit-splice", _("Splice"), sigc::bind (sigc::mem_fun (*this, &Editor::set_edit_mode), Splice)); ActionManager::register_action (editor_actions, "set-edit-ripple", _("Ripple"), bind (mem_fun (*this, &Editor::set_edit_mode), Ripple)); ActionManager::register_action (editor_actions, "set-edit-slide", _("Slide"), sigc::bind (sigc::mem_fun (*this, &Editor::set_edit_mode), Slide)); - ActionManager::register_action (editor_actions, "set-edit-lock", S_("EditMode|Lock"), sigc::bind (sigc::mem_fun (*this, &Editor::set_edit_mode), Lock)); + ActionManager::register_action (editor_actions, "set-edit-constrained", S_("EditMode|Constrained"), sigc::bind (sigc::mem_fun (*this, &Editor::set_edit_mode), Constrained)); ActionManager::register_action (editor_actions, "cycle-edit-mode", _("Cycle Edit Mode"), sigc::mem_fun (*this, &Editor::cycle_edit_mode)); ActionManager::register_action (editor_actions, X_("SnapTo"), _("Snap to")); diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index c21622dd4a..cf1f8007b9 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -339,7 +339,7 @@ Drag::adjusted_current_frame (GdkEvent const * event, bool snap) const frameoffset_t Drag::snap_delta (GdkEvent const * event) const { - if (Keyboard::modifier_state_contains (event->button.state, Keyboard::TertiaryModifier)) { + if (Keyboard::modifier_state_equals (event->button.state, Keyboard::snap_delta_modifier())) { return 0; } else { return _snap_delta; @@ -401,18 +401,23 @@ Drag::motion_handler (GdkEvent* event, bool from_autoscroll) /* just changed */ if (fabs (current_pointer_y() - _grab_y) > fabs (current_pointer_x() - _grab_x)) { - if (event->motion.state & Gdk::BUTTON2_MASK) { + if ((event->motion.state & Gdk::BUTTON2_MASK) || Config->get_edit_mode() == Constrained) { _x_constrained = true; _y_constrained = false; } _initially_vertical = true; } else { - if (event->motion.state & Gdk::BUTTON2_MASK) { + if ((event->motion.state & Gdk::BUTTON2_MASK) || Config->get_edit_mode() == Constrained) { _x_constrained = false; _y_constrained = true; } _initially_vertical = false; } + + if ((event->motion.state & Gdk::BUTTON2_MASK) && Config->get_edit_mode() == Constrained) { + _x_constrained = false; + _y_constrained = false; + } } if (!from_autoscroll) { @@ -630,9 +635,7 @@ RegionMotionDrag::compute_x_delta (GdkEvent const * event, framepos_t* pending_r } double dx = 0; - - /* in locked edit mode, reverse the usual meaning of _x_constrained */ - bool const x_move_allowed = Config->get_edit_mode() == Lock ? _x_constrained : !_x_constrained; + bool x_move_allowed = !_x_constrained; if ((*pending_region_position != _last_frame_position) && x_move_allowed) { @@ -1307,14 +1310,6 @@ RegionMoveDrag::finished (GdkEvent* ev, bool movement_occurred) return; } - /* reverse this here so that we have the correct logic to finalize - the drag. - */ - - if (Config->get_edit_mode() == Lock) { - _x_constrained = !_x_constrained; - } - assert (!_views.empty ()); /* We might have hidden region views so that they weren't visible during the drag diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 5c45951e04..0ff9cbb732 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -6960,7 +6960,7 @@ Editor::insert_time ( { bool commit = false; - if (Config->get_edit_mode() == Lock) { + if (Config->get_edit_mode() == Constrained) { return; } @@ -7133,8 +7133,8 @@ Editor::cut_time (framepos_t pos, framecnt_t frames, InsertTimeOption opt, { bool commit = false; - if (Config->get_edit_mode() == Lock) { - error << (_("Cannot insert or delete time when in Lock edit.")) << endmsg; + if (Config->get_edit_mode() == Constrained) { + error << (_("Cannot insert or delete time when in Constrained edit.")) << endmsg; return; } diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc index bcefc1260b..9c5a603fd7 100644 --- a/gtk2_ardour/rc_option_editor.cc +++ b/gtk2_ardour/rc_option_editor.cc @@ -319,7 +319,7 @@ public: } } - Table* t = manage (new Table (4, 4)); + Table* t = manage (new Table (4, 5)); t->set_spacings (4); Label* l = manage (left_aligned_label (_("Edit using:"))); @@ -391,7 +391,7 @@ public: _insert_note_button_adjustment.set_value (Keyboard::insert_note_button()); _insert_note_button_adjustment.signal_value_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::insert_note_button_changed)); - + /* ignore snap */ set_popdown_strings (_snap_modifier_combo, dumb); _snap_modifier_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::snap_modifier_chosen)); @@ -408,6 +408,23 @@ public: t->attach (*l, 0, 1, 3, 4, FILL | EXPAND, FILL); t->attach (_snap_modifier_combo, 1, 2, 3, 4, FILL | EXPAND, FILL); + /* snap delta */ + set_popdown_strings (_snap_delta_combo, dumb); + _snap_delta_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::snap_delta_modifier_chosen)); + + for (int x = 0; modifiers[x].name; ++x) { + if (modifiers[x].modifier == (guint) Keyboard::snap_delta_modifier ()) { + _snap_delta_combo.set_active_text (S_(modifiers[x].name)); + break; + } + } + + l = manage (left_aligned_label (_("Snap to absolute using:"))); + l->set_name ("OptionsLabel"); + + t->attach (*l, 0, 1, 4, 5, FILL | EXPAND, FILL); + t->attach (_snap_delta_combo, 1, 2, 4, 5, FILL | EXPAND, FILL); + vector strs; for (map::iterator bf = Keyboard::binding_files.begin(); bf != Keyboard::binding_files.end(); ++bf) { @@ -421,8 +438,8 @@ public: l = manage (left_aligned_label (_("Keyboard layout:"))); l->set_name ("OptionsLabel"); - t->attach (*l, 0, 1, 4, 5, FILL | EXPAND, FILL); - t->attach (_keyboard_layout_selector, 1, 2, 4, 5, FILL | EXPAND, FILL); + t->attach (*l, 0, 1, 5, 6, FILL | EXPAND, FILL); + t->attach (_keyboard_layout_selector, 1, 2, 5, 6, FILL | EXPAND, FILL); _box->pack_start (*t, false, false); } @@ -502,6 +519,18 @@ private: } } + void snap_delta_modifier_chosen () + { + string const txt = _snap_delta_combo.get_active_text(); + + for (int i = 0; modifiers[i].name; ++i) { + if (txt == _(modifiers[i].name)) { + Keyboard::set_snap_delta_modifier (modifiers[i].modifier); + break; + } + } + } + void delete_button_changed () { Keyboard::set_delete_button (_delete_button_spin.get_value_as_int()); @@ -522,6 +551,7 @@ private: ComboBoxText _delete_modifier_combo; ComboBoxText _insert_note_modifier_combo; ComboBoxText _snap_modifier_combo; + ComboBoxText _snap_delta_combo; Adjustment _delete_button_adjustment; SpinButton _delete_button_spin; Adjustment _edit_button_adjustment; diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h index b1b4388a74..33cd94f101 100644 --- a/libs/ardour/ardour/types.h +++ b/libs/ardour/ardour/types.h @@ -352,7 +352,7 @@ namespace ARDOUR { Slide, Splice, Ripple, - Lock + Constrained }; enum RegionSelectionAfterSplit { diff --git a/libs/ardour/enums.cc b/libs/ardour/enums.cc index a1cf8d090c..6e53660cfb 100644 --- a/libs/ardour/enums.cc +++ b/libs/ardour/enums.cc @@ -242,7 +242,7 @@ setup_enum_writer () REGISTER_ENUM (Slide); REGISTER_ENUM (Splice); REGISTER_ENUM (Ripple); // XXX do the old enum values have to stay in order? - REGISTER_ENUM (Lock); + REGISTER_ENUM (Constrained); REGISTER (_EditMode); /* * Splice mode is undefined, undocumented, and basically fubar'ed diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc index 6d6511bb9f..82ad8c38d5 100644 --- a/libs/ardour/utils.cc +++ b/libs/ardour/utils.cc @@ -425,8 +425,8 @@ ARDOUR::string_to_edit_mode (string str) return Slide; } else if (str == _("Ripple")) { return Ripple; - } else if (str == _("Lock")) { - return Lock; + } else if (str == _("Constrained")) { + return Constrained; } fatal << string_compose (_("programming error: unknown edit mode string \"%1\""), str) << endmsg; abort(); /*NOTREACHED*/ @@ -440,8 +440,8 @@ ARDOUR::edit_mode_to_string (EditMode mode) case Slide: return _("Slide"); - case Lock: - return _("Lock"); + case Constrained: + return _("Constrained"); case Ripple: return _("Ripple"); diff --git a/libs/gtkmm2ext/gtkmm2ext/keyboard.h b/libs/gtkmm2ext/gtkmm2ext/keyboard.h index 328638373f..6cccca762b 100644 --- a/libs/gtkmm2ext/gtkmm2ext/keyboard.h +++ b/libs/gtkmm2ext/gtkmm2ext/keyboard.h @@ -122,6 +122,12 @@ class LIBGTKMM2EXT_API Keyboard : public sigc::trackable, PBD::Stateful */ static ModifierMask snap_modifier () { return ModifierMask (snap_mod); } + static void set_snap_delta_modifier (guint); + + /** @return Modifier mask to temporarily toggle between relative and absolute grid setting; + */ + static ModifierMask snap_delta_modifier () { return ModifierMask (snap_delta_mod); } + static guint edit_button() { return edit_but; } static void set_edit_button (guint); static guint edit_modifier() { return edit_mod; } @@ -186,6 +192,7 @@ class LIBGTKMM2EXT_API Keyboard : public sigc::trackable, PBD::Stateful static guint insert_note_but; static guint insert_note_mod; static guint snap_mod; + static guint snap_delta_mod; static guint button2_modifiers; static Gtk::Window* current_window; static std::string user_keybindings_path; diff --git a/libs/gtkmm2ext/keyboard.cc b/libs/gtkmm2ext/keyboard.cc index 420d42209b..06f158662b 100644 --- a/libs/gtkmm2ext/keyboard.cc +++ b/libs/gtkmm2ext/keyboard.cc @@ -59,6 +59,7 @@ guint Keyboard::delete_mod = GDK_SHIFT_MASK; guint Keyboard::insert_note_but = 1; guint Keyboard::insert_note_mod = GDK_CONTROL_MASK; guint Keyboard::snap_mod = GDK_MOD3_MASK; +guint Keyboard::snap_delta_mod = 0; #ifdef GTKOSX @@ -179,6 +180,8 @@ Keyboard::get_state (void) node->add_property ("delete-modifier", buf); snprintf (buf, sizeof (buf), "%d", snap_mod); node->add_property ("snap-modifier", buf); + snprintf (buf, sizeof (buf), "%d", snap_delta_mod); + node->add_property ("snap-delta-modifier", buf); snprintf (buf, sizeof (buf), "%d", insert_note_but); node->add_property ("insert-note-button", buf); snprintf (buf, sizeof (buf), "%d", insert_note_mod); @@ -212,6 +215,10 @@ Keyboard::set_state (const XMLNode& node, int /*version*/) sscanf (prop->value().c_str(), "%d", &snap_mod); } + if ((prop = node.property ("snap-delta-modifier")) != 0) { + sscanf (prop->value().c_str(), "%d", &snap_delta_mod); + } + if ((prop = node.property ("insert-note-button")) != 0) { sscanf (prop->value().c_str(), "%d", &insert_note_but); } @@ -466,6 +473,14 @@ Keyboard::set_snap_modifier (guint mod) RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | snap_mod); } +void +Keyboard::set_snap_delta_modifier (guint mod) +{cerr << "setting snap delta mod" << endl; + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask & ~snap_delta_mod); + snap_delta_mod = mod; + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | snap_delta_mod); +} + bool Keyboard::is_edit_event (GdkEventButton *ev) { -- cgit v1.2.3 From dc50730059771b4b2899ffb4c3b5ef49d5ffae91 Mon Sep 17 00:00:00 2001 From: nick_m Date: Tue, 19 May 2015 03:27:50 +1000 Subject: Revert to old Lock mode (still called Lock). Also make midi notes obey the snap delta modifire --- gtk2_ardour/editor.cc | 10 +++++----- gtk2_ardour/editor_actions.cc | 2 +- gtk2_ardour/editor_drag.cc | 19 ++++++++++++------- gtk2_ardour/editor_ops.cc | 6 +++--- libs/ardour/ardour/types.h | 2 +- libs/ardour/enums.cc | 2 +- libs/ardour/utils.cc | 8 ++++---- 7 files changed, 27 insertions(+), 22 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index e785db3de7..ff9d480a35 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -195,7 +195,7 @@ static const gchar *_edit_mode_strings[] = { N_("Slide"), N_("Splice"), N_("Ripple"), - N_("Constrained"), + N_("Lock"), 0 }; @@ -3171,7 +3171,7 @@ Editor::build_edit_mode_menu () edit_mode_selector.AddMenuElem (MenuElem ( edit_mode_strings[(int)Slide], sigc::bind (sigc::mem_fun(*this, &Editor::edit_mode_selection_done), (EditMode) Slide))); // edit_mode_selector.AddMenuElem (MenuElem ( edit_mode_strings[(int)Splice], sigc::bind (sigc::mem_fun(*this, &Editor::edit_mode_selection_done), (EditMode) Splice))); edit_mode_selector.AddMenuElem (MenuElem ( edit_mode_strings[(int)Ripple], sigc::bind (sigc::mem_fun(*this, &Editor::edit_mode_selection_done), (EditMode) Ripple))); - edit_mode_selector.AddMenuElem (MenuElem ( edit_mode_strings[(int)Constrained], sigc::bind (sigc::mem_fun(*this, &Editor::edit_mode_selection_done), (EditMode) Constrained))); + edit_mode_selector.AddMenuElem (MenuElem ( edit_mode_strings[(int)Lock], sigc::bind (sigc::mem_fun(*this, &Editor::edit_mode_selection_done), (EditMode) Lock))); set_size_request_to_display_given_text (edit_mode_selector, edit_mode_strings, COMBO_TRIANGLE_WIDTH, 2); } @@ -3617,16 +3617,16 @@ Editor::cycle_edit_mode () switch (Config->get_edit_mode()) { case Slide: if (Profile->get_sae()) { - Config->set_edit_mode (Constrained); + Config->set_edit_mode (Lock); } else { Config->set_edit_mode (Ripple); } break; case Splice: case Ripple: - Config->set_edit_mode (Constrained); + Config->set_edit_mode (Lock); break; - case Constrained: + case Lock: Config->set_edit_mode (Slide); break; } diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc index f1cf70fd89..baebda73af 100644 --- a/gtk2_ardour/editor_actions.cc +++ b/gtk2_ardour/editor_actions.cc @@ -509,7 +509,7 @@ Editor::register_actions () // ActionManager::register_action (editor_actions, "set-edit-splice", _("Splice"), sigc::bind (sigc::mem_fun (*this, &Editor::set_edit_mode), Splice)); ActionManager::register_action (editor_actions, "set-edit-ripple", _("Ripple"), bind (mem_fun (*this, &Editor::set_edit_mode), Ripple)); ActionManager::register_action (editor_actions, "set-edit-slide", _("Slide"), sigc::bind (sigc::mem_fun (*this, &Editor::set_edit_mode), Slide)); - ActionManager::register_action (editor_actions, "set-edit-constrained", S_("EditMode|Constrained"), sigc::bind (sigc::mem_fun (*this, &Editor::set_edit_mode), Constrained)); + ActionManager::register_action (editor_actions, "set-edit-lock", S_("EditMode|Lock"), sigc::bind (sigc::mem_fun (*this, &Editor::set_edit_mode), Lock)); ActionManager::register_action (editor_actions, "cycle-edit-mode", _("Cycle Edit Mode"), sigc::mem_fun (*this, &Editor::cycle_edit_mode)); ActionManager::register_action (editor_actions, X_("SnapTo"), _("Snap to")); diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index cf1f8007b9..0e75c48cdb 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -401,21 +401,25 @@ Drag::motion_handler (GdkEvent* event, bool from_autoscroll) /* just changed */ if (fabs (current_pointer_y() - _grab_y) > fabs (current_pointer_x() - _grab_x)) { - if ((event->motion.state & Gdk::BUTTON2_MASK) || Config->get_edit_mode() == Constrained) { + if ((event->motion.state & Gdk::BUTTON2_MASK) && Config->get_edit_mode() != Lock) { _x_constrained = true; _y_constrained = false; } _initially_vertical = true; } else { - if ((event->motion.state & Gdk::BUTTON2_MASK) || Config->get_edit_mode() == Constrained) { + if ((event->motion.state & Gdk::BUTTON2_MASK) && Config->get_edit_mode() != Lock) { _x_constrained = false; _y_constrained = true; } _initially_vertical = false; } - if ((event->motion.state & Gdk::BUTTON2_MASK) && Config->get_edit_mode() == Constrained) { - _x_constrained = false; + if (Config->get_edit_mode() == Lock) { + if (event->button.state & Gdk::BUTTON2_MASK) { + _x_constrained = false; + } else { + _x_constrained = true; + } _y_constrained = false; } } @@ -635,7 +639,8 @@ RegionMotionDrag::compute_x_delta (GdkEvent const * event, framepos_t* pending_r } double dx = 0; - bool x_move_allowed = !_x_constrained; + + bool const x_move_allowed = !_x_constrained; if ((*pending_region_position != _last_frame_position) && x_move_allowed) { @@ -2389,7 +2394,7 @@ NoteResizeDrag::motion (GdkEvent* event, bool /*first_move*/) MidiRegionView* mrv = dynamic_cast(*r); if (mrv) { double sd = 0.0; - if (Keyboard::modifier_state_contains (event->button.state, Keyboard::TertiaryModifier)) { + if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::snap_delta_modifier())) { sd = _snap_delta; } mrv->update_resizing (nb, at_front, _drags->current_pointer_x() - grab_x(), relative, sd); @@ -2406,7 +2411,7 @@ NoteResizeDrag::finished (GdkEvent* event, bool /*movement_occurred*/) assert (nb); MidiRegionView* mrv = dynamic_cast(*r); double sd = 0.0; - if (Keyboard::modifier_state_contains (event->button.state, Keyboard::TertiaryModifier)) { + if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::snap_delta_modifier())) { sd = _snap_delta; } if (mrv) { diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 0ff9cbb732..5c45951e04 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -6960,7 +6960,7 @@ Editor::insert_time ( { bool commit = false; - if (Config->get_edit_mode() == Constrained) { + if (Config->get_edit_mode() == Lock) { return; } @@ -7133,8 +7133,8 @@ Editor::cut_time (framepos_t pos, framecnt_t frames, InsertTimeOption opt, { bool commit = false; - if (Config->get_edit_mode() == Constrained) { - error << (_("Cannot insert or delete time when in Constrained edit.")) << endmsg; + if (Config->get_edit_mode() == Lock) { + error << (_("Cannot insert or delete time when in Lock edit.")) << endmsg; return; } diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h index 33cd94f101..b1b4388a74 100644 --- a/libs/ardour/ardour/types.h +++ b/libs/ardour/ardour/types.h @@ -352,7 +352,7 @@ namespace ARDOUR { Slide, Splice, Ripple, - Constrained + Lock }; enum RegionSelectionAfterSplit { diff --git a/libs/ardour/enums.cc b/libs/ardour/enums.cc index 6e53660cfb..a1cf8d090c 100644 --- a/libs/ardour/enums.cc +++ b/libs/ardour/enums.cc @@ -242,7 +242,7 @@ setup_enum_writer () REGISTER_ENUM (Slide); REGISTER_ENUM (Splice); REGISTER_ENUM (Ripple); // XXX do the old enum values have to stay in order? - REGISTER_ENUM (Constrained); + REGISTER_ENUM (Lock); REGISTER (_EditMode); /* * Splice mode is undefined, undocumented, and basically fubar'ed diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc index 82ad8c38d5..6d6511bb9f 100644 --- a/libs/ardour/utils.cc +++ b/libs/ardour/utils.cc @@ -425,8 +425,8 @@ ARDOUR::string_to_edit_mode (string str) return Slide; } else if (str == _("Ripple")) { return Ripple; - } else if (str == _("Constrained")) { - return Constrained; + } else if (str == _("Lock")) { + return Lock; } fatal << string_compose (_("programming error: unknown edit mode string \"%1\""), str) << endmsg; abort(); /*NOTREACHED*/ @@ -440,8 +440,8 @@ ARDOUR::edit_mode_to_string (EditMode mode) case Slide: return _("Slide"); - case Constrained: - return _("Constrained"); + case Lock: + return _("Lock"); case Ripple: return _("Ripple"); -- cgit v1.2.3 From 66221d1dea2fc82f236ee7b3815b6b3598e0dc89 Mon Sep 17 00:00:00 2001 From: nick_m Date: Wed, 20 May 2015 04:00:04 +1000 Subject: Add more modifier preferences. Note that no defaults are set - go to prefs->user interaction to ensure that nothing is set to "no modifer" also - the copy modifier doesn't actually save its state yet. --- gtk2_ardour/editor_drag.cc | 4 +- gtk2_ardour/rc_option_editor.cc | 206 +++++++++++++++++++++++++++++++----- libs/gtkmm2ext/gtkmm2ext/keyboard.h | 14 ++- libs/gtkmm2ext/keyboard.cc | 30 ++++++ 4 files changed, 222 insertions(+), 32 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 0e75c48cdb..ca45cbc755 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -2614,7 +2614,7 @@ TrimDrag::start_grab (GdkEvent* event, Gdk::Cursor*) framepos_t const pf = adjusted_current_frame (event); setup_snap_delta (region_start); - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::SecondaryModifier)) { + if (Keyboard::modifier_state_equals (event->button.state, Keyboard::trim_contents_modifier ())) { /* Move the contents of the region around without changing the region bounds */ _operation = ContentsTrim; Drag::start_grab (event, _editor->cursors()->trimmer); @@ -2720,7 +2720,7 @@ TrimDrag::motion (GdkEvent* event, bool first_move) bool non_overlap_trim = false; - if (event && Keyboard::modifier_state_equals (event->button.state, Keyboard::ModifierMask (Keyboard::PrimaryModifier | Keyboard::TertiaryModifier))) { + if (event && Keyboard::modifier_state_equals (event->button.state, Keyboard::trim_overlap_modifier ())) { non_overlap_trim = true; } diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc index 9c5a603fd7..4df3ff2c2b 100644 --- a/gtk2_ardour/rc_option_editor.cc +++ b/gtk2_ardour/rc_option_editor.cc @@ -319,25 +319,57 @@ public: } } - Table* t = manage (new Table (4, 5)); + Table* t = manage (new Table (5, 11)); t->set_spacings (4); - Label* l = manage (left_aligned_label (_("Edit using:"))); + int row = 0; + int col = 0; + + Label* l = manage (left_aligned_label (_("Select Keyboard layout:"))); + l->set_name ("OptionsLabel"); + + vector strs; + + for (map::iterator bf = Keyboard::binding_files.begin(); bf != Keyboard::binding_files.end(); ++bf) { + strs.push_back (bf->first); + } + + set_popdown_strings (_keyboard_layout_selector, strs); + _keyboard_layout_selector.set_active_text (Keyboard::current_binding_name()); + _keyboard_layout_selector.signal_changed().connect (sigc::mem_fun (*this, &KeyboardOptions::bindings_changed)); + + t->attach (*l, col, col + 1, row, row + 1, FILL | EXPAND, FILL); + t->attach (_keyboard_layout_selector, col + 1, col + 2, row, row + 1, FILL | EXPAND, FILL); + + ++row; + col = 0; + + l = manage (left_aligned_label (_("When Clicking:"))); + l->set_name ("OptionEditorHeading"); + t->attach (*l, col, col + 1, row, row + 1, FILL | EXPAND, FILL); + + ++row; + col = 1; + + l = manage (left_aligned_label (_("Edit using:"))); l->set_name ("OptionsLabel"); - t->attach (*l, 0, 1, 0, 1, FILL | EXPAND, FILL); - t->attach (_edit_modifier_combo, 1, 2, 0, 1, FILL | EXPAND, FILL); + t->attach (*l, col, col + 1, row, row + 1, FILL | EXPAND, FILL); + t->attach (_edit_modifier_combo, col + 1, col + 2, row, row + 1, FILL | EXPAND, FILL); l = manage (new Label (_("+ button"))); l->set_name ("OptionsLabel"); - t->attach (*l, 3, 4, 0, 1, FILL | EXPAND, FILL); - t->attach (_edit_button_spin, 4, 5, 0, 1, FILL | EXPAND, FILL); + t->attach (*l, col + 3, col + 4, row, row + 1, FILL | EXPAND, FILL); + t->attach (_edit_button_spin, col + 4, col + 5, row, row + 1, FILL | EXPAND, FILL); _edit_button_spin.set_name ("OptionsEntry"); _edit_button_adjustment.set_value (Keyboard::edit_button()); _edit_button_adjustment.signal_value_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::edit_button_changed)); + ++row; + col = 1; + set_popdown_strings (_delete_modifier_combo, dumb); _delete_modifier_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::delete_modifier_chosen)); @@ -351,19 +383,21 @@ public: l = manage (left_aligned_label (_("Delete using:"))); l->set_name ("OptionsLabel"); - t->attach (*l, 0, 1, 1, 2, FILL | EXPAND, FILL); - t->attach (_delete_modifier_combo, 1, 2, 1, 2, FILL | EXPAND, FILL); + t->attach (*l, col, col + 1, row, row + 1, FILL | EXPAND, FILL); + t->attach (_delete_modifier_combo, col + 1, col + 2, row, row + 1, FILL | EXPAND, FILL); l = manage (new Label (_("+ button"))); l->set_name ("OptionsLabel"); - t->attach (*l, 3, 4, 1, 2, FILL | EXPAND, FILL); - t->attach (_delete_button_spin, 4, 5, 1, 2, FILL | EXPAND, FILL); + t->attach (*l, col + 3, col + 4, row, row + 1, FILL | EXPAND, FILL); + t->attach (_delete_button_spin, col + 4, col + 5, row, row + 1, FILL | EXPAND, FILL); _delete_button_spin.set_name ("OptionsEntry"); _delete_button_adjustment.set_value (Keyboard::delete_button()); _delete_button_adjustment.signal_value_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::delete_button_changed)); + ++row; + col = 1; set_popdown_strings (_insert_note_modifier_combo, dumb); _insert_note_modifier_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::insert_note_modifier_chosen)); @@ -378,19 +412,80 @@ public: l = manage (left_aligned_label (_("Insert note using:"))); l->set_name ("OptionsLabel"); - t->attach (*l, 0, 1, 2, 3, FILL | EXPAND, FILL); - t->attach (_insert_note_modifier_combo, 1, 2, 2, 3, FILL | EXPAND, FILL); + t->attach (*l, col, col + 1, row, row + 1, FILL | EXPAND, FILL); + t->attach (_insert_note_modifier_combo, col + 1, col + 2, row, row + 1, FILL | EXPAND, FILL); l = manage (new Label (_("+ button"))); l->set_name ("OptionsLabel"); - t->attach (*l, 3, 4, 2, 3, FILL | EXPAND, FILL); - t->attach (_insert_note_button_spin, 4, 5, 2, 3, FILL | EXPAND, FILL); + t->attach (*l, col + 3, col + 4, row, row + 1, FILL | EXPAND, FILL); + t->attach (_insert_note_button_spin, col + 4, col + 5, row, row + 1, FILL | EXPAND, FILL); _insert_note_button_spin.set_name ("OptionsEntry"); _insert_note_button_adjustment.set_value (Keyboard::insert_note_button()); _insert_note_button_adjustment.signal_value_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::insert_note_button_changed)); + ++row; + + l = manage (left_aligned_label (_("When Beginning a Drag:"))); + l->set_name ("OptionEditorHeading"); + t->attach (*l, 0, 1, row, row + 1, FILL | EXPAND, FILL); + + ++row; + col = 1; + + /* copy modifier */ + set_popdown_strings (_copy_modifier_combo, dumb); + _copy_modifier_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::copy_modifier_chosen)); + + for (int x = 0; modifiers[x].name; ++x) { + if (modifiers[x].modifier == (guint) Keyboard::CopyModifier) { + _copy_modifier_combo.set_active_text (S_(modifiers[x].name)); + break; + } + } + + l = manage (left_aligned_label (_("Copy items using:"))); + l->set_name ("OptionsLabel"); + + t->attach (*l, col, col + 1, row, row + 1, FILL | EXPAND, FILL); + t->attach (_copy_modifier_combo, col + 1, col + 2, row, row + 1, FILL | EXPAND, FILL); + + ++row; + + l = manage (left_aligned_label (_("When Beginning a Trim:"))); + l->set_name ("OptionEditorHeading"); + t->attach (*l, 0, 1, row, row + 1, FILL | EXPAND, FILL); + + ++row; + col = 1; + + /* trim_contents */ + set_popdown_strings (_trim_contents_combo, dumb); + _trim_contents_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::trim_contents_modifier_chosen)); + + for (int x = 0; modifiers[x].name; ++x) { + if (modifiers[x].modifier == (guint) Keyboard::trim_contents_modifier ()) { + _trim_contents_combo.set_active_text (S_(modifiers[x].name)); + break; + } + } + + l = manage (left_aligned_label (_("Trim contents using:"))); + l->set_name ("OptionsLabel"); + + t->attach (*l, col, col + 1, row, row + 1, FILL | EXPAND, FILL); + t->attach (_trim_contents_combo, col + 1, col + 2, row, row + 1, FILL | EXPAND, FILL); + + ++row; + + l = manage (left_aligned_label (_("While Dragging:"))); + l->set_name ("OptionEditorHeading"); + t->attach (*l, 0, 1, row, row + 1, FILL | EXPAND, FILL); + + ++row; + col = 1; + /* ignore snap */ set_popdown_strings (_snap_modifier_combo, dumb); _snap_modifier_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::snap_modifier_chosen)); @@ -405,8 +500,11 @@ public: l = manage (left_aligned_label (_("Ignore snap using:"))); l->set_name ("OptionsLabel"); - t->attach (*l, 0, 1, 3, 4, FILL | EXPAND, FILL); - t->attach (_snap_modifier_combo, 1, 2, 3, 4, FILL | EXPAND, FILL); + t->attach (*l, col, col + 1, row, row + 1, FILL | EXPAND, FILL); + t->attach (_snap_modifier_combo, col + 1, col + 2, row, row + 1, FILL | EXPAND, FILL); + + ++row; + col = 1; /* snap delta */ set_popdown_strings (_snap_delta_combo, dumb); @@ -422,24 +520,37 @@ public: l = manage (left_aligned_label (_("Snap to absolute using:"))); l->set_name ("OptionsLabel"); - t->attach (*l, 0, 1, 4, 5, FILL | EXPAND, FILL); - t->attach (_snap_delta_combo, 1, 2, 4, 5, FILL | EXPAND, FILL); + t->attach (*l, col, col + 1, row, row + 1, FILL | EXPAND, FILL); + t->attach (_snap_delta_combo, col + 1, col + 2, row, row + 1, FILL | EXPAND, FILL); - vector strs; + ++row; - for (map::iterator bf = Keyboard::binding_files.begin(); bf != Keyboard::binding_files.end(); ++bf) { - strs.push_back (bf->first); - } + l = manage (left_aligned_label (_("While Trimming:"))); + l->set_name ("OptionEditorHeading"); + t->attach (*l, 0, 1, row, row + 1, FILL | EXPAND, FILL); - set_popdown_strings (_keyboard_layout_selector, strs); - _keyboard_layout_selector.set_active_text (Keyboard::current_binding_name()); - _keyboard_layout_selector.signal_changed().connect (sigc::mem_fun (*this, &KeyboardOptions::bindings_changed)); + ++row; + col = 1; + + /* trim_overlap */ + set_popdown_strings (_trim_overlap_combo, dumb); + _trim_overlap_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::trim_overlap_modifier_chosen)); + + for (int x = 0; modifiers[x].name; ++x) { + if (modifiers[x].modifier == (guint) Keyboard::trim_overlap_modifier ()) { + _trim_overlap_combo.set_active_text (S_(modifiers[x].name)); + break; + } + } - l = manage (left_aligned_label (_("Keyboard layout:"))); + l = manage (left_aligned_label (_("Resize overlaped regions using:"))); l->set_name ("OptionsLabel"); - t->attach (*l, 0, 1, 5, 6, FILL | EXPAND, FILL); - t->attach (_keyboard_layout_selector, 1, 2, 5, 6, FILL | EXPAND, FILL); + t->attach (*l, col, col + 1, row, row + 1, FILL | EXPAND, FILL); + t->attach (_trim_overlap_combo, col + 1, col + 2, row, row + 1, FILL | EXPAND, FILL); + + ++row; + ++row; _box->pack_start (*t, false, false); } @@ -495,6 +606,18 @@ private: } } + void copy_modifier_chosen () + { + string const txt = _copy_modifier_combo.get_active_text(); + + for (int i = 0; modifiers[i].name; ++i) { + if (txt == _(modifiers[i].name)) { + Keyboard::set_copy_modifier (modifiers[i].modifier); + break; + } + } + } + void insert_note_modifier_chosen () { string const txt = _insert_note_modifier_combo.get_active_text(); @@ -531,6 +654,30 @@ private: } } + void trim_contents_modifier_chosen () + { + string const txt = _trim_contents_combo.get_active_text(); + + for (int i = 0; modifiers[i].name; ++i) { + if (txt == _(modifiers[i].name)) { + Keyboard::set_trim_contents_modifier (modifiers[i].modifier); + break; + } + } + } + + void trim_overlap_modifier_chosen () + { + string const txt = _trim_overlap_combo.get_active_text(); + + for (int i = 0; modifiers[i].name; ++i) { + if (txt == _(modifiers[i].name)) { + Keyboard::set_trim_overlap_modifier (modifiers[i].modifier); + break; + } + } + } + void delete_button_changed () { Keyboard::set_delete_button (_delete_button_spin.get_value_as_int()); @@ -549,9 +696,12 @@ private: ComboBoxText _keyboard_layout_selector; ComboBoxText _edit_modifier_combo; ComboBoxText _delete_modifier_combo; + ComboBoxText _copy_modifier_combo; ComboBoxText _insert_note_modifier_combo; ComboBoxText _snap_modifier_combo; ComboBoxText _snap_delta_combo; + ComboBoxText _trim_contents_combo; + ComboBoxText _trim_overlap_combo; Adjustment _delete_button_adjustment; SpinButton _delete_button_spin; Adjustment _edit_button_adjustment; diff --git a/libs/gtkmm2ext/gtkmm2ext/keyboard.h b/libs/gtkmm2ext/gtkmm2ext/keyboard.h index 6cccca762b..5be93fe4f6 100644 --- a/libs/gtkmm2ext/gtkmm2ext/keyboard.h +++ b/libs/gtkmm2ext/gtkmm2ext/keyboard.h @@ -115,7 +115,6 @@ class LIBGTKMM2EXT_API Keyboard : public sigc::trackable, PBD::Stateful static bool no_modifiers_active (guint state); static void set_snap_modifier (guint); - /** @return Modifier mask to temporarily toggle grid setting; with this modifier * - magnetic or normal grid should become no grid and * - no grid should become normal grid @@ -123,11 +122,20 @@ class LIBGTKMM2EXT_API Keyboard : public sigc::trackable, PBD::Stateful static ModifierMask snap_modifier () { return ModifierMask (snap_mod); } static void set_snap_delta_modifier (guint); - /** @return Modifier mask to temporarily toggle between relative and absolute grid setting; */ static ModifierMask snap_delta_modifier () { return ModifierMask (snap_delta_mod); } + static void set_trim_contents_modifier (guint); + /** @return Modifier mask to move contents rather than region bounds during trim; + */ + static ModifierMask trim_contents_modifier () { return ModifierMask (trim_contents_mod); } + + static void set_trim_overlap_modifier (guint); + /** @return Modifier mask to remove region overlaps after trim; + */ + static ModifierMask trim_overlap_modifier () { return ModifierMask (trim_overlap_mod); } + static guint edit_button() { return edit_but; } static void set_edit_button (guint); static guint edit_modifier() { return edit_mod; } @@ -193,6 +201,8 @@ class LIBGTKMM2EXT_API Keyboard : public sigc::trackable, PBD::Stateful static guint insert_note_mod; static guint snap_mod; static guint snap_delta_mod; + static guint trim_contents_mod; + static guint trim_overlap_mod; static guint button2_modifiers; static Gtk::Window* current_window; static std::string user_keybindings_path; diff --git a/libs/gtkmm2ext/keyboard.cc b/libs/gtkmm2ext/keyboard.cc index 4e35b3b80a..f60b91cb4d 100644 --- a/libs/gtkmm2ext/keyboard.cc +++ b/libs/gtkmm2ext/keyboard.cc @@ -60,6 +60,8 @@ guint Keyboard::insert_note_but = 1; guint Keyboard::insert_note_mod = GDK_CONTROL_MASK; guint Keyboard::snap_mod = GDK_MOD3_MASK; guint Keyboard::snap_delta_mod = 0; +guint Keyboard::trim_contents_mod = 0; +guint Keyboard::trim_overlap_mod = 0; #ifdef GTKOSX @@ -182,6 +184,10 @@ Keyboard::get_state (void) node->add_property ("snap-modifier", buf); snprintf (buf, sizeof (buf), "%d", snap_delta_mod); node->add_property ("snap-delta-modifier", buf); + snprintf (buf, sizeof (buf), "%d", trim_contents_mod); + node->add_property ("trim-contents-modifier", buf); + snprintf (buf, sizeof (buf), "%d", trim_overlap_mod); + node->add_property ("trim-overlap-modifier", buf); snprintf (buf, sizeof (buf), "%d", insert_note_but); node->add_property ("insert-note-button", buf); snprintf (buf, sizeof (buf), "%d", insert_note_mod); @@ -219,6 +225,14 @@ Keyboard::set_state (const XMLNode& node, int /*version*/) sscanf (prop->value().c_str(), "%d", &snap_delta_mod); } + if ((prop = node.property ("trim-contents-modifier")) != 0) { + sscanf (prop->value().c_str(), "%d", &trim_contents_mod); + } + + if ((prop = node.property ("trim-overlap-modifier")) != 0) { + sscanf (prop->value().c_str(), "%d", &trim_overlap_mod); + } + if ((prop = node.property ("insert-note-button")) != 0) { sscanf (prop->value().c_str(), "%d", &insert_note_but); } @@ -481,6 +495,22 @@ Keyboard::set_snap_delta_modifier (guint mod) RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | snap_delta_mod); } +void +Keyboard::set_trim_contents_modifier (guint mod) +{ + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask & ~trim_contents_mod); + trim_contents_mod = mod; + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | trim_contents_mod); +} + +void +Keyboard::set_trim_overlap_modifier (guint mod) +{ + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask & ~trim_overlap_mod); + trim_overlap_mod = mod; + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | trim_overlap_mod); +} + bool Keyboard::is_edit_event (GdkEventButton *ev) { -- cgit v1.2.3 From ae0759ae88c2497c936b052936610a0e8c97a236 Mon Sep 17 00:00:00 2001 From: nick_m Date: Thu, 21 May 2015 01:30:57 +1000 Subject: Allow all drag -related modifiers to be set, re-instate "jump after trim" - Copy modifier still doesn't save - Testers please edit the Extra section of ~/.ardourN/config to allow defaults to "take" - Note that the current defaults overlap. - warning - absolute snap modifier has no default and will be always "on" unless you set it! --- gtk2_ardour/editor_drag.cc | 29 ++++-- gtk2_ardour/editor_drag.h | 1 + gtk2_ardour/rc_option_editor.cc | 173 ++++++++++++++++++++++++++++++++++++ libs/gtkmm2ext/gtkmm2ext/keyboard.h | 32 ++++++- libs/gtkmm2ext/keyboard.cc | 79 +++++++++++++++- 5 files changed, 302 insertions(+), 12 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index ca45cbc755..ca0a126e9d 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -2352,7 +2352,7 @@ NoteResizeDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*ignored*/) _item->grab (); - if (event->motion.state & Keyboard::PrimaryModifier) { + if (event->motion.state & Keyboard::note_size_relative_modifier ()) { relative = false; } else { relative = true; @@ -2592,6 +2592,7 @@ VideoTimeLineDrag::aborted (bool) TrimDrag::TrimDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, list const & v, bool preserve_fade_anchor) : RegionDrag (e, i, p, v) , _preserve_fade_anchor (preserve_fade_anchor) + , _jump_position_when_done (false) { DEBUG_TRACE (DEBUG::Drags, "New TrimDrag\n"); } @@ -2623,7 +2624,7 @@ TrimDrag::start_grab (GdkEvent* event, Gdk::Cursor*) if (pf < (region_start + region_length/2)) { /* closer to front */ _operation = StartTrim; - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) { + if (Keyboard::modifier_state_equals (event->button.state, Keyboard::trim_anchored_modifier ())) { Drag::start_grab (event, _editor->cursors()->anchored_left_side_trim); } else { Drag::start_grab (event, _editor->cursors()->left_side_trim); @@ -2631,7 +2632,7 @@ TrimDrag::start_grab (GdkEvent* event, Gdk::Cursor*) } else { /* closer to end */ _operation = EndTrim; - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) { + if (Keyboard::modifier_state_equals (event->button.state, Keyboard::trim_anchored_modifier ())) { Drag::start_grab (event, _editor->cursors()->anchored_right_side_trim); } else { Drag::start_grab (event, _editor->cursors()->right_side_trim); @@ -2639,6 +2640,10 @@ TrimDrag::start_grab (GdkEvent* event, Gdk::Cursor*) } } + if (Keyboard::modifier_state_equals (event->button.state, Keyboard::trim_jump_modifier ())) { + _jump_position_when_done = true; + } + switch (_operation) { case StartTrim: show_verbose_cursor_time (region_start); @@ -2838,6 +2843,9 @@ TrimDrag::finished (GdkEvent* event, bool movement_occurred) ar->set_fade_in_active(true); } } + if (_jump_position_when_done) { + i->view->region()->set_position (i->initial_position); + } } } else if (_operation == EndTrim) { for (list::const_iterator i = _views.begin(); i != _views.end(); ++i) { @@ -2850,6 +2858,9 @@ TrimDrag::finished (GdkEvent* event, bool movement_occurred) ar->set_fade_out_active(true); } } + if (_jump_position_when_done) { + i->view->region()->set_position (i->initial_end - i->view->region()->length()); + } } } @@ -3724,7 +3735,7 @@ MarkerDrag::motion (GdkEvent* event, bool) framepos_t const newframe = adjusted_current_frame (event); framepos_t next = newframe; - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) { + if (Keyboard::modifier_state_equals (event->button.state, Keyboard::push_points_modifier ())) { move_both = true; } @@ -3991,7 +4002,7 @@ ControlPointDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*cursor*/) show_verbose_cursor_text (_point->line().get_verbose_cursor_string (fraction)); - _pushing = Keyboard::modifier_state_contains (event->button.state, Keyboard::PrimaryModifier); + _pushing = Keyboard::modifier_state_contains (event->button.state, Keyboard::push_points_modifier ()); if (!_point->can_slide ()) { _x_constrained = true; @@ -4004,7 +4015,7 @@ ControlPointDrag::motion (GdkEvent* event, bool) double dx = _drags->current_pointer_x() - last_pointer_x(); double dy = current_pointer_y() - last_pointer_y(); - if (event->button.state & Keyboard::SecondaryModifier) { + if (event->button.state & Keyboard::fine_adjust_modifier ()) { dx *= 0.1; dy *= 0.1; } @@ -4059,7 +4070,7 @@ ControlPointDrag::finished (GdkEvent* event, bool movement_occurred) if (!movement_occurred) { /* just a click */ - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::ModifierMask (Keyboard::PrimaryModifier | Keyboard::TertiaryModifier))) { + if (Keyboard::modifier_state_equals (event->button.state, Keyboard::ModifierMask (Keyboard::TertiaryModifier))) { _editor->reset_point_selection (); } @@ -4143,7 +4154,7 @@ LineDrag::motion (GdkEvent* event, bool) { double dy = current_pointer_y() - last_pointer_y(); - if (event->button.state & Keyboard::SecondaryModifier) { + if (event->button.state & Keyboard::fine_adjust_modifier ()) { dy *= 0.1; } @@ -4935,7 +4946,7 @@ RangeMarkerBarDrag::start_grab (GdkEvent* event, Gdk::Cursor *) case CreateTransportMarker: case CreateCDMarker: - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::TertiaryModifier)) { + if (Keyboard::modifier_state_equals (event->button.state, Keyboard::CopyModifier)) { _copy = true; } else { _copy = false; diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index 4ed77999bf..2197f5601e 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -654,6 +654,7 @@ private: Operation _operation; bool _preserve_fade_anchor; + bool _jump_position_when_done; }; /** Meter marker drag */ diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc index 4df3ff2c2b..4fefcfada1 100644 --- a/gtk2_ardour/rc_option_editor.cc +++ b/gtk2_ardour/rc_option_editor.cc @@ -477,6 +477,69 @@ public: t->attach (*l, col, col + 1, row, row + 1, FILL | EXPAND, FILL); t->attach (_trim_contents_combo, col + 1, col + 2, row, row + 1, FILL | EXPAND, FILL); + ++row; + col = 1; + + /* anchored trim */ + set_popdown_strings (_trim_anchored_combo, dumb); + _trim_anchored_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::trim_anchored_modifier_chosen)); + + for (int x = 0; modifiers[x].name; ++x) { + if (modifiers[x].modifier == (guint) Keyboard::trim_anchored_modifier ()) { + _trim_anchored_combo.set_active_text (S_(modifiers[x].name)); + break; + } + } + + l = manage (left_aligned_label (_("Anchored trim using:"))); + l->set_name ("OptionsLabel"); + + t->attach (*l, col, col + 1, row, row + 1, FILL | EXPAND, FILL); + ++col; + t->attach (_trim_anchored_combo, col, col + 1, row, row + 1, FILL | EXPAND, FILL); + + ++row; + col = 1; + + /* jump trim */ + set_popdown_strings (_trim_jump_combo, dumb); + _trim_jump_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::trim_jump_modifier_chosen)); + + for (int x = 0; modifiers[x].name; ++x) { + if (modifiers[x].modifier == (guint) Keyboard::trim_jump_modifier ()) { + _trim_jump_combo.set_active_text (S_(modifiers[x].name)); + break; + } + } + + l = manage (left_aligned_label (_("Jump after trim using:"))); + l->set_name ("OptionsLabel"); + + t->attach (*l, col, col + 1, row, row + 1, FILL | EXPAND, FILL); + ++col; + t->attach (_trim_jump_combo, col, col + 1, row, row + 1, FILL | EXPAND, FILL); + + ++row; + col = 1; + + /* note resize relative */ + set_popdown_strings (_note_size_relative_combo, dumb); + _note_size_relative_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::note_size_relative_modifier_chosen)); + + for (int x = 0; modifiers[x].name; ++x) { + if (modifiers[x].modifier == (guint) Keyboard::note_size_relative_modifier ()) { + _note_size_relative_combo.set_active_text (S_(modifiers[x].name)); + break; + } + } + + l = manage (left_aligned_label (_("Resize notes relatively using:"))); + l->set_name ("OptionsLabel"); + + t->attach (*l, col, col + 1, row, row + 1, FILL | EXPAND, FILL); + ++col; + t->attach (_note_size_relative_combo, col, col + 1, row, row + 1, FILL | EXPAND, FILL); + ++row; l = manage (left_aligned_label (_("While Dragging:"))); @@ -550,6 +613,51 @@ public: t->attach (_trim_overlap_combo, col + 1, col + 2, row, row + 1, FILL | EXPAND, FILL); ++row; + + l = manage (left_aligned_label (_("While Dragging Control Points:"))); + l->set_name ("OptionEditorHeading"); + t->attach (*l, 0, 1, row, row + 1, FILL | EXPAND, FILL); + + ++row; + col = 1; + + /* fine adjust */ + set_popdown_strings (_fine_adjust_combo, dumb); + _fine_adjust_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::fine_adjust_modifier_chosen)); + + for (int x = 0; modifiers[x].name; ++x) { + if (modifiers[x].modifier == (guint) Keyboard::fine_adjust_modifier ()) { + _fine_adjust_combo.set_active_text (S_(modifiers[x].name)); + break; + } + } + + l = manage (left_aligned_label (_("Fine adjust using:"))); + l->set_name ("OptionsLabel"); + + t->attach (*l, col, col + 1, row, row + 1, FILL | EXPAND, FILL); + t->attach (_fine_adjust_combo, col + 1, col + 2, row, row + 1, FILL | EXPAND, FILL); + + ++row; + col = 1; + + /* push points */ + set_popdown_strings (_push_points_combo, dumb); + _push_points_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::push_points_modifier_chosen)); + + for (int x = 0; modifiers[x].name; ++x) { + if (modifiers[x].modifier == (guint) Keyboard::push_points_modifier ()) { + _push_points_combo.set_active_text (S_(modifiers[x].name)); + break; + } + } + + l = manage (left_aligned_label (_("Push points using:"))); + l->set_name ("OptionsLabel"); + + t->attach (*l, col, col + 1, row, row + 1, FILL | EXPAND, FILL); + t->attach (_push_points_combo, col + 1, col + 2, row, row + 1, FILL | EXPAND, FILL); + ++row; _box->pack_start (*t, false, false); @@ -678,6 +786,66 @@ private: } } + void trim_anchored_modifier_chosen () + { + string const txt = _trim_anchored_combo.get_active_text(); + + for (int i = 0; modifiers[i].name; ++i) { + if (txt == _(modifiers[i].name)) { + Keyboard::set_trim_anchored_modifier (modifiers[i].modifier); + break; + } + } + } + + void trim_jump_modifier_chosen () + { + string const txt = _trim_jump_combo.get_active_text(); + + for (int i = 0; modifiers[i].name; ++i) { + if (txt == _(modifiers[i].name)) { + Keyboard::set_trim_jump_modifier (modifiers[i].modifier); + break; + } + } + } + + void fine_adjust_modifier_chosen () + { + string const txt = _fine_adjust_combo.get_active_text(); + + for (int i = 0; modifiers[i].name; ++i) { + if (txt == _(modifiers[i].name)) { + Keyboard::set_fine_adjust_modifier (modifiers[i].modifier); + break; + } + } + } + + void push_points_modifier_chosen () + { + string const txt = _push_points_combo.get_active_text(); + + for (int i = 0; modifiers[i].name; ++i) { + if (txt == _(modifiers[i].name)) { + Keyboard::set_push_points_modifier (modifiers[i].modifier); + break; + } + } + } + + void note_size_relative_modifier_chosen () + { + string const txt = _note_size_relative_combo.get_active_text(); + + for (int i = 0; modifiers[i].name; ++i) { + if (txt == _(modifiers[i].name)) { + Keyboard::set_note_size_relative_modifier (modifiers[i].modifier); + break; + } + } + } + void delete_button_changed () { Keyboard::set_delete_button (_delete_button_spin.get_value_as_int()); @@ -702,6 +870,11 @@ private: ComboBoxText _snap_delta_combo; ComboBoxText _trim_contents_combo; ComboBoxText _trim_overlap_combo; + ComboBoxText _trim_anchored_combo; + ComboBoxText _trim_jump_combo; + ComboBoxText _fine_adjust_combo; + ComboBoxText _push_points_combo; + ComboBoxText _note_size_relative_combo; Adjustment _delete_button_adjustment; SpinButton _delete_button_spin; Adjustment _edit_button_adjustment; diff --git a/libs/gtkmm2ext/gtkmm2ext/keyboard.h b/libs/gtkmm2ext/gtkmm2ext/keyboard.h index 5be93fe4f6..a10a6dbb3e 100644 --- a/libs/gtkmm2ext/gtkmm2ext/keyboard.h +++ b/libs/gtkmm2ext/gtkmm2ext/keyboard.h @@ -132,10 +132,35 @@ class LIBGTKMM2EXT_API Keyboard : public sigc::trackable, PBD::Stateful static ModifierMask trim_contents_modifier () { return ModifierMask (trim_contents_mod); } static void set_trim_overlap_modifier (guint); - /** @return Modifier mask to remove region overlaps after trim; + /** @return Modifier mask to remove region overlaps during trim; */ static ModifierMask trim_overlap_modifier () { return ModifierMask (trim_overlap_mod); } + static void set_trim_anchored_modifier (guint); + /** @return Modifier mask to use anchored trim; + */ + static ModifierMask trim_anchored_modifier () { return ModifierMask (trim_anchored_mod); } + + static void set_fine_adjust_modifier (guint); + /** @return Modifier mask to fine adjust (control points only atm); + */ + static ModifierMask fine_adjust_modifier () { return ModifierMask (fine_adjust_mod); } + + static void set_push_points_modifier (guint); + /** @return Modifier mask to push proceeding points; + */ + static ModifierMask push_points_modifier () { return ModifierMask (push_points_mod); } + + static void set_note_size_relative_modifier (guint); + /** @return Modifier mask to resize notes relatively; + */ + static ModifierMask note_size_relative_modifier () { return ModifierMask (note_size_relative_mod); } + + static void set_trim_jump_modifier (guint); + /** @return Modifier mask to jump position after trim; + */ + static ModifierMask trim_jump_modifier () { return ModifierMask (trim_jump_mod); } + static guint edit_button() { return edit_but; } static void set_edit_button (guint); static guint edit_modifier() { return edit_mod; } @@ -203,6 +228,11 @@ class LIBGTKMM2EXT_API Keyboard : public sigc::trackable, PBD::Stateful static guint snap_delta_mod; static guint trim_contents_mod; static guint trim_overlap_mod; + static guint trim_anchored_mod; + static guint fine_adjust_mod; + static guint push_points_mod; + static guint note_size_relative_mod; + static guint trim_jump_mod; static guint button2_modifiers; static Gtk::Window* current_window; static std::string user_keybindings_path; diff --git a/libs/gtkmm2ext/keyboard.cc b/libs/gtkmm2ext/keyboard.cc index f60b91cb4d..17e41a4b85 100644 --- a/libs/gtkmm2ext/keyboard.cc +++ b/libs/gtkmm2ext/keyboard.cc @@ -60,8 +60,6 @@ guint Keyboard::insert_note_but = 1; guint Keyboard::insert_note_mod = GDK_CONTROL_MASK; guint Keyboard::snap_mod = GDK_MOD3_MASK; guint Keyboard::snap_delta_mod = 0; -guint Keyboard::trim_contents_mod = 0; -guint Keyboard::trim_overlap_mod = 0; #ifdef GTKOSX @@ -106,6 +104,13 @@ guint Keyboard::ScrollZoomVerticalModifier = Keyboard::SecondaryModifier; guint Keyboard::ScrollZoomHorizontalModifier = Keyboard::PrimaryModifier; guint Keyboard::ScrollHorizontalModifier = Keyboard::TertiaryModifier; +guint Keyboard::trim_contents_mod = Keyboard::PrimaryModifier; +guint Keyboard::trim_overlap_mod = Keyboard::TertiaryModifier; +guint Keyboard::trim_anchored_mod = Keyboard::TertiaryModifier; +guint Keyboard::trim_jump_mod = Keyboard::TertiaryModifier; +guint Keyboard::fine_adjust_mod = Keyboard::SecondaryModifier; +guint Keyboard::push_points_mod = Keyboard::PrimaryModifier; +guint Keyboard::note_size_relative_mod = Keyboard::PrimaryModifier; Keyboard* Keyboard::_the_keyboard = 0; Gtk::Window* Keyboard::current_window = 0; @@ -188,6 +193,16 @@ Keyboard::get_state (void) node->add_property ("trim-contents-modifier", buf); snprintf (buf, sizeof (buf), "%d", trim_overlap_mod); node->add_property ("trim-overlap-modifier", buf); + snprintf (buf, sizeof (buf), "%d", trim_anchored_mod); + node->add_property ("trim-anchored-modifier", buf); + snprintf (buf, sizeof (buf), "%d", trim_jump_mod); + node->add_property ("trim-jump-modifier", buf); + snprintf (buf, sizeof (buf), "%d", fine_adjust_mod); + node->add_property ("fine-adjust-modifier", buf); + snprintf (buf, sizeof (buf), "%d", push_points_mod); + node->add_property ("push-points-modifier", buf); + snprintf (buf, sizeof (buf), "%d", note_size_relative_mod); + node->add_property ("note-size-relative-modifier", buf); snprintf (buf, sizeof (buf), "%d", insert_note_but); node->add_property ("insert-note-button", buf); snprintf (buf, sizeof (buf), "%d", insert_note_mod); @@ -233,6 +248,26 @@ Keyboard::set_state (const XMLNode& node, int /*version*/) sscanf (prop->value().c_str(), "%d", &trim_overlap_mod); } + if ((prop = node.property ("trim-anchored-modifier")) != 0) { + sscanf (prop->value().c_str(), "%d", &trim_anchored_mod); + } + + if ((prop = node.property ("trim-jump-modifier")) != 0) { + sscanf (prop->value().c_str(), "%d", &trim_jump_mod); + } + + if ((prop = node.property ("fine-adjust-modifier")) != 0) { + sscanf (prop->value().c_str(), "%d", &fine_adjust_mod); + } + + if ((prop = node.property ("push-points-modifier")) != 0) { + sscanf (prop->value().c_str(), "%d", &push_points_mod); + } + + if ((prop = node.property ("note-size-relative-modifier")) != 0) { + sscanf (prop->value().c_str(), "%d", ¬e_size_relative_mod); + } + if ((prop = node.property ("insert-note-button")) != 0) { sscanf (prop->value().c_str(), "%d", &insert_note_but); } @@ -511,6 +546,46 @@ Keyboard::set_trim_overlap_modifier (guint mod) RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | trim_overlap_mod); } +void +Keyboard::set_trim_anchored_modifier (guint mod) +{ + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask & ~trim_anchored_mod); + trim_anchored_mod = mod; + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | trim_anchored_mod); +} + +void +Keyboard::set_trim_jump_modifier (guint mod) +{ + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask & ~trim_jump_mod); + trim_jump_mod = mod; + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | trim_jump_mod); +} + +void +Keyboard::set_fine_adjust_modifier (guint mod) +{ + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask & ~fine_adjust_mod); + fine_adjust_mod = mod; + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | fine_adjust_mod); +} + +void +Keyboard::set_push_points_modifier (guint mod) +{ + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask & ~push_points_mod); + push_points_mod = mod; + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | push_points_mod); +} + +void +Keyboard::set_note_size_relative_modifier (guint mod) +{ + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask & ~note_size_relative_mod); + note_size_relative_mod = mod; + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | note_size_relative_mod); +} + bool Keyboard::is_edit_event (GdkEventButton *ev) { -- cgit v1.2.3 From 186736043cb277b8352a08d1cf61bc81f3169852 Mon Sep 17 00:00:00 2001 From: nick_m Date: Thu, 21 May 2015 05:32:23 +1000 Subject: Move ui-centric modifiers into ArdourKeyboard, set some bad defaults. - Also makes "Mod4" Appear as "Windows" and adds new combination "Alt-Windows" to the dropdown. - Attempt to set a pair of default snap modifiers (without knowing what it actually is for OSX) - Copy modifier now saves - Snap modifier modifier problem still remains. --- gtk2_ardour/editor_drag.cc | 21 ++++--- gtk2_ardour/keyboard.cc | 109 ++++++++++++++++++++++++++++++++ gtk2_ardour/keyboard.h | 40 ++++++++++++ gtk2_ardour/rc_option_editor.cc | 48 ++++++--------- libs/gtkmm2ext/gtkmm2ext/keyboard.h | 42 ------------- libs/gtkmm2ext/keyboard.cc | 120 ++++-------------------------------- 6 files changed, 190 insertions(+), 190 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index ca0a126e9d..a34c45545c 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -2352,7 +2352,7 @@ NoteResizeDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*ignored*/) _item->grab (); - if (event->motion.state & Keyboard::note_size_relative_modifier ()) { + if (event->motion.state & ArdourKeyboard::note_size_relative_modifier ()) { relative = false; } else { relative = true; @@ -2615,7 +2615,7 @@ TrimDrag::start_grab (GdkEvent* event, Gdk::Cursor*) framepos_t const pf = adjusted_current_frame (event); setup_snap_delta (region_start); - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::trim_contents_modifier ())) { + if (Keyboard::modifier_state_equals (event->button.state, ArdourKeyboard::trim_contents_modifier ())) { /* Move the contents of the region around without changing the region bounds */ _operation = ContentsTrim; Drag::start_grab (event, _editor->cursors()->trimmer); @@ -2624,7 +2624,7 @@ TrimDrag::start_grab (GdkEvent* event, Gdk::Cursor*) if (pf < (region_start + region_length/2)) { /* closer to front */ _operation = StartTrim; - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::trim_anchored_modifier ())) { + if (Keyboard::modifier_state_equals (event->button.state, ArdourKeyboard::trim_anchored_modifier ())) { Drag::start_grab (event, _editor->cursors()->anchored_left_side_trim); } else { Drag::start_grab (event, _editor->cursors()->left_side_trim); @@ -2632,17 +2632,18 @@ TrimDrag::start_grab (GdkEvent* event, Gdk::Cursor*) } else { /* closer to end */ _operation = EndTrim; - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::trim_anchored_modifier ())) { + if (Keyboard::modifier_state_equals (event->button.state, ArdourKeyboard::trim_anchored_modifier ())) { Drag::start_grab (event, _editor->cursors()->anchored_right_side_trim); } else { Drag::start_grab (event, _editor->cursors()->right_side_trim); } } } - + /* jump trim disabled for now if (Keyboard::modifier_state_equals (event->button.state, Keyboard::trim_jump_modifier ())) { _jump_position_when_done = true; } + */ switch (_operation) { case StartTrim: @@ -2725,7 +2726,7 @@ TrimDrag::motion (GdkEvent* event, bool first_move) bool non_overlap_trim = false; - if (event && Keyboard::modifier_state_equals (event->button.state, Keyboard::trim_overlap_modifier ())) { + if (event && Keyboard::modifier_state_equals (event->button.state, ArdourKeyboard::trim_overlap_modifier ())) { non_overlap_trim = true; } @@ -3735,7 +3736,7 @@ MarkerDrag::motion (GdkEvent* event, bool) framepos_t const newframe = adjusted_current_frame (event); framepos_t next = newframe; - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::push_points_modifier ())) { + if (Keyboard::modifier_state_equals (event->button.state, ArdourKeyboard::push_points_modifier ())) { move_both = true; } @@ -4002,7 +4003,7 @@ ControlPointDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*cursor*/) show_verbose_cursor_text (_point->line().get_verbose_cursor_string (fraction)); - _pushing = Keyboard::modifier_state_contains (event->button.state, Keyboard::push_points_modifier ()); + _pushing = Keyboard::modifier_state_contains (event->button.state, ArdourKeyboard::push_points_modifier ()); if (!_point->can_slide ()) { _x_constrained = true; @@ -4015,7 +4016,7 @@ ControlPointDrag::motion (GdkEvent* event, bool) double dx = _drags->current_pointer_x() - last_pointer_x(); double dy = current_pointer_y() - last_pointer_y(); - if (event->button.state & Keyboard::fine_adjust_modifier ()) { + if (event->button.state & ArdourKeyboard::fine_adjust_modifier ()) { dx *= 0.1; dy *= 0.1; } @@ -4154,7 +4155,7 @@ LineDrag::motion (GdkEvent* event, bool) { double dy = current_pointer_y() - last_pointer_y(); - if (event->button.state & Keyboard::fine_adjust_modifier ()) { + if (event->button.state & ArdourKeyboard::fine_adjust_modifier ()) { dy *= 0.1; } diff --git a/gtk2_ardour/keyboard.cc b/gtk2_ardour/keyboard.cc index ca65a2b3f2..2eac66af88 100644 --- a/gtk2_ardour/keyboard.cc +++ b/gtk2_ardour/keyboard.cc @@ -48,6 +48,13 @@ accel_map_changed (GtkAccelMap* /*map*/, me->ui.setup_tooltips (); } +guint ArdourKeyboard::trim_contents_mod = Keyboard::PrimaryModifier; +guint ArdourKeyboard::trim_overlap_mod = Keyboard::TertiaryModifier; +guint ArdourKeyboard::trim_anchored_mod = Keyboard::TertiaryModifier; +guint ArdourKeyboard::fine_adjust_mod = Keyboard::SecondaryModifier; +guint ArdourKeyboard::push_points_mod = Keyboard::PrimaryModifier; +guint ArdourKeyboard::note_size_relative_mod = Keyboard::PrimaryModifier; + void ArdourKeyboard::setup_keybindings () { @@ -174,6 +181,108 @@ ArdourKeyboard::setup_keybindings () g_signal_connect (accelmap, "changed", (GCallback) accel_map_changed, this); } +XMLNode& +ArdourKeyboard::get_state (void) +{ + XMLNode* node = &Keyboard::get_state (); + char buf[32]; + + snprintf (buf, sizeof (buf), "%d", trim_contents_mod); + node->add_property ("trim-contents-modifier", buf); + snprintf (buf, sizeof (buf), "%d", trim_overlap_mod); + node->add_property ("trim-overlap-modifier", buf); + snprintf (buf, sizeof (buf), "%d", trim_anchored_mod); + node->add_property ("trim-anchored-modifier", buf); + snprintf (buf, sizeof (buf), "%d", fine_adjust_mod); + node->add_property ("fine-adjust-modifier", buf); + snprintf (buf, sizeof (buf), "%d", push_points_mod); + node->add_property ("push-points-modifier", buf); + snprintf (buf, sizeof (buf), "%d", note_size_relative_mod); + node->add_property ("note-size-relative-modifier", buf); + + return *node; +} + +int +ArdourKeyboard::set_state (const XMLNode& node, int version) +{ + const XMLProperty* prop; + + if ((prop = node.property ("trim-contents-modifier")) != 0) { + sscanf (prop->value().c_str(), "%d", &trim_contents_mod); + } + + if ((prop = node.property ("trim-overlap-modifier")) != 0) { + sscanf (prop->value().c_str(), "%d", &trim_overlap_mod); + } + + if ((prop = node.property ("trim-anchored-modifier")) != 0) { + sscanf (prop->value().c_str(), "%d", &trim_anchored_mod); + } + + if ((prop = node.property ("fine-adjust-modifier")) != 0) { + sscanf (prop->value().c_str(), "%d", &fine_adjust_mod); + } + + if ((prop = node.property ("push-points-modifier")) != 0) { + sscanf (prop->value().c_str(), "%d", &push_points_mod); + } + + if ((prop = node.property ("note-size-relative-modifier")) != 0) { + sscanf (prop->value().c_str(), "%d", ¬e_size_relative_mod); + } + + return Keyboard::set_state (node, version); +} + +void +ArdourKeyboard::set_trim_contents_modifier (guint mod) +{ + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask & ~trim_contents_mod); + trim_contents_mod = mod; + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | trim_contents_mod); +} + +void +ArdourKeyboard::set_trim_overlap_modifier (guint mod) +{ + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask & ~trim_overlap_mod); + trim_overlap_mod = mod; + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | trim_overlap_mod); +} + +void +ArdourKeyboard::set_trim_anchored_modifier (guint mod) +{ + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask & ~trim_anchored_mod); + trim_anchored_mod = mod; + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | trim_anchored_mod); +} + +void +ArdourKeyboard::set_fine_adjust_modifier (guint mod) +{ + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask & ~fine_adjust_mod); + fine_adjust_mod = mod; + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | fine_adjust_mod); +} + +void +ArdourKeyboard::set_push_points_modifier (guint mod) +{ + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask & ~push_points_mod); + push_points_mod = mod; + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | push_points_mod); +} + +void +ArdourKeyboard::set_note_size_relative_modifier (guint mod) +{ + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask & ~note_size_relative_mod); + note_size_relative_mod = mod; + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | note_size_relative_mod); +} + Selection::Operation ArdourKeyboard::selection_type (guint state) { diff --git a/gtk2_ardour/keyboard.h b/gtk2_ardour/keyboard.h index 6a689567e5..95e40f6e3e 100644 --- a/gtk2_ardour/keyboard.h +++ b/gtk2_ardour/keyboard.h @@ -32,11 +32,51 @@ class ArdourKeyboard : public Gtkmm2ext::Keyboard public: ArdourKeyboard(ARDOUR_UI& ardour_ui) : ui(ardour_ui) {} + XMLNode& get_state (void); + int set_state (const XMLNode&, int version); + void setup_keybindings (); static Selection::Operation selection_type (guint state); ARDOUR_UI& ui; + + static void set_trim_contents_modifier (guint); + /** @return Modifier mask to move contents rather than region bounds during trim; + */ + static ModifierMask trim_contents_modifier () { return ModifierMask (trim_contents_mod); } + + static void set_trim_overlap_modifier (guint); + /** @return Modifier mask to remove region overlaps during trim; + */ + static ModifierMask trim_overlap_modifier () { return ModifierMask (trim_overlap_mod); } + + static void set_trim_anchored_modifier (guint); + /** @return Modifier mask to use anchored trim; + */ + static ModifierMask trim_anchored_modifier () { return ModifierMask (trim_anchored_mod); } + + static void set_fine_adjust_modifier (guint); + /** @return Modifier mask to fine adjust (control points only atm); + */ + static ModifierMask fine_adjust_modifier () { return ModifierMask (fine_adjust_mod); } + + static void set_push_points_modifier (guint); + /** @return Modifier mask to push proceeding points; + */ + static ModifierMask push_points_modifier () { return ModifierMask (push_points_mod); } + + static void set_note_size_relative_modifier (guint); + /** @return Modifier mask to resize notes relatively; + */ + static ModifierMask note_size_relative_modifier () { return ModifierMask (note_size_relative_mod); } +private: + static guint trim_contents_mod; + static guint trim_overlap_mod; + static guint trim_anchored_mod; + static guint fine_adjust_mod; + static guint push_points_mod; + static guint note_size_relative_mod; }; #endif /* __ardour_keyboard_h__ */ diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc index 4fefcfada1..65589abf9e 100644 --- a/gtk2_ardour/rc_option_editor.cc +++ b/gtk2_ardour/rc_option_editor.cc @@ -277,14 +277,15 @@ static const struct { #else { "Key|Shift", GDK_SHIFT_MASK }, { "Control", GDK_CONTROL_MASK }, - { "Alt (Mod1)", GDK_MOD1_MASK }, + { "Alt", GDK_MOD1_MASK }, { "Control-Shift", GDK_CONTROL_MASK|GDK_SHIFT_MASK }, { "Control-Alt", GDK_CONTROL_MASK|GDK_MOD1_MASK }, { "Shift-Alt", GDK_SHIFT_MASK|GDK_MOD1_MASK }, { "Control-Shift-Alt", GDK_CONTROL_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK }, + { "Alt-Windows", GDK_MOD1_MASK|GDK_MOD4_MASK }, { "Mod2", GDK_MOD2_MASK }, { "Mod3", GDK_MOD3_MASK }, - { "Mod4", GDK_MOD4_MASK }, + { "Windows", GDK_MOD4_MASK }, { "Mod5", GDK_MOD5_MASK }, #endif { 0, 0 } @@ -465,7 +466,7 @@ public: _trim_contents_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::trim_contents_modifier_chosen)); for (int x = 0; modifiers[x].name; ++x) { - if (modifiers[x].modifier == (guint) Keyboard::trim_contents_modifier ()) { + if (modifiers[x].modifier == (guint) ArdourKeyboard::trim_contents_modifier ()) { _trim_contents_combo.set_active_text (S_(modifiers[x].name)); break; } @@ -485,7 +486,7 @@ public: _trim_anchored_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::trim_anchored_modifier_chosen)); for (int x = 0; modifiers[x].name; ++x) { - if (modifiers[x].modifier == (guint) Keyboard::trim_anchored_modifier ()) { + if (modifiers[x].modifier == (guint) ArdourKeyboard::trim_anchored_modifier ()) { _trim_anchored_combo.set_active_text (S_(modifiers[x].name)); break; } @@ -499,9 +500,9 @@ public: t->attach (_trim_anchored_combo, col, col + 1, row, row + 1, FILL | EXPAND, FILL); ++row; - col = 1; + col = 1; - /* jump trim */ + /* jump trim disabled for now set_popdown_strings (_trim_jump_combo, dumb); _trim_jump_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::trim_jump_modifier_chosen)); @@ -521,13 +522,14 @@ public: ++row; col = 1; + */ /* note resize relative */ set_popdown_strings (_note_size_relative_combo, dumb); _note_size_relative_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::note_size_relative_modifier_chosen)); for (int x = 0; modifiers[x].name; ++x) { - if (modifiers[x].modifier == (guint) Keyboard::note_size_relative_modifier ()) { + if (modifiers[x].modifier == (guint) ArdourKeyboard::note_size_relative_modifier ()) { _note_size_relative_combo.set_active_text (S_(modifiers[x].name)); break; } @@ -600,7 +602,7 @@ public: _trim_overlap_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::trim_overlap_modifier_chosen)); for (int x = 0; modifiers[x].name; ++x) { - if (modifiers[x].modifier == (guint) Keyboard::trim_overlap_modifier ()) { + if (modifiers[x].modifier == (guint) ArdourKeyboard::trim_overlap_modifier ()) { _trim_overlap_combo.set_active_text (S_(modifiers[x].name)); break; } @@ -626,7 +628,7 @@ public: _fine_adjust_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::fine_adjust_modifier_chosen)); for (int x = 0; modifiers[x].name; ++x) { - if (modifiers[x].modifier == (guint) Keyboard::fine_adjust_modifier ()) { + if (modifiers[x].modifier == (guint) ArdourKeyboard::fine_adjust_modifier ()) { _fine_adjust_combo.set_active_text (S_(modifiers[x].name)); break; } @@ -646,7 +648,7 @@ public: _push_points_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::push_points_modifier_chosen)); for (int x = 0; modifiers[x].name; ++x) { - if (modifiers[x].modifier == (guint) Keyboard::push_points_modifier ()) { + if (modifiers[x].modifier == (guint) ArdourKeyboard::push_points_modifier ()) { _push_points_combo.set_active_text (S_(modifiers[x].name)); break; } @@ -658,8 +660,6 @@ public: t->attach (*l, col, col + 1, row, row + 1, FILL | EXPAND, FILL); t->attach (_push_points_combo, col + 1, col + 2, row, row + 1, FILL | EXPAND, FILL); - ++row; - _box->pack_start (*t, false, false); } @@ -768,7 +768,7 @@ private: for (int i = 0; modifiers[i].name; ++i) { if (txt == _(modifiers[i].name)) { - Keyboard::set_trim_contents_modifier (modifiers[i].modifier); + ArdourKeyboard::set_trim_contents_modifier (modifiers[i].modifier); break; } } @@ -780,7 +780,7 @@ private: for (int i = 0; modifiers[i].name; ++i) { if (txt == _(modifiers[i].name)) { - Keyboard::set_trim_overlap_modifier (modifiers[i].modifier); + ArdourKeyboard::set_trim_overlap_modifier (modifiers[i].modifier); break; } } @@ -792,19 +792,7 @@ private: for (int i = 0; modifiers[i].name; ++i) { if (txt == _(modifiers[i].name)) { - Keyboard::set_trim_anchored_modifier (modifiers[i].modifier); - break; - } - } - } - - void trim_jump_modifier_chosen () - { - string const txt = _trim_jump_combo.get_active_text(); - - for (int i = 0; modifiers[i].name; ++i) { - if (txt == _(modifiers[i].name)) { - Keyboard::set_trim_jump_modifier (modifiers[i].modifier); + ArdourKeyboard::set_trim_anchored_modifier (modifiers[i].modifier); break; } } @@ -816,7 +804,7 @@ private: for (int i = 0; modifiers[i].name; ++i) { if (txt == _(modifiers[i].name)) { - Keyboard::set_fine_adjust_modifier (modifiers[i].modifier); + ArdourKeyboard::set_fine_adjust_modifier (modifiers[i].modifier); break; } } @@ -828,7 +816,7 @@ private: for (int i = 0; modifiers[i].name; ++i) { if (txt == _(modifiers[i].name)) { - Keyboard::set_push_points_modifier (modifiers[i].modifier); + ArdourKeyboard::set_push_points_modifier (modifiers[i].modifier); break; } } @@ -840,7 +828,7 @@ private: for (int i = 0; modifiers[i].name; ++i) { if (txt == _(modifiers[i].name)) { - Keyboard::set_note_size_relative_modifier (modifiers[i].modifier); + ArdourKeyboard::set_note_size_relative_modifier (modifiers[i].modifier); break; } } diff --git a/libs/gtkmm2ext/gtkmm2ext/keyboard.h b/libs/gtkmm2ext/gtkmm2ext/keyboard.h index a10a6dbb3e..25c5154024 100644 --- a/libs/gtkmm2ext/gtkmm2ext/keyboard.h +++ b/libs/gtkmm2ext/gtkmm2ext/keyboard.h @@ -126,41 +126,6 @@ class LIBGTKMM2EXT_API Keyboard : public sigc::trackable, PBD::Stateful */ static ModifierMask snap_delta_modifier () { return ModifierMask (snap_delta_mod); } - static void set_trim_contents_modifier (guint); - /** @return Modifier mask to move contents rather than region bounds during trim; - */ - static ModifierMask trim_contents_modifier () { return ModifierMask (trim_contents_mod); } - - static void set_trim_overlap_modifier (guint); - /** @return Modifier mask to remove region overlaps during trim; - */ - static ModifierMask trim_overlap_modifier () { return ModifierMask (trim_overlap_mod); } - - static void set_trim_anchored_modifier (guint); - /** @return Modifier mask to use anchored trim; - */ - static ModifierMask trim_anchored_modifier () { return ModifierMask (trim_anchored_mod); } - - static void set_fine_adjust_modifier (guint); - /** @return Modifier mask to fine adjust (control points only atm); - */ - static ModifierMask fine_adjust_modifier () { return ModifierMask (fine_adjust_mod); } - - static void set_push_points_modifier (guint); - /** @return Modifier mask to push proceeding points; - */ - static ModifierMask push_points_modifier () { return ModifierMask (push_points_mod); } - - static void set_note_size_relative_modifier (guint); - /** @return Modifier mask to resize notes relatively; - */ - static ModifierMask note_size_relative_modifier () { return ModifierMask (note_size_relative_mod); } - - static void set_trim_jump_modifier (guint); - /** @return Modifier mask to jump position after trim; - */ - static ModifierMask trim_jump_modifier () { return ModifierMask (trim_jump_mod); } - static guint edit_button() { return edit_but; } static void set_edit_button (guint); static guint edit_modifier() { return edit_mod; } @@ -226,13 +191,6 @@ class LIBGTKMM2EXT_API Keyboard : public sigc::trackable, PBD::Stateful static guint insert_note_mod; static guint snap_mod; static guint snap_delta_mod; - static guint trim_contents_mod; - static guint trim_overlap_mod; - static guint trim_anchored_mod; - static guint fine_adjust_mod; - static guint push_points_mod; - static guint note_size_relative_mod; - static guint trim_jump_mod; static guint button2_modifiers; static Gtk::Window* current_window; static std::string user_keybindings_path; diff --git a/libs/gtkmm2ext/keyboard.cc b/libs/gtkmm2ext/keyboard.cc index 17e41a4b85..954887e3be 100644 --- a/libs/gtkmm2ext/keyboard.cc +++ b/libs/gtkmm2ext/keyboard.cc @@ -58,8 +58,6 @@ guint Keyboard::delete_but = 3; guint Keyboard::delete_mod = GDK_SHIFT_MASK; guint Keyboard::insert_note_but = 1; guint Keyboard::insert_note_mod = GDK_CONTROL_MASK; -guint Keyboard::snap_mod = GDK_MOD3_MASK; -guint Keyboard::snap_delta_mod = 0; #ifdef GTKOSX @@ -78,6 +76,9 @@ const char* Keyboard::level4_modifier_name() { return _("Option"); } const char* Keyboard::copy_modifier_name() { return _("Control"); } const char* Keyboard::rangeselect_modifier_name() { return S_("Key|Shift"); } +guint Keyboard::snap_mod = GDK_MOD3_MASK|Keyboard::Level4Modifier; // XXX this is probably completely wrong +guint Keyboard::snap_delta_mod = GDK_MOD3_MASK; + #else guint Keyboard::PrimaryModifier = GDK_CONTROL_MASK; // Control @@ -95,6 +96,9 @@ const char* Keyboard::level4_modifier_name() { return _("Meta"); } const char* Keyboard::copy_modifier_name() { return _("Control"); } const char* Keyboard::rangeselect_modifier_name() { return S_("Key|Shift"); } +guint Keyboard::snap_mod = Keyboard::SecondaryModifier|Keyboard::Level4Modifier; +guint Keyboard::snap_delta_mod = Keyboard::SecondaryModifier; + #endif guint Keyboard::GainFineScaleModifier = Keyboard::PrimaryModifier; @@ -104,14 +108,6 @@ guint Keyboard::ScrollZoomVerticalModifier = Keyboard::SecondaryModifier; guint Keyboard::ScrollZoomHorizontalModifier = Keyboard::PrimaryModifier; guint Keyboard::ScrollHorizontalModifier = Keyboard::TertiaryModifier; -guint Keyboard::trim_contents_mod = Keyboard::PrimaryModifier; -guint Keyboard::trim_overlap_mod = Keyboard::TertiaryModifier; -guint Keyboard::trim_anchored_mod = Keyboard::TertiaryModifier; -guint Keyboard::trim_jump_mod = Keyboard::TertiaryModifier; -guint Keyboard::fine_adjust_mod = Keyboard::SecondaryModifier; -guint Keyboard::push_points_mod = Keyboard::PrimaryModifier; -guint Keyboard::note_size_relative_mod = Keyboard::PrimaryModifier; - Keyboard* Keyboard::_the_keyboard = 0; Gtk::Window* Keyboard::current_window = 0; bool Keyboard::_some_magic_widget_has_focus = false; @@ -177,6 +173,8 @@ Keyboard::get_state (void) XMLNode* node = new XMLNode ("Keyboard"); char buf[32]; + snprintf (buf, sizeof (buf), "%d", CopyModifier); + node->add_property ("copy-modifier", buf); snprintf (buf, sizeof (buf), "%d", edit_but); node->add_property ("edit-button", buf); snprintf (buf, sizeof (buf), "%d", edit_mod); @@ -189,20 +187,6 @@ Keyboard::get_state (void) node->add_property ("snap-modifier", buf); snprintf (buf, sizeof (buf), "%d", snap_delta_mod); node->add_property ("snap-delta-modifier", buf); - snprintf (buf, sizeof (buf), "%d", trim_contents_mod); - node->add_property ("trim-contents-modifier", buf); - snprintf (buf, sizeof (buf), "%d", trim_overlap_mod); - node->add_property ("trim-overlap-modifier", buf); - snprintf (buf, sizeof (buf), "%d", trim_anchored_mod); - node->add_property ("trim-anchored-modifier", buf); - snprintf (buf, sizeof (buf), "%d", trim_jump_mod); - node->add_property ("trim-jump-modifier", buf); - snprintf (buf, sizeof (buf), "%d", fine_adjust_mod); - node->add_property ("fine-adjust-modifier", buf); - snprintf (buf, sizeof (buf), "%d", push_points_mod); - node->add_property ("push-points-modifier", buf); - snprintf (buf, sizeof (buf), "%d", note_size_relative_mod); - node->add_property ("note-size-relative-modifier", buf); snprintf (buf, sizeof (buf), "%d", insert_note_but); node->add_property ("insert-note-button", buf); snprintf (buf, sizeof (buf), "%d", insert_note_mod); @@ -216,6 +200,10 @@ Keyboard::set_state (const XMLNode& node, int /*version*/) { const XMLProperty* prop; + if ((prop = node.property ("copy-modifier")) != 0) { + sscanf (prop->value().c_str(), "%d", &CopyModifier); + } + if ((prop = node.property ("edit-button")) != 0) { sscanf (prop->value().c_str(), "%d", &edit_but); } @@ -240,34 +228,6 @@ Keyboard::set_state (const XMLNode& node, int /*version*/) sscanf (prop->value().c_str(), "%d", &snap_delta_mod); } - if ((prop = node.property ("trim-contents-modifier")) != 0) { - sscanf (prop->value().c_str(), "%d", &trim_contents_mod); - } - - if ((prop = node.property ("trim-overlap-modifier")) != 0) { - sscanf (prop->value().c_str(), "%d", &trim_overlap_mod); - } - - if ((prop = node.property ("trim-anchored-modifier")) != 0) { - sscanf (prop->value().c_str(), "%d", &trim_anchored_mod); - } - - if ((prop = node.property ("trim-jump-modifier")) != 0) { - sscanf (prop->value().c_str(), "%d", &trim_jump_mod); - } - - if ((prop = node.property ("fine-adjust-modifier")) != 0) { - sscanf (prop->value().c_str(), "%d", &fine_adjust_mod); - } - - if ((prop = node.property ("push-points-modifier")) != 0) { - sscanf (prop->value().c_str(), "%d", &push_points_mod); - } - - if ((prop = node.property ("note-size-relative-modifier")) != 0) { - sscanf (prop->value().c_str(), "%d", ¬e_size_relative_mod); - } - if ((prop = node.property ("insert-note-button")) != 0) { sscanf (prop->value().c_str(), "%d", &insert_note_but); } @@ -530,62 +490,6 @@ Keyboard::set_snap_delta_modifier (guint mod) RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | snap_delta_mod); } -void -Keyboard::set_trim_contents_modifier (guint mod) -{ - RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask & ~trim_contents_mod); - trim_contents_mod = mod; - RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | trim_contents_mod); -} - -void -Keyboard::set_trim_overlap_modifier (guint mod) -{ - RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask & ~trim_overlap_mod); - trim_overlap_mod = mod; - RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | trim_overlap_mod); -} - -void -Keyboard::set_trim_anchored_modifier (guint mod) -{ - RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask & ~trim_anchored_mod); - trim_anchored_mod = mod; - RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | trim_anchored_mod); -} - -void -Keyboard::set_trim_jump_modifier (guint mod) -{ - RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask & ~trim_jump_mod); - trim_jump_mod = mod; - RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | trim_jump_mod); -} - -void -Keyboard::set_fine_adjust_modifier (guint mod) -{ - RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask & ~fine_adjust_mod); - fine_adjust_mod = mod; - RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | fine_adjust_mod); -} - -void -Keyboard::set_push_points_modifier (guint mod) -{ - RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask & ~push_points_mod); - push_points_mod = mod; - RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | push_points_mod); -} - -void -Keyboard::set_note_size_relative_modifier (guint mod) -{ - RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask & ~note_size_relative_mod); - note_size_relative_mod = mod; - RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | note_size_relative_mod); -} - bool Keyboard::is_edit_event (GdkEventButton *ev) { -- cgit v1.2.3 From 5d176eefa6706f11031f0b6c01179fe80cbbc6c1 Mon Sep 17 00:00:00 2001 From: nick_m Date: Thu, 21 May 2015 23:47:32 +1000 Subject: Make the prefs less squashed looking, add another entry for OSX modifiers. - Defaults are probably still wrong, but at least they are actual keys. --- gtk2_ardour/rc_option_editor.cc | 17 +++++++++-------- libs/gtkmm2ext/keyboard.cc | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc index 65589abf9e..406b0401f1 100644 --- a/gtk2_ardour/rc_option_editor.cc +++ b/gtk2_ardour/rc_option_editor.cc @@ -271,7 +271,8 @@ static const struct { { "Option", GDK_MOD1_MASK }, { "Command-Shift", GDK_META_MASK|GDK_SHIFT_MASK }, { "Command-Option", GDK_MOD1_MASK|GDK_META_MASK }, - { "Shift-Option", GDK_SHIFT_MASK|GDK_MOD1_MASK }, + { "Option-Shift", GDK_MOD1_MASK|GDK_SHIFT_MASK }, + { "Control-Shift", GDK_CONTROL_MASK|GDK_SHIFT_MASK }, { "Shift-Command-Option", GDK_MOD5_MASK|GDK_SHIFT_MASK|GDK_META_MASK }, #else @@ -347,7 +348,7 @@ public: l = manage (left_aligned_label (_("When Clicking:"))); l->set_name ("OptionEditorHeading"); - t->attach (*l, col, col + 1, row, row + 1, FILL | EXPAND, FILL); + t->attach (*l, col, col + 2, row, row + 1, FILL | EXPAND, FILL); ++row; col = 1; @@ -430,7 +431,7 @@ public: l = manage (left_aligned_label (_("When Beginning a Drag:"))); l->set_name ("OptionEditorHeading"); - t->attach (*l, 0, 1, row, row + 1, FILL | EXPAND, FILL); + t->attach (*l, 0, 2, row, row + 1, FILL | EXPAND, FILL); ++row; col = 1; @@ -456,7 +457,7 @@ public: l = manage (left_aligned_label (_("When Beginning a Trim:"))); l->set_name ("OptionEditorHeading"); - t->attach (*l, 0, 1, row, row + 1, FILL | EXPAND, FILL); + t->attach (*l, 0, 2, row, row + 1, FILL | EXPAND, FILL); ++row; col = 1; @@ -546,7 +547,7 @@ public: l = manage (left_aligned_label (_("While Dragging:"))); l->set_name ("OptionEditorHeading"); - t->attach (*l, 0, 1, row, row + 1, FILL | EXPAND, FILL); + t->attach (*l, 0, 2, row, row + 1, FILL | EXPAND, FILL); ++row; col = 1; @@ -562,7 +563,7 @@ public: } } - l = manage (left_aligned_label (_("Ignore snap using:"))); + l = manage (left_aligned_label (_("Ignore snap by including:"))); l->set_name ("OptionsLabel"); t->attach (*l, col, col + 1, row, row + 1, FILL | EXPAND, FILL); @@ -592,7 +593,7 @@ public: l = manage (left_aligned_label (_("While Trimming:"))); l->set_name ("OptionEditorHeading"); - t->attach (*l, 0, 1, row, row + 1, FILL | EXPAND, FILL); + t->attach (*l, 0, 2, row, row + 1, FILL | EXPAND, FILL); ++row; col = 1; @@ -618,7 +619,7 @@ public: l = manage (left_aligned_label (_("While Dragging Control Points:"))); l->set_name ("OptionEditorHeading"); - t->attach (*l, 0, 1, row, row + 1, FILL | EXPAND, FILL); + t->attach (*l, 0, 2, row, row + 1, FILL | EXPAND, FILL); ++row; col = 1; diff --git a/libs/gtkmm2ext/keyboard.cc b/libs/gtkmm2ext/keyboard.cc index 954887e3be..48bdaf0052 100644 --- a/libs/gtkmm2ext/keyboard.cc +++ b/libs/gtkmm2ext/keyboard.cc @@ -76,8 +76,8 @@ const char* Keyboard::level4_modifier_name() { return _("Option"); } const char* Keyboard::copy_modifier_name() { return _("Control"); } const char* Keyboard::rangeselect_modifier_name() { return S_("Key|Shift"); } -guint Keyboard::snap_mod = GDK_MOD3_MASK|Keyboard::Level4Modifier; // XXX this is probably completely wrong -guint Keyboard::snap_delta_mod = GDK_MOD3_MASK; +guint Keyboard::snap_mod = Keyboard::Level4Modifier|Keyboard::TertiaryModifier; // XXX this is probably completely wrong +guint Keyboard::snap_delta_mod = Keyboard::Level4Modifier; #else -- cgit v1.2.3 From eaf49f02ff92f22cbfa214ae89ec0a2fc3861d29 Mon Sep 17 00:00:00 2001 From: nick_m Date: Fri, 22 May 2015 02:12:58 +1000 Subject: Fix up modifier behaviour - its now possible to use snap modifiers in combination with others afaict this hasn't worked for some time. - use "contains" rather than "equals" during drag. Still uncertain about this wrt beginning a drag. for now they are all "equals". - probably solve the "snap modifier modifier" problem using ArdourKeyboard::indicates_snap () and friend. --- gtk2_ardour/editor.cc | 2 +- gtk2_ardour/editor_drag.cc | 16 ++++++++-------- gtk2_ardour/keyboard.cc | 24 ++++++++++++++++++++++-- gtk2_ardour/keyboard.h | 3 +++ gtk2_ardour/rc_option_editor.cc | 2 +- 5 files changed, 35 insertions(+), 12 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index ff9d480a35..05f9b0ca93 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -2597,7 +2597,7 @@ Editor::snap_to_with_modifier (framepos_t& start, GdkEvent const * event, RoundM return; } - if (Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) { + if (ArdourKeyboard::indicates_snap (event->button.state)) { if (_snap_mode == SnapOff) { snap_to_internal (start, direction, for_mark); } diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index a34c45545c..570ea1d31f 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -339,11 +339,11 @@ Drag::adjusted_current_frame (GdkEvent const * event, bool snap) const frameoffset_t Drag::snap_delta (GdkEvent const * event) const { - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::snap_delta_modifier())) { + if (ArdourKeyboard::indicates_snap_delta (event->button.state)) { return 0; - } else { - return _snap_delta; } + + return _snap_delta; } double @@ -2394,7 +2394,7 @@ NoteResizeDrag::motion (GdkEvent* event, bool /*first_move*/) MidiRegionView* mrv = dynamic_cast(*r); if (mrv) { double sd = 0.0; - if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::snap_delta_modifier())) { + if (!ArdourKeyboard::indicates_snap_delta (event->button.state)) { sd = _snap_delta; } mrv->update_resizing (nb, at_front, _drags->current_pointer_x() - grab_x(), relative, sd); @@ -2411,7 +2411,7 @@ NoteResizeDrag::finished (GdkEvent* event, bool /*movement_occurred*/) assert (nb); MidiRegionView* mrv = dynamic_cast(*r); double sd = 0.0; - if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::snap_delta_modifier())) { + if (!ArdourKeyboard::indicates_snap_delta (event->button.state)) { sd = _snap_delta; } if (mrv) { @@ -2726,7 +2726,7 @@ TrimDrag::motion (GdkEvent* event, bool first_move) bool non_overlap_trim = false; - if (event && Keyboard::modifier_state_equals (event->button.state, ArdourKeyboard::trim_overlap_modifier ())) { + if (event && Keyboard::modifier_state_contains (event->button.state, ArdourKeyboard::trim_overlap_modifier ())) { non_overlap_trim = true; } @@ -3736,7 +3736,7 @@ MarkerDrag::motion (GdkEvent* event, bool) framepos_t const newframe = adjusted_current_frame (event); framepos_t next = newframe; - if (Keyboard::modifier_state_equals (event->button.state, ArdourKeyboard::push_points_modifier ())) { + if (Keyboard::modifier_state_contains (event->button.state, ArdourKeyboard::push_points_modifier ())) { move_both = true; } @@ -4003,7 +4003,7 @@ ControlPointDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*cursor*/) show_verbose_cursor_text (_point->line().get_verbose_cursor_string (fraction)); - _pushing = Keyboard::modifier_state_contains (event->button.state, ArdourKeyboard::push_points_modifier ()); + _pushing = Keyboard::modifier_state_equals (event->button.state, ArdourKeyboard::push_points_modifier ()); if (!_point->can_slide ()) { _x_constrained = true; diff --git a/gtk2_ardour/keyboard.cc b/gtk2_ardour/keyboard.cc index 2eac66af88..72b9ff1ba4 100644 --- a/gtk2_ardour/keyboard.cc +++ b/gtk2_ardour/keyboard.cc @@ -235,6 +235,28 @@ ArdourKeyboard::set_state (const XMLNode& node, int version) return Keyboard::set_state (node, version); } +bool +ArdourKeyboard::indicates_snap (guint state) +{ + bool contains_s = Keyboard::modifier_state_contains (state, Keyboard::snap_modifier()); + bool equals_s = Keyboard::modifier_state_equals (state, Keyboard::snap_modifier()); + bool contains_d = Keyboard::modifier_state_contains (state, Keyboard::snap_delta_modifier()); + bool equals_d = Keyboard::modifier_state_equals (state, Keyboard::snap_delta_modifier()); + + return (equals_s || (contains_s && ((contains_d && !equals_d) || !contains_d))); +} + +bool +ArdourKeyboard::indicates_snap_delta (guint state) +{ + bool contains_d = Keyboard::modifier_state_contains (state, Keyboard::snap_delta_modifier()); + bool equals_d = Keyboard::modifier_state_equals (state, Keyboard::snap_delta_modifier()); + bool contains_s = Keyboard::modifier_state_contains (state, Keyboard::snap_modifier()); + bool equals_s = Keyboard::modifier_state_equals (state, Keyboard::snap_modifier()); + + return (equals_d || (contains_d && ((contains_s && !equals_s) || !contains_s))); +} + void ArdourKeyboard::set_trim_contents_modifier (guint mod) { @@ -296,5 +318,3 @@ ArdourKeyboard::selection_type (guint state) return Selection::Set; } } - - diff --git a/gtk2_ardour/keyboard.h b/gtk2_ardour/keyboard.h index 95e40f6e3e..8ed30efb72 100644 --- a/gtk2_ardour/keyboard.h +++ b/gtk2_ardour/keyboard.h @@ -41,6 +41,9 @@ class ArdourKeyboard : public Gtkmm2ext::Keyboard ARDOUR_UI& ui; + static bool indicates_snap (guint state); + static bool indicates_snap_delta (guint state); + static void set_trim_contents_modifier (guint); /** @return Modifier mask to move contents rather than region bounds during trim; */ diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc index 406b0401f1..a5f4b6e6f1 100644 --- a/gtk2_ardour/rc_option_editor.cc +++ b/gtk2_ardour/rc_option_editor.cc @@ -563,7 +563,7 @@ public: } } - l = manage (left_aligned_label (_("Ignore snap by including:"))); + l = manage (left_aligned_label (_("Ignore snap using:"))); l->set_name ("OptionsLabel"); t->attach (*l, col, col + 1, row, row + 1, FILL | EXPAND, FILL); -- cgit v1.2.3 From b7348bf4f5b36084b7f47c450db69919766e0ec0 Mon Sep 17 00:00:00 2001 From: nick_m Date: Fri, 22 May 2015 02:20:51 +1000 Subject: Fix excessive use of logic. --- gtk2_ardour/keyboard.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/keyboard.cc b/gtk2_ardour/keyboard.cc index 72b9ff1ba4..e656ede9db 100644 --- a/gtk2_ardour/keyboard.cc +++ b/gtk2_ardour/keyboard.cc @@ -239,22 +239,20 @@ bool ArdourKeyboard::indicates_snap (guint state) { bool contains_s = Keyboard::modifier_state_contains (state, Keyboard::snap_modifier()); - bool equals_s = Keyboard::modifier_state_equals (state, Keyboard::snap_modifier()); bool contains_d = Keyboard::modifier_state_contains (state, Keyboard::snap_delta_modifier()); bool equals_d = Keyboard::modifier_state_equals (state, Keyboard::snap_delta_modifier()); - return (equals_s || (contains_s && ((contains_d && !equals_d) || !contains_d))); + return (contains_s && ((contains_d && !equals_d) || !contains_d)); } bool ArdourKeyboard::indicates_snap_delta (guint state) { bool contains_d = Keyboard::modifier_state_contains (state, Keyboard::snap_delta_modifier()); - bool equals_d = Keyboard::modifier_state_equals (state, Keyboard::snap_delta_modifier()); bool contains_s = Keyboard::modifier_state_contains (state, Keyboard::snap_modifier()); bool equals_s = Keyboard::modifier_state_equals (state, Keyboard::snap_modifier()); - return (equals_d || (contains_d && ((contains_s && !equals_s) || !contains_s))); + return (contains_d && ((contains_s && !equals_s) || !contains_s)); } void -- cgit v1.2.3 From 224b85d03819449b827c81c9b44843b3e684a5d4 Mon Sep 17 00:00:00 2001 From: nick_m Date: Fri, 22 May 2015 02:31:25 +1000 Subject: Appease Our Dear Leader --- gtk2_ardour/keyboard.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/keyboard.cc b/gtk2_ardour/keyboard.cc index e656ede9db..8a7c811c3c 100644 --- a/gtk2_ardour/keyboard.cc +++ b/gtk2_ardour/keyboard.cc @@ -238,9 +238,9 @@ ArdourKeyboard::set_state (const XMLNode& node, int version) bool ArdourKeyboard::indicates_snap (guint state) { - bool contains_s = Keyboard::modifier_state_contains (state, Keyboard::snap_modifier()); - bool contains_d = Keyboard::modifier_state_contains (state, Keyboard::snap_delta_modifier()); - bool equals_d = Keyboard::modifier_state_equals (state, Keyboard::snap_delta_modifier()); + const bool contains_s = Keyboard::modifier_state_contains (state, Keyboard::snap_modifier()); + const bool contains_d = Keyboard::modifier_state_contains (state, Keyboard::snap_delta_modifier()); + const bool equals_d = Keyboard::modifier_state_equals (state, Keyboard::snap_delta_modifier()); return (contains_s && ((contains_d && !equals_d) || !contains_d)); } @@ -248,9 +248,9 @@ ArdourKeyboard::indicates_snap (guint state) bool ArdourKeyboard::indicates_snap_delta (guint state) { - bool contains_d = Keyboard::modifier_state_contains (state, Keyboard::snap_delta_modifier()); - bool contains_s = Keyboard::modifier_state_contains (state, Keyboard::snap_modifier()); - bool equals_s = Keyboard::modifier_state_equals (state, Keyboard::snap_modifier()); + const bool contains_d = Keyboard::modifier_state_contains (state, Keyboard::snap_delta_modifier()); + const bool contains_s = Keyboard::modifier_state_contains (state, Keyboard::snap_modifier()); + const bool equals_s = Keyboard::modifier_state_equals (state, Keyboard::snap_modifier()); return (contains_d && ((contains_s && !equals_s) || !contains_s)); } -- cgit v1.2.3 From 7edf0e17bc0d914937490f55381978434afa1943 Mon Sep 17 00:00:00 2001 From: nick_m Date: Fri, 22 May 2015 03:09:29 +1000 Subject: Clean up a bit - should be a no-op --- gtk2_ardour/editor_drag.cc | 48 +++++++++++++++++++++++----------------------- gtk2_ardour/editor_drag.h | 2 +- 2 files changed, 25 insertions(+), 25 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 570ea1d31f..18a3b5115b 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -337,9 +337,9 @@ Drag::adjusted_current_frame (GdkEvent const * event, bool snap) const } frameoffset_t -Drag::snap_delta (GdkEvent const * event) const +Drag::snap_delta (guint state) const { - if (ArdourKeyboard::indicates_snap_delta (event->button.state)) { + if (ArdourKeyboard::indicates_snap_delta (state)) { return 0; } @@ -612,7 +612,7 @@ RegionMotionDrag::compute_x_delta (GdkEvent const * event, framepos_t* pending_r /* compute the amount of pointer motion in frames, and where the region would be if we moved it by that much. */ - *pending_region_position = adjusted_frame (_drags->current_pointer_frame () + snap_delta (event), event, true); + *pending_region_position = adjusted_frame (_drags->current_pointer_frame () + snap_delta (event->button.state), event, true); framepos_t sync_frame; framecnt_t sync_offset; @@ -628,7 +628,7 @@ RegionMotionDrag::compute_x_delta (GdkEvent const * event, framepos_t* pending_r _editor->snap_to_with_modifier (sync_frame, event); - *pending_region_position = _primary->region()->adjust_to_sync (sync_frame) - snap_delta (event); + *pending_region_position = _primary->region()->adjust_to_sync (sync_frame) - snap_delta (event->button.state); } else { *pending_region_position = _last_frame_position; @@ -2679,8 +2679,8 @@ TrimDrag::motion (GdkEvent* event, bool first_move) if (tv && tv->is_track()) { speed = tv->track()->speed(); } - framecnt_t adj_frame = adjusted_frame (_drags->current_pointer_frame () + snap_delta (event), event, true); - framecnt_t dt = adj_frame - raw_grab_frame () + _pointer_frame_offset - snap_delta (event); + framecnt_t adj_frame = adjusted_frame (_drags->current_pointer_frame () + snap_delta (event->button.state), event, true); + framecnt_t dt = adj_frame - raw_grab_frame () + _pointer_frame_offset - snap_delta (event->button.state); if (first_move) { @@ -3267,7 +3267,7 @@ CursorDrag::start_grab (GdkEvent* event, Gdk::Cursor* c) _grab_zoom = _editor->samples_per_pixel; - framepos_t where = _editor->canvas_event_sample (event) + snap_delta (event); + framepos_t where = _editor->canvas_event_sample (event) + snap_delta (event->button.state); _editor->snap_to_with_modifier (where, event); @@ -3305,16 +3305,16 @@ CursorDrag::start_grab (GdkEvent* event, Gdk::Cursor* c) } } - fake_locate (where - snap_delta (event)); + fake_locate (where - snap_delta (event->button.state)); } void CursorDrag::motion (GdkEvent* event, bool) { - framepos_t where = _editor->canvas_event_sample (event) + snap_delta (event); + framepos_t where = _editor->canvas_event_sample (event) + snap_delta (event->button.state); _editor->snap_to_with_modifier (where, event); if (where != last_pointer_frame()) { - fake_locate (where - snap_delta (event)); + fake_locate (where - snap_delta (event->button.state)); } } @@ -3383,9 +3383,9 @@ FadeInDrag::motion (GdkEvent* event, bool) { framecnt_t fade_length; - framepos_t pos = _editor->canvas_event_sample (event) + snap_delta (event); + framepos_t pos = _editor->canvas_event_sample (event) + snap_delta (event->button.state); _editor->snap_to_with_modifier (pos, event); - pos -= snap_delta (event); + pos -= snap_delta (event->button.state); boost::shared_ptr region = boost::dynamic_pointer_cast (_primary->region ()); @@ -3419,9 +3419,9 @@ FadeInDrag::finished (GdkEvent* event, bool movement_occurred) } framecnt_t fade_length; - framepos_t pos = _editor->canvas_event_sample (event) + snap_delta (event); + framepos_t pos = _editor->canvas_event_sample (event) + snap_delta (event->button.state); _editor->snap_to_with_modifier (pos, event); - pos -= snap_delta (event); + pos -= snap_delta (event->button.state); boost::shared_ptr region = boost::dynamic_pointer_cast (_primary->region ()); @@ -3501,9 +3501,9 @@ FadeOutDrag::motion (GdkEvent* event, bool) { framecnt_t fade_length; - framepos_t pos = _editor->canvas_event_sample (event) + snap_delta (event); + framepos_t pos = _editor->canvas_event_sample (event) + snap_delta (event->button.state); _editor->snap_to_with_modifier (pos, event); - pos -= snap_delta (event); + pos -= snap_delta (event->button.state); boost::shared_ptr region = boost::dynamic_pointer_cast (_primary->region ()); @@ -3538,9 +3538,9 @@ FadeOutDrag::finished (GdkEvent* event, bool movement_occurred) framecnt_t fade_length; - framepos_t pos = _editor->canvas_event_sample (event) + snap_delta (event); + framepos_t pos = _editor->canvas_event_sample (event) + snap_delta (event->button.state); _editor->snap_to_with_modifier (pos, event); - pos -= snap_delta (event); + pos -= snap_delta (event->button.state); boost::shared_ptr region = boost::dynamic_pointer_cast (_primary->region ()); @@ -4049,13 +4049,13 @@ ControlPointDrag::motion (GdkEvent* event, bool) cy = max (0.0, cy); cy = min ((double) _point->line().height(), cy); - framepos_t cx_frames = _editor->pixel_to_sample (cx) + snap_delta (event); + framepos_t cx_frames = _editor->pixel_to_sample (cx) + snap_delta (event->button.state); if (!_x_constrained) { _editor->snap_to_with_modifier (cx_frames, event); } - cx_frames -= snap_delta (event); + cx_frames -= snap_delta (event->button.state); cx_frames = min (cx_frames, _point->line().maximum_time()); float const fraction = 1.0 - (cy / _point->line().height()); @@ -4481,9 +4481,9 @@ TimeFXDrag::motion (GdkEvent* event, bool) pair const tv = _editor->trackview_by_y_position (grab_y()); int layer = tv.first->layer_display() == Overlaid ? 0 : tv.second; int layers = tv.first->layer_display() == Overlaid ? 1 : cv->layers(); - framepos_t pf = _editor->canvas_event_sample (event) + snap_delta (event); + framepos_t pf = _editor->canvas_event_sample (event) + snap_delta (event->button.state); _editor->snap_to_with_modifier (pf, event); - pf -= snap_delta (event); + pf -= snap_delta (event->button.state); if (pf > rv->region()->position()) { rv->get_time_axis_view().show_timestretch (rv->region()->position(), pf, layers, layer); @@ -5205,7 +5205,7 @@ NoteDrag::total_dx (GdkEvent const * event) const frameoffset_t const n = _region->source_beats_to_absolute_frames (_primary->note()->time ()); /* new time of the primary note in session frames */ - frameoffset_t st = n + dx + snap_delta (event); + frameoffset_t st = n + dx + snap_delta (event->button.state); framepos_t const rp = _region->region()->position (); @@ -5213,7 +5213,7 @@ NoteDrag::total_dx (GdkEvent const * event) const st = max (st, rp); /* snap and return corresponding delta */ - return _region->snap_frame_to_frame (st - rp) + rp - n - snap_delta (event); + return _region->snap_frame_to_frame (st - rp) + rp - n - snap_delta (event->button.state); } /** @return Current total drag y change in note number */ diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index 2197f5601e..b11b1c26a1 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -217,7 +217,7 @@ protected: return _last_pointer_frame; } - ARDOUR::frameoffset_t snap_delta (GdkEvent const *) const; + ARDOUR::frameoffset_t snap_delta (guint const) const; double current_pointer_x () const; double current_pointer_y () const; -- cgit v1.2.3 From 65e06fa35090dc4e1f84419b57316932c21a9682 Mon Sep 17 00:00:00 2001 From: nick_m Date: Fri, 22 May 2015 04:26:16 +1000 Subject: More cleanup - remove "no_magnets" ugh. --- gtk2_ardour/editor.cc | 18 ++++-------------- gtk2_ardour/editor.h | 9 +++------ gtk2_ardour/editor_drag.cc | 4 ++-- gtk2_ardour/midi_region_view.cc | 27 ++++----------------------- gtk2_ardour/midi_region_view.h | 18 ++++-------------- gtk2_ardour/public_editor.h | 7 ++----- gtk2_ardour/region_view.cc | 32 +++----------------------------- gtk2_ardour/region_view.h | 3 +-- 8 files changed, 23 insertions(+), 95 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 05f9b0ca93..45c7ca94b0 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -2609,23 +2609,13 @@ Editor::snap_to_with_modifier (framepos_t& start, GdkEvent const * event, RoundM } void -Editor::snap_to (framepos_t& start, RoundMode direction, bool for_mark) +Editor::snap_to (framepos_t& start, RoundMode direction, bool for_mark, bool explicitly) { if (!_session || _snap_mode == SnapOff) { return; } - snap_to_internal (start, direction, for_mark); -} - -void -Editor::snap_to_no_magnets (framepos_t& start, RoundMode direction, bool for_mark) -{ - if (!_session || _snap_mode == SnapOff) { - return; - } - - snap_to_internal (start, direction, for_mark, true); + snap_to_internal (start, direction, for_mark, explicitly); } void @@ -2695,7 +2685,7 @@ Editor::timecode_snap_to_internal (framepos_t& start, RoundMode direction, bool } void -Editor::snap_to_internal (framepos_t& start, RoundMode direction, bool for_mark, bool no_magnets) +Editor::snap_to_internal (framepos_t& start, RoundMode direction, bool for_mark, bool explicitly) { const framepos_t one_second = _session->frame_rate(); const framepos_t one_minute = _session->frame_rate() * 60; @@ -2865,7 +2855,7 @@ Editor::snap_to_internal (framepos_t& start, RoundMode direction, bool for_mark, case SnapMagnetic: - if (no_magnets) { + if (explicitly) { return; } diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 8362b00551..663a97a56d 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -436,11 +436,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void snap_to (framepos_t& first, ARDOUR::RoundMode direction = ARDOUR::RoundNearest, - bool for_mark = false); - - void snap_to_no_magnets (framepos_t& first, - ARDOUR::RoundMode direction = ARDOUR::RoundNearest, - bool for_mark = false); + bool for_mark = false, + bool explicitly = false); void snap_to_with_modifier (framepos_t& first, GdkEvent const * ev, @@ -2136,7 +2133,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void snap_to_internal (framepos_t& first, ARDOUR::RoundMode direction = ARDOUR::RoundNearest, bool for_mark = false, - bool no_magnets = false); + bool explicitly = false); void timecode_snap_to_internal (framepos_t& first, ARDOUR::RoundMode direction = ARDOUR::RoundNearest, diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 18a3b5115b..3f08a8c750 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -366,7 +366,7 @@ void Drag::setup_snap_delta (framepos_t pos) { framepos_t temp = pos; - _editor->snap_to_no_magnets (temp); + _editor->snap_to (temp, ARDOUR::RoundNearest, false, true); _snap_delta = temp - pos; } @@ -2347,7 +2347,7 @@ NoteResizeDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*ignored*/) region = &cnote->region_view(); double temp; - temp = region->snap_to_pixel_no_magnets (cnote->x0 ()); + temp = region->snap_to_pixel (cnote->x0 (), true); _snap_delta = temp - cnote->x0 (); _item->grab (); diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index be280001d2..2fa8f4a3cd 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -2627,38 +2627,19 @@ MidiRegionView::note_dropped(NoteBase *, frameoffset_t dt, int8_t dnote) * @return Snapped frame relative to the region position. */ framepos_t -MidiRegionView::snap_pixel_to_sample(double x) +MidiRegionView::snap_pixel_to_sample(double x, bool explicitly) { PublicEditor& editor (trackview.editor()); - return snap_frame_to_frame (editor.pixel_to_sample (x)); -} - -/** @param x Pixel relative to the region position explicitly (no magnetic snap) - * @return Snapped frame relative to the region position. - */ -framepos_t -MidiRegionView::snap_pixel_to_sample_no_magnets (double x) -{ - PublicEditor& editor (trackview.editor()); - return snap_frame_to_frame_no_magnets (editor.pixel_to_sample (x)); + return snap_frame_to_frame (editor.pixel_to_sample (x), explicitly); } /** @param x Pixel relative to the region position. * @return Snapped pixel relative to the region position. */ double -MidiRegionView::snap_to_pixel(double x) -{ - return (double) trackview.editor().sample_to_pixel(snap_pixel_to_sample(x)); -} - -/** @param x Pixel relative to the region position. - * @return Explicitly snapped pixel relative to the region position (no magnetic snap). - */ -double -MidiRegionView::snap_to_pixel_no_magnets (double x) +MidiRegionView::snap_to_pixel(double x, bool explicitly) { - return (double) trackview.editor().sample_to_pixel(snap_pixel_to_sample_no_magnets(x)); + return (double) trackview.editor().sample_to_pixel(snap_pixel_to_sample(x, explicitly)); } double diff --git a/gtk2_ardour/midi_region_view.h b/gtk2_ardour/midi_region_view.h index 7329c6facc..37a66aa398 100644 --- a/gtk2_ardour/midi_region_view.h +++ b/gtk2_ardour/midi_region_view.h @@ -250,27 +250,17 @@ public: /** Snap a region relative pixel coordinate to pixel units. * @param x a pixel coordinate relative to region start + * @param explicitly do not use magnetic snap (required for snap delta calculation) * @return the snapped pixel coordinate relative to region start */ - double snap_to_pixel(double x); - - /** Snap a region relative pixel coordinate to pixel units explicitly (no magnetic snap). - * @param x a pixel coordinate relative to region start - * @return the explicitly snapped pixel coordinate relative to region start - */ - double snap_to_pixel_no_magnets (double x); + double snap_to_pixel(double x, bool explicitly = false); /** Snap a region relative pixel coordinate to frame units. * @param x a pixel coordinate relative to region start + * @param explicitly do not use magnetic snap (required for snap delta calculation) * @return the snapped framepos_t coordinate relative to region start */ - framepos_t snap_pixel_to_sample(double x); - - /** Explicitly snap a region relative pixel coordinate to frame units (no magnetic snap). - * @param x a pixel coordinate relative to region start - * @return the explicitly snapped framepos_t coordinate relative to region start - */ - framepos_t snap_pixel_to_sample_no_magnets (double x); + framepos_t snap_pixel_to_sample(double x, bool explicitly = false); /** Convert a timestamp in beats into frames (both relative to region position) */ framepos_t region_beats_to_region_frames(Evoral::Beats beats) const; diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index a89993a479..463d7614d2 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -144,11 +144,8 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible, publi /** Snap a value according to the current snap setting. */ virtual void snap_to (framepos_t& first, ARDOUR::RoundMode direction = ARDOUR::RoundNearest, - bool for_mark = false) = 0; - /** Snap a value according to the current snap setting. */ - virtual void snap_to_no_magnets (framepos_t& first, - ARDOUR::RoundMode direction = ARDOUR::RoundNearest, - bool for_mark = false) = 0; + bool for_mark = false, + bool explicitly = false) = 0; /** Undo some transactions. * @param n Number of transactions to undo. diff --git a/gtk2_ardour/region_view.cc b/gtk2_ardour/region_view.cc index cd83154a9f..5a8e3f235b 100644 --- a/gtk2_ardour/region_view.cc +++ b/gtk2_ardour/region_view.cc @@ -942,7 +942,7 @@ RegionView::move_contents (frameoffset_t distance) * @return Snapped frame offset from this region's position. */ frameoffset_t -RegionView::snap_frame_to_frame (frameoffset_t x) const +RegionView::snap_frame_to_frame (frameoffset_t x, bool explicitly) const { PublicEditor& editor = trackview.editor(); @@ -951,38 +951,12 @@ RegionView::snap_frame_to_frame (frameoffset_t x) const /* try a snap in either direction */ framepos_t frame = session_frame; - editor.snap_to (frame, RoundNearest); + editor.snap_to (frame, RoundNearest, false, explicitly); /* if we went off the beginning of the region, snap forwards */ if (frame < _region->position ()) { frame = session_frame; - editor.snap_to (frame, RoundUpAlways); - } - - /* back to region relative */ - return frame - _region->position(); -} - -/** Snap a frame offset within our region using the current snap settings. - * @param x Frame offset from this region's position. - * @return Snapped frame offset from this region's position. - */ -frameoffset_t -RegionView::snap_frame_to_frame_no_magnets (frameoffset_t x) const -{ - PublicEditor& editor = trackview.editor(); - - /* x is region relative, convert it to global absolute frames */ - framepos_t const session_frame = x + _region->position(); - - /* try a snap in either direction */ - framepos_t frame = session_frame; - editor.snap_to_no_magnets (frame, RoundNearest); - - /* if we went off the beginning of the region, snap forwards */ - if (frame < _region->position ()) { - frame = session_frame; - editor.snap_to_no_magnets (frame, RoundUpAlways); + editor.snap_to (frame, RoundUpAlways, false, explicitly); } /* back to region relative */ diff --git a/gtk2_ardour/region_view.h b/gtk2_ardour/region_view.h index 77abb5e2a9..23b08f4b12 100644 --- a/gtk2_ardour/region_view.h +++ b/gtk2_ardour/region_view.h @@ -121,8 +121,7 @@ class RegionView : public TimeAxisViewItem } }; - ARDOUR::frameoffset_t snap_frame_to_frame (ARDOUR::frameoffset_t) const; - ARDOUR::frameoffset_t snap_frame_to_frame_no_magnets (ARDOUR::frameoffset_t) const; + ARDOUR::frameoffset_t snap_frame_to_frame (ARDOUR::frameoffset_t, bool explicitly = false) const; protected: -- cgit v1.2.3 From 37ee083931c6e57e0d5611ac909294126d92ba05 Mon Sep 17 00:00:00 2001 From: nick_m Date: Fri, 22 May 2015 04:48:34 +1000 Subject: Small cleanup --- gtk2_ardour/editor_drag.cc | 10 +++++----- gtk2_ardour/editor_drag.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 3f08a8c750..b119aab1ea 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -5196,7 +5196,7 @@ NoteDrag::start_grab (GdkEvent* event, Gdk::Cursor *) /** @return Current total drag x change in frames */ frameoffset_t -NoteDrag::total_dx (GdkEvent const * event) const +NoteDrag::total_dx (guint const state) const { /* dx in frames */ frameoffset_t const dx = _editor->pixel_to_sample (_drags->current_pointer_x() - grab_x()); @@ -5205,7 +5205,7 @@ NoteDrag::total_dx (GdkEvent const * event) const frameoffset_t const n = _region->source_beats_to_absolute_frames (_primary->note()->time ()); /* new time of the primary note in session frames */ - frameoffset_t st = n + dx + snap_delta (event->button.state); + frameoffset_t st = n + dx + snap_delta (state); framepos_t const rp = _region->region()->position (); @@ -5213,7 +5213,7 @@ NoteDrag::total_dx (GdkEvent const * event) const st = max (st, rp); /* snap and return corresponding delta */ - return _region->snap_frame_to_frame (st - rp) + rp - n - snap_delta (event->button.state); + return _region->snap_frame_to_frame (st - rp) + rp - n - snap_delta (state); } /** @return Current total drag y change in note number */ @@ -5235,7 +5235,7 @@ void NoteDrag::motion (GdkEvent * event, bool) { /* Total change in x and y since the start of the drag */ - frameoffset_t const dx = total_dx (event); + frameoffset_t const dx = total_dx (event->button.state); int8_t const dy = total_dy (); /* Now work out what we have to do to the note canvas items to set this new drag delta */ @@ -5304,7 +5304,7 @@ NoteDrag::finished (GdkEvent* ev, bool moved) } } } else { - _region->note_dropped (_primary, total_dx (ev), total_dy()); + _region->note_dropped (_primary, total_dx (ev->button.state), total_dy()); } } diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index b11b1c26a1..7d02a23e52 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -527,7 +527,7 @@ class NoteDrag : public Drag private: - ARDOUR::frameoffset_t total_dx (GdkEvent const *) const; + ARDOUR::frameoffset_t total_dx (guint const) const; int8_t total_dy () const; MidiRegionView* _region; -- cgit v1.2.3 From 784abd03e0d0d5ff38dbe2c97c8cce157c39e1d1 Mon Sep 17 00:00:00 2001 From: nick_m Date: Fri, 22 May 2015 06:54:16 +1000 Subject: Make note drags and resizes obey the disable sanp modifier. --- gtk2_ardour/editor_drag.cc | 9 ++++++-- gtk2_ardour/midi_region_view.cc | 49 +++++++++++++++++++++++++++-------------- gtk2_ardour/midi_region_view.h | 4 ++-- 3 files changed, 42 insertions(+), 20 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index b119aab1ea..c390533522 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -2397,7 +2397,7 @@ NoteResizeDrag::motion (GdkEvent* event, bool /*first_move*/) if (!ArdourKeyboard::indicates_snap_delta (event->button.state)) { sd = _snap_delta; } - mrv->update_resizing (nb, at_front, _drags->current_pointer_x() - grab_x(), relative, sd); + mrv->update_resizing (nb, at_front, _drags->current_pointer_x() - grab_x(), relative, sd, event->button.state); } } } @@ -2415,7 +2415,7 @@ NoteResizeDrag::finished (GdkEvent* event, bool /*movement_occurred*/) sd = _snap_delta; } if (mrv) { - mrv->commit_resizing (nb, at_front, _drags->current_pointer_x() - grab_x(), relative, sd); + mrv->commit_resizing (nb, at_front, _drags->current_pointer_x() - grab_x(), relative, sd, event->button.state); } } @@ -5213,6 +5213,11 @@ NoteDrag::total_dx (guint const state) const st = max (st, rp); /* snap and return corresponding delta */ + + if (ArdourKeyboard::indicates_snap (state)) { + return (st - rp) + rp - n - snap_delta (state); + } + return _region->snap_frame_to_frame (st - rp) + rp - n - snap_delta (state); } diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 2fa8f4a3cd..fda5aec725 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -2747,7 +2747,7 @@ MidiRegionView::begin_resizing (bool /*at_front*/) * @param snap_delta snap offset of the primary note in pixels. used in SnapRelative SnapDelta mode. */ void -MidiRegionView::update_resizing (NoteBase* primary, bool at_front, double delta_x, bool relative, double snap_delta) +MidiRegionView::update_resizing (NoteBase* primary, bool at_front, double delta_x, bool relative, double snap_delta, guint key_state) { bool cursor_set = false; @@ -2780,10 +2780,18 @@ MidiRegionView::update_resizing (NoteBase* primary, bool at_front, double delta_ } if (at_front) { - resize_rect->set_x0 (snap_to_pixel(current_x) - snap_delta); + if (ArdourKeyboard::indicates_snap (key_state)) { + resize_rect->set_x0 (current_x - snap_delta); + } else { + resize_rect->set_x0 (snap_to_pixel(current_x) - snap_delta); + } resize_rect->set_x1 (canvas_note->x1()); } else { - resize_rect->set_x1 (snap_to_pixel(current_x) - snap_delta); + if (ArdourKeyboard::indicates_snap (key_state)) { + resize_rect->set_x1 (current_x - snap_delta); + } else { + resize_rect->set_x1 (snap_to_pixel(current_x) - snap_delta); + } resize_rect->set_x0 (canvas_note->x0()); } @@ -2832,9 +2840,12 @@ MidiRegionView::update_resizing (NoteBase* primary, bool at_front, double delta_ * Parameters the same as for \a update_resizing(). */ void -MidiRegionView::commit_resizing (NoteBase* primary, bool at_front, double delta_x, bool relative, double snap_delta) +MidiRegionView::commit_resizing (NoteBase* primary, bool at_front, double delta_x, bool relative, double snap_delta, guint key_state) { + bool snap_keys = ArdourKeyboard::indicates_snap (key_state); + _note_diff_command = _model->new_note_diff_command (_("resize notes")); + for (std::vector::iterator i = _resize_data.begin(); i != _resize_data.end(); ++i) { Note* canvas_note = (*i)->note; ArdourCanvas::Rectangle* resize_rect = (*i)->resize_rect; @@ -2865,25 +2876,31 @@ MidiRegionView::commit_resizing (NoteBase* primary, bool at_front, double delta_ if (current_x > trackview.editor().sample_to_pixel(_region->length())) { current_x = trackview.editor().sample_to_pixel(_region->length()); } - framepos_t delta_samps = trackview.editor().pixel_to_sample (snap_delta); - double delta_beats; + framepos_t snap_delta_samps = trackview.editor().pixel_to_sample (snap_delta); + double snap_delta_beats; int sign = 1; - if (delta_samps > 0) { - delta_beats = region_frames_to_region_beats_double (delta_samps); - } else if (delta_samps < 0) { - delta_beats = region_frames_to_region_beats_double ( - delta_samps); + if (snap_delta_samps > 0) { + snap_delta_beats = region_frames_to_region_beats_double (snap_delta_samps); + } else if (snap_delta_samps < 0) { + snap_delta_beats = region_frames_to_region_beats_double ( - snap_delta_samps); sign = -1; } /* Convert that to a frame within the source */ - framepos_t current_fr = snap_pixel_to_sample (current_x) + _region->start (); + framepos_t current_fr; + + if (snap_keys) { + current_fr = trackview.editor().pixel_to_sample (current_x) + _region->start (); + } else { + current_fr = snap_pixel_to_sample (current_x) + _region->start (); + } /* and then to beats */ const Evoral::Beats x_beats = region_frames_to_region_beats (current_fr); - if (at_front && x_beats < canvas_note->note()->end_time()) { - note_diff_add_change (canvas_note, MidiModel::NoteDiffCommand::StartTime, x_beats - (sign * delta_beats)); - Evoral::Beats len = canvas_note->note()->time() - x_beats + (sign * delta_beats); + if (at_front && x_beats < canvas_note->note()->end_time()) { + note_diff_add_change (canvas_note, MidiModel::NoteDiffCommand::StartTime, x_beats - (sign * snap_delta_beats)); + Evoral::Beats len = canvas_note->note()->time() - x_beats + (sign * snap_delta_beats); len += canvas_note->note()->length(); if (!!len) { @@ -2892,8 +2909,8 @@ MidiRegionView::commit_resizing (NoteBase* primary, bool at_front, double delta_ } if (!at_front) { - const Evoral::Beats len = std::max(Evoral::Beats(1 / 512.0), - x_beats - canvas_note->note()->time() - (sign * delta_beats)); + Evoral::Beats len = std::max(Evoral::Beats(1 / 512.0), + x_beats - canvas_note->note()->time() - (sign * snap_delta_beats)); note_diff_add_change (canvas_note, MidiModel::NoteDiffCommand::Length, len); } diff --git a/gtk2_ardour/midi_region_view.h b/gtk2_ardour/midi_region_view.h index 37a66aa398..9c39fa1576 100644 --- a/gtk2_ardour/midi_region_view.h +++ b/gtk2_ardour/midi_region_view.h @@ -223,8 +223,8 @@ public: */ void begin_resizing(bool at_front); - void update_resizing (NoteBase*, bool, double, bool, double); - void commit_resizing (NoteBase*, bool, double, bool, double); + void update_resizing (NoteBase*, bool, double, bool, double, guint); + void commit_resizing (NoteBase*, bool, double, bool, double, guint); void abort_resizing (); /** Change the channel of the selection. -- cgit v1.2.3 From 88477ace25dbf1c65b568be3bfb08dfd67623c13 Mon Sep 17 00:00:00 2001 From: nick_m Date: Sat, 23 May 2015 03:09:48 +1000 Subject: Fix inverted logic of SnapOff with snap modifiers pressed. - also clean up, rename and comment some previous hanges. --- gtk2_ardour/editor.cc | 13 +++++---- gtk2_ardour/editor.h | 4 +-- gtk2_ardour/editor_drag.cc | 65 ++++++++++++++++++++++++++++++++++------- gtk2_ardour/editor_drag.h | 2 +- gtk2_ardour/midi_region_view.cc | 39 +++++++++++-------------- gtk2_ardour/midi_region_view.h | 13 +++++---- gtk2_ardour/public_editor.h | 7 +++-- gtk2_ardour/region_view.cc | 8 +++-- gtk2_ardour/region_view.h | 4 +-- 9 files changed, 102 insertions(+), 53 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 45c7ca94b0..474fb4c6f9 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -2604,18 +2604,21 @@ Editor::snap_to_with_modifier (framepos_t& start, GdkEvent const * event, RoundM } else { if (_snap_mode != SnapOff) { snap_to_internal (start, direction, for_mark); + } else if (ArdourKeyboard::indicates_snap_delta (event->button.state)) { + /* SnapOff, but we pressed the snap_delta modifier */ + snap_to_internal (start, direction, for_mark); } } } void -Editor::snap_to (framepos_t& start, RoundMode direction, bool for_mark, bool explicitly) +Editor::snap_to (framepos_t& start, RoundMode direction, bool for_mark, bool ensure_snap) { - if (!_session || _snap_mode == SnapOff) { + if (!_session || (_snap_mode == SnapOff && !ensure_snap)) { return; } - snap_to_internal (start, direction, for_mark, explicitly); + snap_to_internal (start, direction, for_mark, ensure_snap); } void @@ -2685,7 +2688,7 @@ Editor::timecode_snap_to_internal (framepos_t& start, RoundMode direction, bool } void -Editor::snap_to_internal (framepos_t& start, RoundMode direction, bool for_mark, bool explicitly) +Editor::snap_to_internal (framepos_t& start, RoundMode direction, bool for_mark, bool ensure_snap) { const framepos_t one_second = _session->frame_rate(); const framepos_t one_minute = _session->frame_rate() * 60; @@ -2855,7 +2858,7 @@ Editor::snap_to_internal (framepos_t& start, RoundMode direction, bool for_mark, case SnapMagnetic: - if (explicitly) { + if (ensure_snap) { return; } diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 663a97a56d..603103532f 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -437,7 +437,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void snap_to (framepos_t& first, ARDOUR::RoundMode direction = ARDOUR::RoundNearest, bool for_mark = false, - bool explicitly = false); + bool ensure_snap = false); void snap_to_with_modifier (framepos_t& first, GdkEvent const * ev, @@ -2133,7 +2133,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void snap_to_internal (framepos_t& first, ARDOUR::RoundMode direction = ARDOUR::RoundNearest, bool for_mark = false, - bool explicitly = false); + bool ensure_snap = false); void timecode_snap_to_internal (framepos_t& first, ARDOUR::RoundMode direction = ARDOUR::RoundNearest, diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index c390533522..014b4679e8 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -2394,10 +2394,28 @@ NoteResizeDrag::motion (GdkEvent* event, bool /*first_move*/) MidiRegionView* mrv = dynamic_cast(*r); if (mrv) { double sd = 0.0; - if (!ArdourKeyboard::indicates_snap_delta (event->button.state)) { + bool snap = true; + bool apply_snap_delta = !ArdourKeyboard::indicates_snap_delta (event->button.state); + + if (ArdourKeyboard::indicates_snap (event->button.state)) { + if (_editor->snap_mode () != SnapOff) { + snap = false; + } + } else { + if (_editor->snap_mode () == SnapOff) { + snap = false; + /* inverted logic here - we;re in snapoff but we've pressed the snap delta modifier */ + if (!apply_snap_delta) { + snap = true; + } + } + } + + if (apply_snap_delta) { sd = _snap_delta; } - mrv->update_resizing (nb, at_front, _drags->current_pointer_x() - grab_x(), relative, sd, event->button.state); + + mrv->update_resizing (nb, at_front, _drags->current_pointer_x() - grab_x(), relative, sd, snap); } } } @@ -2411,11 +2429,26 @@ NoteResizeDrag::finished (GdkEvent* event, bool /*movement_occurred*/) assert (nb); MidiRegionView* mrv = dynamic_cast(*r); double sd = 0.0; - if (!ArdourKeyboard::indicates_snap_delta (event->button.state)) { - sd = _snap_delta; - } + bool snap = true; + bool apply_snap_delta = !ArdourKeyboard::indicates_snap_delta (event->button.state); if (mrv) { - mrv->commit_resizing (nb, at_front, _drags->current_pointer_x() - grab_x(), relative, sd, event->button.state); + if (ArdourKeyboard::indicates_snap (event->button.state)) { + if (_editor->snap_mode () != SnapOff) { + snap = false; + } + } else { + if (_editor->snap_mode () == SnapOff) { + snap = false; + /* inverted logic here - we;re in snapoff but we've pressed the snap delta modifier */ + if (!apply_snap_delta) { + snap = true; + } + } + } + if (apply_snap_delta) { + sd = _snap_delta; + } + mrv->commit_resizing (nb, at_front, _drags->current_pointer_x() - grab_x(), relative, sd, snap); } } @@ -5196,7 +5229,7 @@ NoteDrag::start_grab (GdkEvent* event, Gdk::Cursor *) /** @return Current total drag x change in frames */ frameoffset_t -NoteDrag::total_dx (guint const state) const +NoteDrag::total_dx (const guint state) const { /* dx in frames */ frameoffset_t const dx = _editor->pixel_to_sample (_drags->current_pointer_x() - grab_x()); @@ -5212,13 +5245,25 @@ NoteDrag::total_dx (guint const state) const /* prevent the note being dragged earlier than the region's position */ st = max (st, rp); - /* snap and return corresponding delta */ + /* possibly snap and return corresponding delta */ + + bool snap = true; if (ArdourKeyboard::indicates_snap (state)) { - return (st - rp) + rp - n - snap_delta (state); + if (_editor->snap_mode () != SnapOff) { + snap = false; + } + } else { + if (_editor->snap_mode () == SnapOff) { + snap = false; + /* inverted logic here - we;re in snapoff but we've pressed the snap delta modifier */ + if (ArdourKeyboard::indicates_snap_delta (state)) { + snap = true; + } + } } - return _region->snap_frame_to_frame (st - rp) + rp - n - snap_delta (state); + return _region->snap_frame_to_frame (st - rp, snap) + rp - n - snap_delta (state); } /** @return Current total drag y change in note number */ diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index 7d02a23e52..bf08fc31a1 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -527,7 +527,7 @@ class NoteDrag : public Drag private: - ARDOUR::frameoffset_t total_dx (guint const) const; + ARDOUR::frameoffset_t total_dx (const guint) const; int8_t total_dy () const; MidiRegionView* _region; diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index fda5aec725..0650068d0a 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -2624,22 +2624,25 @@ MidiRegionView::note_dropped(NoteBase *, frameoffset_t dt, int8_t dnote) } /** @param x Pixel relative to the region position. + * @param ensure_snap defaults to false. true = snap always, ignoring snap mode and magnetic snap. + * Used for inverting the snap logic with key modifiers and snap delta calculation. * @return Snapped frame relative to the region position. */ framepos_t -MidiRegionView::snap_pixel_to_sample(double x, bool explicitly) +MidiRegionView::snap_pixel_to_sample(double x, bool ensure_snap) { PublicEditor& editor (trackview.editor()); - return snap_frame_to_frame (editor.pixel_to_sample (x), explicitly); + return snap_frame_to_frame (editor.pixel_to_sample (x), ensure_snap); } /** @param x Pixel relative to the region position. + * @param ensure_snap defaults to false. true = ignore magnetic snap and snap mode (used for snap delta calculation). * @return Snapped pixel relative to the region position. */ double -MidiRegionView::snap_to_pixel(double x, bool explicitly) +MidiRegionView::snap_to_pixel(double x, bool ensure_snap) { - return (double) trackview.editor().sample_to_pixel(snap_pixel_to_sample(x, explicitly)); + return (double) trackview.editor().sample_to_pixel(snap_pixel_to_sample(x, ensure_snap)); } double @@ -2747,7 +2750,7 @@ MidiRegionView::begin_resizing (bool /*at_front*/) * @param snap_delta snap offset of the primary note in pixels. used in SnapRelative SnapDelta mode. */ void -MidiRegionView::update_resizing (NoteBase* primary, bool at_front, double delta_x, bool relative, double snap_delta, guint key_state) +MidiRegionView::update_resizing (NoteBase* primary, bool at_front, double delta_x, bool relative, double snap_delta, bool with_snap) { bool cursor_set = false; @@ -2780,17 +2783,17 @@ MidiRegionView::update_resizing (NoteBase* primary, bool at_front, double delta_ } if (at_front) { - if (ArdourKeyboard::indicates_snap (key_state)) { - resize_rect->set_x0 (current_x - snap_delta); + if (with_snap) { + resize_rect->set_x0 (snap_to_pixel(current_x, true) - snap_delta); } else { - resize_rect->set_x0 (snap_to_pixel(current_x) - snap_delta); + resize_rect->set_x0 (current_x - snap_delta); } resize_rect->set_x1 (canvas_note->x1()); } else { - if (ArdourKeyboard::indicates_snap (key_state)) { - resize_rect->set_x1 (current_x - snap_delta); + if (with_snap) { + resize_rect->set_x1 (snap_to_pixel(current_x, true) - snap_delta); } else { - resize_rect->set_x1 (snap_to_pixel(current_x) - snap_delta); + resize_rect->set_x1 (current_x - snap_delta); } resize_rect->set_x0 (canvas_note->x0()); } @@ -2808,7 +2811,7 @@ MidiRegionView::update_resizing (NoteBase* primary, bool at_front, double delta_ sign = -1; } - const double snapped_x = snap_pixel_to_sample (current_x); + const double snapped_x = (with_snap ? snap_pixel_to_sample (current_x, true) : trackview.editor ().pixel_to_sample (current_x)); Evoral::Beats beats = region_frames_to_region_beats (snapped_x); Evoral::Beats len = Evoral::Beats(); @@ -2840,10 +2843,8 @@ MidiRegionView::update_resizing (NoteBase* primary, bool at_front, double delta_ * Parameters the same as for \a update_resizing(). */ void -MidiRegionView::commit_resizing (NoteBase* primary, bool at_front, double delta_x, bool relative, double snap_delta, guint key_state) +MidiRegionView::commit_resizing (NoteBase* primary, bool at_front, double delta_x, bool relative, double snap_delta, bool with_snap) { - bool snap_keys = ArdourKeyboard::indicates_snap (key_state); - _note_diff_command = _model->new_note_diff_command (_("resize notes")); for (std::vector::iterator i = _resize_data.begin(); i != _resize_data.end(); ++i) { @@ -2887,13 +2888,7 @@ MidiRegionView::commit_resizing (NoteBase* primary, bool at_front, double delta_ } /* Convert that to a frame within the source */ - framepos_t current_fr; - - if (snap_keys) { - current_fr = trackview.editor().pixel_to_sample (current_x) + _region->start (); - } else { - current_fr = snap_pixel_to_sample (current_x) + _region->start (); - } + const framepos_t current_fr = snap_pixel_to_sample (current_x, with_snap) + _region->start (); /* and then to beats */ const Evoral::Beats x_beats = region_frames_to_region_beats (current_fr); diff --git a/gtk2_ardour/midi_region_view.h b/gtk2_ardour/midi_region_view.h index 9c39fa1576..4cab6b16bf 100644 --- a/gtk2_ardour/midi_region_view.h +++ b/gtk2_ardour/midi_region_view.h @@ -223,8 +223,8 @@ public: */ void begin_resizing(bool at_front); - void update_resizing (NoteBase*, bool, double, bool, double, guint); - void commit_resizing (NoteBase*, bool, double, bool, double, guint); + void update_resizing (NoteBase* primary, bool at_front, double delta_x, bool relative, double snap_delta, bool with_snap); + void commit_resizing (NoteBase* primary, bool at_front, double delat_x, bool relative, double snap_delta, bool with_snap); void abort_resizing (); /** Change the channel of the selection. @@ -250,17 +250,18 @@ public: /** Snap a region relative pixel coordinate to pixel units. * @param x a pixel coordinate relative to region start - * @param explicitly do not use magnetic snap (required for snap delta calculation) + * @param ensure_snap do not use magnetic snap (required for snap delta calculation) * @return the snapped pixel coordinate relative to region start */ - double snap_to_pixel(double x, bool explicitly = false); + double snap_to_pixel(double x, bool ensure_snap = false); /** Snap a region relative pixel coordinate to frame units. * @param x a pixel coordinate relative to region start - * @param explicitly do not use magnetic snap (required for snap delta calculation) + * @param ensure_snap ignore SnapOff and magnetic snap. + * Required for inverting snap logic with modifier keys and snap delta calculation. * @return the snapped framepos_t coordinate relative to region start */ - framepos_t snap_pixel_to_sample(double x, bool explicitly = false); + framepos_t snap_pixel_to_sample(double x, bool ensure_snap = false); /** Convert a timestamp in beats into frames (both relative to region position) */ framepos_t region_beats_to_region_frames(Evoral::Beats beats) const; diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index 463d7614d2..951c3e9b0e 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -141,11 +141,14 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible, publi */ virtual void set_snap_threshold (double t) = 0; - /** Snap a value according to the current snap setting. */ + /** + * Snap a value according to the current snap setting. + * ensure_snap overrides SnapOff and magnetic snap + */ virtual void snap_to (framepos_t& first, ARDOUR::RoundMode direction = ARDOUR::RoundNearest, bool for_mark = false, - bool explicitly = false) = 0; + bool ensure_snap = false) = 0; /** Undo some transactions. * @param n Number of transactions to undo. diff --git a/gtk2_ardour/region_view.cc b/gtk2_ardour/region_view.cc index 5a8e3f235b..75e091f2d0 100644 --- a/gtk2_ardour/region_view.cc +++ b/gtk2_ardour/region_view.cc @@ -939,10 +939,12 @@ RegionView::move_contents (frameoffset_t distance) /** Snap a frame offset within our region using the current snap settings. * @param x Frame offset from this region's position. + * @param ensure_snap whether to ignore snap_mode (in the case of SnapOff) and magnetic snap. + * Used when inverting snap mode logic with key modifiers, or snap distance calculation. * @return Snapped frame offset from this region's position. */ frameoffset_t -RegionView::snap_frame_to_frame (frameoffset_t x, bool explicitly) const +RegionView::snap_frame_to_frame (frameoffset_t x, bool ensure_snap) const { PublicEditor& editor = trackview.editor(); @@ -951,12 +953,12 @@ RegionView::snap_frame_to_frame (frameoffset_t x, bool explicitly) const /* try a snap in either direction */ framepos_t frame = session_frame; - editor.snap_to (frame, RoundNearest, false, explicitly); + editor.snap_to (frame, RoundNearest, false, ensure_snap); /* if we went off the beginning of the region, snap forwards */ if (frame < _region->position ()) { frame = session_frame; - editor.snap_to (frame, RoundUpAlways, false, explicitly); + editor.snap_to (frame, RoundUpAlways, false, ensure_snap); } /* back to region relative */ diff --git a/gtk2_ardour/region_view.h b/gtk2_ardour/region_view.h index 23b08f4b12..f17e37a72d 100644 --- a/gtk2_ardour/region_view.h +++ b/gtk2_ardour/region_view.h @@ -121,8 +121,8 @@ class RegionView : public TimeAxisViewItem } }; - ARDOUR::frameoffset_t snap_frame_to_frame (ARDOUR::frameoffset_t, bool explicitly = false) const; - + ARDOUR::frameoffset_t snap_frame_to_frame (ARDOUR::frameoffset_t, bool ensure_snap = false) const; + protected: /** Allows derived types to specify their visibility requirements -- cgit v1.2.3 From 3d599be991a71b7e4611b1c38ee88a77bf1c5460 Mon Sep 17 00:00:00 2001 From: nick_m Date: Sat, 23 May 2015 03:44:42 +1000 Subject: Fix missing comment. --- gtk2_ardour/midi_region_view.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 0650068d0a..4b0c9f54c4 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -2748,6 +2748,7 @@ MidiRegionView::begin_resizing (bool /*at_front*/) * amount of the drag. In non-relative mode, all selected notes are set to have the same start or end point * as the \a primary note. * @param snap_delta snap offset of the primary note in pixels. used in SnapRelative SnapDelta mode. + * @param with_snap true if snap is to be used to determine the position, false if no snap is to be used. */ void MidiRegionView::update_resizing (NoteBase* primary, bool at_front, double delta_x, bool relative, double snap_delta, bool with_snap) -- cgit v1.2.3 From ea8b5a970f7fdc0818fb86c32c93dd564eff941c Mon Sep 17 00:00:00 2001 From: nick_m Date: Sat, 23 May 2015 05:36:03 +1000 Subject: Bring back contrained drag modifier with preference setting. - this should work as before, but when applied to a button 1 drag, the constraint is in the first direction travelled. --- gtk2_ardour/editor_drag.cc | 32 +++++++++++++++++++++----------- gtk2_ardour/keyboard.cc | 15 +++++++++++++++ gtk2_ardour/keyboard.h | 6 ++++++ gtk2_ardour/midi_region_view.cc | 24 ++++++++++++++---------- gtk2_ardour/rc_option_editor.cc | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 89 insertions(+), 21 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 014b4679e8..97a24a1a1a 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -249,7 +249,6 @@ Drag::swap_grab (ArdourCanvas::Item* new_item, Gdk::Cursor* cursor, uint32_t /*t void Drag::start_grab (GdkEvent* event, Gdk::Cursor *cursor) { - // if dragging with button2, the motion is x constrained, with Alt-button2 it is y constrained /* we set up x/y dragging constraints on first move */ _x_constrained = false; @@ -401,20 +400,31 @@ Drag::motion_handler (GdkEvent* event, bool from_autoscroll) /* just changed */ if (fabs (current_pointer_y() - _grab_y) > fabs (current_pointer_x() - _grab_x)) { - if ((event->motion.state & Gdk::BUTTON2_MASK) && Config->get_edit_mode() != Lock) { - _x_constrained = true; - _y_constrained = false; - } _initially_vertical = true; } else { - if ((event->motion.state & Gdk::BUTTON2_MASK) && Config->get_edit_mode() != Lock) { - _x_constrained = false; - _y_constrained = true; - } _initially_vertical = false; } - - if (Config->get_edit_mode() == Lock) { + if (Config->get_edit_mode() != Lock) { + if (event->motion.state & Gdk::BUTTON2_MASK) { + // if dragging with button2, the motion is x constrained, with constraint modifier it is y constrained + if (Keyboard::modifier_state_equals (event->button.state, ArdourKeyboard::constraint_modifier ())) { + _x_constrained = false; + _y_constrained = true; + } else { + _x_constrained = true; + _y_constrained = false; + } + } else if (Keyboard::modifier_state_equals (event->button.state, ArdourKeyboard::constraint_modifier ())) { + // if dragging normally, the motion is constrained to the first direction of movement. + if (_initially_vertical) { + _x_constrained = true; + _y_constrained = false; + } else { + _x_constrained = false; + _y_constrained = true; + } + } + } else { if (event->button.state & Gdk::BUTTON2_MASK) { _x_constrained = false; } else { diff --git a/gtk2_ardour/keyboard.cc b/gtk2_ardour/keyboard.cc index 8a7c811c3c..bdce6badda 100644 --- a/gtk2_ardour/keyboard.cc +++ b/gtk2_ardour/keyboard.cc @@ -48,6 +48,7 @@ accel_map_changed (GtkAccelMap* /*map*/, me->ui.setup_tooltips (); } +guint ArdourKeyboard::constraint_mod = Keyboard::SecondaryModifier; guint ArdourKeyboard::trim_contents_mod = Keyboard::PrimaryModifier; guint ArdourKeyboard::trim_overlap_mod = Keyboard::TertiaryModifier; guint ArdourKeyboard::trim_anchored_mod = Keyboard::TertiaryModifier; @@ -187,6 +188,8 @@ ArdourKeyboard::get_state (void) XMLNode* node = &Keyboard::get_state (); char buf[32]; + snprintf (buf, sizeof (buf), "%d", constraint_mod); + node->add_property ("constraint-modifier", buf); snprintf (buf, sizeof (buf), "%d", trim_contents_mod); node->add_property ("trim-contents-modifier", buf); snprintf (buf, sizeof (buf), "%d", trim_overlap_mod); @@ -208,6 +211,10 @@ ArdourKeyboard::set_state (const XMLNode& node, int version) { const XMLProperty* prop; + if ((prop = node.property ("constraint-modifier")) != 0) { + sscanf (prop->value().c_str(), "%d", &constraint_mod); + } + if ((prop = node.property ("trim-contents-modifier")) != 0) { sscanf (prop->value().c_str(), "%d", &trim_contents_mod); } @@ -255,6 +262,14 @@ ArdourKeyboard::indicates_snap_delta (guint state) return (contains_d && ((contains_s && !equals_s) || !contains_s)); } +void +ArdourKeyboard::set_constraint_modifier (guint mod) +{ + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask & ~constraint_mod); + constraint_mod = mod; + RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | constraint_mod); +} + void ArdourKeyboard::set_trim_contents_modifier (guint mod) { diff --git a/gtk2_ardour/keyboard.h b/gtk2_ardour/keyboard.h index 8ed30efb72..b163bfaa37 100644 --- a/gtk2_ardour/keyboard.h +++ b/gtk2_ardour/keyboard.h @@ -44,6 +44,11 @@ class ArdourKeyboard : public Gtkmm2ext::Keyboard static bool indicates_snap (guint state); static bool indicates_snap_delta (guint state); + static void set_constraint_modifier (guint); + /** @return Modifier mask to constrain drags in a particular direction; + */ + static ModifierMask constraint_modifier () { return ModifierMask (constraint_mod); } + static void set_trim_contents_modifier (guint); /** @return Modifier mask to move contents rather than region bounds during trim; */ @@ -74,6 +79,7 @@ class ArdourKeyboard : public Gtkmm2ext::Keyboard */ static ModifierMask note_size_relative_modifier () { return ModifierMask (note_size_relative_mod); } private: + static guint constraint_mod; static guint trim_contents_mod; static guint trim_overlap_mod; static guint trim_anchored_mod; diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 4b0c9f54c4..7c74b5f1e0 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -2800,15 +2800,16 @@ MidiRegionView::update_resizing (NoteBase* primary, bool at_front, double delta_ } if (!cursor_set) { - /* snap delta is in pixels (sigh) */ - framepos_t delta_samps = trackview.editor().pixel_to_sample (snap_delta); - double delta_beats; + /* Convert snap delta from pixels to beats. */ + framepos_t snap_delta_samps = trackview.editor().pixel_to_sample (snap_delta); + double snap_delta_beats; int sign = 1; + /* negative beat offsets aren't allowed */ - if (delta_samps > 0) { - delta_beats = region_frames_to_region_beats_double (delta_samps); - } else if (delta_samps < 0) { - delta_beats = region_frames_to_region_beats_double ( - delta_samps); + if (snap_delta_samps > 0) { + snap_delta_beats = region_frames_to_region_beats_double (snap_delta_samps); + } else if (snap_delta_samps < 0) { + snap_delta_beats = region_frames_to_region_beats_double ( - snap_delta_samps); sign = -1; } @@ -2818,12 +2819,12 @@ MidiRegionView::update_resizing (NoteBase* primary, bool at_front, double delta_ if (at_front) { if (beats < canvas_note->note()->end_time()) { - len = canvas_note->note()->time() - beats + (sign * delta_beats); + len = canvas_note->note()->time() - beats + (sign * snap_delta_beats); len += canvas_note->note()->length(); } } else { if (beats >= canvas_note->note()->time()) { - len = beats - canvas_note->note()->time() - (sign * delta_beats); + len = beats - canvas_note->note()->time() - (sign * snap_delta_beats); } } @@ -2878,9 +2879,12 @@ MidiRegionView::commit_resizing (NoteBase* primary, bool at_front, double delta_ if (current_x > trackview.editor().sample_to_pixel(_region->length())) { current_x = trackview.editor().sample_to_pixel(_region->length()); } + + /* Convert snap delta from pixels to beats with sign. */ framepos_t snap_delta_samps = trackview.editor().pixel_to_sample (snap_delta); double snap_delta_beats; int sign = 1; + if (snap_delta_samps > 0) { snap_delta_beats = region_frames_to_region_beats_double (snap_delta_samps); } else if (snap_delta_samps < 0) { @@ -2888,7 +2892,7 @@ MidiRegionView::commit_resizing (NoteBase* primary, bool at_front, double delta_ sign = -1; } - /* Convert that to a frame within the source */ + /* Convert the new x position to a frame within the source */ const framepos_t current_fr = snap_pixel_to_sample (current_x, with_snap) + _region->start (); /* and then to beats */ diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc index a5f4b6e6f1..9b38b558c9 100644 --- a/gtk2_ardour/rc_option_editor.cc +++ b/gtk2_ardour/rc_option_editor.cc @@ -453,6 +453,26 @@ public: t->attach (*l, col, col + 1, row, row + 1, FILL | EXPAND, FILL); t->attach (_copy_modifier_combo, col + 1, col + 2, row, row + 1, FILL | EXPAND, FILL); + ++row; + col = 1; + + /* constraint modifier */ + set_popdown_strings (_constraint_modifier_combo, dumb); + _constraint_modifier_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::constraint_modifier_chosen)); + + for (int x = 0; modifiers[x].name; ++x) { + if (modifiers[x].modifier == (guint) ArdourKeyboard::constraint_modifier ()) { + _constraint_modifier_combo.set_active_text (S_(modifiers[x].name)); + break; + } + } + + l = manage (left_aligned_label (_("Constrain drag using:"))); + l->set_name ("OptionsLabel"); + + t->attach (*l, col, col + 1, row, row + 1, FILL | EXPAND, FILL); + t->attach (_constraint_modifier_combo, col + 1, col + 2, row, row + 1, FILL | EXPAND, FILL); + ++row; l = manage (left_aligned_label (_("When Beginning a Trim:"))); @@ -763,6 +783,18 @@ private: } } + void constraint_modifier_chosen () + { + string const txt = _constraint_modifier_combo.get_active_text(); + + for (int i = 0; modifiers[i].name; ++i) { + if (txt == _(modifiers[i].name)) { + ArdourKeyboard::set_constraint_modifier (modifiers[i].modifier); + break; + } + } + } + void trim_contents_modifier_chosen () { string const txt = _trim_contents_combo.get_active_text(); @@ -857,6 +889,7 @@ private: ComboBoxText _insert_note_modifier_combo; ComboBoxText _snap_modifier_combo; ComboBoxText _snap_delta_combo; + ComboBoxText _constraint_modifier_combo; ComboBoxText _trim_contents_combo; ComboBoxText _trim_overlap_combo; ComboBoxText _trim_anchored_combo; -- cgit v1.2.3 From 406bcb4dfe8a2e7dae33b550efe7fa561214ef98 Mon Sep 17 00:00:00 2001 From: nick_m Date: Sat, 23 May 2015 22:59:19 +1000 Subject: Proper initialisation of _x/y_constrained. --- gtk2_ardour/editor_drag.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 97a24a1a1a..f9222ac35a 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -218,6 +218,8 @@ Drag::Drag (Editor* e, ArdourCanvas::Item* i, bool trackview_only) : _editor (e) , _item (i) , _pointer_frame_offset (0) + , _x_constrained (false) + , _y_constrained (false) , _trackview_only (trackview_only) , _move_threshold_passed (false) , _starting_point_passed (false) @@ -251,8 +253,6 @@ Drag::start_grab (GdkEvent* event, Gdk::Cursor *cursor) { /* we set up x/y dragging constraints on first move */ - _x_constrained = false; - _y_constrained = false; _raw_grab_frame = _editor->canvas_event_sample (event, &_grab_x, &_grab_y); -- cgit v1.2.3 From 39d4bbf5e16662929719bb1884b741ffc8805adf Mon Sep 17 00:00:00 2001 From: nick_m Date: Sat, 23 May 2015 23:19:00 +1000 Subject: Clarify the convention on modifiers and drags. --- gtk2_ardour/editor_drag.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index f9222ac35a..00811f6eea 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -404,6 +404,11 @@ Drag::motion_handler (GdkEvent* event, bool from_autoscroll) } else { _initially_vertical = false; } + /** check constraints for this drag. + * Note that the current convention is to use "contains" for + * key modifiers during motion and "equals" when initiating a drag. + * In this case we haven't moved yet, so "equals" applies here. + */ if (Config->get_edit_mode() != Lock) { if (event->motion.state & Gdk::BUTTON2_MASK) { // if dragging with button2, the motion is x constrained, with constraint modifier it is y constrained -- cgit v1.2.3 From 9a55bcb04fc9af5e0425b7ef12c628cad9494433 Mon Sep 17 00:00:00 2001 From: nick_m Date: Sun, 24 May 2015 01:10:06 +1000 Subject: Rekative snap - add comments --- gtk2_ardour/keyboard.cc | 3 +++ gtk2_ardour/keyboard.h | 7 +++++++ 2 files changed, 10 insertions(+) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/keyboard.cc b/gtk2_ardour/keyboard.cc index bdce6badda..96c73f63d4 100644 --- a/gtk2_ardour/keyboard.cc +++ b/gtk2_ardour/keyboard.cc @@ -242,6 +242,9 @@ ArdourKeyboard::set_state (const XMLNode& node, int version) return Keyboard::set_state (node, version); } +/* Snap and snap delta modifiers may contain each other, so we use the + * following two methods to sort that out: + */ bool ArdourKeyboard::indicates_snap (guint state) { diff --git a/gtk2_ardour/keyboard.h b/gtk2_ardour/keyboard.h index b163bfaa37..9ca60950bb 100644 --- a/gtk2_ardour/keyboard.h +++ b/gtk2_ardour/keyboard.h @@ -41,7 +41,14 @@ class ArdourKeyboard : public Gtkmm2ext::Keyboard ARDOUR_UI& ui; + /** @param state The button state from a GdkEvent. + * @return true if the modifier state indicates snap modifier + */ static bool indicates_snap (guint state); + + /** @param state The button state from a GdkEvent. + * @return true if the modifier state indicates snap delta + */ static bool indicates_snap_delta (guint state); static void set_constraint_modifier (guint); -- cgit v1.2.3 From b86c3f97b09779e516939c40983977e5e5a0e458 Mon Sep 17 00:00:00 2001 From: nick_m Date: Sun, 24 May 2015 04:04:37 +1000 Subject: Fix bug where inserting notes in MouseContent mode disallowed resizing. --- gtk2_ardour/editor_drag.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index bf08fc31a1..6fcd92751a 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -550,7 +550,7 @@ public: void aborted (bool); bool active (Editing::MouseMode mode) { - return mode == Editing::MouseDraw; + return mode == Editing::MouseDraw || mode == Editing::MouseContent; } bool y_movement_matters () const { -- cgit v1.2.3