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
This commit is contained in:
Paul Davis
2009-10-26 23:43:04 +00:00
parent b6e90314b0
commit 0cc0c13444
9 changed files with 55 additions and 31 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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:

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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)
*/