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

Grid align scrollbar movement #183

Open
rm-code opened this issue Oct 27, 2017 · 1 comment
Open

Grid align scrollbar movement #183

rm-code opened this issue Oct 27, 2017 · 1 comment

Comments

@rm-code
Copy link
Owner

rm-code commented Oct 27, 2017

Scrollbar cursors still aren't aligning to the grid correctly.

Example-code by Antti Riikonen:

from math import *
# Input text has this many lines (starts at 0 because that's where you'll probably be indexing from)
textHeight=200
# Scrollbar has this many lines
scrollbarHeight=34

def scrollbarPos(textHeight, scrollbarHeight, currentHeight):
    # One scrollbar line corresponds to at least this many lines of text
    minSegmentHeight = floor(textHeight / scrollbarHeight)

    # How many extra lines we have that don't fit neatly into segments of minSegmentHeight size
    remainder = textHeight-scrollbarHeight*minSegmentHeight
    # Extra line is added to a scrollbar segment after each remainderSplit number of lines
    remainderSplit = textHeight / remainder

    return floor((currentHeight - floor(currentHeight / remainderSplit)) / minSegmentHeight)

print("Text height: ", textHeight, ", scrollbar height: ",scrollbarHeight,", minSegmentHeight: ",floor(textHeight / scrollbarHeight),", remainder: ", textHeight-scrollbarHeight*floor(textHeight / scrollbarHeight))
for i in range(textHeight):
    print ("Line ",i,"/",textHeight,", scrollbar at ",scrollbarPos(textHeight,scrollbarHeight, i))
@rm-code rm-code added this to the UI milestone Oct 27, 2017
@rm-code rm-code self-assigned this Oct 27, 2017
@rm-code rm-code removed this from the UI milestone Nov 7, 2017
@rm-code
Copy link
Owner Author

rm-code commented Sep 8, 2018

This should actually be listed as a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant