mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 21:37:36 +00:00
LibGUI: Give SeparatorWidget a minimum size
Without this, it can be squished down into nothing, which looks really odd.
This commit is contained in:
parent
ddc7bedca6
commit
64eb326f26
2 changed files with 12 additions and 2 deletions
|
@ -12,6 +12,8 @@
|
||||||
REGISTER_WIDGET(GUI, HorizontalSeparator)
|
REGISTER_WIDGET(GUI, HorizontalSeparator)
|
||||||
REGISTER_WIDGET(GUI, VerticalSeparator)
|
REGISTER_WIDGET(GUI, VerticalSeparator)
|
||||||
|
|
||||||
|
constexpr int minimum_size = 8;
|
||||||
|
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
SeparatorWidget::SeparatorWidget(Gfx::Orientation orientation)
|
SeparatorWidget::SeparatorWidget(Gfx::Orientation orientation)
|
||||||
|
@ -39,8 +41,15 @@ void SeparatorWidget::paint_event(PaintEvent& event)
|
||||||
Optional<UISize> SeparatorWidget::calculated_preferred_size() const
|
Optional<UISize> SeparatorWidget::calculated_preferred_size() const
|
||||||
{
|
{
|
||||||
if (m_orientation == Gfx::Orientation::Vertical)
|
if (m_orientation == Gfx::Orientation::Vertical)
|
||||||
return UISize { 8, SpecialDimension::OpportunisticGrow };
|
return UISize { minimum_size, SpecialDimension::OpportunisticGrow };
|
||||||
return UISize { SpecialDimension::OpportunisticGrow, 8 };
|
return UISize { SpecialDimension::OpportunisticGrow, minimum_size };
|
||||||
|
}
|
||||||
|
|
||||||
|
Optional<UISize> SeparatorWidget::calculated_min_size() const
|
||||||
|
{
|
||||||
|
if (m_orientation == Gfx::Orientation::Vertical)
|
||||||
|
return UISize { minimum_size, 0 };
|
||||||
|
return UISize { 0, minimum_size };
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
virtual void paint_event(PaintEvent&) override;
|
virtual void paint_event(PaintEvent&) override;
|
||||||
virtual Optional<UISize> calculated_preferred_size() const override;
|
virtual Optional<UISize> calculated_preferred_size() const override;
|
||||||
|
virtual Optional<UISize> calculated_min_size() const override;
|
||||||
|
|
||||||
const Gfx::Orientation m_orientation;
|
const Gfx::Orientation m_orientation;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue