Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes bug with pasting of TCOs (#5840) #5847

Merged
merged 3 commits into from
Dec 25, 2020
Merged

Commits on Dec 13, 2020

  1. Fixes bug with pasting of TCOs (LMMS#5840)

    	TimePos::quantize works for negative values, but ends
    up snapping the TCO to the opposite direction. This is because the
    snapping happens in the direction of the origin, which is left for
    positive values and right for negative values.
    	That wasn't accounted for in the pasteSelection method
    and we ended up with wrong positions when pasting before the
    TCO(s) we copied. This PR attempts a fix by doing the
    following:
    
    	- Changing TimePos::quantize to have a boolean parameter that
    will define whether it snaps the position up if we are halfway through
    the interval or not (this removes the need to use that trick of
    subtracting "TimePos::ticksPerBar() * snapSize / 2" from the offset to
    try to "bias" it.
    	- Checking if we need quantizing at all by checking if the
    offset falls outsize the snap grid.
    	- If we do need quantizing and the offset is negative we
    subtract one snap, since the quantization will move the TCO to the
    opposite end (to the right). Then we call quantize.
    IanCaio committed Dec 13, 2020
    Configuration menu
    Copy the full SHA
    b7647d4 View commit details
    Browse the repository at this point in the history
  2. Uses an alternative fix for the issue

    	This PR reverts the changes from the previous ones and
    implements an alternative fix for the snapping issue. I'm pushing the
    changes for the sake of comparison, so it can be decided which approach
    is better.
    	This one might be better as it changes less code and might be
    slightly less confusing than the previous one to the reader.
    IanCaio committed Dec 13, 2020
    Configuration menu
    Copy the full SHA
    4b4c793 View commit details
    Browse the repository at this point in the history

Commits on Dec 14, 2020

  1. Fixes a calculation on TimePos::quantize

    	Since we are working with integers, using "offset /
    (interval/2)" would be problematic if interval was odd. We instead
    multiply both sides by two and use "(2 * offset) / interval" to obtain
    the result for snapUp.
    IanCaio committed Dec 14, 2020
    Configuration menu
    Copy the full SHA
    971b14c View commit details
    Browse the repository at this point in the history