1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:18:11 +00:00

LibGUI: Add Widget shrink-to-fit layout flag

If this flag is enabled for a widget, it will be automatically sized
based on its children. This only works for widgets using a layout.

This allows you to put widgets inside each other without having to
manually calculate how large the container should be. It's not the
perfect API but it's a decent progression in ergonomics. :^)
This commit is contained in:
Andreas Kling 2021-01-04 18:17:14 +01:00
parent ce7b09a3c5
commit b03e1b08b5
5 changed files with 90 additions and 0 deletions

View file

@ -41,11 +41,15 @@ public:
Gfx::Orientation orientation() const { return m_orientation; }
virtual void run(Widget&) override;
virtual Gfx::IntSize preferred_size() const override;
protected:
explicit BoxLayout(Gfx::Orientation);
private:
int preferred_primary_size() const;
int preferred_secondary_size() const;
Gfx::Orientation m_orientation;
};