raylib: frame independent scroller (#36227)

* rm that

* almost

* yess

* some work

* more

* todo

* okay viber is good once in a while

* temp

* chadder can't do this

* revert

* this was broken anyway

* fixes

* mouse wheel scroll

* some clean up

* kinda works

* way better

* can tap to stop

* more clean up

* more clean up

* revert last mouse

* fix

* debug only

* no print

* ahh setup.py fps doesn't affect DEFAULT_FPS ofc

* rest

* fix text

* fix touch valid for network
This commit is contained in:
Shane Smiskol
2025-09-30 22:25:43 -07:00
committed by GitHub
parent 63e0e038fa
commit 5f33b2fb2d
9 changed files with 123 additions and 190 deletions
+4 -4
View File
@@ -53,14 +53,14 @@ class TextWindow(Widget):
self._textarea_rect = rl.Rectangle(MARGIN, MARGIN, gui_app.width - MARGIN * 2, gui_app.height - MARGIN * 2)
self._wrapped_lines = wrap_text(text, FONT_SIZE, self._textarea_rect.width - 20)
self._content_rect = rl.Rectangle(0, 0, self._textarea_rect.width - 20, len(self._wrapped_lines) * LINE_HEIGHT)
self._scroll_panel = GuiScrollPanel(show_vertical_scroll_bar=True)
self._scroll_panel._offset.y = -max(self._content_rect.height - self._textarea_rect.height, 0)
self._scroll_panel = GuiScrollPanel()
self._scroll_panel._offset_filter_y.x = -max(self._content_rect.height - self._textarea_rect.height, 0)
def _render(self, rect: rl.Rectangle):
scroll = self._scroll_panel.handle_scroll(self._textarea_rect, self._content_rect)
scroll = self._scroll_panel.update(self._textarea_rect, self._content_rect)
rl.begin_scissor_mode(int(self._textarea_rect.x), int(self._textarea_rect.y), int(self._textarea_rect.width), int(self._textarea_rect.height))
for i, line in enumerate(self._wrapped_lines):
position = rl.Vector2(self._textarea_rect.x + scroll.x, self._textarea_rect.y + scroll.y + i * LINE_HEIGHT)
position = rl.Vector2(self._textarea_rect.x, self._textarea_rect.y + scroll + i * LINE_HEIGHT)
if position.y + LINE_HEIGHT < self._textarea_rect.y or position.y > self._textarea_rect.y + self._textarea_rect.height:
continue
rl.draw_text_ex(gui_app.font(), line, position, FONT_SIZE, 0, rl.WHITE)