mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 08:41:15 +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:
parent
0f3b0b65ae
commit
1cca2405fc
Notes:
sideshowbarker
2024-07-19 00:25:25 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/1cca2405fc4
|
@ -112,7 +112,6 @@ Tab::Tab(Type type)
|
|||
toolbar.add_action(*m_reload_action);
|
||||
|
||||
m_location_box = toolbar.add<GUI::TextBox>();
|
||||
m_location_box->set_fixed_height(22);
|
||||
m_location_box->set_placeholder("Address");
|
||||
|
||||
m_location_box->on_return_pressed = [this] {
|
||||
|
|
|
@ -116,7 +116,6 @@ void DisplaySettingsWidget::create_frame()
|
|||
wallpaper_label.set_text("Wallpaper:");
|
||||
|
||||
m_wallpaper_combo = wallpaper_selection_container.add<GUI::ComboBox>();
|
||||
m_wallpaper_combo->set_fixed_height(22);
|
||||
m_wallpaper_combo->set_only_allow_values_from_model(true);
|
||||
m_wallpaper_combo->set_model(*GUI::ItemListModel<AK::String>::create(m_wallpapers));
|
||||
m_wallpaper_combo->on_change = [this](auto& text, const GUI::ModelIndex& index) {
|
||||
|
@ -170,7 +169,6 @@ void DisplaySettingsWidget::create_frame()
|
|||
mode_label.set_text("Mode:");
|
||||
|
||||
m_mode_combo = mode_selection_container.add<GUI::ComboBox>();
|
||||
m_mode_combo->set_fixed_height(22);
|
||||
m_mode_combo->set_only_allow_values_from_model(true);
|
||||
m_mode_combo->set_model(*GUI::ItemListModel<AK::String>::create(m_modes));
|
||||
m_mode_combo->on_change = [this](auto&, const GUI::ModelIndex& index) {
|
||||
|
@ -190,7 +188,6 @@ void DisplaySettingsWidget::create_frame()
|
|||
m_resolution_label.set_text("Resolution:");
|
||||
|
||||
m_resolution_combo = resolution_selection_container.add<GUI::ComboBox>();
|
||||
m_resolution_combo->set_fixed_height(22);
|
||||
m_resolution_combo->set_only_allow_values_from_model(true);
|
||||
m_resolution_combo->set_model(*GUI::ItemListModel<Gfx::IntSize>::create(m_resolutions));
|
||||
m_resolution_combo->on_change = [this](auto&, const GUI::ModelIndex& index) {
|
||||
|
|
|
@ -76,7 +76,6 @@ PropertiesDialog::PropertiesDialog(const String& path, bool disable_rename, Wind
|
|||
m_parent_path = lexical_path.dirname();
|
||||
|
||||
m_name_box = file_container.add<GUI::TextBox>();
|
||||
m_name_box->set_fixed_height(22);
|
||||
m_name_box->set_text(m_name);
|
||||
m_name_box->set_mode(disable_rename ? GUI::TextBox::Mode::DisplayOnly : GUI::TextBox::Mode::Editable);
|
||||
m_name_box->on_change = [&]() {
|
||||
|
|
|
@ -72,7 +72,6 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::Font>&& edite
|
|||
glyph_width_label.set_text("Glyph width:");
|
||||
|
||||
auto& glyph_width_spinbox = editor_container.add<GUI::SpinBox>();
|
||||
glyph_width_spinbox.set_fixed_height(22);
|
||||
glyph_width_spinbox.set_min(0);
|
||||
glyph_width_spinbox.set_max(32);
|
||||
glyph_width_spinbox.set_value(0);
|
||||
|
@ -253,7 +252,6 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::Font>&& edite
|
|||
|
||||
//// Fixed checkbox Row
|
||||
auto& fixed_width_checkbox = font_metadata_group_box.add<GUI::CheckBox>();
|
||||
fixed_width_checkbox.set_fixed_height(22);
|
||||
fixed_width_checkbox.set_text("Fixed width");
|
||||
fixed_width_checkbox.set_checked(m_edited_font->is_fixed_width());
|
||||
|
||||
|
|
|
@ -134,7 +134,6 @@ int main(int argc, char** argv)
|
|||
character_map_file_label.set_text("Character Mapping File:");
|
||||
|
||||
auto& character_map_file_combo = character_map_file_selection_container.add<GUI::ComboBox>();
|
||||
character_map_file_combo.set_fixed_height(22);
|
||||
character_map_file_combo.set_only_allow_values_from_model(true);
|
||||
character_map_file_combo.set_model(*CharacterMapFileListModel::create(character_map_files));
|
||||
character_map_file_combo.set_selected_index(initial_keymap_index);
|
||||
|
|
|
@ -299,9 +299,7 @@ static RefPtr<GUI::Window> create_find_window(TerminalWidget& terminal)
|
|||
};
|
||||
|
||||
auto& match_case = search.add<GUI::CheckBox>("Case sensitive");
|
||||
match_case.set_fixed_height(22);
|
||||
auto& wrap_around = search.add<GUI::CheckBox>("Wrap around");
|
||||
wrap_around.set_fixed_height(22);
|
||||
|
||||
find_backwards.on_click = [&](auto) {
|
||||
auto needle = find_textbox.text();
|
||||
|
|
|
@ -68,7 +68,6 @@ int main([[maybe_unused]] int argc, [[maybe_unused]] char** argv, [[maybe_unused
|
|||
|
||||
auto& button = main_widget.add<GUI::Button>();
|
||||
button.set_text("Good-bye");
|
||||
button.set_fixed_height(20);
|
||||
button.on_click = [&](auto) {
|
||||
app->quit();
|
||||
};
|
||||
|
|
|
@ -68,7 +68,6 @@ int main(int argc, char** argv)
|
|||
|
||||
auto& button = main_widget.add<GUI::Button>();
|
||||
button.set_text("Good-bye");
|
||||
button.set_fixed_height(20);
|
||||
button.on_click = [&](auto) {
|
||||
app->quit();
|
||||
};
|
||||
|
|
|
@ -175,9 +175,11 @@ int main(int argc, char** argv)
|
|||
auto& checkbox2 = checkbox_container.add<GUI::CheckBox>("CheckBox 2");
|
||||
checkbox2.set_enabled(false);
|
||||
|
||||
[[maybe_unused]] auto& label1 = label_container.add<GUI::Label>("Label 1");
|
||||
auto& label1 = label_container.add<GUI::Label>("Label 1");
|
||||
label1.set_fixed_height(22);
|
||||
auto& label2 = label_container.add<GUI::Label>("Label 2");
|
||||
label2.set_enabled(false);
|
||||
label2.set_fixed_height(22);
|
||||
|
||||
[[maybe_unused]] auto& spinbox1 = spin_container.add<GUI::SpinBox>();
|
||||
auto& spinbox2 = spin_container.add<GUI::SpinBox>();
|
||||
|
@ -424,7 +426,6 @@ int main(int argc, char** argv)
|
|||
content_textbox.set_text("Demo text for message box.");
|
||||
|
||||
auto& msgbox_button = msgbox_text_container.add<GUI::Button>("Create");
|
||||
msgbox_button.set_fixed_height(30);
|
||||
msgbox_button.on_click = [&](auto) {
|
||||
GUI::MessageBox::show(window, content_textbox.text(), title_textbox.text(), msg_box_type, msg_box_input_type);
|
||||
};
|
||||
|
@ -446,7 +447,6 @@ int main(int argc, char** argv)
|
|||
input_button_container.layout()->set_margins({ 4, 0, 4, 0 });
|
||||
|
||||
auto& input_button = input_button_container.add<GUI::Button>("Input...");
|
||||
input_button.set_fixed_height(30);
|
||||
String value;
|
||||
input_button.on_click = [&](auto) {
|
||||
if (GUI::InputBox::show(value, window, "Enter input:", "Input Box") == GUI::InputBox::ExecOK && !value.is_empty())
|
||||
|
|
|
@ -38,6 +38,7 @@ namespace GUI {
|
|||
Button::Button(String text)
|
||||
: AbstractButton(move(text))
|
||||
{
|
||||
set_fixed_height(22);
|
||||
set_focus_policy(GUI::FocusPolicy::StrongFocus);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ static const int s_box_height = 13;
|
|||
CheckBox::CheckBox(String text)
|
||||
: AbstractButton(move(text))
|
||||
{
|
||||
set_fixed_height(22);
|
||||
}
|
||||
|
||||
CheckBox::~CheckBox()
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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] {
|
||||
|
|
|
@ -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>();
|
||||
|
|
|
@ -36,6 +36,7 @@ namespace GUI {
|
|||
RadioButton::RadioButton(String text)
|
||||
: AbstractButton(move(text))
|
||||
{
|
||||
set_fixed_height(22);
|
||||
}
|
||||
|
||||
RadioButton::~RadioButton()
|
||||
|
|
|
@ -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] {
|
||||
|
|
|
@ -31,6 +31,7 @@ namespace GUI {
|
|||
TextBox::TextBox()
|
||||
: TextEditor(TextEditor::SingleLine)
|
||||
{
|
||||
set_fixed_height(22);
|
||||
}
|
||||
|
||||
TextBox::~TextBox()
|
||||
|
|
Loading…
Reference in a new issue