| 128 | }; |
| 129 | |
| 130 | float ImageButton::getCaptionWidth(NVGcontext* ctx, size_t cutoff) const { |
| 131 | const auto pieces = getCaptionPieces(cutoff); |
| 132 | |
| 133 | nvgFontSize(ctx, m_font_size); |
| 134 | |
| 135 | float totalSize = 0; |
| 136 | for (size_t i = 0; i < 3; ++i) { |
| 137 | if (pieces[i].empty()) { |
| 138 | continue; |
| 139 | } |
| 140 | |
| 141 | nvgFontFace(ctx, i == 1 ? "sans-bold" : "sans"); |
| 142 | totalSize += nvgTextBounds(ctx, 0, 0, pieces[i].data(), pieces[i].data() + pieces[i].size(), nullptr); |
| 143 | } |
| 144 | |
| 145 | return totalSize; |
| 146 | } |
| 147 | |
| 148 | void ImageButton::draw(NVGcontext* ctx) { |
| 149 | Widget::draw(ctx); |