From 444e628d22db67742181ae14ae2ed0a9c2b6cd67 Mon Sep 17 00:00:00 2001 From: Yuqian Yang Date: Mon, 22 Sep 2025 14:58:02 +0800 Subject: Impl window rect of xcb window. --- include/cru/platform/GraphicsBase.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'include/cru/platform/GraphicsBase.h') diff --git a/include/cru/platform/GraphicsBase.h b/include/cru/platform/GraphicsBase.h index b0f653ef..d5936476 100644 --- a/include/cru/platform/GraphicsBase.h +++ b/include/cru/platform/GraphicsBase.h @@ -206,10 +206,22 @@ struct Rect final { height + thickness.GetVerticalTotal()); } - constexpr Rect Shrink(const Thickness& thickness) const { - return Rect(left + thickness.left, top + thickness.top, + constexpr Rect Shrink(const Thickness& thickness, + bool normalize = false) const { + Rect result(left + thickness.left, top + thickness.top, width - thickness.GetHorizontalTotal(), height - thickness.GetVerticalTotal()); + + if (normalize) { + if (result.width < 0) { + result.width = 0; + } + if (result.height < 0) { + result.height = 0; + } + } + + return result; } constexpr bool IsPointInside(const Point& point) const { -- cgit v1.2.3