MCPcopy Create free account
hub / github.com/Tom94/tev / preferred_size_impl

Method preferred_size_impl

src/ImageButton.cpp:50–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50Vector2i 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
67bool ImageButton::mouse_button_event(const Vector2i& p, int button, bool down, int modifiers) {
68 if (Widget::mouse_button_event(p, button, down, modifiers)) {

Callers

nothing calls this directly

Calls 2

dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected