summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2009-10-26 23:43:04 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2009-10-26 23:43:04 +0000
commit0cc0c13444408163e5555a2a1deb32d8f79ec826 (patch)
tree252047abb98f62d9176bcec404087c6a63865522 /gtk2_ardour
parentb6e90314b0087e870ad21ce658b92bd23851fe29 (diff)
provide accessors to Editor::snap_{type,mode} ; when nudging notes, use grid in preference to nudge clock
git-svn-id: svn://localhost/ardour2/branches/3.0@5934 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/editor.cc48
-rw-r--r--gtk2_ardour/editor.h7
-rw-r--r--gtk2_ardour/editor_actions.cc4
-rw-r--r--gtk2_ardour/editor_drag.cc2
-rw-r--r--gtk2_ardour/editor_mouse.cc4
-rw-r--r--gtk2_ardour/editor_ops.cc6
-rw-r--r--gtk2_ardour/editor_rulers.cc2
-rw-r--r--gtk2_ardour/midi_region_view.cc10
-rw-r--r--gtk2_ardour/public_editor.h3
9 files changed, 55 insertions, 31 deletions
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index ac65d7bd41..60d6c9a3a4 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -605,10 +605,10 @@ Editor::Editor ()
setup_toolbar ();
setup_midi_toolbar ();
- snap_type = SnapToBeat;
- set_snap_to (snap_type);
- snap_mode = SnapOff;
- set_snap_mode (snap_mode);
+ _snap_type = SnapToBeat;
+ set_snap_to (_snap_type);
+ _snap_mode = SnapOff;
+ set_snap_mode (_snap_mode);
set_mouse_mode (MouseObject, true);
set_edit_point_preference (EditAtMouse, true);
@@ -1176,7 +1176,7 @@ Editor::connect_to_session (Session *t)
start_scrolling ();
- switch (snap_type) {
+ switch (_snap_type) {
case SnapToRegionStart:
case SnapToRegionEnd:
case SnapToRegionSync:
@@ -2103,16 +2103,28 @@ Editor::add_bus_context_items (Menu_Helpers::MenuList& edit_items)
edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
}
+SnapType
+Editor::snap_type() const
+{
+ return _snap_type;
+}
+
+SnapMode
+Editor::snap_mode() const
+{
+ return _snap_mode;
+}
+
void
Editor::set_snap_to (SnapType st)
{
unsigned int snap_ind = (unsigned int)st;
- snap_type = st;
+ _snap_type = st;
if (snap_ind > snap_type_strings.size() - 1) {
snap_ind = 0;
- snap_type = (SnapType)snap_ind;
+ _snap_type = (SnapType)snap_ind;
}
string str = snap_type_strings[snap_ind];
@@ -2123,7 +2135,7 @@ Editor::set_snap_to (SnapType st)
instant_save ();
- switch (snap_type) {
+ switch (_snap_type) {
case SnapToAThirtysecondBeat:
case SnapToASixteenthBeat:
case SnapToAEighthBeat:
@@ -2149,7 +2161,7 @@ Editor::set_snap_to (SnapType st)
void
Editor::set_snap_mode (SnapMode mode)
{
- snap_mode = mode;
+ _snap_mode = mode;
string str = snap_mode_strings[(int)mode];
if (str != snap_mode_selector.get_active_text ()) {
@@ -2476,9 +2488,9 @@ Editor::get_state ()
node->add_property ("zoom-focus", buf);
snprintf (buf, sizeof(buf), "%f", frames_per_unit);
node->add_property ("zoom", buf);
- snprintf (buf, sizeof(buf), "%d", (int) snap_type);
+ snprintf (buf, sizeof(buf), "%d", (int) _snap_type);
node->add_property ("snap-to", buf);
- snprintf (buf, sizeof(buf), "%d", (int) snap_mode);
+ snprintf (buf, sizeof(buf), "%d", (int) _snap_mode);
node->add_property ("snap-mode", buf);
node->add_property ("edit-point", enum_2_string (_edit_point));
@@ -2543,11 +2555,11 @@ Editor::snap_to_with_modifier (nframes64_t& start, GdkEvent const * event, int32
}
if (Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
- if (snap_mode == SnapOff) {
+ if (_snap_mode == SnapOff) {
snap_to_internal (start, direction, for_mark);
}
} else {
- if (snap_mode != SnapOff) {
+ if (_snap_mode != SnapOff) {
snap_to_internal (start, direction, for_mark);
}
}
@@ -2556,7 +2568,7 @@ Editor::snap_to_with_modifier (nframes64_t& start, GdkEvent const * event, int32
void
Editor::snap_to (nframes64_t& start, int32_t direction, bool for_mark)
{
- if (!session || snap_mode == SnapOff) {
+ if (!session || _snap_mode == SnapOff) {
return;
}
@@ -2569,7 +2581,7 @@ Editor::timecode_snap_to_internal (nframes64_t& start, int32_t direction, bool /
const nframes64_t one_timecode_second = (nframes64_t)(rint(session->timecode_frames_per_second()) * session->frames_per_timecode_frame());
nframes64_t one_timecode_minute = (nframes64_t)(rint(session->timecode_frames_per_second()) * session->frames_per_timecode_frame() * 60);
- switch (snap_type) {
+ switch (_snap_type) {
case SnapToTimecodeFrame:
if (((direction == 0) && (fmod((double)start, (double)session->frames_per_timecode_frame()) > (session->frames_per_timecode_frame() / 2))) || (direction > 0)) {
start = (nframes64_t) (ceil ((double) start / session->frames_per_timecode_frame()) * session->frames_per_timecode_frame());
@@ -2633,7 +2645,7 @@ Editor::snap_to_internal (nframes64_t& start, int32_t direction, bool for_mark)
nframes64_t before;
nframes64_t after;
- switch (snap_type) {
+ switch (_snap_type) {
case SnapToTimecodeFrame:
case SnapToTimecodeSeconds:
case SnapToTimecodeMinutes:
@@ -2745,7 +2757,7 @@ Editor::snap_to_internal (nframes64_t& start, int32_t direction, bool for_mark)
break;
}
- switch (snap_mode) {
+ switch (_snap_mode) {
case SnapNormal:
return;
@@ -3835,7 +3847,7 @@ Editor::get_grid_type_as_beats (bool& success, nframes64_t position)
{
success = true;
- switch (snap_type) {
+ switch (_snap_type) {
case SnapToBeat:
return 1.0;
break;
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index e4cb5ec57d..030be68ec1 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -176,6 +176,9 @@ class Editor : public PublicEditor
void set_snap_mode (Editing::SnapMode);
void set_snap_threshold (double pixel_distance) {snap_threshold = pixel_distance;}
+ Editing::SnapMode snap_mode () const;
+ Editing::SnapType snap_type () const;
+
void undo (uint32_t n = 1);
void redo (uint32_t n = 1);
@@ -1285,8 +1288,8 @@ class Editor : public PublicEditor
void extend_selection_to_end_of_region (bool next);
void extend_selection_to_start_of_region (bool previous);
- Editing::SnapType snap_type;
- Editing::SnapMode snap_mode;
+ Editing::SnapType _snap_type;
+ Editing::SnapMode _snap_mode;
/// Snap threshold in pixels
double snap_threshold;
diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc
index f059c740fb..9d5fec0969 100644
--- a/gtk2_ardour/editor_actions.cc
+++ b/gtk2_ardour/editor_actions.cc
@@ -1083,7 +1083,7 @@ Editor::snap_type_action (SnapType type)
void
Editor::cycle_snap_choice()
{
- switch (snap_type) {
+ switch (_snap_type) {
case Editing::SnapToCDFrame:
set_snap_to (Editing::SnapToTimecodeFrame);
break;
@@ -1192,7 +1192,7 @@ Editor::snap_mode_action (SnapMode mode)
void
Editor::cycle_snap_mode ()
{
- switch (snap_mode) {
+ switch (_snap_mode) {
case SnapOff:
set_snap_mode (SnapNormal);
break;
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc
index 81f210a901..1c5d98f1b2 100644
--- a/gtk2_ardour/editor_drag.cc
+++ b/gtk2_ardour/editor_drag.cc
@@ -119,7 +119,7 @@ Drag::start_grab (GdkEvent* event, Gdk::Cursor *cursor)
_was_rolling = false;
}
- switch (_editor->snap_type) {
+ switch (_editor->snap_type()) {
case SnapToRegionStart:
case SnapToRegionEnd:
case SnapToRegionSync:
diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc
index f4e5a7d03c..60edec69c4 100644
--- a/gtk2_ardour/editor_mouse.cc
+++ b/gtk2_ardour/editor_mouse.cc
@@ -2390,14 +2390,14 @@ Editor::mouse_brush_insert_region (RegionView* rv, nframes64_t pos)
{
/* no brushing without a useful snap setting */
- switch (snap_mode) {
+ switch (_snap_mode) {
case SnapMagnetic:
return; /* can't work because it allows region to be placed anywhere */
default:
break; /* OK */
}
- switch (snap_type) {
+ switch (_snap_type) {
case SnapToMark:
return;
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index 7f5907dec6..a128ed6cf2 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -125,7 +125,7 @@ Editor::split_regions_at (nframes64_t where, RegionSelection& regions)
// region boundaries, don't pay attention to them
if (regions.size() == 1) {
- switch (snap_type) {
+ switch (_snap_type) {
case SnapToRegionStart:
case SnapToRegionSync:
case SnapToRegionEnd:
@@ -579,7 +579,7 @@ Editor::build_region_boundary_cache ()
return;
}
- switch (snap_type) {
+ switch (_snap_type) {
case SnapToRegionStart:
interesting_points.push_back (Start);
break;
@@ -594,7 +594,7 @@ Editor::build_region_boundary_cache ()
interesting_points.push_back (End);
break;
default:
- fatal << string_compose (_("build_region_boundary_cache called with snap_type = %1"), snap_type) << endmsg;
+ fatal << string_compose (_("build_region_boundary_cache called with snap_type = %1"), _snap_type) << endmsg;
/*NOTREACHED*/
return;
}
diff --git a/gtk2_ardour/editor_rulers.cc b/gtk2_ardour/editor_rulers.cc
index e044487274..12b4547747 100644
--- a/gtk2_ardour/editor_rulers.cc
+++ b/gtk2_ardour/editor_rulers.cc
@@ -1154,7 +1154,7 @@ Editor::compute_bbt_ruler_scale (nframes64_t lower, nframes64_t upper)
bbt_ruler_scale = bbt_over;
- switch (snap_type) {
+ switch (_snap_type) {
case SnapToAThirdBeat:
bbt_beat_subdivision = 3;
break;
diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc
index 0642efc826..77ba80b077 100644
--- a/gtk2_ardour/midi_region_view.cc
+++ b/gtk2_ardour/midi_region_view.cc
@@ -2203,9 +2203,15 @@ MidiRegionView::nudge_notes (bool forward)
nframes64_t unused;
nframes64_t distance;
- if ((distance = trackview.editor().get_nudge_distance (ref_point, unused)) == 0) {
+ if (trackview.editor().snap_mode() == Editing::SnapOff) {
+
+ /* grid is off - use nudge distance */
- /* no nudge distance set - use grid */
+ distance = trackview.editor().get_nudge_distance (ref_point, unused);
+
+ } else {
+
+ /* use grid */
nframes64_t next_pos = ref_point;
diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h
index d0d63e060b..035d05c1af 100644
--- a/gtk2_ardour/public_editor.h
+++ b/gtk2_ardour/public_editor.h
@@ -109,6 +109,9 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulThingWithGoingAway
*/
virtual void set_snap_to (Editing::SnapType t) = 0;
+ virtual Editing::SnapType snap_type () const = 0;
+ virtual Editing::SnapMode snap_mode () const = 0;
+
/** Set the snap mode.
* @param m Snap mode (defined in editing_syms.h)
*/