9#include "sml/graphics_wrapper/primitives.h"
16 void Skin::prerenderControl() {}
18 Component* Skin::getHitComponent(int32_t x, int32_t y)
20 if (Sml::isPointInsideRectangle({x, y}, getControl()->getLayoutBounds()))
22 return getModifiableControl();
28 #define CHECK_ENABLED_SIZE(size) if (size != USE_COMPUTED_SIZE) { return size; }
30 int32_t Skin::computePrefHeight(int32_t width)
const
32 const Control* control = getControl();
35 COMPONENT_COMPUTE_DIMENSION(Pref, Height, width, Y, control->getChildrenReadonly(),
36 control->getPrefHeight(),
37 control->getInsets().top + control->getInsets().bottom);
40 int32_t Skin::computePrefWidth(int32_t height)
const
42 const Control* control = getControl();
45 COMPONENT_COMPUTE_DIMENSION(Pref, Width, height, X, control->getChildrenReadonly(),
46 control->getPrefWidth(),
47 control->getInsets().left + control->getInsets().right);
50 int32_t Skin::computeMinHeight(int32_t width)
const
52 const Control* control = getControl();
55 COMPONENT_COMPUTE_DIMENSION(Min, Height, width, Y, control->getChildrenReadonly(),
56 control->getMinHeight(),
57 control->getInsets().top + control->getInsets().bottom);
60 int32_t Skin::computeMinWidth(int32_t height)
const
62 const Control* control = getControl();
65 COMPONENT_COMPUTE_DIMENSION(Min, Width, height, X, control->getChildrenReadonly(),
66 control->getMinWidth(),
67 control->getInsets().left + control->getInsets().right);
70 int32_t Skin::computeMaxHeight(int32_t width)
const {
return Component::UNLIMITED_SIZE; }
71 int32_t Skin::computeMaxWidth(int32_t height)
const {
return Component::UNLIMITED_SIZE; }
73 void Skin::layoutChildren()
75 Control* control = getModifiableControl();
78 for (Component* child : control->getChildren())
80 child->setLayoutWidth(child->computePrefWidth());
81 child->setLayoutHeight(child->computePrefHeight());
85 Skin* Skinnable::getSkin()
90 void Skinnable::setSkin(Skin* skin)
92 if (m_Skin !=
nullptr)
virtual void dispose()=0
Should be called by Control when this skin is replaced.