Skip to content

Commit 0b3a16b

Browse files
authored
Merge pull request #16 from oroderico/drop-orphaned-plain-screens
Drop the plain screens the chrome replaced, and test what ships
2 parents b3b1d2b + 2310564 commit 0b3a16b

7 files changed

Lines changed: 55 additions & 162 deletions

File tree

‎host/origo_sdl.c‎

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,6 @@ void seedtool_display_screen(const char* title, const char* line1, const char* l
9292
present();
9393
}
9494

95-
void seedtool_display_screen3(
96-
const char* title, const char* line1, const char* line2, const char* line3, const char* footer)
97-
{
98-
seedtool_render_screen3(title, line1, line2, line3, footer);
99-
present();
100-
}
101-
102-
void seedtool_display_screen4(const char* title, const char* line1, const char* line2, const char* line3,
103-
const char* line4, const char* footer)
104-
{
105-
seedtool_render_screen4(title, line1, line2, line3, line4, footer);
106-
present();
107-
}
108-
10995
void seedtool_display_dice_screen(const char* title, const char* line1, const char* line2, const char* footer,
11096
const seedtool_progress_t* progress)
11197
{
@@ -133,13 +119,6 @@ void seedtool_display_splash(void)
133119
present();
134120
}
135121

136-
void seedtool_display_list(const char* title, const char* const* items, const size_t count, const size_t selected,
137-
const size_t top, const char* footer)
138-
{
139-
seedtool_render_list(title, items, count, selected, top, footer);
140-
present();
141-
}
142-
143122
void seedtool_display_nav_text(
144123
const seedtool_nav_t* nav, const char* title, const char* line1, const char* line2, const char* line3)
145124
{

‎host/origo_simulator.c‎

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,19 @@ static bool wire_order_is_big_endian(void)
312312
{
313313
static uint16_t wire[SEEDTOOL_DISPLAY_WIDTH * 5];
314314
const char* const items[] = { "Create Seed", "Restore Seed", "Complete Checksum" };
315+
/* The Origo menu as the firmware draws it: the nav chrome, no arrow (it has
316+
* no level above it), the selection on the first row. What this test needs
317+
* from the image is the selection orange on row 21 and black and white
318+
* elsewhere, and the chrome's list puts the bar in the same place and at
319+
* the same width the plain list did - 226 orange pixels on that row either
320+
* way, measured before this was switched over. */
321+
const seedtool_nav_t nav = { .selected = 0,
322+
.confirm = NULL,
323+
.confirm_enabled = false,
324+
.back = false,
325+
.confirm_as_tick = true };
315326

316-
seedtool_render_list("Origo", items, 3, 0, 0, "1/3");
327+
seedtool_render_nav_list(&nav, "Origo", items, 3, 0);
317328
const uint16_t* const pixels = seedtool_render_pixels();
318329
for (size_t row = 0; row + 5 <= SEEDTOOL_DISPLAY_HEIGHT; row += 5) {
319330
seedtool_render_wire_rows(wire, row, 5);
@@ -331,7 +342,7 @@ static bool wire_order_is_big_endian(void)
331342
}
332343
/* The selection orange is the colour that actually came out blue. */
333344
seedtool_render_clear();
334-
seedtool_render_list("Origo", items, 3, 0, 0, "1/3");
345+
seedtool_render_nav_list(&nav, "Origo", items, 3, 0);
335346
seedtool_render_wire_rows(wire, 21, 1);
336347
bool orange_found = false;
337348
for (size_t i = 0; i < SEEDTOOL_DISPLAY_WIDTH; ++i) {
@@ -2213,10 +2224,23 @@ static int self_test(void)
22132224
fputs("Origo QR self-test failed\n", stderr);
22142225
return 1;
22152226
}
2216-
/* Draw a list scrolled to its end and one scrolled to its start, so both
2217-
* arrows and the selection bar are exercised. */
2218-
seedtool_render_list("Wallet", menu_labels, 7, 6, 4, "7/7 L/R move BOTH select");
2219-
seedtool_render_list("Word 3/12 aba", menu_labels, MENU_LABEL_COUNT, 0, 0, "1/24 L/R move BOTH select");
2227+
/* Draw a list scrolled to its end and one scrolled to its start, so the
2228+
* scroll indicator and the selection bar are both exercised. On the chrome
2229+
* that indicator is the thumb, not the pair of arrows the plain list drew -
2230+
* these two used to paint the old list, which meant they were exercising a
2231+
* widget the firmware had stopped shipping. */
2232+
const seedtool_nav_t scrolled = { .selected = 6,
2233+
.confirm = NULL,
2234+
.confirm_enabled = false,
2235+
.back = true,
2236+
.confirm_as_tick = true };
2237+
const seedtool_nav_t at_start = { .selected = 0,
2238+
.confirm = NULL,
2239+
.confirm_enabled = false,
2240+
.back = true,
2241+
.confirm_as_tick = true };
2242+
seedtool_render_nav_list(&scrolled, "Wallet", menu_labels, 7, 4);
2243+
seedtool_render_nav_list(&at_start, "Word 3/12 aba", menu_labels, MENU_LABEL_COUNT, 0);
22202244
/* Draw the real layouts, each opened at its centre, so one that overflows a
22212245
* row is caught here rather than on the device. */
22222246
const bool letters[SEEDTOOL_LETTERS + 1] = { true };

‎main/seedtool_app.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -728,9 +728,9 @@ static void hexstr(const uint8_t* bytes, const size_t len, char* output)
728728

729729
/* Three body lines per page, split by what actually fits on the display
730730
* rather than by a character count. Three rather than two costs nothing but
731-
* the tighter line pitch seedtool_render_screen3 uses: a third fewer pages to
732-
* review the same value. Returns true when the reader advanced past the last
733-
* page or accepted, false when they backed out. */
731+
* the tighter line pitch the renderer uses for a third line: a third fewer
732+
* pages to review the same value. Returns true when the reader advanced past
733+
* the last page or accepted, false when they backed out. */
734734
static bool page_text_impl(const char* title, const char* text, const bool confirmable)
735735
{
736736
size_t start[MAX_PAGE_LINES], length[MAX_PAGE_LINES];

‎main/seedtool_display.c‎

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -188,20 +188,6 @@ void seedtool_display_screen(const char* title, const char* line1, const char* l
188188
flush();
189189
}
190190

191-
void seedtool_display_screen3(
192-
const char* title, const char* line1, const char* line2, const char* line3, const char* footer)
193-
{
194-
seedtool_render_screen3(title, line1, line2, line3, footer);
195-
flush();
196-
}
197-
198-
void seedtool_display_screen4(const char* title, const char* line1, const char* line2, const char* line3,
199-
const char* line4, const char* footer)
200-
{
201-
seedtool_render_screen4(title, line1, line2, line3, line4, footer);
202-
flush();
203-
}
204-
205191
void seedtool_display_digits(const char* title, const char* digits, const size_t count, const size_t active,
206192
const char* footer, const seedtool_progress_t* progress)
207193
{
@@ -229,13 +215,6 @@ void seedtool_display_splash(void)
229215
flush();
230216
}
231217

232-
void seedtool_display_list(const char* title, const char* const* items, const size_t count, const size_t selected,
233-
const size_t top, const char* footer)
234-
{
235-
seedtool_render_list(title, items, count, selected, top, footer);
236-
flush();
237-
}
238-
239218
void seedtool_display_nav_text(
240219
const seedtool_nav_t* nav, const char* title, const char* line1, const char* line2, const char* line3)
241220
{

‎main/seedtool_display.h‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,9 @@ void seedtool_display_init(void);
2525
void seedtool_display_set_orientation(bool flipped);
2626
void seedtool_display_set_brightness(unsigned level);
2727
void seedtool_display_screen(const char* title, const char* line1, const char* line2, const char* footer);
28-
void seedtool_display_screen3(
29-
const char* title, const char* line1, const char* line2, const char* line3, const char* footer);
30-
void seedtool_display_screen4(const char* title, const char* line1, const char* line2, const char* line3,
31-
const char* line4, const char* footer);
3228
void seedtool_display_dice_screen(const char* title, const char* line1, const char* line2, const char* footer,
3329
const seedtool_progress_t* progress);
3430
void seedtool_display_splash(void);
35-
void seedtool_display_list(const char* title, const char* const* items, size_t count, size_t selected, size_t top,
36-
const char* footer);
3731
/* One wrapper per nav screen shape, each just its renderer plus a flush. A
3832
* new shape needs one here and one in each backend; everything about the
3933
* chrome itself is already carried by seedtool_nav_t. */

‎main/seedtool_render.c‎

Lines changed: 13 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
#define DICE_BAR_Y 90
2525
#define DICE_BAR_HEIGHT 14
2626

27-
/* Left margin for seedtool_render_screen4's four body lines: a numbered list
28-
* reads as a table, so every row starts at the same x rather than each being
29-
* centred as its own block and drifting with how wide its own text is. */
27+
/* Left margin for the four-row body: a numbered list reads as a table, so every
28+
* row starts at the same x rather than each being centred as its own block and
29+
* drifting with how wide its own text is. */
3030
#define SCREEN4_TEXT_X 20
3131

3232
#define KEYBOARD_COLUMNS 10
@@ -80,8 +80,11 @@
8080
* at 103) and the bar. The small face fits the 14px left over; the 16px one
8181
* would not. */
8282
#define NAV_COUNTER_Y 105
83-
/* seedtool_render_screen4's four left-aligned rows, kept at its own heights so
84-
* a numbered list reads the same with the chrome as without it. */
83+
/* Four left-aligned rows. The heights are inherited from the plain four-line
84+
* screen this replaced, and kept rather than re-derived: 28 to 88 in steps of
85+
* 20 fits four 16px lines between the header and the counter with a real gap
86+
* under each, which is the arithmetic the pixel scan in the self-test holds
87+
* them to. */
8588
#define NAV_ROWS_SHOWN 4
8689
#define NAV_ROWS_TOP 28
8790
#define NAV_ROWS_HEIGHT 20
@@ -425,42 +428,6 @@ void seedtool_render_screen(const char* title, const char* line1, const char* li
425428
draw_centered(tft_DefaultFont, footer, 111);
426429
}
427430

428-
/* Same face and footer as seedtool_render_screen, but a third body line
429-
* pitched tighter (25px apart rather than 26, and starting closer to the
430-
* title) so it still clears the footer: a long value paged three lines at a
431-
* time needs a third of fewer pages to review, at the same 16px face. */
432-
void seedtool_render_screen3(
433-
const char* title, const char* line1, const char* line2, const char* line3, const char* footer)
434-
{
435-
seedtool_render_clear();
436-
draw_centered(tft_Ubuntu16, title, 5);
437-
draw_centered(tft_Ubuntu16, line1, 33);
438-
draw_centered(tft_Ubuntu16, line2, 58);
439-
draw_centered(tft_Ubuntu16, line3, 83);
440-
draw_centered(tft_DefaultFont, footer, 111);
441-
}
442-
443-
/* Same face and footer again, pitched tighter still (20px, against three
444-
* lines' 25px) to fit a fourth: a numbered word (or word-number) list reads
445-
* one entry per line, so 12 or 24 entries comes out to a clean 3 or 6 pages
446-
* this way instead of the 4 or 8 three lines would need. Still clears the
447-
* footer with room to spare at the same 16px face - the four lines run
448-
* title+23 to title+23+3*20+16, i.e. y=28 to 108, three pixels shy of the
449-
* footer at 111. Pixel-scanned directly (seedtool_render_pixels) to confirm
450-
* every line clears the next with a real gap - the zoomed Compact SeedQR
451-
* region label overlap bug was proof enough not to eyeball this arithmetic. */
452-
void seedtool_render_screen4(const char* title, const char* line1, const char* line2, const char* line3,
453-
const char* line4, const char* footer)
454-
{
455-
seedtool_render_clear();
456-
draw_centered(tft_Ubuntu16, title, 5);
457-
draw_left(tft_Ubuntu16, line1, SCREEN4_TEXT_X, 28);
458-
draw_left(tft_Ubuntu16, line2, SCREEN4_TEXT_X, 48);
459-
draw_left(tft_Ubuntu16, line3, SCREEN4_TEXT_X, 68);
460-
draw_left(tft_Ubuntu16, line4, SCREEN4_TEXT_X, 88);
461-
draw_centered(tft_DefaultFont, footer, 111);
462-
}
463-
464431
seedtool_thumb_t seedtool_list_thumb(const size_t count, const size_t top, const int track)
465432
{
466433
seedtool_thumb_t thumb = { 0, track };
@@ -504,44 +471,6 @@ size_t seedtool_list_top(const size_t count, const size_t selected, size_t previ
504471
return previous_top;
505472
}
506473

507-
void seedtool_render_list(const char* title, const char* const* items, const size_t count, const size_t selected,
508-
const size_t top, const char* footer)
509-
{
510-
seedtool_render_clear();
511-
draw_centered(tft_Ubuntu16, title, LIST_TITLE_Y);
512-
for (size_t row = 0; row < SEEDTOOL_LIST_ROWS && top + row < count; ++row) {
513-
const char* const item = items[top + row];
514-
const bool highlighted = top + row == selected;
515-
const int y = LIST_TOP + (int)row * LIST_ROW_HEIGHT;
516-
/* A rule between rows, matching the nav lists and Jade's own menus:
517-
* the rows read as cells rather than as stacked lines of text, and it
518-
* sits in the gap between them so the selection bar never paints over
519-
* it. Between them and not above the first, so this list and a nav one
520-
* carry the same line in the same places - a screen that gained the
521-
* chrome should not also change how its rows are drawn.
522-
*
523-
* It used to be drawn above the last row alone, to set the way out
524-
* apart from the choices. That distinction now rests on position,
525-
* which the last row has always had and which every list here keeps. */
526-
if (row) {
527-
fill_rect(LIST_BAR_X, y - 1, LIST_BAR_WIDTH, 1, COLOR_DIM);
528-
}
529-
if (highlighted) {
530-
fill_rect(LIST_BAR_X, y, LIST_BAR_WIDTH, LIST_ROW_HEIGHT - 2, COLOR_HIGHLIGHT);
531-
}
532-
draw_line_at(tft_Ubuntu16, item, seedtool_render_fit_row(item), LIST_TEXT_X,
533-
y + (LIST_ROW_HEIGHT - tft_Ubuntu16[1]) / 2, highlighted ? COLOR_BLACK : COLOR_WHITE);
534-
}
535-
if (count > SEEDTOOL_LIST_ROWS) {
536-
/* With three rows visible, "there is more" is not enough on its own: the
537-
* thumb's size says how much more and its place says where in it. */
538-
const seedtool_thumb_t thumb = seedtool_list_thumb(count, top, LIST_SCROLL_HEIGHT);
539-
fill_rect(LIST_SCROLL_X, LIST_TOP, LIST_SCROLL_WIDTH, LIST_SCROLL_HEIGHT, COLOR_DIM);
540-
fill_rect(LIST_SCROLL_X, LIST_TOP + thumb.offset, LIST_SCROLL_WIDTH, thumb.height, COLOR_WHITE);
541-
}
542-
draw_centered(tft_DefaultFont, footer, LIST_FOOTER_Y);
543-
}
544-
545474
/* A solid left-pointing triangle with its apex at (x, y + height / 2): the
546475
* back arrow, drawn rather than set, since the 16px face carries no glyph for
547476
* one and Jade's own symbols font is not linked here. */
@@ -702,10 +631,11 @@ void seedtool_render_nav_text(
702631
const seedtool_nav_t* nav, const char* title, const char* line1, const char* line2, const char* line3)
703632
{
704633
nav_begin(nav, title);
705-
/* The same heights the plain screens use, so a screen gaining the chrome
706-
* does not also move its own text - and the same choice between them that
707-
* seedtool_render_screen and seedtool_render_screen3 make by being two
708-
* functions: a third line means the three-line layout. */
634+
/* Two layouts in one function, chosen by whether there is a third line:
635+
* two lines sit at 39 and 65, three at 33, 58 and 83, pitched tighter to
636+
* clear the counter. These were two separate screens before the chrome,
637+
* and the heights are theirs unchanged - a screen gaining the chrome
638+
* should not also move its own text. */
709639
if (line3) {
710640
draw_centered(tft_Ubuntu16, line1, 33);
711641
draw_centered(tft_Ubuntu16, line2, 58);

‎main/seedtool_render.h‎

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,6 @@
2323
void seedtool_render_clear(void);
2424
void seedtool_render_screen(const char* title, const char* line1, const char* line2, const char* footer);
2525

26-
/* Same as seedtool_render_screen, but with a third body line: for a long
27-
* value paged three lines at a time instead of two. */
28-
void seedtool_render_screen3(
29-
const char* title, const char* line1, const char* line2, const char* line3, const char* footer);
30-
31-
/* Same again, with a fourth body line: for a numbered word or word-number
32-
* list, one entry per line, four entries per page. */
33-
void seedtool_render_screen4(const char* title, const char* line1, const char* line2, const char* line3,
34-
const char* line4, const char* footer);
35-
3626
/* The dice-roll quality bar drawn under a D6/D20 entry screen: a top segment
3727
* for rolls collected against the minimum, a bottom segment for Shannon's
3828
* entropy of those rolls against the minimum bits needed. `warn` colors the
@@ -95,9 +85,6 @@ typedef struct {
9585

9686
seedtool_thumb_t seedtool_list_thumb(size_t count, size_t top, int track);
9787

98-
void seedtool_render_list(const char* title, const char* const* items, size_t count, size_t selected, size_t top,
99-
const char* footer);
100-
10188
/* The two fixed controls a nav screen always carries, addressed as selections
10289
* alongside an ordinary item index. Sentinels rather than positions past the
10390
* end of the list, so a caller never has to know how many rows the chrome
@@ -152,20 +139,20 @@ typedef struct {
152139
bool confirm_as_tick;
153140
} seedtool_nav_t;
154141

155-
/* Two or three centred body lines - three when `line3` is given, the same
156-
* choice seedtool_render_screen and seedtool_render_screen3 make by being two
157-
* functions. Body heights match theirs, so a screen gaining the chrome does
158-
* not also move its own text. */
142+
/* Two or three centred body lines - three when `line3` is given, which picks
143+
* the tighter pitch. Both layouts keep the heights the plain screens used
144+
* before the chrome replaced them, so a screen gaining the chrome does not
145+
* also move its own text. */
159146
void seedtool_render_nav_text(
160147
const seedtool_nav_t* nav, const char* title, const char* line1, const char* line2, const char* line3);
161148

162-
/* Four left-aligned rows, at seedtool_render_screen4's own heights: a numbered
163-
* word list, which reads as a table rather than as centred blocks. */
149+
/* Four left-aligned rows: a numbered word list, which reads as a table rather
150+
* than as centred blocks. */
164151
void seedtool_render_nav_rows(const seedtool_nav_t* nav, const char* title, const char* const* rows, size_t count);
165152

166-
/* A scrolling list under the chrome. Shows the same SEEDTOOL_LIST_ROWS rows as
167-
* seedtool_render_list, one pixel shorter each to buy the bar its height, so
168-
* seedtool_list_top and seedtool_list_thumb apply here unchanged. */
153+
/* A scrolling list under the chrome, SEEDTOOL_LIST_ROWS rows at a time, each a
154+
* pixel shorter than the plain list's were to buy the bar its height - which is
155+
* why seedtool_list_top and seedtool_list_thumb apply here unchanged. */
169156
void seedtool_render_nav_list(
170157
const seedtool_nav_t* nav, const char* title, const char* const* items, size_t count, size_t top);
171158

0 commit comments

Comments
 (0)