Skip to content
Snippets Groups Projects
Commit 93e13a9f authored by dos's avatar dos Committed by ave
Browse files

py,st3m: MenuItemAppLaunch: Scroll too long labels into view

I believe this concludes the scrolling label saga.
parent 50a8a541
No related branches found
No related tags found
No related merge requests found
Pipeline #8212 passed
......@@ -18,6 +18,7 @@ import stat
import sys
import sys_display
import random
from math import sin
log = Log(__name__)
......@@ -320,6 +321,8 @@ class MenuItemAppLaunch(MenuItem):
def __init__(self, bundle: BundleMetadata):
self._bundle = bundle
self._instance: Optional[Application] = None
self._scroll_pos = 0.0
self._highlighted = False
def press(self, vm: Optional[ViewManager]) -> None:
if vm is None:
......@@ -340,6 +343,21 @@ class MenuItemAppLaunch(MenuItem):
def label(self) -> str:
return self._bundle.name
def highlight(self, active: bool) -> None:
self._highlighted = active
self._scroll_pos = 0.0
def draw(self, ctx: Context) -> None:
ctx.save()
if self._highlighted and (width := ctx.text_width(self.label())) > 220:
ctx.translate(sin(self._scroll_pos) * (width - 220) / 2, 0)
super().draw(ctx)
ctx.restore()
def think(self, ins: InputState, delta_ms: int) -> None:
if self._highlighted:
self._scroll_pos += delta_ms / 1000
class BundleManager:
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment