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

fil3s: Scroll too long filenames into view

\o/
parent 142f92f1
Branches
Tags
1 merge request!564fil3s: Scroll too long filenames into view
Pipeline #9227 passed
import os
import uos
import stat
import math
from st3m.goose import Callable, Generator, Optional
from st3m.input import InputState
from ctx import Context
......@@ -38,6 +39,8 @@ class Browser(ActionView):
self._delete_hold_time = 1.5
self._delete_require_release = False
self._scroll_pos = 0.0
self.path = path
self.selected = selected
self.navigate = navigate
......@@ -75,13 +78,18 @@ class Browser(ActionView):
ctx.text(self.current_entry[1])
ctx.font_size = 24
ctx.move_to(0, 20)
ctx.font = "Camp Font 3"
xpos = 0.0
if (width := ctx.text_width(self.current_entry[0])) > 220:
xpos = math.sin(self._scroll_pos) * (width - 220) / 2
ctx.move_to(xpos, 20)
ctx.text(self.current_entry[0])
def think(self, ins: InputState, delta_ms: int) -> None:
super().think(ins, delta_ms)
self._scroll_pos += delta_ms / 1000
# Handle delete petal being held down
if ins.captouch.petals[0].pressed:
if not self._delete_require_release:
......@@ -222,5 +230,6 @@ class Browser(ActionView):
]
and self.select_enabled
)
self._scroll_pos = math.pi / 2
self._update_actions()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment