summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r--Userland/Libraries/LibGUI/AbstractTableView.h4
-rw-r--r--Userland/Libraries/LibGUI/Application.cpp4
-rw-r--r--Userland/Libraries/LibGUI/Button.cpp2
-rw-r--r--Userland/Libraries/LibGUI/Calendar.cpp2
-rw-r--r--Userland/Libraries/LibGUI/GlyphMapWidget.cpp22
-rw-r--r--Userland/Libraries/LibGUI/GroupBox.cpp8
-rw-r--r--Userland/Libraries/LibGUI/IconView.cpp14
-rw-r--r--Userland/Libraries/LibGUI/MessageBox.cpp2
-rw-r--r--Userland/Libraries/LibGUI/RadioButton.cpp2
-rw-r--r--Userland/Libraries/LibGUI/TabWidget.cpp2
-rw-r--r--Userland/Libraries/LibGUI/TextEditor.cpp2
-rw-r--r--Userland/Libraries/LibGUI/Wizards/WizardPage.cpp4
12 files changed, 34 insertions, 34 deletions
diff --git a/Userland/Libraries/LibGUI/AbstractTableView.h b/Userland/Libraries/LibGUI/AbstractTableView.h
index 5039304148..636ae23aa0 100644
--- a/Userland/Libraries/LibGUI/AbstractTableView.h
+++ b/Userland/Libraries/LibGUI/AbstractTableView.h
@@ -24,7 +24,7 @@ public:
class AbstractTableView : public AbstractView {
public:
- int row_height() const { return font().glyph_height() + vertical_padding(); }
+ int row_height() const { return font().pixel_size_rounded_up() + vertical_padding(); }
virtual int horizontal_padding() const { return m_horizontal_padding; }
void set_horizontal_padding(int padding) { m_horizontal_padding = padding; }
@@ -122,7 +122,7 @@ private:
bool m_highlight_selected_rows { true };
int m_vertical_padding { 8 };
- int m_horizontal_padding { font().glyph_height() / 2 };
+ int m_horizontal_padding { font().pixel_size_rounded_up() / 2 };
int m_tab_moves { 0 };
};
diff --git a/Userland/Libraries/LibGUI/Application.cpp b/Userland/Libraries/LibGUI/Application.cpp
index 286e229355..324324a3a5 100644
--- a/Userland/Libraries/LibGUI/Application.cpp
+++ b/Userland/Libraries/LibGUI/Application.cpp
@@ -30,8 +30,8 @@ public:
m_label->set_text(Gfx::parse_ampersand_string(tooltip));
int tooltip_width = m_label->effective_min_size().width().as_int() + 10;
int line_count = m_label->text().count("\n"sv);
- int glyph_height = m_label->font().glyph_height();
- int tooltip_height = glyph_height * (1 + line_count) + ((glyph_height + 1) / 2) * line_count + 8;
+ int font_size = m_label->font().pixel_size_rounded_up();
+ int tooltip_height = font_size * (1 + line_count) + ((font_size + 1) / 2) * line_count + 8;
Gfx::IntRect desktop_rect = Desktop::the().rect();
if (tooltip_width > desktop_rect.width())
diff --git a/Userland/Libraries/LibGUI/Button.cpp b/Userland/Libraries/LibGUI/Button.cpp
index 99eaaa9545..8a96a5cb25 100644
--- a/Userland/Libraries/LibGUI/Button.cpp
+++ b/Userland/Libraries/LibGUI/Button.cpp
@@ -105,7 +105,7 @@ void Button::paint_event(PaintEvent& event)
content_rect.set_width(content_rect.width() - m_icon->width() - icon_spacing());
}
- Gfx::IntRect text_rect { 0, 0, static_cast<int>(ceilf(font.width(text()))), font.glyph_height() };
+ Gfx::IntRect text_rect { 0, 0, static_cast<int>(ceilf(font.width(text()))), font.pixel_size_rounded_up() };
if (text_rect.width() > content_rect.width())
text_rect.set_width(content_rect.width());
text_rect.align_within(content_rect, text_alignment());
diff --git a/Userland/Libraries/LibGUI/Calendar.cpp b/Userland/Libraries/LibGUI/Calendar.cpp
index 73fc74d8a2..5d42dc2af9 100644
--- a/Userland/Libraries/LibGUI/Calendar.cpp
+++ b/Userland/Libraries/LibGUI/Calendar.cpp
@@ -484,7 +484,7 @@ void Calendar::paint_event(GUI::PaintEvent& event)
x_offset,
y_offset + 4,
m_tiles[0][i].width - 4,
- font().glyph_height() + 4);
+ font().pixel_size_rounded_up() + 4);
if (width > 150 && height > 150) {
set_font(extra_large_font);
diff --git a/Userland/Libraries/LibGUI/GlyphMapWidget.cpp b/Userland/Libraries/LibGUI/GlyphMapWidget.cpp
index 2efdd54ec2..e63e3de1ab 100644
--- a/Userland/Libraries/LibGUI/GlyphMapWidget.cpp
+++ b/Userland/Libraries/LibGUI/GlyphMapWidget.cpp
@@ -102,9 +102,9 @@ Gfx::IntRect GlyphMapWidget::get_outer_rect(int glyph) const
int column = glyph % columns();
return Gfx::IntRect {
column * (font().max_glyph_width() + m_horizontal_spacing),
- row * (font().glyph_height() + m_vertical_spacing),
+ row * (font().pixel_size_rounded_up() + m_vertical_spacing),
font().max_glyph_width() + m_horizontal_spacing,
- font().glyph_height() + m_vertical_spacing
+ font().pixel_size_rounded_up() + m_vertical_spacing
}
.translated(frame_thickness() - horizontal_scrollbar().value(), frame_thickness() - vertical_scrollbar().value());
}
@@ -136,7 +136,7 @@ void GlyphMapWidget::paint_event(PaintEvent& event)
outer_rect.x() + m_horizontal_spacing / 2,
outer_rect.y() + m_vertical_spacing / 2,
font().max_glyph_width(),
- font().glyph_height());
+ font().pixel_size_rounded_up());
if (m_selection.contains(glyph)) {
painter.fill_rect(outer_rect, is_focused() ? palette().selection() : palette().inactive_selection());
if (font().contains_glyph(glyph))
@@ -184,7 +184,7 @@ Optional<int> GlyphMapWidget::glyph_at_position(Gfx::IntPoint position) const
Gfx::IntPoint map_offset { frame_thickness() - horizontal_scrollbar().value(), frame_thickness() - vertical_scrollbar().value() };
auto map_position = position - map_offset;
auto col = (map_position.x() - 1) / ((font().max_glyph_width() + m_horizontal_spacing));
- auto row = (map_position.y() - 1) / ((font().glyph_height() + m_vertical_spacing));
+ auto row = (map_position.y() - 1) / ((font().pixel_size_rounded_up() + m_vertical_spacing));
auto glyph = row * columns() + col + m_active_range.first;
if (row >= 0 && row < rows() && col >= 0 && col < columns() && glyph < m_glyph_count + m_active_range.first)
return glyph;
@@ -197,7 +197,7 @@ int GlyphMapWidget::glyph_at_position_clamped(Gfx::IntPoint position) const
Gfx::IntPoint map_offset { frame_thickness() - horizontal_scrollbar().value(), frame_thickness() - vertical_scrollbar().value() };
auto map_position = position - map_offset;
auto col = clamp((map_position.x() - 1) / ((font().max_glyph_width() + m_horizontal_spacing)), 0, columns() - 1);
- auto row = clamp((map_position.y() - 1) / ((font().glyph_height() + m_vertical_spacing)), 0, rows() - 1);
+ auto row = clamp((map_position.y() - 1) / ((font().pixel_size_rounded_up() + m_vertical_spacing)), 0, rows() - 1);
auto glyph = row * columns() + col + m_active_range.first;
if (row == rows() - 1)
glyph = min(glyph, m_glyph_count + m_active_range.first - 1);
@@ -448,7 +448,7 @@ void GlyphMapWidget::keydown_event(KeyEvent& event)
void GlyphMapWidget::did_change_font()
{
recalculate_content_size();
- vertical_scrollbar().set_step(font().glyph_height() + m_vertical_spacing);
+ vertical_scrollbar().set_step(font().pixel_size_rounded_up() + m_vertical_spacing);
}
void GlyphMapWidget::scroll_to_glyph(int glyph)
@@ -458,9 +458,9 @@ void GlyphMapWidget::scroll_to_glyph(int glyph)
int column = glyph % columns();
auto scroll_rect = Gfx::IntRect {
column * (font().max_glyph_width() + m_horizontal_spacing),
- row * (font().glyph_height() + m_vertical_spacing),
+ row * (font().pixel_size_rounded_up() + m_vertical_spacing),
font().max_glyph_width() + m_horizontal_spacing,
- font().glyph_height() + m_vertical_spacing
+ font().pixel_size_rounded_up() + m_vertical_spacing
};
scroll_into_view(scroll_rect, true, true);
}
@@ -515,12 +515,12 @@ void GlyphMapWidget::recalculate_content_size()
m_rows = ceil_div(m_glyph_count, m_columns);
constexpr auto overdraw_margins = 2;
- auto max_visible_rows = event_height / (font().glyph_height() + m_vertical_spacing);
+ auto max_visible_rows = event_height / (font().pixel_size_rounded_up() + m_vertical_spacing);
m_visible_rows = min(max_visible_rows, m_rows);
m_visible_glyphs = (m_visible_rows + overdraw_margins) * m_columns;
int content_width = columns() * (font().max_glyph_width() + m_horizontal_spacing);
- int content_height = rows() * (font().glyph_height() + m_vertical_spacing);
+ int content_height = rows() * (font().pixel_size_rounded_up() + m_vertical_spacing);
set_content_size({ content_width, content_height });
scroll_to_glyph(m_active_glyph);
@@ -590,7 +590,7 @@ void GlyphMapWidget::leave_event(Core::Event&)
Optional<UISize> GlyphMapWidget::calculated_min_size() const
{
auto scrollbar = vertical_scrollbar().effective_min_size().height().as_int();
- auto min_height = max(font().glyph_height() + m_vertical_spacing, scrollbar);
+ auto min_height = max(font().pixel_size_rounded_up() + m_vertical_spacing, scrollbar);
auto min_width = font().max_glyph_width() + m_horizontal_spacing + width_occupied_by_vertical_scrollbar();
return { { min_width + frame_thickness() * 2, min_height + frame_thickness() * 2 } };
}
diff --git a/Userland/Libraries/LibGUI/GroupBox.cpp b/Userland/Libraries/LibGUI/GroupBox.cpp
index 6b4b2d1d73..5219680c57 100644
--- a/Userland/Libraries/LibGUI/GroupBox.cpp
+++ b/Userland/Libraries/LibGUI/GroupBox.cpp
@@ -24,7 +24,7 @@ GroupBox::GroupBox(StringView title)
Margins GroupBox::content_margins() const
{
return {
- (!m_title.is_empty() ? static_cast<int>(ceilf(font().glyph_height())) + 1 /*room for the focus rect*/ : 2),
+ (!m_title.is_empty() ? font().pixel_size_rounded_up() + 1 /*room for the focus rect*/ : 2),
2,
2,
2
@@ -37,13 +37,13 @@ void GroupBox::paint_event(PaintEvent& event)
painter.add_clip_rect(event.rect());
Gfx::IntRect frame_rect {
- 0, (!m_title.is_empty() ? font().glyph_height() / 2 : 0),
- width(), height() - (!m_title.is_empty() ? static_cast<int>(ceilf(font().glyph_height())) / 2 : 0)
+ 0, (!m_title.is_empty() ? font().pixel_size_rounded_up() / 2 : 0),
+ width(), height() - (!m_title.is_empty() ? font().pixel_size_rounded_up() / 2 : 0)
};
Gfx::StylePainter::paint_frame(painter, frame_rect, palette(), Gfx::FrameShape::Box, Gfx::FrameShadow::Sunken, 2);
if (!m_title.is_empty()) {
- Gfx::IntRect text_rect { 6, 1, static_cast<int>(ceilf(font().width(m_title) + 6)), font().glyph_height() };
+ Gfx::IntRect text_rect { 6, 1, static_cast<int>(ceilf(font().width(m_title) + 6)), font().pixel_size_rounded_up() };
painter.fill_rect(text_rect, palette().button());
painter.draw_text(text_rect, m_title, Gfx::TextAlignment::CenterLeft, palette().button_text());
}
diff --git a/Userland/Libraries/LibGUI/IconView.cpp b/Userland/Libraries/LibGUI/IconView.cpp
index 4cc0da5836..3445145af4 100644
--- a/Userland/Libraries/LibGUI/IconView.cpp
+++ b/Userland/Libraries/LibGUI/IconView.cpp
@@ -379,7 +379,7 @@ Gfx::IntRect IconView::editing_rect(ModelIndex const& index) const
return {};
auto& item_data = get_item_data(index.row());
auto editing_rect = item_data.text_rect;
- editing_rect.set_height(font_for_index(index)->glyph_height() + 8);
+ editing_rect.set_height(font_for_index(index)->pixel_size_rounded_up() + 8);
editing_rect.set_y(item_data.text_rect.y() - 2);
return editing_rect;
}
@@ -425,13 +425,13 @@ void IconView::get_item_rects(int item_index, ItemData& item_data, Gfx::Font con
{
auto item_rect = this->item_rect(item_index);
item_data.icon_rect = Gfx::IntRect(0, 0, 32, 32).centered_within(item_rect);
- item_data.icon_offset_y = -font.glyph_height() - 6;
+ item_data.icon_offset_y = -font.pixel_size_rounded_up() - 6;
item_data.icon_rect.translate_by(0, item_data.icon_offset_y);
int unwrapped_text_width = static_cast<int>(ceilf(font.width(item_data.text)));
int available_width = item_rect.width() - 6;
- item_data.text_rect = { 0, item_data.icon_rect.bottom() + 6 + 1, 0, font.glyph_height() };
+ item_data.text_rect = { 0, item_data.icon_rect.bottom() + 6 + 1, 0, font.pixel_size_rounded_up() };
item_data.wrapped_text_lines.clear();
if ((unwrapped_text_width > available_width) && (item_data.selected || m_hovered_index == item_data.index || cursor_index() == item_data.index || m_always_wrap_item_labels)) {
@@ -458,7 +458,7 @@ void IconView::get_item_rects(int item_index, ItemData& item_data, Gfx::Font con
item_data.text_rect.set_width(widest_line_width);
item_data.text_rect.center_horizontally_within(item_rect);
item_data.text_rect.intersect(item_rect);
- item_data.text_rect.set_height(font.glyph_height() * item_data.wrapped_text_lines.size());
+ item_data.text_rect.set_height(font.pixel_size_rounded_up() * item_data.wrapped_text_lines.size());
item_data.text_rect.inflate(6, 6);
item_data.text_rect_wrapped = item_data.text_rect;
} else {
@@ -551,14 +551,14 @@ void IconView::paint_event(PaintEvent& event)
// Item text would not fit in the item text rect, let's break it up into lines..
const auto& lines = item_data.wrapped_text_lines;
- size_t number_of_text_lines = min((size_t)text_rect.height() / font->glyph_height(), lines.size());
+ size_t number_of_text_lines = min((size_t)text_rect.height() / font->pixel_size_rounded_up(), lines.size());
size_t previous_line_lengths = 0;
for (size_t line_index = 0; line_index < number_of_text_lines; ++line_index) {
Gfx::IntRect line_rect;
line_rect.set_width(text_rect.width());
- line_rect.set_height(font->glyph_height());
+ line_rect.set_height(font->pixel_size_rounded_up());
line_rect.center_horizontally_within(item_data.text_rect);
- line_rect.set_y(3 + item_data.text_rect.y() + line_index * font->glyph_height());
+ line_rect.set_y(3 + item_data.text_rect.y() + line_index * font->pixel_size_rounded_up());
line_rect.inflate(6, 0);
// Shrink the line_rect on the last line to apply elision if there are more lines.
diff --git a/Userland/Libraries/LibGUI/MessageBox.cpp b/Userland/Libraries/LibGUI/MessageBox.cpp
index 13e3b0de3c..0ed8291247 100644
--- a/Userland/Libraries/LibGUI/MessageBox.cpp
+++ b/Userland/Libraries/LibGUI/MessageBox.cpp
@@ -117,7 +117,7 @@ void MessageBox::build()
int text_width = widget->font().width(m_text);
auto number_of_lines = m_text.split('\n').size();
- int padded_text_height = widget->font().glyph_height() * 1.6;
+ int padded_text_height = widget->font().pixel_size_rounded_up() * 1.6;
int total_text_height = number_of_lines * padded_text_height;
int icon_width = 0;
diff --git a/Userland/Libraries/LibGUI/RadioButton.cpp b/Userland/Libraries/LibGUI/RadioButton.cpp
index 0cc1923395..7884677ac8 100644
--- a/Userland/Libraries/LibGUI/RadioButton.cpp
+++ b/Userland/Libraries/LibGUI/RadioButton.cpp
@@ -51,7 +51,7 @@ void RadioButton::paint_event(PaintEvent& event)
Gfx::StylePainter::paint_radio_button(painter, circle_rect, palette(), is_checked(), is_being_pressed());
- Gfx::IntRect text_rect { circle_rect.right() + 5 + horizontal_padding(), 0, static_cast<int>(ceilf(font().width(text()))), font().glyph_height() };
+ Gfx::IntRect text_rect { circle_rect.right() + 5 + horizontal_padding(), 0, static_cast<int>(ceilf(font().width(text()))), font().pixel_size_rounded_up() };
text_rect.center_vertically_within(rect());
paint_text(painter, text_rect, font(), Gfx::TextAlignment::TopLeft);
diff --git a/Userland/Libraries/LibGUI/TabWidget.cpp b/Userland/Libraries/LibGUI/TabWidget.cpp
index 4c068b994f..e4a54b330d 100644
--- a/Userland/Libraries/LibGUI/TabWidget.cpp
+++ b/Userland/Libraries/LibGUI/TabWidget.cpp
@@ -321,7 +321,7 @@ void TabWidget::paint_event(PaintEvent& event)
painter.draw_text(tab_button_content_rect, m_tabs[i].title, m_text_alignment, palette().button_text(), Gfx::TextElision::Right);
if (is_focused()) {
- Gfx::IntRect focus_rect { 0, 0, min(tab_button_content_rect.width(), font().width(m_tabs[i].title)), font().glyph_height() };
+ Gfx::IntRect focus_rect { 0, 0, min(tab_button_content_rect.width(), font().width(m_tabs[i].title)), font().pixel_size_rounded_up() };
focus_rect.align_within(tab_button_content_rect, m_text_alignment);
focus_rect.inflate(6, 4);
diff --git a/Userland/Libraries/LibGUI/TextEditor.cpp b/Userland/Libraries/LibGUI/TextEditor.cpp
index 3f801aa1c9..9cb591c8b7 100644
--- a/Userland/Libraries/LibGUI/TextEditor.cpp
+++ b/Userland/Libraries/LibGUI/TextEditor.cpp
@@ -1437,7 +1437,7 @@ Gfx::IntRect TextEditor::line_content_rect(size_t line_index) const
{
auto& line = this->line(line_index);
if (is_single_line()) {
- Gfx::IntRect line_rect = { content_x_for_position({ line_index, 0 }), 0, text_width_for_font(line.view(), font()), font().glyph_height() + 4 };
+ Gfx::IntRect line_rect = { content_x_for_position({ line_index, 0 }), 0, text_width_for_font(line.view(), font()), font().pixel_size_rounded_up() + 4 };
line_rect.center_vertically_within({ {}, frame_inner_rect().size() });
return line_rect;
}
diff --git a/Userland/Libraries/LibGUI/Wizards/WizardPage.cpp b/Userland/Libraries/LibGUI/Wizards/WizardPage.cpp
index 9082392e08..35b0037fe2 100644
--- a/Userland/Libraries/LibGUI/Wizards/WizardPage.cpp
+++ b/Userland/Libraries/LibGUI/Wizards/WizardPage.cpp
@@ -27,11 +27,11 @@ WizardPage::WizardPage(DeprecatedString const& title_text, DeprecatedString cons
header_widget.set_layout<VerticalBoxLayout>(GUI::Margins { 15, 30, 0 });
m_title_label = header_widget.add<Label>(title_text);
m_title_label->set_font(Gfx::FontDatabase::default_font().bold_variant());
- m_title_label->set_fixed_height(m_title_label->font().glyph_height() + 2);
+ m_title_label->set_fixed_height(m_title_label->font().pixel_size_rounded_up() + 2);
m_title_label->set_text_alignment(Gfx::TextAlignment::TopLeft);
m_subtitle_label = header_widget.add<Label>(subtitle_text);
m_subtitle_label->set_text_alignment(Gfx::TextAlignment::TopLeft);
- m_subtitle_label->set_fixed_height(m_subtitle_label->font().glyph_height());
+ m_subtitle_label->set_fixed_height(m_subtitle_label->font().pixel_size_rounded_up());
header_widget.add_spacer().release_value_but_fixme_should_propagate_errors();
auto& separator = add<SeparatorWidget>(Gfx::Orientation::Horizontal);