raylib: fix slow Toggles panel first load (#36061)

fix slow load on toggles page
pull/36045/merge
Shane Smiskol 2 days ago committed by GitHub
parent 15fcbf24f1
commit 2dc0f97c93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      system/ui/widgets/list_view.py

@ -213,6 +213,7 @@ class ListItem(Widget):
self.set_rect(rl.Rectangle(0, 0, ITEM_BASE_WIDTH, ITEM_BASE_HEIGHT)) self.set_rect(rl.Rectangle(0, 0, ITEM_BASE_WIDTH, ITEM_BASE_HEIGHT))
self._font = gui_app.font(FontWeight.NORMAL) self._font = gui_app.font(FontWeight.NORMAL)
self._icon_texture = gui_app.texture(os.path.join("icons", self.icon), ICON_SIZE, ICON_SIZE) if self.icon else None
# Cached properties for performance # Cached properties for performance
self._prev_max_width: int = 0 self._prev_max_width: int = 0
@ -261,8 +262,7 @@ class ListItem(Widget):
if self.title: if self.title:
# Draw icon if present # Draw icon if present
if self.icon: if self.icon:
icon_texture = gui_app.texture(os.path.join("icons", self.icon), ICON_SIZE, ICON_SIZE) rl.draw_texture(self._icon_texture, int(content_x), int(self._rect.y + (ITEM_BASE_HEIGHT - self._icon_texture.width) // 2), rl.WHITE)
rl.draw_texture(icon_texture, int(content_x), int(self._rect.y + (ITEM_BASE_HEIGHT - icon_texture.width) // 2), rl.WHITE)
text_x += ICON_SIZE + ITEM_PADDING text_x += ICON_SIZE + ITEM_PADDING
# Draw main text # Draw main text

Loading…
Cancel
Save