From b33f18db9f801cd265ce36409ff746c1f7e94937 Mon Sep 17 00:00:00 2001
From: moon2 <moon2protonmail@protonmail.com>
Date: Thu, 23 Nov 2023 18:42:26 +0100
Subject: [PATCH] Revert "audio_config: Push submenus onto the view stack"
This reverts commit 6df6c9a06eb3cadcad0e1a53b4ce0259b294b05c.
---
python_payload/apps/audio_config/__init__.py | 113 +++++++++----------
1 file changed, 54 insertions(+), 59 deletions(-)
diff --git a/python_payload/apps/audio_config/__init__.py b/python_payload/apps/audio_config/__init__.py
index 827a606eb6..db87a1cfe5 100644
--- a/python_payload/apps/audio_config/__init__.py
+++ b/python_payload/apps/audio_config/__init__.py
@@ -1,5 +1,4 @@
from st3m.application import Application
-from st3m.ui.view import View, ViewTransitionDirection
import math, random, sys_display
from st3m import settings
import audio
@@ -272,9 +271,11 @@ class Drawable:
class Submenu(Drawable):
def __init__(self, press):
super().__init__(press)
+ self.submenu_active = False
def draw(self, ctx):
- self._draw(ctx)
+ if self.submenu_active:
+ self._draw(ctx)
def _draw(self, ctx):
# override w specific implementation!
@@ -564,18 +565,6 @@ class Press:
self.select_pressed = False
-class SubView(View):
- def __init__(self, menu, app):
- self.menu = menu
- self.app = app
-
- def think(self, ins, delta_ms):
- 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)
@@ -607,45 +596,52 @@ class App(Application):
def draw(self, ctx):
self.ctx = ctx
- self.draw_bg()
- ctx.save()
- ctx.rgb(*colours.GO_GREEN)
- ctx.rotate(math.tau / 10)
- for i in range(5):
- if i == 2:
+ 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)
+ ctx.rotate(math.tau / 10)
+ for i in range(5):
+ if i == 2:
+ ctx.rotate(math.tau / 5)
+ continue
+ ctx.round_rectangle(-40, -110, 80, 45, 6).stroke()
ctx.rotate(math.tau / 5)
- continue
- ctx.round_rectangle(-40, -110, 80, 45, 6).stroke()
- ctx.rotate(math.tau / 5)
- ctx.restore()
+ ctx.restore()
- ctx.text_align = ctx.CENTER
- ctx.rotate(math.tau / 10)
- ctx.move_to(0, -91)
- ctx.text("volume")
- ctx.move_to(0, -74)
- ctx.text("control")
- ctx.move_to(0, 0)
- ctx.rotate(math.tau * (1 / 5 + 1 / 2))
- ctx.move_to(0, 92)
- ctx.text("inputs")
- ctx.move_to(0, 0)
- ctx.rotate(math.tau * 2 / 5)
- ctx.move_to(0, 92)
- ctx.text("speaker")
- ctx.move_to(0, 0)
- ctx.rotate(math.tau * (1 / 5 + 1 / 2))
- ctx.move_to(0, -91)
- ctx.text("head")
- ctx.move_to(0, -74)
- ctx.text("phones")
- ctx.rotate(math.tau / 10)
- ctx.move_to(0, 0)
- ctx.text("audio config")
- ctx.rgb(0.7, 0.7, 0.7)
- ctx.font_size = 18
- ctx.move_to(0, 20)
- ctx.text("exit to save")
+ ctx.text_align = ctx.CENTER
+ ctx.rotate(math.tau / 10)
+ ctx.move_to(0, -91)
+ ctx.text("volume")
+ ctx.move_to(0, -74)
+ ctx.text("control")
+ ctx.move_to(0, 0)
+ ctx.rotate(math.tau * (1 / 5 + 1 / 2))
+ ctx.move_to(0, 92)
+ ctx.text("inputs")
+ ctx.move_to(0, 0)
+ ctx.rotate(math.tau * 2 / 5)
+ ctx.move_to(0, 92)
+ ctx.text("speaker")
+ ctx.move_to(0, 0)
+ ctx.rotate(math.tau * (1 / 5 + 1 / 2))
+ ctx.move_to(0, -91)
+ ctx.text("head")
+ ctx.move_to(0, -74)
+ ctx.text("phones")
+ ctx.rotate(math.tau / 10)
+ ctx.move_to(0, 0)
+ ctx.text("audio config")
+ ctx.rgb(0.7, 0.7, 0.7)
+ ctx.font_size = 18
+ ctx.move_to(0, 20)
+ ctx.text("exit to save")
self.press.select_pressed = False
self.press.left_pressed = False
@@ -655,12 +651,12 @@ class App(Application):
super().think(ins, delta_ms)
for i in range(1, 10, 2):
if self.input.captouch.petals[i].whole.pressed:
- if not self.is_active():
- self.vm.pop()
+ for menu in self.menus:
+ menu.submenu_active = False
if i < 5:
- self.vm.push(SubView(self.menus[i // 2], self))
+ self.menus[i // 2].submenu_active = True
elif i > 5:
- self.vm.push(SubView(self.menus[(i // 2) - 1], self))
+ self.menus[(i // 2) - 1].submenu_active = True
if (
self.input.buttons.app.right.pressed
@@ -674,12 +670,11 @@ class App(Application):
def on_enter(self, vm):
super().on_enter(vm)
- if self.vm.direction == ViewTransitionDirection.FORWARD:
- settings.load_all()
+ settings.load_all()
def on_exit(self):
- if self.vm.direction == ViewTransitionDirection.BACKWARD:
- settings.save_all()
+ settings.save_all()
+ super().on_exit()
if __name__ == "__main__":
--
GitLab