Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Arcade [PyPi Release History](https://pypi.org/project/arcade/#history) page.

- GUI
- Fix a bug, where the caret of UIInputText was misplaced after resizing the widget
- Use incremental layout for UIScrollArea to improve performance of changing text

## 3.3.2

Expand Down
3 changes: 2 additions & 1 deletion arcade/examples/gui/1_layouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from datetime import datetime

import arcade
import arcade.gui
from arcade.gui import UIAnchorLayout, UIImage, UITextArea

arcade.resources.load_kenney_fonts()
Expand Down Expand Up @@ -186,5 +187,5 @@ def main():
window.run()


if __name__ == '__main__':
if __name__ == "__main__":
main()
6 changes: 3 additions & 3 deletions arcade/gui/experimental/scroll_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ def __init__(self, scroll_area: UIScrollArea, vertical: bool = True):

bind(self, "_thumb_hover", UIScrollBar.trigger_render)
bind(self, "_dragging", UIScrollBar.trigger_render)
bind(scroll_area, "scroll_x", UIScrollBar.trigger_full_render)
bind(scroll_area, "scroll_y", UIScrollBar.trigger_full_render)
bind(scroll_area, "rect", UIScrollBar.trigger_full_render)
bind(scroll_area, "scroll_x", self.trigger_full_render, weak=True)
bind(scroll_area, "scroll_y", self.trigger_full_render, weak=True)
bind(scroll_area, "rect", self.trigger_full_render, weak=True)

def on_event(self, event: UIEvent) -> bool | None:
# check if we are scrollable
Expand Down
5 changes: 3 additions & 2 deletions arcade/gui/widgets/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,14 +855,14 @@ def __init__(
),
)

self.layout = pyglet.text.layout.ScrollableTextLayout(
self.layout = pyglet.text.layout.IncrementalTextLayout(
self.doc,
width=int(self.content_width),
height=int(self.content_height),
multiline=multiline,
)

bind(self, "rect", self._update_layout)
bind(self, "rect", UITextArea._update_layout)

def fit_content(self):
"""Set the width and height of the text area to contain the whole text."""
Expand Down Expand Up @@ -894,6 +894,7 @@ def _update_layout(self):
layout.begin_update()
layout.width = content_width
layout.height = content_height
layout.y = 0 # reset y position to 0 (Required by IncrementalTextLayout)
layout.end_update()

@override
Expand Down
Loading