Skip to content
Snippets Groups Projects

gr33nhouse: Scroll too long app names into view

Merged dos requested to merge dos/flow3r-firmware:gr33nhouse-scroll into main
1 unresolved thread

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
101 103
102 104 ctx.move_to(0, 0)
103 105 for idx, app in enumerate(self.apps):
104 if idx == self._sc.target_position():
106 target = idx == self._sc.target_position()
107 if target:
105 108 ctx.gray(0.0)
106 109 else:
107 110 ctx.gray(1.0)
108 111
109 112 if abs(self._sc.current_position() - idx) <= 5:
110 ctx.move_to(0, offset)
113 xpos = 0.0
114 if target and (width := ctx.text_width(app["name"])) > 220:
  • Contributor

    ctx.text_width is a fairly expensive call, maybe cache it whenever we switch between apps? You can have something like a text_width: Optional[float] which means 'no need to scroll' if it's None.

  • Author Maintainer

    There's no ctx in think, so it's not easy to do it right away when switching, and otherwise I'm not sure if it's worth the complexity - it's already being short-circuited for anything else than currently selected app, so it only does one call per draw anyway. Unlike !212 (merged) the difference in performance isn't really noticeable here ;)

  • Please register or sign in to reply
  • q3k
  • dos added 1 commit

    added 1 commit

    • ea105125 - gr33nhouse: Scroll too long app names into view

    Compare with previous version

  • q3k approved this merge request

    approved this merge request

  • q3k added 15 commits

    added 15 commits

    Compare with previous version

  • q3k enabled an automatic merge when the pipeline for d9c434aa succeeds

    enabled an automatic merge when the pipeline for d9c434aa succeeds

  • q3k merged

    merged

  • Please register or sign in to reply
    Loading