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

Function drawActionButton

switch/source/MainScreen.cpp:167–198  ·  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

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