diff --git a/docs/api/ctx.rst b/docs/api/ctx.rst index 4f50aaafb0c4c97f9ecb2eb4136b795a2c1d3f67..0daaed0798e1a610acfc8bd2c6d5e3cd7010c1cc 100644 --- a/docs/api/ctx.rst +++ b/docs/api/ctx.rst @@ -1,6 +1,7 @@ ``ctx`` module ============== -.. automodule:: st3m.ui.ctx +.. automodule:: ctx :members: :undoc-members: + :member-order: groupwise diff --git a/python_payload/mypystubs/badge_link.pyi b/python_payload/mypystubs/badge_link.pyi index 2d2df2110d6cde924d1810c258a38f02897c11c0..2190f3b8caef4c8b595327cb4148032ac5511da6 100644 --- a/python_payload/mypystubs/badge_link.pyi +++ b/python_payload/mypystubs/badge_link.pyi @@ -35,7 +35,7 @@ Pin(4) try: from typing import Protocol except ImportError: - from typing_extensions import Protocol + from typing_extensions import Protocol # type: ignore import machine diff --git a/python_payload/st3m/ui/ctx.py b/python_payload/mypystubs/ctx.pyi similarity index 71% rename from python_payload/st3m/ui/ctx.py rename to python_payload/mypystubs/ctx.pyi index 5c9c7aedb404af49af9a21c6891e989e80793479..a8dce095450ac618ab44a67f1b9d05eb3e8d9b2c 100644 --- a/python_payload/st3m/ui/ctx.py +++ b/python_payload/mypystubs/ctx.pyi @@ -1,7 +1,9 @@ -from st3m.goose import ABCBase, abstractmethod, List +try: + from typing import Protocol +except ImportError: + from typing_extensions import Protocol # type: ignore - -class Ctx(ABCBase): +class Context(Protocol): """ Ctx is the rendering/rasterization API used by st3m. @@ -20,35 +22,23 @@ class Ctx(ABCBase): For more information, see: https://ctx.graphics/ """ - __slots__ = ( - "font_size", - "text_align", - "text_baseline", - "line_width", - "global_alpha", - ) - - CENTER = "center" - RIGHT = "right" - MIDDLE = "middle" + font_size: float = 10 + text_align: str = "start" + text_baseline: str = "alphabetic" + line_width: float = 1.0 + global_alpha: float = 1.0 + font: str = "" - @abstractmethod - def __init__(self) -> None: - self.font_size: float = 10 - self.text_align: str = "start" - self.text_baseline: str = "alphabetic" - self.line_width: float = 1.0 - self.global_alpha: float = 1.0 - self.font: str = "" + CENTER: str = "center" + RIGHT: str = "right" + MIDDLE: str = "middle" - @abstractmethod + def __init__(self) -> None: ... def text_width(self, text: str) -> float: """ Calculates width of rendered text, without rendering it. """ pass - - @abstractmethod def get_font_name(self, ix: int) -> str: """ Returns font name from internal font index. See ctx_config.h for @@ -57,32 +47,24 @@ class Ctx(ABCBase): TODO(q3k): expose these font indices into mpy """ pass - - @abstractmethod - def begin_path(self) -> "Ctx": + def begin_path(self) -> "Context": """ Clears the current path if any. """ pass - - @abstractmethod - def save(self) -> "Ctx": + def save(self) -> "Context": """ Stores the transform, clipping state, fill and stroke sources, font size, stroking and dashing options. """ pass - - @abstractmethod - def restore(self) -> "Ctx": + def restore(self) -> "Context": """ Restores the state previously saved with save, calls to save/restore should be balanced. """ pass - - @abstractmethod - def start_frame(self) -> "Ctx": + def start_frame(self) -> "Context": """ Prepare for rendering a new frame, clears internal drawlist and initializes the state. @@ -90,9 +72,7 @@ class Ctx(ABCBase): TODO(q3k): we probably shouldn't expose this """ pass - - @abstractmethod - def end_frame(self) -> "Ctx": + def end_frame(self) -> "Context": """ We're done rendering a frame, this does nothing on a context created for a framebuffer, where drawing commands are immediate. @@ -100,53 +80,39 @@ class Ctx(ABCBase): TODO(q3k): we probably shouldn't expose this """ pass - - @abstractmethod - def start_group(self) -> "Ctx": + def start_group(self) -> "Context": """ Start a compositing group. """ pass - - @abstractmethod - def end_group(self) -> "Ctx": + def end_group(self) -> "Context": """ End a compositing group, the global alpha, compositing mode and blend mode set before this call is used to apply the group. """ pass - - @abstractmethod - def clip(self) -> "Ctx": + def clip(self) -> "Context": """ Use the current path as a clipping mask, subsequent draw calls are limited by the path. The only way to increase the visible area is to first call save and then later restore to undo the clip. """ pass - - @abstractmethod - def rotate(self, x: float) -> "Ctx": + def rotate(self, x: float) -> "Context": """ Add rotation to the user to device space transform. """ pass - - @abstractmethod - def scale(self, x: float, y: float) -> "Ctx": + def scale(self, x: float, y: float) -> "Context": """ Scales the user to device transform. """ pass - - @abstractmethod - def translate(self, x: float, y: float) -> "Ctx": + def translate(self, x: float, y: float) -> "Context": """ Adds translation to the user to device transform. """ pass - - @abstractmethod def apply_transform( self, a: float, @@ -158,133 +124,101 @@ class Ctx(ABCBase): g: float, h: float, i: float, - ) -> "Ctx": + ) -> "Context": """ Adds a 3x3 matrix on top of the existing user to device space transform. TODO(q3k): we probably shouldn't expose this """ pass - - @abstractmethod - def line_to(self, x: float, y: float) -> "Ctx": + def line_to(self, x: float, y: float) -> "Context": """ Draws a line segment from the position of the last {line,move,curve,quad}_to) to the given coordinates. """ pass - - @abstractmethod - def move_to(self, x: float, y: float) -> "Ctx": + def move_to(self, x: float, y: float) -> "Context": """ Moves the virtual pen to the given coordinates without drawing anything. """ pass - - @abstractmethod def curve_to( self, cx0: float, cy0: float, cx1: float, cy1: float, x: float, y: float - ) -> "Ctx": + ) -> "Context": """ TOD(q3k): document """ pass - - @abstractmethod - def quad_to(self, cx: float, cy: float, x: float, y: float) -> "Ctx": + def quad_to(self, cx: float, cy: float, x: float, y: float) -> "Context": """ TOD(q3k): document """ pass - - @abstractmethod - def gray(self, a: float) -> "Ctx": + def gray(self, a: float) -> "Context": """ Set current draw color to a floating point grayscale value from 0 to 1. """ pass - - @abstractmethod - def rgb(self, r: float, g: float, b: float) -> "Ctx": + def rgb(self, r: float, g: float, b: float) -> "Context": """ Set current draw color to an RGB color defined by component values from 0 to 1. """ pass - - @abstractmethod - def rgba(self, r: float, g: float, b: float, a: float) -> "Ctx": + def rgba(self, r: float, g: float, b: float, a: float) -> "Context": """ Set current draw color to an RGBA color defined by component values from 0 to 1. """ pass - - @abstractmethod def arc_to( self, x1: float, y1: float, x2: float, y2: float, radius: float - ) -> "Ctx": + ) -> "Context": """ TOD(q3k): document """ pass - - @abstractmethod - def rel_line_to(self, x: float, y: float) -> "Ctx": + def rel_line_to(self, x: float, y: float) -> "Context": """ TOD(q3k): document """ pass - - @abstractmethod - def rel_move_to(self, x: float, y: float) -> "Ctx": + def rel_move_to(self, x: float, y: float) -> "Context": """ TOD(q3k): document """ pass - - @abstractmethod def rel_curve_to( self, cx0: float, cy0: float, cx1: float, cy1: float, x: float, y: float - ) -> "Ctx": + ) -> "Context": """ TOD(q3k): document """ pass - - @abstractmethod - def rel_quad_to(self, cx: float, cy: float, x: float, y: float) -> "Ctx": + def rel_quad_to(self, cx: float, cy: float, x: float, y: float) -> "Context": """ TOD(q3k): document """ pass - - @abstractmethod def rel_arc_to( self, x1: float, y1: float, x2: float, y2: float, radius: float - ) -> "Ctx": + ) -> "Context": """ TOD(q3k): document """ pass - - @abstractmethod - def rectangle(self, x: float, y: float, w: float, h: float) -> "Ctx": + def rectangle(self, x: float, y: float, w: float, h: float) -> "Context": """ TOD(q3k): document """ pass - - @abstractmethod def round_rectangle( self, x: float, y: float, w: float, h: float, r: float - ) -> "Ctx": + ) -> "Context": """ TOD(q3k): document """ pass - - @abstractmethod def arc( self, x: float, @@ -293,49 +227,37 @@ class Ctx(ABCBase): angle1: float, angle2: float, direction: float, - ) -> "Ctx": + ) -> "Context": """ TOD(q3k): document """ pass - - @abstractmethod - def close_path(self) -> "Ctx": + def close_path(self) -> "Context": """ TOD(q3k): document """ pass - - @abstractmethod - def preserve(self) -> "Ctx": + def preserve(self) -> "Context": """ TOD(q3k): document """ pass - - @abstractmethod - def fill(self) -> "Ctx": + def fill(self) -> "Context": """ TOD(q3k): document """ pass - - @abstractmethod - def stroke(self) -> "Ctx": + def stroke(self) -> "Context": """ TOD(q3k): document """ pass - - @abstractmethod - def paint(self) -> "Ctx": + def paint(self) -> "Context": """ TOD(q3k): document """ pass - - @abstractmethod - def linear_gradient(self, x0: float, y0: float, x1: float, y1: float) -> "Ctx": + def linear_gradient(self, x0: float, y0: float, x1: float, y1: float) -> "Context": """ Change the source to a linear gradient from x0,y0 to x1,y1, by default an empty gradient from black to white exists, add stops with @@ -344,11 +266,9 @@ class Ctx(ABCBase): TODO(q3k): check gradient_add_stop """ pass - - @abstractmethod def radial_gradient( self, x0: float, y0: float, r0: float, x1: float, y1: float, r1: float - ) -> "Ctx": + ) -> "Context": """ Change the source to a radial gradient from a circle x0,y0 with radius0 to an outer circle x1,y1 with radidus r1. @@ -357,16 +277,12 @@ class Ctx(ABCBase): radiuses are in use. """ pass - - @abstractmethod - def logo(self, x: float, y: float, dim: float) -> "Ctx": + def logo(self, x: float, y: float, dim: float) -> "Context": """ TOD(q3k): document """ pass - - @abstractmethod - def text(self, text: str) -> "Ctx": + def text(self, text: str) -> "Context": """ TOD(q3k): document """ diff --git a/python_payload/mypystubs/hardware.pyi b/python_payload/mypystubs/hardware.pyi index 267e3628a78cbfc7d48e86b5e514c0ba3518d484..57de5ae57b1b028533bf9e3ba301d96a7557d6ee 100644 --- a/python_payload/mypystubs/hardware.pyi +++ b/python_payload/mypystubs/hardware.pyi @@ -1,12 +1,12 @@ import time -from st3m.ui.ctx import Ctx +from ctx import Context def freertos_sleep(ms: int) -> None: ... -def get_ctx() -> Ctx: ... +def get_ctx() -> Context: ... def display_pipe_full() -> bool: ... def display_pipe_flush() -> None: ... -def display_update(c: Ctx) -> None: ... +def display_update(c: Context) -> None: ... def display_set_backlight(percent: int) -> None: ... def usb_connected() -> bool: ... def usb_console_active() -> bool: ... @@ -18,7 +18,7 @@ def left_button_get() -> int: ... def right_button_get() -> int: ... def menu_button_set_left(left: int) -> None: ... def menu_button_get_left() -> int: ... -def scope_draw(ctx: Ctx) -> None: ... +def scope_draw(ctx: Context) -> None: ... BUTTON_PRESSED_LEFT: int BUTTON_PRESSED_RIGHT: int diff --git a/python_payload/mypystubs/machine.pyi b/python_payload/mypystubs/machine.pyi index b0640990879a89f5d54835c7517b74611ffb0f3a..4e527e1d56f69cdd720f53c286fce2cf5e94a8d6 100644 --- a/python_payload/mypystubs/machine.pyi +++ b/python_payload/mypystubs/machine.pyi @@ -1,7 +1,7 @@ try: from typing import Protocol except ImportError: - from typing_extensions import Protocol + from typing_extensions import Protocol # type: ignore class Pin(Protocol): """ diff --git a/python_payload/st3m/__init__.py b/python_payload/st3m/__init__.py index d10e6483253ff0043a008d0b091fffb787b948c2..9e04bc8a9c686c8421f0b1887885b8b7201ee5f7 100644 --- a/python_payload/st3m/__init__.py +++ b/python_payload/st3m/__init__.py @@ -1,5 +1,4 @@ from st3m.reactor import Reactor, Responder -from st3m.ui.ctx import Ctx from st3m.input import InputState, InputController __all__ = [ @@ -7,5 +6,4 @@ __all__ = [ "Responder", "InputState", "InputController", - "Ctx", ] diff --git a/python_payload/st3m/input.py b/python_payload/st3m/input.py index ef771bddff62f0b65110bdbd8f06bf2b4cfd141a..17f6b78cd8da60dab38f5b8f1b9f723c92b87372 100644 --- a/python_payload/st3m/input.py +++ b/python_payload/st3m/input.py @@ -1,5 +1,4 @@ from st3m.goose import List, Optional, Enum, Tuple -from st3m.ui.ctx import Ctx import hardware import captouch diff --git a/python_payload/st3m/reactor.py b/python_payload/st3m/reactor.py index 2d0b7906b66d4fc25a585a242fb07b837c1c988e..33d9a51058a0684b5807849844d3a3fad06365ad 100644 --- a/python_payload/st3m/reactor.py +++ b/python_payload/st3m/reactor.py @@ -1,6 +1,6 @@ from st3m.goose import ABCBase, abstractmethod, List, Optional from st3m.input import InputState -from st3m.ui.ctx import Ctx +from ctx import Context import time, hardware @@ -29,7 +29,7 @@ class Responder(ABCBase): pass @abstractmethod - def draw(self, ctx: Ctx) -> None: + def draw(self, ctx: Context) -> None: """ draw() will be called when the Responder should draw, ie. generate a drawlist by performing calls on the given ctx object. @@ -91,7 +91,7 @@ class Reactor: self._ts: int = 0 self._last_tick: Optional[int] = None self._last_ctx_get: Optional[int] = None - self._ctx: Optional[Ctx] = None + self._ctx: Optional[Context] = None self.stats = ReactorStats() def set_top(self, top: Responder) -> None: diff --git a/python_payload/st3m/settings.py b/python_payload/st3m/settings.py index 0e61d92ce9f44d67f540b3be6936bfa6e85a874c..9ef81a0a046a14f35b1f9d647715b567ca5b551c 100644 --- a/python_payload/st3m/settings.py +++ b/python_payload/st3m/settings.py @@ -10,12 +10,13 @@ request. import json -from st3m import Ctx, InputState, Responder, logging +from st3m import InputState, Responder, logging from st3m.goose import ABCBase, abstractmethod, Any, Dict, List, Optional, Callable from st3m.ui.menu import MenuController, MenuItem, MenuItemBack from st3m.ui.elements.menus import SimpleMenu from st3m.ui.view import ViewManager from st3m.utils import lerp, ease_out_cubic, reduce +from ctx import Context log = logging.Log(__name__, level=logging.INFO) @@ -211,7 +212,7 @@ class OnOffWidget(TunableWidget): self._progress = 1.0 - (self._animating / animation_duration) self._prev_state = self._state - def draw(self, ctx: Ctx) -> None: + def draw(self, ctx: Context) -> None: # TODO(pippin): graphical glitches without the two next lines ctx.rectangle(-200, -200, 10, 10) ctx.fill() @@ -257,7 +258,7 @@ class SettingsMenuItem(MenuItem): def label(self) -> str: return self.tunable._name - def draw(self, ctx: Ctx) -> None: + def draw(self, ctx: Context) -> None: ctx.move_to(40, 0) ctx.text_align = ctx.RIGHT super().draw(ctx) diff --git a/python_payload/st3m/ui/elements/menus.py b/python_payload/st3m/ui/elements/menus.py index c7617af741037688faf2ed3bbc4d4bf454d7ab2b..e5091a57c16264af4a81d3a5d6fe9e826a502488 100644 --- a/python_payload/st3m/ui/elements/menus.py +++ b/python_payload/st3m/ui/elements/menus.py @@ -3,10 +3,11 @@ from st3m.ui.view import ViewManager from st3m.ui.elements.visuals import Sun, GroupRing, FlowerIcon from st3m.ui.menu import MenuController, MenuItem -from st3m import Ctx, InputState +from st3m import InputState from st3m.utils import lerp, tau import math +from ctx import Context class SimpleMenu(MenuController): @@ -17,7 +18,7 @@ class SimpleMenu(MenuController): SIZE_LARGE = 30 SIZE_SMALL = 20 - def draw(self, ctx: Ctx) -> None: + def draw(self, ctx: Context) -> None: ctx.gray(0) ctx.rectangle(-120, -120, 240, 240).fill() @@ -61,7 +62,7 @@ class SunMenu(MenuController): self._ts += delta_ms def _draw_item_angled( - self, ctx: Ctx, item: MenuItem, angle: float, activity: float + self, ctx: Context, item: MenuItem, angle: float, activity: float ) -> None: size = lerp(20, 40, activity) color = lerp(0, 1, activity) @@ -75,7 +76,7 @@ class SunMenu(MenuController): item.draw(ctx) ctx.restore() - def draw(self, ctx: Ctx) -> None: + def draw(self, ctx: Context) -> None: ctx.gray(0) ctx.rectangle(-120, -120, 240, 240).fill() @@ -124,7 +125,7 @@ class FlowerMenu(MenuController): self.ui.think(ins, delta_ms) self._ts += delta_ms - def draw(self, ctx: Ctx) -> None: + def draw(self, ctx: Context) -> None: ctx.gray(0) ctx.rectangle(-120, -120, 240, 240).fill() # for item in self.ui.items_ring: diff --git a/python_payload/st3m/ui/elements/overlays.py b/python_payload/st3m/ui/elements/overlays.py index fa06a953a5a188601f5b25c5e4a22e5a0ceae3b7..f0ce39a65a9dbb3b37b8eb9172c5148a98a94f03 100644 --- a/python_payload/st3m/ui/elements/overlays.py +++ b/python_payload/st3m/ui/elements/overlays.py @@ -6,9 +6,10 @@ for persistent, anchored symbols like charging symbols, toasts, debug overlays, etc. """ -from st3m import Responder, Ctx, InputState, Reactor +from st3m import Responder, InputState, Reactor from st3m.goose import Dict, Enum, List, ABCBase, abstractmethod from st3m.utils import tau +from ctx import Context class OverlayKind(Enum): @@ -62,7 +63,7 @@ class Compositor(Responder): for overlay in self._enabled_overlays(): overlay.think(ins, delta_ms) - def draw(self, ctx: Ctx) -> None: + def draw(self, ctx: Context) -> None: self.main.draw(ctx) for overlay in self._enabled_overlays(): overlay.draw(ctx) @@ -132,7 +133,7 @@ class OverlayDebug(Overlay): text = [f.text() for f in self.fragments if f.text() != ""] return " ".join(text) - def draw(self, ctx: Ctx) -> None: + def draw(self, ctx: Context) -> None: ctx.save() ctx.text_align = ctx.CENTER ctx.text_baseline = ctx.MIDDLE @@ -159,7 +160,7 @@ class OverlayCaptouch(Overlay): self.phi = phi self.rad = rad - def draw(self, ctx: Ctx) -> None: + def draw(self, ctx: Context) -> None: if not self.pressed: return @@ -180,7 +181,7 @@ class OverlayCaptouch(Overlay): for dot in self.dots: dot.think(ins, delta_ms) - def draw(self, ctx: Ctx) -> None: + def draw(self, ctx: Context) -> None: for dot in self.dots: ctx.save() dot.draw(ctx) diff --git a/python_payload/st3m/ui/elements/visuals.py b/python_payload/st3m/ui/elements/visuals.py index 760801a86422419f7b1cf442032ffbe4f900605c..b39692a53585064780a73f5259bf68ef93e533ee 100644 --- a/python_payload/st3m/ui/elements/visuals.py +++ b/python_payload/st3m/ui/elements/visuals.py @@ -1,7 +1,8 @@ from st3m.utils import xy_from_polar, tau from st3m.property import PUSH_RED, GO_GREEN, BLACK from st3m.goose import List, Optional -from st3m import Responder, Ctx, InputState +from st3m import Responder, InputState +from ctx import Context import random @@ -23,7 +24,7 @@ class Sun(Responder): self.ts += delta_ms pass - def draw(self, ctx: Ctx) -> None: + def draw(self, ctx: Context) -> None: nrays = 10 angle_per_ray = 6.28 / nrays for i in range(nrays): @@ -68,7 +69,7 @@ class GroupRing(Responder): for item in self.items_ring: item.think(ins, delta_ms) - def draw(self, ctx: Ctx) -> None: + def draw(self, ctx: Context) -> None: if self.item_center: self.item_center.draw(ctx) @@ -110,7 +111,7 @@ class FlowerIcon(Responder): self.ts += delta_ms pass - def draw(self, ctx: Ctx) -> None: + def draw(self, ctx: Context) -> None: x = self.x y = self.y petal_size = 0.0 diff --git a/python_payload/st3m/ui/interactions.py b/python_payload/st3m/ui/interactions.py index d1d55019109ab259027a794491c9f0e424b78dc9..51ca66a4d296f541e8a03de239e2afb837807d59 100644 --- a/python_payload/st3m/ui/interactions.py +++ b/python_payload/st3m/ui/interactions.py @@ -1,9 +1,9 @@ import st3m from st3m.input import InputState, Touchable -from st3m.ui.ctx import Ctx from st3m.goose import Optional, Tuple from st3m import Responder +from ctx import Context class ScrollController(st3m.Responder): @@ -79,7 +79,7 @@ class ScrollController(st3m.Responder): self._physics_step(delta_ms / 1000.0) - def draw(self, ctx: Ctx) -> None: + def draw(self, ctx: Context) -> None: pass def current_position(self) -> float: diff --git a/python_payload/st3m/ui/menu.py b/python_payload/st3m/ui/menu.py index a3437f12d7315e12d8a74ed24a7d1afd9961d7e1..781eacdc36910e26b1c328880d0b80f2708d888f 100644 --- a/python_payload/st3m/ui/menu.py +++ b/python_payload/st3m/ui/menu.py @@ -12,7 +12,7 @@ from st3m.ui.view import ( ViewTransitionSwipeRight, ) from st3m.ui.interactions import ScrollController -from st3m.ui.ctx import Ctx +from ctx import Context log = logging.Log(__name__) @@ -47,7 +47,7 @@ class MenuItem(Responder): """ pass - def draw(self, ctx: Ctx) -> None: + def draw(self, ctx: Context) -> None: ctx.text(self.label()) def think(self, ins: InputState, delta_ms: int) -> None: @@ -102,7 +102,7 @@ class MenuItemBack(MenuItem): def label(self) -> str: return "Back" - def draw(self, ctx: Ctx) -> None: + def draw(self, ctx: Context) -> None: ctx.move_to(0, 0) ctx.font = "Material Icons" ctx.text("\ue5c4") @@ -165,7 +165,7 @@ class MenuController(ViewWithInputState): self.select() self._parse_state() - def draw(self, ctx: Ctx) -> None: + def draw(self, ctx: Context) -> None: pass def select(self) -> None: diff --git a/python_payload/st3m/ui/view.py b/python_payload/st3m/ui/view.py index 7939670c5a63b39acee162daca496aab1a068e5d..e5217641d869ae5516792f949227816696fb3919 100644 --- a/python_payload/st3m/ui/view.py +++ b/python_payload/st3m/ui/view.py @@ -1,7 +1,7 @@ from st3m.reactor import Responder from st3m.goose import ABCBase, abstractmethod, Optional, List from st3m.input import InputState, InputController -from st3m.ui.ctx import Ctx +from ctx import Context class View(Responder): @@ -52,7 +52,7 @@ class ViewTransition(ABCBase): @abstractmethod def draw( - self, ctx: Ctx, transition: float, incoming: Responder, outgoing: Responder + self, ctx: Context, transition: float, incoming: Responder, outgoing: Responder ) -> None: """ Called when the ViewManager performs a transition from the outgoing @@ -71,7 +71,7 @@ class ViewTransitionBlend(ViewTransition): """ def draw( - self, ctx: Ctx, transition: float, incoming: Responder, outgoing: Responder + self, ctx: Context, transition: float, incoming: Responder, outgoing: Responder ) -> None: ctx.start_group() outgoing.draw(ctx) @@ -89,7 +89,7 @@ class ViewTransitionSwipeLeft(ViewTransition): """ def draw( - self, ctx: Ctx, transition: float, incoming: Responder, outgoing: Responder + self, ctx: Context, transition: float, incoming: Responder, outgoing: Responder ) -> None: ctx.save() ctx.translate(transition * -240, 0) @@ -108,7 +108,7 @@ class ViewTransitionSwipeRight(ViewTransition): """ def draw( - self, ctx: Ctx, transition: float, incoming: Responder, outgoing: Responder + self, ctx: Context, transition: float, incoming: Responder, outgoing: Responder ) -> None: ctx.save() ctx.translate(transition * 240, 0) @@ -160,7 +160,7 @@ class ViewManager(Responder): if self._incoming is not None: self._incoming.think(ins, delta_ms) - def draw(self, ctx: Ctx) -> None: + def draw(self, ctx: Context) -> None: if self._transitioning: vt = self._default_vt if self._overriden_vt is not None: diff --git a/sim/fakes/ctx.py b/sim/fakes/ctx.py index af4773ff02a77721ae4b7e83e90ce6322b59ca36..27993172391bde25bbd80e9f2bbe7dcc6973b229 100644 --- a/sim/fakes/ctx.py +++ b/sim/fakes/ctx.py @@ -88,7 +88,7 @@ class Wasm: _wasm = Wasm() -class Ctx: +class Context: """ Ctx implements a subset of uctx [1]. It should be extended as needed as we make use of more and more uctx features in the badge code. diff --git a/sim/fakes/hardware.py b/sim/fakes/hardware.py index 4b8d78381e6f605e34cab4941b0458a308123442..03462f885e11572ccdd51d522f14416da45ad0f6 100644 --- a/sim/fakes/hardware.py +++ b/sim/fakes/hardware.py @@ -450,7 +450,7 @@ fbm = FramebufferManager() def get_ctx(): dctx = ctx._wasm.ctx_new_drawlist(240, 240) - return ctx.Ctx(dctx) + return ctx.Context(dctx) def display_update(subctx):