1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 11:47:35 +00:00

LibGUI: Use UIDimension in place of int in Widget

This commit is contained in:
FrHun 2022-06-12 21:19:41 +02:00 committed by Sam Atkins
parent 024305e742
commit b47bf2fd7c
2 changed files with 28 additions and 22 deletions

View file

@ -780,16 +780,18 @@ void Widget::set_font_fixed_width(bool fixed_width)
set_font(Gfx::FontDatabase::the().get(Gfx::FontDatabase::the().default_font().family(), m_font->presentation_size(), m_font->weight(), m_font->slope()));
}
void Widget::set_min_size(Gfx::IntSize const& size)
void Widget::set_min_size(UISize const& size)
{
VERIFY(size.width().is_one_of(SpecialDimension::Regular, SpecialDimension::Shrink));
if (m_min_size == size)
return;
m_min_size = size;
invalidate_layout();
}
void Widget::set_max_size(Gfx::IntSize const& size)
void Widget::set_max_size(UISize const& size)
{
VERIFY(size.width().is_one_of(SpecialDimension::Regular, SpecialDimension::Grow));
if (m_max_size == size)
return;
m_max_size = size;

View file

@ -18,6 +18,7 @@
#include <LibGUI/Forward.h>
#include <LibGUI/GML/AST.h>
#include <LibGUI/Margins.h>
#include <LibGUI/UIDimensions.h>
#include <LibGfx/Color.h>
#include <LibGfx/Forward.h>
#include <LibGfx/Orientation.h>
@ -80,40 +81,43 @@ public:
return layout;
}
Gfx::IntSize min_size() const { return m_min_size; }
void set_min_size(Gfx::IntSize const&);
void set_min_size(int width, int height) { set_min_size({ width, height }); }
UISize min_size() const { return m_min_size; }
void set_min_size(UISize const&);
void set_min_size(UIDimension width, UIDimension height) { set_min_size({ width, height }); }
int min_width() const { return m_min_size.width(); }
int min_height() const { return m_min_size.height(); }
void set_min_width(int width) { set_min_size(width, min_height()); }
void set_min_height(int height) { set_min_size(min_width(), height); }
UIDimension min_width() const { return m_min_size.width(); }
UIDimension min_height() const { return m_min_size.height(); }
void set_min_width(UIDimension width) { set_min_size(width, min_height()); }
void set_min_height(UIDimension height) { set_min_size(min_width(), height); }
Gfx::IntSize max_size() const { return m_max_size; }
void set_max_size(Gfx::IntSize const&);
void set_max_size(int width, int height) { set_max_size({ width, height }); }
UISize max_size() const { return m_max_size; }
void set_max_size(UISize const&);
void set_max_size(UIDimension width, UIDimension height) { set_max_size({ width, height }); }
int max_width() const { return m_max_size.width(); }
int max_height() const { return m_max_size.height(); }
void set_max_width(int width) { set_max_size(width, max_height()); }
void set_max_height(int height) { set_max_size(max_width(), height); }
UIDimension max_width() const { return m_max_size.width(); }
UIDimension max_height() const { return m_max_size.height(); }
void set_max_width(UIDimension width) { set_max_size(width, max_height()); }
void set_max_height(UIDimension height) { set_max_size(max_width(), height); }
void set_fixed_size(Gfx::IntSize const& size)
void set_fixed_size(UISize const& size)
{
VERIFY(size.has_only_int_values());
set_min_size(size);
set_max_size(size);
}
void set_fixed_size(int width, int height) { set_fixed_size({ width, height }); }
void set_fixed_size(UIDimension width, UIDimension height) { set_fixed_size({ width, height }); }
void set_fixed_width(int width)
void set_fixed_width(UIDimension width)
{
VERIFY(width.is_int());
set_min_width(width);
set_max_width(width);
}
void set_fixed_height(int height)
void set_fixed_height(UIDimension height)
{
VERIFY(height.is_int());
set_min_height(height);
set_max_height(height);
}
@ -377,8 +381,8 @@ private:
NonnullRefPtr<Gfx::Font> m_font;
String m_tooltip;
Gfx::IntSize m_min_size { -1, -1 };
Gfx::IntSize m_max_size { -1, -1 };
UISize m_min_size { SpecialDimension::Shrink };
UISize m_max_size { SpecialDimension::Grow };
Margins m_grabbable_margins;
bool m_fill_with_background_color { false };