* @param event Event to get current key modifier information from, or 0.
*/
void
-Editor::snap_to_with_modifier (framepos_t& start, GdkEvent const * event, int32_t direction, bool for_mark)
+Editor::snap_to_with_modifier (framepos_t& start, GdkEvent const * event, RoundMode direction, bool for_mark)
{
if (!_session || !event) {
return;
}
void
-Editor::snap_to (framepos_t& start, int32_t direction, bool for_mark)
+Editor::snap_to (framepos_t& start, RoundMode direction, bool for_mark)
{
if (!_session || _snap_mode == SnapOff) {
return;
}
void
-Editor::timecode_snap_to_internal (framepos_t& start, int32_t direction, bool /*for_mark*/)
+Editor::timecode_snap_to_internal (framepos_t& start, RoundMode direction, bool /*for_mark*/)
{
const framepos_t one_timecode_second = (framepos_t)(rint(_session->timecode_frames_per_second()) * _session->frames_per_timecode_frame());
framepos_t one_timecode_minute = (framepos_t)(rint(_session->timecode_frames_per_second()) * _session->frames_per_timecode_frame() * 60);
}
void
-Editor::snap_to_internal (framepos_t& start, int32_t direction, bool for_mark)
+Editor::snap_to_internal (framepos_t& start, RoundMode direction, bool for_mark)
{
const framepos_t one_second = _session->frame_rate();
const framepos_t one_minute = _session->frame_rate() * 60;
Gtkmm2ext::TearOff* mouse_mode_tearoff () const { return _mouse_mode_tearoff; }
Gtkmm2ext::TearOff* tools_tearoff () const { return _tools_tearoff; }
- void snap_to (framepos_t& first, int32_t direction = 0, bool for_mark = false);
- void snap_to_with_modifier (framepos_t& first, GdkEvent const *, int32_t direction = 0, bool for_mark = false);
- void snap_to (framepos_t& first, framepos_t& last, int32_t direction = 0, bool for_mark = false);
+ void snap_to (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,
+ bool for_mark = false);
+
+ void snap_to (framepos_t& first,
+ framepos_t& last,
+ ARDOUR::RoundMode direction = ARDOUR::RoundNearest,
+ bool for_mark = false);
void begin_reversible_command (std::string cmd_name);
void begin_reversible_command (GQuark);
void select_next_route ();
void select_prev_route ();
- void snap_to_internal (framepos_t& first, int32_t direction = 0, bool for_mark = false);
- void timecode_snap_to_internal (framepos_t& first, int32_t direction = 0, bool for_mark = false);
+ void snap_to_internal (framepos_t& first,
+ ARDOUR::RoundMode direction = ARDOUR::RoundNearest,
+ bool for_mark = false);
+
+ void timecode_snap_to_internal (framepos_t& first,
+ ARDOUR::RoundMode direction = ARDOUR::RoundNearest,
+ bool for_mark = false);
RhythmFerret* rhythm_ferret;
motion (event, false);
TempoMap& map (_editor->session()->tempo_map());
- framepos_t beat_time = map.round_to_beat (last_pointer_frame(), 0);
+ framepos_t beat_time = map.round_to_beat (last_pointer_frame(), RoundNearest);
Timecode::BBT_Time when;
map.bbt_time (beat_time, when);
} else if (new_start < copy_location->end()) {
copy_location->set_start (new_start);
} else if (newframe > 0) {
- _editor->snap_to (next, 1, true);
+ _editor->snap_to (next, RoundUpAlways, true);
copy_location->set_end (next);
copy_location->set_start (newframe);
}
} else if (new_end > copy_location->start()) {
copy_location->set_end (new_end);
} else if (newframe > 0) {
- _editor->snap_to (next, -1, true);
+ _editor->snap_to (next, RoundDownAlways, true);
copy_location->set_start (next);
copy_location->set_end (newframe);
}
if (first_move) {
grab = adjusted_current_frame (event, false);
if (grab < pending_position) {
- _editor->snap_to (grab, -1);
+ _editor->snap_to (grab, RoundDownAlways);
} else {
- _editor->snap_to (grab, 1);
+ _editor->snap_to (grab, RoundUpAlways);
}
}
case MarkerBarItem:
if (!_dragging_playhead) {
- snap_to_with_modifier (where, event, 0, true);
+ snap_to_with_modifier (where, event, RoundNearest, true);
mouse_add_new_marker (where);
}
return true;
case CdMarkerBarItem:
if (!_dragging_playhead) {
// if we get here then a dragged range wasn't done
- snap_to_with_modifier (where, event, 0, true);
+ snap_to_with_modifier (where, event, RoundNearest, true);
mouse_add_new_marker (where, true);
}
return true;
framepos_t pos = playhead_cursor->current_frame ();
if (pos < max_framepos - 1) {
pos += 2;
- snap_to_internal (pos, 1, false);
+ snap_to_internal (pos, RoundUpAlways, false);
_session->request_locate (pos);
}
}
framepos_t pos = playhead_cursor->current_frame ();
if (pos > 2) {
pos -= 2;
- snap_to_internal (pos, -1, false);
+ snap_to_internal (pos, RoundDownAlways, false);
_session->request_locate (pos);
}
}
next_pos -= 1;
}
- trackview.editor().snap_to (next_pos, (forward ? 1 : -1), false);
+ trackview.editor().snap_to (next_pos, (forward ? RoundUpAlways : RoundDownAlways), false);
distance = ref_point - next_pos;
}
real_editor->begin_reversible_command (Operations::create_region);
playlist()->clear_changes ();
- real_editor->snap_to (pos, 0);
+ real_editor->snap_to (pos, RoundNearest);
boost::shared_ptr<Source> src = _session->create_midi_source_by_stealing_name (view()->trackview().track());
PropertyList plist;
virtual void set_snap_threshold (double t) = 0;
/** Snap a value according to the current snap setting. */
- virtual void snap_to (framepos_t& first, int32_t direction = 0, bool for_mark = false) = 0;
+ virtual void snap_to (framepos_t& first,
+ ARDOUR::RoundMode direction = ARDOUR::RoundNearest,
+ bool for_mark = false) = 0;
/** Undo some transactions.
* @param n Number of transactions to undo.
virtual ARDOUR::Location* find_location_from_marker (Marker *, bool &) const = 0;
virtual Marker* find_marker_from_location_id (PBD::ID const &, bool) const = 0;
- virtual void snap_to_with_modifier (framepos_t &, GdkEvent const *, int32_t direction = 0, bool for_mark = false) = 0;
+ virtual void snap_to_with_modifier (framepos_t & first,
+ GdkEvent const * ev,
+ ARDOUR::RoundMode direction = ARDOUR::RoundNearest,
+ bool for_mark = false) = 0;
virtual void get_regions_at (RegionSelection &, framepos_t where, TrackViewList const &) const = 0;
virtual RegionSelection get_regions_from_selection_and_mouse (framepos_t) = 0;
/* try a snap in either direction */
framepos_t frame = session_frame;
- editor.snap_to (frame, 0);
+ editor.snap_to (frame, RoundNearest);
/* if we went off the beginning of the region, snap forwards */
if (frame < _region->position ()) {
frame = session_frame;
- editor.snap_to (frame, 1);
+ editor.snap_to (frame, RoundUpAlways);
}
/* back to region relative */
}
framepos_t fpos = step_edit_region_view->region_beats_to_absolute_frames (step_edit_beat_pos);
- fpos = _session->tempo_map().round_to_bar (fpos, 1);
+ fpos = _session->tempo_map().round_to_bar (fpos, RoundUpAlways);
step_edit_beat_pos = ceil (step_edit_region_view->region_frames_to_region_beats (fpos - step_edit_region->position()));
step_edit_region_view->move_step_edit_cursor (step_edit_beat_pos);
}
: ArdourDialog (_("New Meter"))
{
Timecode::BBT_Time when;
- frame = map.round_to_bar(frame,0);
+ frame = map.round_to_bar(frame, RoundNearest);
Meter meter (map.meter_at(frame));
map.bbt_time (frame, when);
void replace_tempo (const TempoSection&, const Tempo&, const Timecode::BBT_Time& where);
void replace_meter (const MeterSection&, const Meter&, const Timecode::BBT_Time& where);
- framepos_t round_to_bar (framepos_t frame, int dir);
- framepos_t round_to_beat (framepos_t frame, int dir);
- framepos_t round_to_beat_subdivision (framepos_t fr, int sub_num, int dir);
- framepos_t round_to_tick (framepos_t frame, int dir);
+ framepos_t round_to_bar (framepos_t frame, RoundMode dir);
+ framepos_t round_to_beat (framepos_t frame, RoundMode dir);
+ framepos_t round_to_beat_subdivision (framepos_t fr, int sub_num, RoundMode dir);
void set_length (framepos_t frames);
BBTPointList::const_iterator bbt_before_or_at (const Timecode::BBT_Time&);
BBTPointList::const_iterator bbt_after_or_at (framepos_t);
- framepos_t round_to_type (framepos_t fr, int dir, BBTPointType);
+ framepos_t round_to_type (framepos_t fr, RoundMode dir, BBTPointType);
void bbt_time (framepos_t, Timecode::BBT_Time&, const BBTPointList::const_iterator&);
framecnt_t bbt_duration_at_unlocked (const Timecode::BBT_Time& when, const Timecode::BBT_Time& bbt, int dir);
TrackColor
};
+ enum RoundMode {
+ RoundDownAlways = -1, ///< Always round down, even if on a division
+ RoundNearest = 0, ///< Round to nearest
+ RoundUpAlways = 1 ///< Always round up, even if on a division
+ };
+
class AnyTime {
public:
enum Type {
}
framepos_t
-TempoMap::round_to_bar (framepos_t fr, int dir)
+TempoMap::round_to_bar (framepos_t fr, RoundMode dir)
{
return round_to_type (fr, dir, Bar);
}
framepos_t
-TempoMap::round_to_beat (framepos_t fr, int dir)
+TempoMap::round_to_beat (framepos_t fr, RoundMode dir)
{
return round_to_type (fr, dir, Beat);
}
framepos_t
-TempoMap::round_to_beat_subdivision (framepos_t fr, int sub_num, int dir)
+TempoMap::round_to_beat_subdivision (framepos_t fr, int sub_num, RoundMode dir)
{
require_map_to (fr);
}
framepos_t
-TempoMap::round_to_type (framepos_t frame, int dir, BBTPointType type)
+TempoMap::round_to_type (framepos_t frame, RoundMode dir, BBTPointType type)
{
require_map_to (frame);