diff options
Diffstat (limited to 'src/ui/render/render_object.cpp')
-rw-r--r-- | src/ui/render/render_object.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/ui/render/render_object.cpp b/src/ui/render/render_object.cpp index 232eda41..5c6af580 100644 --- a/src/ui/render/render_object.cpp +++ b/src/ui/render/render_object.cpp @@ -1,5 +1,7 @@ #include "render_object.hpp" +#include <algorithm> + #include "cru_debug.hpp" namespace cru::ui::render { @@ -96,6 +98,15 @@ void RenderObject::OnLayoutCore(const Rect& rect) { coerced_content_available_size.height}); } +Rect RenderObject::GetContentRect() const { + Rect rect{Point::Zero(), GetSize()}; + rect = rect.Shrink(GetMargin()); + rect = rect.Shrink(GetPadding()); + rect.width = std::max(rect.width, 0.0f); + rect.height = std::max(rect.height, 0.0f); + return rect; +} + void RenderObject::SetParent(RenderObject* new_parent) { const auto old_parent = parent_; parent_ = new_parent; |