1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 17:55:08 +00:00

LibGUI: Move Icon and FontDatabase into the GUI namespace

We also clean up some old references to the old G prefixed GUI classes

This also fixes a potential bug with using: C_OBJECT_ABSTRACT(GAbstractButton)
instead of C_OBJECT_ABSTRACT(AbstractButton)
This commit is contained in:
Shannon Booth 2020-03-07 12:02:21 +13:00 committed by Andreas Kling
parent 57f1c919df
commit 6a3b12664a
24 changed files with 120 additions and 104 deletions

View file

@ -32,16 +32,18 @@
#include <stdio.h>
#include <stdlib.h>
static GFontDatabase* s_the;
namespace GUI {
GFontDatabase& GFontDatabase::the()
static FontDatabase* s_the;
FontDatabase& FontDatabase::the()
{
if (!s_the)
s_the = new GFontDatabase;
s_the = new FontDatabase;
return *s_the;
}
GFontDatabase::GFontDatabase()
FontDatabase::FontDatabase()
{
Core::DirIterator di("/res/fonts", Core::DirIterator::SkipDots);
if (di.has_error()) {
@ -61,11 +63,11 @@ GFontDatabase::GFontDatabase()
}
}
GFontDatabase::~GFontDatabase()
FontDatabase::~FontDatabase()
{
}
void GFontDatabase::for_each_font(Function<void(const StringView&)> callback)
void FontDatabase::for_each_font(Function<void(const StringView&)> callback)
{
Vector<String> names;
names.ensure_capacity(m_name_to_metadata.size());
@ -76,7 +78,7 @@ void GFontDatabase::for_each_font(Function<void(const StringView&)> callback)
callback(name);
}
void GFontDatabase::for_each_fixed_width_font(Function<void(const StringView&)> callback)
void FontDatabase::for_each_fixed_width_font(Function<void(const StringView&)> callback)
{
Vector<String> names;
names.ensure_capacity(m_name_to_metadata.size());
@ -89,10 +91,12 @@ void GFontDatabase::for_each_fixed_width_font(Function<void(const StringView&)>
callback(name);
}
RefPtr<Gfx::Font> GFontDatabase::get_by_name(const StringView& name)
RefPtr<Gfx::Font> FontDatabase::get_by_name(const StringView& name)
{
auto it = m_name_to_metadata.find(name);
if (it == m_name_to_metadata.end())
return nullptr;
return Gfx::Font::load_from_file((*it).value.path);
}
}