1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 19:57:45 +00:00

LibGUI: Add content margins

Introduce the basic interface through which widgets can define a
rect relative to which Layout margins are now applied.
This commit is contained in:
FrHun 2021-09-14 23:21:05 +02:00 committed by Andreas Kling
parent 8249ea792e
commit 72139e1262
2 changed files with 11 additions and 5 deletions

View file

@ -134,8 +134,12 @@ public:
int height() const { return m_relative_rect.height(); }
int length(Orientation orientation) const { return orientation == Orientation::Vertical ? height() : width(); }
virtual Margins content_margins() const { return { 0 }; }
Gfx::IntRect rect() const { return { 0, 0, width(), height() }; }
Gfx::IntSize size() const { return m_relative_rect.size(); }
Gfx::IntRect content_rect() const { return this->content_margins().applied_to(rect()); };
Gfx::IntSize content_size() const { return this->content_rect().size(); };
// Invalidate the widget (or an area thereof), causing a repaint to happen soon.
void update();