1 # Simple Screen UI Framework
5 This is a framework for creating simple user interfaces for devices with tiny
6 screens and just a few buttons.
8 For example, the [M5Stack](http://m5stack.com/) ESP32 Basic Core IoT device has
9 a 320x240 TFT display and three push buttons.
11 This framework enables a UI such as the following, where focus is indicated by
12 color, the left and middle buttons function as a single axis navpad, the right
13 button function as an action button, and the back button is provided by the
16 +--------------------------------------+
27 | PREVIOUS NEXT ACTION |
28 +--------------------------------------+
32 - stack of screens with system back button
33 - labeled buttons for navigation and action
35 - custom screen content
36 - virtual LEDs (VLEDs)
40 The screen manager maintains a stack of screens that are pushed and popped for
41 interaction. Each is drawn with a title, system back button, three button
42 labels, and custom screen content. The screen manager dispatches events to the
43 topmost screen, such as:
45 - enter/exit events (including whether the screen was pushed or popped)
46 - focus events (for navigation)
48 - display events (lazily)
50 If configured, virtual LEDs (VLEDs) are omnipresent and can be toggled at will.
54 Screens provide a title and three button labels to the screen manager. They
55 handle events from the screen manager, and cooperate to ensure focus behaves
60 Screens are created without focus, and indicate to the screen manager whether
61 they can receive focus. If so, the screen manager focuses them when they are
62 pushed, and subsequently dispatches focus next/previous events which the screen
63 can use for navigation before any action is performed.
65 The screen can request the screen manager to focus the system back button, which
66 is always available except when there are no covered screens on the stack. In
67 this way, a list screen can wrap its focus of list items through the system back
68 button if it is available, while skipping it otherwise.
70 Blur and unblur focus events allow a screen's focus state to be preserved when
71 it is covered by a pushed screen and restored when it is subsequently uncovered.
73 In summary, screens collaborate with the screen manager to handle focus via the
74 following focus event types:
76 - NONE: remove focus from screen completely
77 - BLUR: unfocus screen (but retain focus state)
78 - UNBLUR: restore focus state (that was retained when blurred)
79 - NEXT: navigate focus forward in screen (possibly requesting focus back
81 - PREVIOUS: navigate focus forward (possibly requesting back button focus)
85 A list screen can provide multiple options to the user. Each list item can push
86 another screen on the stack with more items. In this way a hierarchy of screens
89 The back button dismisses a screen much as "escape" or "cancel" would. It's
90 possible to push an informational screen that is not focusable and has no
91 interaction, such that the only action available is back.