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

Function drawActionButton

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

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