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

LibGFX: Move default_xxx_font() methods from Font to FontDatabase

When we have an abstract font class it makes no sense to keep
these methods in the Font class.
This commit is contained in:
Stephan Unverwerth 2020-12-29 18:25:13 +01:00 committed by Andreas Kling
parent 1a072a61fb
commit b4d1390714
48 changed files with 152 additions and 115 deletions

View file

@ -33,6 +33,7 @@
#include <LibGUI/Label.h>
#include <LibGUI/Widget.h>
#include <LibGfx/Font.h>
#include <LibGfx/FontDatabase.h>
namespace GUI {
@ -82,7 +83,7 @@ AboutDialog::AboutDialog(const StringView& name, const Gfx::Bitmap* icon, Window
label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
label.set_fixed_height(14);
if (bold)
label.set_font(Gfx::Font::default_bold_font());
label.set_font(Gfx::FontDatabase::default_bold_font());
};
make_label(m_name, true);
// If we are displaying a dialog for an application, insert 'SerenityOS' below the application name

View file

@ -30,6 +30,7 @@
#include <LibGUI/Button.h>
#include <LibGUI/Painter.h>
#include <LibGfx/Font.h>
#include <LibGfx/FontDatabase.h>
#include <LibGfx/Palette.h>
#include <LibGfx/StylePainter.h>
@ -89,7 +90,7 @@ void Button::paint_event(PaintEvent& event)
painter.blit_disabled(icon_location, *m_icon, m_icon->rect(), palette());
}
}
auto& font = is_checked() ? Gfx::Font::default_bold_font() : this->font();
auto& font = is_checked() ? Gfx::FontDatabase::default_bold_font() : this->font();
if (m_icon && !text().is_empty()) {
content_rect.move_by(m_icon->width() + 4, 0);
content_rect.set_width(content_rect.width() - m_icon->width() - 4);

View file

@ -32,6 +32,7 @@
#include <LibGUI/Painter.h>
#include <LibGUI/Window.h>
#include <LibGfx/Font.h>
#include <LibGfx/FontDatabase.h>
#include <LibGfx/Palette.h>
namespace GUI {
@ -72,7 +73,7 @@ Calendar::Calendar(Core::DateTime date_time)
m_day_name_container->set_background_role(Gfx::ColorRole::HoverHighlight);
for (auto& day : m_day_names) {
day = m_day_name_container->add<GUI::Label>();
day->set_font(Gfx::Font::default_bold_font());
day->set_font(Gfx::FontDatabase::default_bold_font());
}
m_calendar_tile_container = add<GUI::Widget>();
@ -357,13 +358,13 @@ void Calendar::CalendarTile::paint_event(GUI::PaintEvent& event)
} else if (is_selected()) {
painter.draw_rect(frame_inner_rect(), palette().base_text());
}
painter.draw_text(day_rect, display_date, Gfx::Font::default_bold_font(), Gfx::TextAlignment::Center, palette().base_text());
painter.draw_text(day_rect, display_date, Gfx::FontDatabase::default_bold_font(), Gfx::TextAlignment::Center, palette().base_text());
} else if (is_outside_selection()) {
painter.draw_text(day_rect, display_date, Gfx::Font::default_font(), Gfx::TextAlignment::Center, Color::LightGray);
painter.draw_text(day_rect, display_date, Gfx::FontDatabase::default_font(), Gfx::TextAlignment::Center, Color::LightGray);
} else {
if (!has_grid() && is_selected())
painter.draw_rect(frame_inner_rect(), palette().base_text());
painter.draw_text(day_rect, display_date, Gfx::Font::default_font(), Gfx::TextAlignment::Center, palette().base_text());
painter.draw_text(day_rect, display_date, Gfx::FontDatabase::default_font(), Gfx::TextAlignment::Center, palette().base_text());
}
}

View file

@ -40,6 +40,7 @@
#include <LibGUI/SortingProxyModel.h>
#include <LibGUI/TextBox.h>
#include <LibGUI/ToolBar.h>
#include <LibGfx/FontDatabase.h>
#include <string.h>
namespace GUI {
@ -253,7 +254,7 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, Options options, const
m_preview_image->set_fixed_size(160, 160);
m_preview_name_label = m_preview_container->add<Label>();
m_preview_name_label->set_font(Gfx::Font::default_bold_font());
m_preview_name_label->set_font(Gfx::FontDatabase::default_bold_font());
m_preview_name_label->set_fixed_height(m_preview_name_label->font().glyph_height());
m_preview_geometry_label = m_preview_container->add<Label>();

View file

@ -31,6 +31,7 @@
#include <LibGUI/Model.h>
#include <LibGUI/Painter.h>
#include <LibGUI/Window.h>
#include <LibGfx/FontDatabase.h>
#include <LibGfx/Palette.h>
#include <LibGfx/StylePainter.h>
@ -42,7 +43,7 @@ HeaderView::HeaderView(AbstractTableView& table_view, Gfx::Orientation orientati
: m_table_view(table_view)
, m_orientation(orientation)
{
set_font(Gfx::Font::default_bold_font());
set_font(Gfx::FontDatabase::default_bold_font());
if (m_orientation == Gfx::Orientation::Horizontal) {
set_fixed_height(16);

View file

@ -72,7 +72,7 @@ TextEditor::TextEditor(Type type)
set_visualize_trailing_whitespace(false);
set_scrollbars_enabled(is_multi_line());
if (is_multi_line())
set_font(Gfx::Font::default_fixed_width_font());
set_font(Gfx::FontDatabase::default_fixed_width_font());
vertical_scrollbar().set_step(line_height());
m_cursor = { 0, 0 };
m_automatic_selection_scroll_timer = add<Core::Timer>(100, [this] {

View file

@ -61,6 +61,7 @@
#include <LibGUI/WindowServerConnection.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/Font.h>
#include <LibGfx/FontDatabase.h>
#include <LibGfx/Palette.h>
#include <unistd.h>
@ -127,7 +128,7 @@ Widget::Widget()
: Core::Object(nullptr, true)
, m_background_role(Gfx::ColorRole::Window)
, m_foreground_role(Gfx::ColorRole::WindowText)
, m_font(Gfx::Font::default_font())
, m_font(Gfx::FontDatabase::default_font())
, m_palette(Application::the()->palette().impl())
{
REGISTER_RECT_PROPERTY("relative_rect", relative_rect, set_relative_rect);
@ -645,7 +646,7 @@ void Widget::set_font(const Gfx::Font* font)
return;
if (!font)
m_font = Gfx::Font::default_font();
m_font = Gfx::FontDatabase::default_font();
else
m_font = *font;