Page MenuHome

Text Editor: Add smooth scrolling

Authored by Kai Jægersen (kaio) on Sep 23 2019, 4:33 PM.
"Love" token, awarded by Andrea_Monzini."Burninate" token, awarded by Draise."Like" token, awarded by Fracture128."Love" token, awarded by intracube."Love" token, awarded by amonpaike."Love" token, awarded by johnsyed."Y So Serious" token, awarded by shader."Love" token, awarded by brilliant_ape."Like" token, awarded by Samirosman."Love" token, awarded by lucky3."Love" token, awarded by zgorg."Love" token, awarded by pablodp606."Love" token, awarded by monio."Like" token, awarded by fin.eskimo."Love" token, awarded by Arindam."Love" token, awarded by tintwotin."Like" token, awarded by cmbasnett.



This patch makes it so text in the text editor may be smooth scrolled.

Works by making st->top, st->left as floats, then calculate draw offsets and adding them to the draw coordinates.

This patch makes some changes in draw order so that text may be scrolled horizontally behind line numbers margin.

Does not change the behavior of scroll operators which use fixed values, e.g a mouse wheel still scrolls three lines. However drag scrolling (middle mouse pan, text scroll bar) now applies delta directly to st->top and st->left without being accumulated.

Also added behavior to reveal line when setting cursor on a partially visible line.

Diff Detail

Event Timeline

-- (zgorg) added a subscriber: -- (zgorg).EditedSep 24 2019, 4:53 PM
This comment has been deleted.

Would this make sense in other 2D editors also? e.g. the Outliner and properties?

@Aaron Carlisle (Blendify) From what I gathered, most 2d editors already share a common pan and scroll operator which on paper does support by-pixel scrolling. The text editor is a bit of an oddball here, being one of the last editors that still uses fixed line scrolling. There were some remarks in the code about it being left out, but no explanation as to why.

If you meant in terms of smooth animated scrolling using the mousewheel, it's not being tackled this round, however I'd be keen on trying to add support for this (and yes, I think it would be a nice, toggleable feature to have).

Campbell Barton (campbellbarton) requested changes to this revision.EditedNov 22 2019, 10:09 AM

Basic smooth scrolling could be supported for transitions.

Middle mouse panning could use existing smooth offset, rounding it once the operators finished.

Suggest look into VIEW2D_OT_smoothview, the text editor could use something like this for page up/down, scroll-wheel, centering the view.

This would give the pleasant experience of smooth transitions, without having to support floating point scrolling for all other interactions.

Note that full smooth scrolling support isn't a bad feature, I just rather avoid having to support it for all operators since it adds some maintenance overhead.

This revision now requires changes to proceed.Nov 22 2019, 10:09 AM

I looked into this and ended up committing a simpler implementation that's only active while scrolling.

rB3106ca8f6397: Text Editor: smooth scrolling.