mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-15 19:16:40 +01:00
bring in change from bf7d4f895e but also try to fix API ambiguity and bug in that commit and existing code
_grid_type is an EditingContext member; grid_type is a method parameter
This commit is contained in:
parent
a0413c525c
commit
d0890abe9c
3 changed files with 11 additions and 26 deletions
|
|
@ -1417,11 +1417,11 @@ EditingContext::snap_to (timepos_t& start, Temporal::RoundMode direction, SnapPr
|
|||
timepos_t
|
||||
EditingContext::snap_to_bbt (timepos_t const & presnap, Temporal::RoundMode direction, SnapPref gpref) const
|
||||
{
|
||||
return _snap_to_bbt (presnap, direction, gpref, _grid_type);
|
||||
return snap_to_bbt_via_grid (presnap, direction, gpref, _grid_type);
|
||||
}
|
||||
|
||||
timepos_t
|
||||
EditingContext::_snap_to_bbt (timepos_t const & presnap, Temporal::RoundMode direction, SnapPref gpref, GridType grid_type) const
|
||||
EditingContext::snap_to_bbt_via_grid (timepos_t const & presnap, Temporal::RoundMode direction, SnapPref gpref, GridType grid_type) const
|
||||
{
|
||||
timepos_t ret(presnap);
|
||||
TempoMap::SharedPtr tmap (TempoMap::use());
|
||||
|
|
@ -1434,22 +1434,7 @@ EditingContext::_snap_to_bbt (timepos_t const & presnap, Temporal::RoundMode dir
|
|||
*/
|
||||
|
||||
if (grid_type == GridTypeBar) {
|
||||
TempoMetric m (tmap->metric_at (presnap));
|
||||
BBT_Argument bbt (m.bbt_at (presnap));
|
||||
switch (direction) {
|
||||
case RoundDownAlways:
|
||||
bbt = BBT_Argument (bbt.reference(), bbt.round_down_to_bar ());
|
||||
break;
|
||||
case RoundUpAlways:
|
||||
bbt = BBT_Argument (bbt.reference(), bbt.round_up_to_bar ());
|
||||
break;
|
||||
case RoundNearest:
|
||||
bbt = BBT_Argument (bbt.reference(), m.round_to_bar (bbt));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return timepos_t (tmap->quarters_at (bbt));
|
||||
return timepos_t (tmap->quarters_at (presnap).round_to_subdivision (get_grid_beat_divisions(grid_type), direction));
|
||||
}
|
||||
|
||||
if (gpref != SnapToGrid_Unscaled) { // use the visual grid lines which are limited by the zoom scale that the user selected
|
||||
|
|
@ -1531,7 +1516,7 @@ EditingContext::_snap_to_bbt (timepos_t const & presnap, Temporal::RoundMode dir
|
|||
* zoom level
|
||||
*/
|
||||
|
||||
ret = timepos_t (tmap->quarters_at (presnap).round_to_subdivision (get_grid_beat_divisions(_grid_type), direction));
|
||||
ret = timepos_t (tmap->quarters_at (presnap).round_to_subdivision (get_grid_beat_divisions (grid_type), direction));
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -568,10 +568,10 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider
|
|||
Editing::ZoomFocus _zoom_focus;
|
||||
virtual Editing::ZoomFocus effective_zoom_focus() const { return _zoom_focus; }
|
||||
|
||||
Temporal::timepos_t _snap_to_bbt (Temporal::timepos_t const & start,
|
||||
Temporal::RoundMode direction,
|
||||
ARDOUR::SnapPref gpref,
|
||||
Editing::GridType grid_type) const;
|
||||
Temporal::timepos_t snap_to_bbt_via_grid (Temporal::timepos_t const & start,
|
||||
Temporal::RoundMode direction,
|
||||
ARDOUR::SnapPref gpref,
|
||||
Editing::GridType grid_type) const;
|
||||
|
||||
virtual Temporal::timepos_t snap_to_grid (Temporal::timepos_t const & start,
|
||||
Temporal::RoundMode direction,
|
||||
|
|
|
|||
|
|
@ -1728,10 +1728,10 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT
|
|||
|
||||
|
||||
GridType
|
||||
Editor::determine_mapping_grid_snap(timepos_t t)
|
||||
Editor::determine_mapping_grid_snap (timepos_t t)
|
||||
{
|
||||
timepos_t snapped = _snap_to_bbt (t, RoundNearest, SnapToGrid_Unscaled, GridTypeBeat);
|
||||
timepos_t snapped_to_bar = _snap_to_bbt (t, RoundNearest, SnapToGrid_Unscaled, GridTypeBar);
|
||||
timepos_t snapped = snap_to_bbt_via_grid (t, RoundNearest, SnapToGrid_Unscaled, GridTypeBeat);
|
||||
timepos_t snapped_to_bar = snap_to_bbt_via_grid (t, RoundNearest, SnapToGrid_Unscaled, GridTypeBar);
|
||||
const double unsnapped_pos = time_to_pixel_unrounded (t);
|
||||
const double snapped_pos = time_to_pixel_unrounded (snapped);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue