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

audio_config: Push submenus onto the view stack

This lets the OS button go back in the submenu hierarchy
consistently to other parts of the system.
parent a88552d9
No related branches found
No related tags found
1 merge request!485audio_config: Push submenus onto the view stack
Pipeline #12030 passed
from st3m.application import Application
from st3m.ui.view import View, ViewTransitionDirection
import math, random, sys_display
from st3m import settings
import audio
......@@ -271,10 +272,8 @@ class Drawable:
class Submenu(Drawable):
def __init__(self, press):
super().__init__(press)
self.submenu_active = False
def draw(self, ctx):
if self.submenu_active:
self._draw(ctx)
def _draw(self, ctx):
......@@ -565,6 +564,22 @@ class Press:
self.select_pressed = False
class SubView(View):
def __init__(self, menu, app):
self.menu = menu
self.app = app
def on_enter(self, vm):
self.vm = vm
def think(self, ins, delta_ms):
if self.vm.is_active(self):
self.app.think(ins, delta_ms)
def draw(self, ctx):
self.menu.draw(ctx)
class App(Application):
def __init__(self, app_ctx):
super().__init__(app_ctx)
......@@ -596,13 +611,6 @@ class App(Application):
def draw(self, ctx):
self.ctx = ctx
main_menu_active = True
for menu in self.menus:
menu.draw(self.ctx)
if menu.submenu_active:
main_menu_active = False
if main_menu_active:
self.draw_bg()
ctx.save()
ctx.rgb(*colours.GO_GREEN)
......@@ -651,12 +659,12 @@ class App(Application):
super().think(ins, delta_ms)
for i in range(1, 10, 2):
if self.input.captouch.petals[i].whole.pressed:
for menu in self.menus:
menu.submenu_active = False
if not self.is_active():
self.vm.pop()
if i < 5:
self.menus[i // 2].submenu_active = True
self.vm.push(SubView(self.menus[i // 2], self))
elif i > 5:
self.menus[(i // 2) - 1].submenu_active = True
self.vm.push(SubView(self.menus[(i // 2) - 1], self))
if (
self.input.buttons.app.right.pressed
......@@ -670,11 +678,12 @@ class App(Application):
def on_enter(self, vm):
super().on_enter(vm)
if self.vm.direction == ViewTransitionDirection.FORWARD:
settings.load_all()
def on_exit(self):
if self.vm.direction == ViewTransitionDirection.BACKWARD:
settings.save_all()
super().on_exit()
if __name__ == "__main__":
......
  • Phileas @pl

    mentioned in commit b33f18db

    By moon2 on 2023-11-23T17:43:46 (imported from GitLab)

    ·

    mentioned in commit b33f18db

    By moon2 on 2023-11-23T17:43:46 (imported from GitLab)

    Edited by Ghost User
    Toggle commit list
  • Phileas @pl

    mentioned in merge request !626 (merged)

    By moon2 on 2023-11-23T17:44:09 (imported from GitLab)

    ·

    mentioned in merge request !626 (merged)

    By moon2 on 2023-11-23T17:44:09 (imported from GitLab)

    Edited by Ghost User
    Toggle commit list
  • Phileas @pl

    mentioned in commit 63c44a11

    By moon2 on 2023-11-23T17:46:08 (imported from GitLab)

    ·

    mentioned in commit 63c44a11

    By moon2 on 2023-11-23T17:46:08 (imported from GitLab)

    Edited by Ghost User
    Toggle commit list
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment