• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lexus2k / lcdgfx / 23985608556

04 Apr 2026 07:07PM UTC coverage: 50.577% (+1.6%) from 48.93%
23985608556

push

github

lexus2k
Add scroll indicators and checkbox menu widget

- LcdGfxMenu::show() now draws scroll indicators (▲/▼ arrows and thin
  scrollbar) when menu items overflow the visible area
- New LcdGfxCheckboxMenu class with toggle/isChecked/setChecked API,
  uint16_t bitmask supporting up to 16 items, scaled checkbox boxes
- 16 new unit tests for menu navigation, scrolling, and checkbox state
- All 363 tests pass

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

44 of 50 new or added lines in 1 file covered. (88.0%)

920 of 1819 relevant lines covered (50.58%)

16474.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.0
/src/v2/gui/checkbox_menu.cpp
1
/*
2
    MIT License
3

4
    Copyright (c) 2020,2022,2025 Alexey Dynda
5

6
    Permission is hereby granted, free of charge, to any person obtaining a copy
7
    of this software and associated documentation files (the "Software"), to deal
8
    in the Software without restriction, including without limitation the rights
9
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
    copies of the Software, and to permit persons to whom the Software is
11
    furnished to do so, subject to the following conditions:
12

13
    The above copyright notice and this permission notice shall be included in all
14
    copies or substantial portions of the Software.
15

16
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
    SOFTWARE.
23
*/
24

25
#include "checkbox_menu.h"
26

27
LcdGfxCheckboxMenu::LcdGfxCheckboxMenu(const char **items, uint8_t count, const NanoRect &rect)
10✔
28
    : m_checked(0)
10✔
29
{
30
    menu.items = items;
10✔
31
    menu.count = count > 16 ? 16 : count;
10✔
32
    menu.selection = 0;
10✔
33
    menu.oldSelection = 0;
10✔
34
    menu.scrollPosition = 0;
10✔
35
    menu.top = rect.p1.y;
10✔
36
    menu.left = rect.p1.x;
10✔
37
    menu.width = rect.p2.x ? rect.width() : 0;
10✔
38
    menu.height = rect.p2.y ? rect.height() : 0;
10✔
39
}
10✔
40

41
void LcdGfxCheckboxMenu::down()
9✔
42
{
43
    if ( menu.selection < menu.count - 1 )
9✔
44
    {
45
        menu.selection++;
8✔
46
    }
47
    else
48
    {
49
        menu.selection = 0;
1✔
50
    }
51
}
9✔
52

53
void LcdGfxCheckboxMenu::up()
2✔
54
{
55
    if ( menu.selection > 0 )
2✔
56
    {
57
        menu.selection--;
1✔
58
    }
59
    else
60
    {
61
        menu.selection = menu.count - 1;
1✔
62
    }
63
}
2✔
64

65
void LcdGfxCheckboxMenu::toggle()
5✔
66
{
67
    m_checked ^= (1u << menu.selection);
5✔
68
}
5✔
69

70
bool LcdGfxCheckboxMenu::isChecked(uint8_t index)
10✔
71
{
72
    if ( index >= menu.count )
10✔
73
        return false;
74
    return (m_checked & (1u << index)) != 0;
9✔
75
}
76

77
void LcdGfxCheckboxMenu::setChecked(uint8_t index, bool checked)
9✔
78
{
79
    if ( index >= menu.count )
9✔
80
        return;
81
    if ( checked )
8✔
82
    {
83
        m_checked |= (1u << index);
7✔
84
    }
85
    else
86
    {
87
        m_checked &= ~(1u << index);
1✔
88
    }
89
}
90

91
uint16_t LcdGfxCheckboxMenu::checkedMask()
8✔
92
{
93
    return m_checked;
8✔
94
}
95

96
uint8_t LcdGfxCheckboxMenu::selection()
10✔
97
{
98
    return menu.selection;
10✔
99
}
100

101
void LcdGfxCheckboxMenu::setSelection(uint8_t s)
2✔
102
{
103
    if ( s >= menu.count )
2✔
104
    {
105
        menu.selection = menu.count - 1;
1✔
106
    }
107
    else
108
    {
109
        menu.selection = s;
1✔
110
    }
111
}
2✔
112

NEW
113
void LcdGfxCheckboxMenu::setRect(const NanoRect &rect)
×
114
{
NEW
115
    menu.top = rect.p1.y;
×
NEW
116
    menu.left = rect.p1.x;
×
NEW
117
    menu.width = rect.p2.x ? rect.width() : 0;
×
NEW
118
    menu.height = rect.p2.y ? rect.height() : 0;
×
NEW
119
}
×
120

121
uint8_t LcdGfxCheckboxMenu::size()
2✔
122
{
123
    return menu.count;
2✔
124
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc