13 const ColorFill Container::DEFAULT_FILL = ColorFill{Sml::COLOR_WHITE};
14 const Background Container::DEFAULT_BACKGROUND = Background{&Container::DEFAULT_FILL};
16 Container::Container() : Parent()
18 m_Background = &DEFAULT_BACKGROUND;
21 Component* Container::getHitComponent(int32_t x, int32_t y)
23 if (!isInteractable()) {
return nullptr; }
25 Component* hitted = Parent::getHitComponent(x, y);
27 if (hitted !=
nullptr)
32 if (Sml::isPointInsideRectangle({x, y}, getLayoutBounds()))
40 void Container::render(
const Sml::Rectangle<int32_t>& targetRegion)
47 renderShadow(targetRegion);
49 Sml::Rectangle<int32_t> translatedTargetRegion = getLayoutBounds();
50 translatedTargetRegion.pos += targetRegion.pos;
52 if (m_Snapshot !=
nullptr)
54 Sml::Rectangle<int32_t> originBounds = getOriginBounds();
55 renderTexture(*m_Snapshot, &translatedTargetRegion, &originBounds);
58 for (Component* child : getChildren())
60 child->render(translatedTargetRegion);
64 void Container::prerenderSelf()
66 if (m_Background !=
nullptr)
68 Background::fillArea(m_Background, getOriginBounds());
71 if (m_Border !=
nullptr)
73 Border::encloseArea(m_Border, getOriginBounds());
77 int32_t BlankContainer::computeCustomPrefWidth(int32_t height)
const {
return 0; }
78 int32_t BlankContainer::computeCustomPrefHeight(int32_t width)
const {
return 0; }