Handle choice menu overflow

This commit is contained in:
LoafyLemon 2024-05-29 22:16:58 +01:00
parent e9cadcdc89
commit 792467e25a

View File

@ -153,23 +153,31 @@ screen choice(items):
variant "pc"
default has_icons = any(x is not None for x in [e.kwargs.get("icon", None) for e in items])
default columns = math.ceil(len(items) / 12)
vbox:
hbox:
at gui_choice_show_hide
for i, entry in enumerate(items, 1):
for column in range(columns):
vbox:
$ start_index = column * 12
$ end_index = start_index + 12
for i, entry in enumerate(items[start_index:end_index], 1):
$ scale = (1.0 * (28 / max(28, len(entry.caption))))
$ icon = entry.kwargs.get("icon", None)
$ progress = entry.kwargs.get("progress", None)
vbox:
spacing 2
button:
action entry.action
# Handle columns
if columns > 1:
xmaximum (config.screen_width // columns)
if i < 10 and entry.action:
keysym ("K_"+str(i), "K_KP"+str(i))
text "[i]" style "choice_number":
text "[i+start_index]" style "choice_number":
at gui_perspective
hbox:
@ -257,12 +265,13 @@ style choice_button is button
style choice_button_text is button_text
style choice_vbox:
xalign 0.5
yanchor 1.0
ypos 0.75
align (0.5, 1.0)
spacing 10
style choice_hbox:
xalign 0.5
yanchor 1.0
ypos 0.75
spacing 2
style choice_button: