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

Method draw

3ds/source/clickable.cpp:62–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62void Clickable::draw(float size, u32 overlayWhenFocused)
63{
64 u8 r, g, b;
65 if (mSelected || held()) {
66 r = (overlayWhenFocused >> 0) & 0xFF;
67 g = (overlayWhenFocused >> 8) & 0xFF;
68 b = (overlayWhenFocused >> 16) & 0xFF;
69 }
70 else {
71 r = 0;
72 g = 0;
73 b = 0;
74 }
75 // Localized labels can outgrow the box: shrink the scale a little first
76 // (down to 80%), then ellipsis-truncate whatever still overflows.
77 const float availWidth = mCentered ? mw - 8 : mw - 16;
78 const float drawSize = TextPool::get().fitScale(text(), availWidth, size, size * 0.8f);
79 const std::string message = TextPool::get().truncate(text(), availWidth, drawSize);
80 const float messageHeight = ceilf(drawSize * fontGetInfo(NULL)->lineFeed);
81 const float messageWidth = mCentered ? TextPool::get().width(message, drawSize) : mw - 8;
82
83 C2D_DrawRectSolid(mx, my, 0.5f, mw, mh, mColorBg);
84 if (mCanChangeColorWhenSelected && held()) {
85 C2D_DrawRectSolid(mx, my, 0.5f, mw, mh, C2D_Color32(r, g, b, 100));
86 }
87 if (!mCentered && mSelected) {
88 C2D_DrawRectSolid(mx + 4, my + 6, 0.5f, 4, mh - 12, COLOR_WHITE);
89 }
90 if (mSelected) {
91 C2D_DrawRectSolid(mx, my, 0.5f, mw, mh, C2D_Color32(r, g, b, 100));
92 }
93 int offset = ceilf(mx + (mw - messageWidth) / 2) + (!mCentered ? 8 : 0);
94 TextPool::get().draw(message, offset, ceilf(my + (mh - messageHeight) / 2), drawSize, mColorText);
95}
96
97void Clickable::drawOutline(u32 color)
98{

Callers

nothing calls this directly

Calls 4

getFunction · 0.85
fitScaleMethod · 0.80
truncateMethod · 0.80
widthMethod · 0.45

Tested by

no test coverage detected