1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:17:44 +00:00

LibGUI: Give some widgets a reasonable default fixed height

Instead of hard-coding 22 in random places, just make the following
widgets have a fixed height of 22 by default: Button, CheckBox,
ColorInput, ComboBox, RadioButton, SpinBox, TextBox.

In the future we can make this relative to the current font size,
but for now at least this centralizes the setting a bit better.
This commit is contained in:
Andreas Kling 2020-12-30 01:53:13 +01:00
parent 0f3b0b65ae
commit 1cca2405fc
17 changed files with 11 additions and 16 deletions

View file

@ -38,6 +38,7 @@ namespace GUI {
Button::Button(String text)
: AbstractButton(move(text))
{
set_fixed_height(22);
set_focus_policy(GUI::FocusPolicy::StrongFocus);
}

View file

@ -39,6 +39,7 @@ static const int s_box_height = 13;
CheckBox::CheckBox(String text)
: AbstractButton(move(text))
{
set_fixed_height(22);
}
CheckBox::~CheckBox()

View file

@ -35,6 +35,7 @@ namespace GUI {
ColorInput::ColorInput()
: TextEditor(TextEditor::SingleLine)
{
set_fixed_height(22);
TextEditor::on_change = [this] {
auto parsed_color = Color::from_string(text());
if (parsed_color.has_value())

View file

@ -58,6 +58,8 @@ private:
ComboBox::ComboBox()
{
set_fixed_height(22);
m_editor = add<ComboBoxEditor>();
m_editor->set_frame_thickness(0);
m_editor->on_return_pressed = [this] {

View file

@ -113,7 +113,6 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, Options options, const
toolbar.set_has_frame(false);
m_location_textbox = upper_container.add<TextBox>();
m_location_textbox->set_fixed_height(22);
m_location_textbox->set_text(path);
m_view = vertical_container.add<MultiView>();

View file

@ -36,6 +36,7 @@ namespace GUI {
RadioButton::RadioButton(String text)
: AbstractButton(move(text))
{
set_fixed_height(22);
}
RadioButton::~RadioButton()

View file

@ -32,6 +32,7 @@ namespace GUI {
SpinBox::SpinBox()
{
set_fixed_height(22);
m_editor = add<TextBox>();
m_editor->set_text("0");
m_editor->on_change = [this] {

View file

@ -31,6 +31,7 @@ namespace GUI {
TextBox::TextBox()
: TextEditor(TextEditor::SingleLine)
{
set_fixed_height(22);
}
TextBox::~TextBox()