| 30 | namespace tev { |
| 31 | |
| 32 | ImageButton::ImageButton(Widget* parent, string_view caption, bool canBeReference) : |
| 33 | Widget{parent}, mCaption{caption}, mCanBeReference{canBeReference} { |
| 34 | this->set_layout(new BoxLayout{Orientation::Vertical, Alignment::Fill}); |
| 35 | mCaptionTextBox = new TextBox{this, caption}; |
| 36 | mCaptionTextBox->set_visible(false); |
| 37 | mCaptionTextBox->set_editable(true); |
| 38 | mCaptionTextBox->set_alignment(TextBox::Alignment::Right); |
| 39 | mCaptionTextBox->set_placeholder(caption); |
| 40 | mCaptionTextBox->set_callback([this](const string&) { |
| 41 | this->hideTextBox(); |
| 42 | return true; |
| 43 | }); |
| 44 | mCaptionTextBox->set_corner_radius(0.0f); |
| 45 | mCaptionTextBox->set_solid_color(IMAGE_COLOR); |
| 46 | |
| 47 | m_preferred_size_depends_on_size = false; |
| 48 | } |
| 49 | |
| 50 | Vector2i ImageButton::preferred_size_impl(NVGcontext* ctx) const { |
| 51 | if (m_preferred_size_cache != Vector2i(-1)) { |
nothing calls this directly
no test coverage detected