mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:07:44 +00:00
LibGfx: Make Font::width() return a float
This commit is contained in:
parent
b9d2b8f7b2
commit
3407ab0fd1
25 changed files with 40 additions and 40 deletions
|
@ -109,10 +109,10 @@ void Breadcrumbbar::append_segment(DeprecatedString text, Gfx::Bitmap const* ico
|
|||
auto button_width = min(button_text_width + icon_width + icon_padding + 16, max_button_width);
|
||||
auto shrunken_width = icon_width + icon_padding + (icon ? 4 : 16);
|
||||
|
||||
button.set_max_size(button_width, 16 + 8);
|
||||
button.set_max_size(static_cast<int>(ceilf(button_width)), 16 + 8);
|
||||
button.set_min_size(shrunken_width, 16 + 8);
|
||||
|
||||
Segment segment { icon, text, data, button_width, shrunken_width, button.make_weak_ptr<GUI::Button>() };
|
||||
Segment segment { icon, text, data, static_cast<int>(ceilf(button_width)), shrunken_width, button.make_weak_ptr<GUI::Button>() };
|
||||
|
||||
m_segments.append(move(segment));
|
||||
relayout();
|
||||
|
|
|
@ -108,7 +108,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, font.width(text()), font.glyph_height() };
|
||||
Gfx::IntRect text_rect { 0, 0, static_cast<int>(ceilf(font.width(text()))), font.glyph_height() };
|
||||
if (text_rect.width() > content_rect.width())
|
||||
text_rect.set_width(content_rect.width());
|
||||
text_rect.align_within(content_rect, text_alignment());
|
||||
|
|
|
@ -43,7 +43,7 @@ void GroupBox::paint_event(PaintEvent& event)
|
|||
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, font().width(m_title) + 6, font().glyph_height() };
|
||||
Gfx::IntRect text_rect { 6, 1, static_cast<int>(ceilf(font().width(m_title) + 6)), font().glyph_height() };
|
||||
painter.fill_rect(text_rect, palette().button());
|
||||
painter.draw_text(text_rect, m_title, Gfx::TextAlignment::Center, palette().button_text());
|
||||
}
|
||||
|
|
|
@ -272,7 +272,7 @@ void HeaderView::paint_horizontal(Painter& painter)
|
|||
painter.draw_text(text_rect, text, font(), section_data.alignment, palette().button_text());
|
||||
|
||||
if (is_key_column && (m_table_view.sort_order() != SortOrder::None)) {
|
||||
Gfx::IntPoint offset { text_rect.x() + font().width(text) + sorting_arrow_offset, sorting_arrow_offset };
|
||||
Gfx::IntPoint offset { text_rect.x() + static_cast<int>(ceilf(font().width(text))) + sorting_arrow_offset, sorting_arrow_offset };
|
||||
auto coordinates = m_table_view.sort_order() == SortOrder::Ascending
|
||||
? ascending_arrow_coordinates.span()
|
||||
: descending_arrow_coordinates.span();
|
||||
|
|
|
@ -79,7 +79,7 @@ void LinkLabel::paint_event(PaintEvent& event)
|
|||
GUI::Painter painter(*this);
|
||||
|
||||
if (m_hovered)
|
||||
painter.draw_line({ 0, rect().bottom() }, { font().width(text()), rect().bottom() }, palette().link());
|
||||
painter.draw_line({ 0, rect().bottom() }, { static_cast<int>(ceilf(font().width(text()))), rect().bottom() }, palette().link());
|
||||
|
||||
if (is_focused())
|
||||
painter.draw_focus_rect(text_rect(), palette().focus_outline());
|
||||
|
|
|
@ -46,7 +46,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() + 7, 0, font().width(text()), font().glyph_height() };
|
||||
Gfx::IntRect text_rect { circle_rect.right() + 7, 0, static_cast<int>(ceilf(font().width(text()))), font().glyph_height() };
|
||||
text_rect.center_vertically_within(rect());
|
||||
paint_text(painter, text_rect, font(), Gfx::TextAlignment::TopLeft);
|
||||
|
||||
|
|
|
@ -452,7 +452,7 @@ Gfx::IntRect TabWidget::close_button_rect(size_t index) const
|
|||
|
||||
int TabWidget::TabData::width(Gfx::Font const& font) const
|
||||
{
|
||||
auto width = 16 + font.width(title) + (icon ? (16 + 4) : 0);
|
||||
auto width = 16 + static_cast<int>(ceilf(font.width(title))) + (icon ? (16 + 4) : 0);
|
||||
// NOTE: This needs to always be an odd number, because the button rect
|
||||
// includes 3px of light and shadow on the left and right edges. If
|
||||
// the button rect width is not an odd number, the area left for the
|
||||
|
|
|
@ -188,7 +188,7 @@ void TreeView::traverse_in_paint_order(Callback callback) const
|
|||
auto node_text = index.data().to_deprecated_string();
|
||||
Gfx::IntRect rect = {
|
||||
x_offset, y_offset,
|
||||
icon_size() + icon_spacing() + text_padding() + font_for_index(index)->width(node_text) + text_padding(), row_height()
|
||||
static_cast<int>(ceilf(icon_size() + icon_spacing() + text_padding() + font_for_index(index)->width(node_text) + text_padding())), row_height()
|
||||
};
|
||||
Gfx::IntRect toggle_rect;
|
||||
if (row_count_at_index > 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue