| 48 | } |
| 49 | |
| 50 | Vector2i ImageButton::preferred_size_impl(NVGcontext* ctx) const { |
| 51 | if (m_preferred_size_cache != Vector2i(-1)) { |
| 52 | return m_preferred_size_cache; |
| 53 | } |
| 54 | |
| 55 | nvgFontSize(ctx, m_font_size + 2); |
| 56 | nvgFontFace(ctx, "sans-bold"); |
| 57 | const string idString = to_string(mId); |
| 58 | const float idSize = nvgTextBounds(ctx, 0, 0, idString.data(), idString.data() + idString.size(), nullptr); |
| 59 | |
| 60 | m_preferred_size_cache = Vector2i(static_cast<int>(getCaptionWidth(ctx, 0) + idSize) + 15, m_font_size + 6); |
| 61 | |
| 62 | mSizeForWhichCutoffWasComputed = Vector2i(-1); |
| 63 | |
| 64 | return m_preferred_size_cache; |
| 65 | } |
| 66 | |
| 67 | bool ImageButton::mouse_button_event(const Vector2i& p, int button, bool down, int modifiers) { |
| 68 | if (Widget::mouse_button_event(p, button, down, modifiers)) { |