![]() (- (ceiling (/ (line-pixels text-field) (if (= max-box-pos 0) 1 max-box-pos)))))) (let* ((max-box-pos (get-max-box-pos scroll-bar))) (defun get-movement-rate (text-field scroll-bar) (* (- (get-line-amount text-field) (text-field-shown-lines text-field)) (sdl:get-font-size " " :size :h :font (get-text-font text-field)))) (floor (/ (h text-field) (sdl:get-font-size " " :size :h :font (get-text-font text-field))))) (defun text-field-shown-lines (text-field) (- (h scroll-bar) (h (get-scroll-box scroll-bar)))) I use aux (local variable) for objects (such as the scroll box within scroll-bar), let (also local variable) is used in all other cases (especially if logic is involved). Hitboxes are used for the collision checking, something I'll rewrite at a later time, but essentially it's a rectangle with an absolute position that is used by collision-checking for the mouse (in this case, outside of this it holds more parameters than just position). Text-scrolling is only doing vertical scrolling as I want to solve this before making it work horizontally as well, the scrolling portion of the code (that handles moving of the scroll-box) supports both. So what I essentially want, is for the last line to be drawn when the box has gone all the way down, rather than continue scrolling after. I'm trying to make a scrollbar that can scroll text in an text-area, I already searched for an answer on this (google, here, etc) and I found this:Īnd since a picture says more than a thousand words, here's a screenshot of the issue (The scrollbox is 30 pixels in height): So let me just get this right out of the way, I'm using SDL1.2 (Lispbuilder-sdl specifically, as I'm using Common Lisp), so on to the problem.
0 Comments
Leave a Reply. |