MCPcopy Create free account
hub / github.com/BernardoGiordano/Checkpoint / drawActionButton

Function drawActionButton

switch/source/MainScreen.cpp:165–196  ·  view source on GitHub ↗

An action button: filled accent (Backup/Send) or outlined (Restore/Receive), label + the shoulder-key system glyph centered as a group. An empty `key` draws the label alone (the wireless buttons are touch-only — every face/shoulder button is already bound). `enabled` false greys the button out (faint fill, muted text) for a shown-but-inactive action, e.g. Send while a non-sendable row is highlight

Source from the content-addressed store, hash-verified

163 // greys the button out (faint fill, muted text) for a shown-but-inactive
164 // action, e.g. Send while a non-sendable row is highlighted.
165 void drawActionButton(int x, int y, const std::string& label, const std::string& key, bool filled, int w = BTN_W, bool enabled = true)
166 {
167 // Square buttons (radius 0), matching the 3DS action buttons and the
168 // squared rail / rows.
169 if (!enabled) {
170 Shapes::fillRound(x, y, w, BTN_H, 0, COLOR_FILL1);
171 }
172 else if (filled) {
173 Shapes::fillRound(x, y, w, BTN_H, 0, COLOR_ACCENT);
174 }
175 else {
176 Shapes::strokeRound(x, y, w, BTN_H, 0, 2, COLOR_STROKE3);
177 }
178
179 const Color fg = !enabled ? COLOR_TEXT3 : (filled ? COLOR_WHITE : COLOR_TEXT);
180
181 u32 lw, lh;
182 Gfx::GetTextDimensions(16, label.c_str(), &lw, &lh);
183 if (key.empty()) {
184 Gfx::DrawText(16, x + (w - (int)lw) / 2, y + (BTN_H - (int)lh) / 2, fg, label.c_str());
185 return;
186 }
187
188 const std::string glyph = UiKit::buttonGlyph(key);
189 u32 gw, gh;
190 Gfx::GetTextDimensions(ACTION_GLYPH_SIZE, glyph.c_str(), &gw, &gh);
191 const int gap = 10;
192 const int group = (int)lw + gap + (int)gw;
193 const int sx = x + (w - group) / 2;
194 Gfx::DrawText(16, sx, y + (BTN_H - (int)lh) / 2, fg, label.c_str());
195 Gfx::DrawText(ACTION_GLYPH_SIZE, sx + (int)lw + gap, y + (BTN_H - (int)gh) / 2, fg, glyph.c_str());
196 }
197
198 // Maps a failed network send to a user-facing message (mirrors the 3DS
199 // OutcomeMessages::sendError). EmptyBackup and Cancelled are handled by the

Callers 1

drawMethod · 0.85

Calls 1

emptyMethod · 0.45

Tested by

no test coverage detected