1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:27:44 +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

@ -144,8 +144,8 @@ DirectoryView::DirectoryView()
}; };
// NOTE: We're using the on_update hook on the GSortingProxyModel here instead of // NOTE: We're using the on_update hook on the GSortingProxyModel here instead of
// the GFileSystemModel's hook. This is because GSortingProxyModel has already // the GUI::FileSystemModel's hook. This is because GSortingProxyModel has already
// installed an on_update hook on the GFileSystemModel internally. // installed an on_update hook on the GUI::FileSystemModel internally.
// FIXME: This is an unfortunate design. We should come up with something better. // FIXME: This is an unfortunate design. We should come up with something better.
m_table_view->model()->on_update = [this] { m_table_view->model()->on_update = [this] {
for_each_view_implementation([](auto& view) { for_each_view_implementation([](auto& view) {

View file

@ -79,7 +79,7 @@ PropertiesDialog::PropertiesDialog(GUI::FileSystemModel& model, String path, boo
m_name_box->set_text(m_name); m_name_box->set_text(m_name);
m_name_box->on_change = [&, disable_rename]() { m_name_box->on_change = [&, disable_rename]() {
if (disable_rename) { if (disable_rename) {
m_name_box->set_text(m_name); //FIXME: GTextBox does not support set_enabled yet... m_name_box->set_text(m_name); //FIXME: GUI::TextBox does not support set_enabled yet...
} else { } else {
m_name_dirty = m_name != m_name_box->text(); m_name_dirty = m_name != m_name_box->text();
m_apply_button->set_enabled(true); m_apply_button->set_enabled(true);

View file

@ -52,6 +52,6 @@ public:
private: private:
ManualModel(); ManualModel();
GIcon m_section_icon; GUI::Icon m_section_icon;
GIcon m_page_icon; GUI::Icon m_page_icon;
}; };

View file

@ -44,7 +44,7 @@
HexEditor::HexEditor() HexEditor::HexEditor()
{ {
set_scrollbars_enabled(true); set_scrollbars_enabled(true);
set_font(GFontDatabase::the().get_by_name("Csilla Thin")); set_font(GUI::FontDatabase::the().get_by_name("Csilla Thin"));
set_background_role(ColorRole::Base); set_background_role(ColorRole::Base);
set_foreground_role(ColorRole::BaseText); set_foreground_role(ColorRole::BaseText);
vertical_scrollbar().set_step(line_height()); vertical_scrollbar().set_step(line_height());

View file

@ -281,11 +281,11 @@ int main(int argc, char** argv)
GUI::ActionGroup font_action_group; GUI::ActionGroup font_action_group;
font_action_group.set_exclusive(true); font_action_group.set_exclusive(true);
auto font_menu = GUI::Menu::construct("Font"); auto font_menu = GUI::Menu::construct("Font");
GFontDatabase::the().for_each_fixed_width_font([&](const StringView& font_name) { GUI::FontDatabase::the().for_each_fixed_width_font([&](const StringView& font_name) {
auto action = GUI::Action::create(font_name, [&](GUI::Action& action) { auto action = GUI::Action::create(font_name, [&](GUI::Action& action) {
action.set_checked(true); action.set_checked(true);
terminal.set_font(GFontDatabase::the().get_by_name(action.text())); terminal.set_font(GUI::FontDatabase::the().get_by_name(action.text()));
auto metadata = GFontDatabase::the().get_metadata_by_name(action.text()); auto metadata = GUI::FontDatabase::the().get_metadata_by_name(action.text());
ASSERT(metadata.has_value()); ASSERT(metadata.has_value());
config->write_entry("Text", "Font", metadata.value().path); config->write_entry("Text", "Font", metadata.value().path);
config->sync(); config->sync();

View file

@ -370,9 +370,9 @@ TextEditorWidget::TextEditorWidget()
menubar->add_menu(move(edit_menu)); menubar->add_menu(move(edit_menu));
auto font_menu = GUI::Menu::construct("Font"); auto font_menu = GUI::Menu::construct("Font");
GFontDatabase::the().for_each_fixed_width_font([&](const StringView& font_name) { GUI::FontDatabase::the().for_each_fixed_width_font([&](const StringView& font_name) {
font_menu->add_action(GUI::Action::create(font_name, [this](const GUI::Action& action) { font_menu->add_action(GUI::Action::create(font_name, [this](const GUI::Action& action) {
m_editor->set_font(GFontDatabase::the().get_by_name(action.text())); m_editor->set_font(GUI::FontDatabase::the().get_by_name(action.text()));
m_editor->update(); m_editor->update();
})); }));
}); });

View file

@ -169,11 +169,11 @@ Project::Project(const String& path, Vector<String>&& filenames)
{ {
m_name = FileSystemPath(m_path).basename(); m_name = FileSystemPath(m_path).basename();
m_file_icon = GIcon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-unknown.png")); m_file_icon = GUI::Icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-unknown.png"));
m_cplusplus_icon = GIcon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-cplusplus.png")); m_cplusplus_icon = GUI::Icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-cplusplus.png"));
m_header_icon = GIcon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-header.png")); m_header_icon = GUI::Icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-header.png"));
m_directory_icon = GIcon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-folder.png")); m_directory_icon = GUI::Icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-folder.png"));
m_project_icon = GIcon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-hack-studio.png")); m_project_icon = GUI::Icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-hack-studio.png"));
for (auto& filename : filenames) { for (auto& filename : filenames) {
m_files.append(ProjectFile::construct_with_name(filename)); m_files.append(ProjectFile::construct_with_name(filename));

View file

@ -71,9 +71,9 @@ private:
NonnullRefPtrVector<ProjectFile> m_files; NonnullRefPtrVector<ProjectFile> m_files;
RefPtr<ProjectTreeNode> m_root_node; RefPtr<ProjectTreeNode> m_root_node;
GIcon m_directory_icon; GUI::Icon m_directory_icon;
GIcon m_file_icon; GUI::Icon m_file_icon;
GIcon m_cplusplus_icon; GUI::Icon m_cplusplus_icon;
GIcon m_header_icon; GUI::Icon m_header_icon;
GIcon m_project_icon; GUI::Icon m_project_icon;
}; };

View file

@ -47,5 +47,5 @@ private:
explicit WidgetTreeModel(GUI::Widget&); explicit WidgetTreeModel(GUI::Widget&);
NonnullRefPtr<GUI::Widget> m_root; NonnullRefPtr<GUI::Widget> m_root;
GIcon m_widget_icon; GUI::Icon m_widget_icon;
}; };

View file

@ -55,8 +55,8 @@ private:
RemoteProcess& m_process; RemoteProcess& m_process;
GIcon m_object_icon; GUI::Icon m_object_icon;
GIcon m_window_icon; GUI::Icon m_window_icon;
GIcon m_layout_icon; GUI::Icon m_layout_icon;
GIcon m_timer_icon; GUI::Icon m_timer_icon;
}; };

View file

@ -61,6 +61,6 @@ private:
Profile& m_profile; Profile& m_profile;
GIcon m_user_frame_icon; GUI::Icon m_user_frame_icon;
GIcon m_kernel_frame_icon; GUI::Icon m_kernel_frame_icon;
}; };

View file

@ -35,7 +35,7 @@
SnakeGame::SnakeGame() SnakeGame::SnakeGame()
{ {
set_font(GFontDatabase::the().get_by_name("Liza Regular")); set_font(GUI::FontDatabase::the().get_by_name("Liza Regular"));
m_fruit_bitmaps.append(*Gfx::Bitmap::load_from_file("/res/icons/snake/paprika.png")); m_fruit_bitmaps.append(*Gfx::Bitmap::load_from_file("/res/icons/snake/paprika.png"));
m_fruit_bitmaps.append(*Gfx::Bitmap::load_from_file("/res/icons/snake/eggplant.png")); m_fruit_bitmaps.append(*Gfx::Bitmap::load_from_file("/res/icons/snake/eggplant.png"));
m_fruit_bitmaps.append(*Gfx::Bitmap::load_from_file("/res/icons/snake/cauliflower.png")); m_fruit_bitmaps.append(*Gfx::Bitmap::load_from_file("/res/icons/snake/cauliflower.png"));

View file

@ -31,7 +31,7 @@
namespace GUI { namespace GUI {
class AbstractButton : public Widget { class AbstractButton : public Widget {
C_OBJECT_ABSTRACT(GAbstractButton) C_OBJECT_ABSTRACT(AbstractButton)
public: public:
virtual ~AbstractButton() override; virtual ~AbstractButton() override;

View file

@ -199,14 +199,14 @@ FileSystemModel::FileSystemModel(const StringView& root_path, Mode mode)
: m_root_path(canonicalized_path(root_path)) : m_root_path(canonicalized_path(root_path))
, m_mode(mode) , m_mode(mode)
{ {
m_directory_icon = GIcon::default_icon("filetype-folder"); m_directory_icon = Icon::default_icon("filetype-folder");
m_file_icon = GIcon::default_icon("filetype-unknown"); m_file_icon = Icon::default_icon("filetype-unknown");
m_symlink_icon = GIcon::default_icon("filetype-symlink"); m_symlink_icon = Icon::default_icon("filetype-symlink");
m_socket_icon = GIcon::default_icon("filetype-socket"); m_socket_icon = Icon::default_icon("filetype-socket");
m_executable_icon = GIcon::default_icon("filetype-executable"); m_executable_icon = Icon::default_icon("filetype-executable");
m_filetype_image_icon = GIcon::default_icon("filetype-image"); m_filetype_image_icon = Icon::default_icon("filetype-image");
m_filetype_sound_icon = GIcon::default_icon("filetype-sound"); m_filetype_sound_icon = Icon::default_icon("filetype-sound");
m_filetype_html_icon = GIcon::default_icon("filetype-html"); m_filetype_html_icon = Icon::default_icon("filetype-html");
setpwent(); setpwent();
while (auto* passwd = getpwent()) while (auto* passwd = getpwent())
@ -341,7 +341,7 @@ Variant FileSystemModel::data(const ModelIndex& index, Role role) const
auto& node = this->node(index); auto& node = this->node(index);
if (role == Role::Custom) { if (role == Role::Custom) {
// For GFileSystemModel, custom role means the full path. // For GUI::FileSystemModel, custom role means the full path.
ASSERT(index.column() == Column::Name); ASSERT(index.column() == Column::Name);
return node.full_path(*this); return node.full_path(*this);
} }
@ -409,7 +409,7 @@ Variant FileSystemModel::data(const ModelIndex& index, Role role) const
return {}; return {};
} }
GIcon FileSystemModel::icon_for_file(const mode_t mode, const String& name) const Icon FileSystemModel::icon_for_file(const mode_t mode, const String& name) const
{ {
if (S_ISDIR(mode)) if (S_ISDIR(mode))
return m_directory_icon; return m_directory_icon;
@ -428,14 +428,14 @@ GIcon FileSystemModel::icon_for_file(const mode_t mode, const String& name) cons
return m_file_icon; return m_file_icon;
} }
GIcon FileSystemModel::icon_for(const Node& node) const Icon FileSystemModel::icon_for(const Node& node) const
{ {
if (node.name.to_lowercase().ends_with(".png")) { if (node.name.to_lowercase().ends_with(".png")) {
if (!node.thumbnail) { if (!node.thumbnail) {
if (!const_cast<FileSystemModel*>(this)->fetch_thumbnail_for(node)) if (!const_cast<FileSystemModel*>(this)->fetch_thumbnail_for(node))
return m_filetype_image_icon; return m_filetype_image_icon;
} }
return GIcon(m_filetype_image_icon.bitmap_for_size(16), *node.thumbnail); return GUI::Icon(m_filetype_image_icon.bitmap_for_size(16), *node.thumbnail);
} }
return icon_for_file(node.mode, node.name); return icon_for_file(node.mode, node.name);

View file

@ -109,7 +109,7 @@ public:
ModelIndex index(const StringView& path, int column) const; ModelIndex index(const StringView& path, int column) const;
const Node& node(const ModelIndex& index) const; const Node& node(const ModelIndex& index) const;
GIcon icon_for_file(const mode_t mode, const String& name) const; GUI::Icon icon_for_file(const mode_t mode, const String& name) const;
Function<void(int done, int total)> on_thumbnail_progress; Function<void(int done, int total)> on_thumbnail_progress;
Function<void()> on_root_path_change; Function<void()> on_root_path_change;
@ -141,20 +141,20 @@ private:
HashMap<gid_t, String> m_group_names; HashMap<gid_t, String> m_group_names;
bool fetch_thumbnail_for(const Node& node); bool fetch_thumbnail_for(const Node& node);
GIcon icon_for(const Node& node) const; GUI::Icon icon_for(const Node& node) const;
String m_root_path; String m_root_path;
Mode m_mode { Invalid }; Mode m_mode { Invalid };
OwnPtr<Node> m_root { nullptr }; OwnPtr<Node> m_root { nullptr };
GIcon m_directory_icon; GUI::Icon m_directory_icon;
GIcon m_file_icon; GUI::Icon m_file_icon;
GIcon m_symlink_icon; GUI::Icon m_symlink_icon;
GIcon m_socket_icon; GUI::Icon m_socket_icon;
GIcon m_executable_icon; GUI::Icon m_executable_icon;
GIcon m_filetype_image_icon; GUI::Icon m_filetype_image_icon;
GIcon m_filetype_sound_icon; GUI::Icon m_filetype_sound_icon;
GIcon m_filetype_html_icon; GUI::Icon m_filetype_html_icon;
unsigned m_thumbnail_progress { 0 }; unsigned m_thumbnail_progress { 0 };
unsigned m_thumbnail_progress_total { 0 }; unsigned m_thumbnail_progress_total { 0 };

View file

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

View file

@ -31,15 +31,17 @@
#include <AK/String.h> #include <AK/String.h>
#include <LibGfx/Forward.h> #include <LibGfx/Forward.h>
namespace GUI {
struct Metadata { struct Metadata {
String path; String path;
bool is_fixed_width; bool is_fixed_width;
int glyph_height; int glyph_height;
}; };
class GFontDatabase { class FontDatabase {
public: public:
static GFontDatabase& the(); static FontDatabase& the();
RefPtr<Gfx::Font> get_by_name(const StringView&); RefPtr<Gfx::Font> get_by_name(const StringView&);
void for_each_font(Function<void(const StringView&)>); void for_each_font(Function<void(const StringView&)>);
@ -51,8 +53,10 @@ public:
} }
private: private:
GFontDatabase(); FontDatabase();
~GFontDatabase(); ~FontDatabase();
HashMap<String, Metadata> m_name_to_metadata; HashMap<String, Metadata> m_name_to_metadata;
}; };
}

View file

@ -28,23 +28,25 @@
#include <LibGUI/Icon.h> #include <LibGUI/Icon.h>
#include <LibGfx/Bitmap.h> #include <LibGfx/Bitmap.h>
GIcon::GIcon() namespace GUI {
: m_impl(GIconImpl::create())
Icon::Icon()
: m_impl(IconImpl::create())
{ {
} }
GIcon::GIcon(const GIconImpl& impl) Icon::Icon(const IconImpl& impl)
: m_impl(const_cast<GIconImpl&>(impl)) : m_impl(const_cast<IconImpl&>(impl))
{ {
} }
GIcon::GIcon(const GIcon& other) Icon::Icon(const Icon& other)
: m_impl(other.m_impl) : m_impl(other.m_impl)
{ {
} }
GIcon::GIcon(RefPtr<Gfx::Bitmap>&& bitmap) Icon::Icon(RefPtr<Gfx::Bitmap>&& bitmap)
: GIcon() : Icon()
{ {
if (bitmap) { if (bitmap) {
ASSERT(bitmap->width() == bitmap->height()); ASSERT(bitmap->width() == bitmap->height());
@ -53,8 +55,8 @@ GIcon::GIcon(RefPtr<Gfx::Bitmap>&& bitmap)
} }
} }
GIcon::GIcon(RefPtr<Gfx::Bitmap>&& bitmap1, RefPtr<Gfx::Bitmap>&& bitmap2) Icon::Icon(RefPtr<Gfx::Bitmap>&& bitmap1, RefPtr<Gfx::Bitmap>&& bitmap2)
: GIcon(move(bitmap1)) : Icon(move(bitmap1))
{ {
if (bitmap2) { if (bitmap2) {
ASSERT(bitmap2->width() == bitmap2->height()); ASSERT(bitmap2->width() == bitmap2->height());
@ -63,7 +65,7 @@ GIcon::GIcon(RefPtr<Gfx::Bitmap>&& bitmap1, RefPtr<Gfx::Bitmap>&& bitmap2)
} }
} }
const Gfx::Bitmap* GIconImpl::bitmap_for_size(int size) const const Gfx::Bitmap* IconImpl::bitmap_for_size(int size) const
{ {
auto it = m_bitmaps.find(size); auto it = m_bitmaps.find(size);
if (it != m_bitmaps.end()) if (it != m_bitmaps.end())
@ -81,7 +83,7 @@ const Gfx::Bitmap* GIconImpl::bitmap_for_size(int size) const
return best_fit; return best_fit;
} }
void GIconImpl::set_bitmap_for_size(int size, RefPtr<Gfx::Bitmap>&& bitmap) void IconImpl::set_bitmap_for_size(int size, RefPtr<Gfx::Bitmap>&& bitmap)
{ {
if (!bitmap) { if (!bitmap) {
m_bitmaps.remove(size); m_bitmaps.remove(size);
@ -90,9 +92,11 @@ void GIconImpl::set_bitmap_for_size(int size, RefPtr<Gfx::Bitmap>&& bitmap)
m_bitmaps.set(size, move(bitmap)); m_bitmaps.set(size, move(bitmap));
} }
GIcon GIcon::default_icon(const StringView& name) Icon Icon::default_icon(const StringView& name)
{ {
auto bitmap16 = Gfx::Bitmap::load_from_file(String::format("/res/icons/16x16/%s.png", String(name).characters())); auto bitmap16 = Gfx::Bitmap::load_from_file(String::format("/res/icons/16x16/%s.png", String(name).characters()));
auto bitmap32 = Gfx::Bitmap::load_from_file(String::format("/res/icons/32x32/%s.png", String(name).characters())); auto bitmap32 = Gfx::Bitmap::load_from_file(String::format("/res/icons/32x32/%s.png", String(name).characters()));
return GIcon(move(bitmap16), move(bitmap32)); return Icon(move(bitmap16), move(bitmap32));
}
} }

View file

@ -31,31 +31,33 @@
#include <AK/RefCounted.h> #include <AK/RefCounted.h>
#include <LibGfx/Forward.h> #include <LibGfx/Forward.h>
class GIconImpl : public RefCounted<GIconImpl> { namespace GUI {
class IconImpl : public RefCounted<IconImpl> {
public: public:
static NonnullRefPtr<GIconImpl> create() { return adopt(*new GIconImpl); } static NonnullRefPtr<IconImpl> create() { return adopt(*new IconImpl); }
~GIconImpl() {} ~IconImpl() {}
const Gfx::Bitmap* bitmap_for_size(int) const; const Gfx::Bitmap* bitmap_for_size(int) const;
void set_bitmap_for_size(int, RefPtr<Gfx::Bitmap>&&); void set_bitmap_for_size(int, RefPtr<Gfx::Bitmap>&&);
private: private:
GIconImpl() {} IconImpl() {}
HashMap<int, RefPtr<Gfx::Bitmap>> m_bitmaps; HashMap<int, RefPtr<Gfx::Bitmap>> m_bitmaps;
}; };
class GIcon { class Icon {
public: public:
GIcon(); Icon();
explicit GIcon(RefPtr<Gfx::Bitmap>&&); explicit Icon(RefPtr<Gfx::Bitmap>&&);
explicit GIcon(RefPtr<Gfx::Bitmap>&&, RefPtr<Gfx::Bitmap>&&); explicit Icon(RefPtr<Gfx::Bitmap>&&, RefPtr<Gfx::Bitmap>&&);
explicit GIcon(const GIconImpl&); explicit Icon(const IconImpl&);
GIcon(const GIcon&); Icon(const Icon&);
~GIcon() {} ~Icon() {}
static GIcon default_icon(const StringView&); static Icon default_icon(const StringView&);
GIcon& operator=(const GIcon& other) Icon& operator=(const Icon& other)
{ {
if (this != &other) if (this != &other)
m_impl = other.m_impl; m_impl = other.m_impl;
@ -65,8 +67,10 @@ public:
const Gfx::Bitmap* bitmap_for_size(int size) const { return m_impl->bitmap_for_size(size); } const Gfx::Bitmap* bitmap_for_size(int size) const { return m_impl->bitmap_for_size(size); }
void set_bitmap_for_size(int size, RefPtr<Gfx::Bitmap>&& bitmap) { m_impl->set_bitmap_for_size(size, move(bitmap)); } void set_bitmap_for_size(int size, RefPtr<Gfx::Bitmap>&& bitmap) { m_impl->set_bitmap_for_size(size, move(bitmap)); }
const GIconImpl& impl() const { return *m_impl; } const IconImpl& impl() const { return *m_impl; }
private: private:
NonnullRefPtr<GIconImpl> m_impl; NonnullRefPtr<IconImpl> m_impl;
}; };
}

View file

@ -56,7 +56,7 @@ TextEditor::TextEditor(Type type)
set_foreground_role(ColorRole::BaseText); set_foreground_role(ColorRole::BaseText);
set_document(TextDocument::create()); set_document(TextDocument::create());
set_scrollbars_enabled(is_multi_line()); set_scrollbars_enabled(is_multi_line());
set_font(GFontDatabase::the().get_by_name("Csilla Thin")); set_font(FontDatabase::the().get_by_name("Csilla Thin"));
// FIXME: Recompute vertical scrollbar step size on font change. // FIXME: Recompute vertical scrollbar step size on font change.
vertical_scrollbar().set_step(line_height()); vertical_scrollbar().set_step(line_height());
m_cursor = { 0, 0 }; m_cursor = { 0, 0 };

View file

@ -190,10 +190,10 @@ Variant::Variant(const Gfx::Bitmap& value)
AK::ref_if_not_null(m_value.as_bitmap); AK::ref_if_not_null(m_value.as_bitmap);
} }
Variant::Variant(const GIcon& value) Variant::Variant(const GUI::Icon& value)
: m_type(Type::Icon) : m_type(Type::Icon)
{ {
m_value.as_icon = &const_cast<GIconImpl&>(value.impl()); m_value.as_icon = &const_cast<GUI::IconImpl&>(value.impl());
AK::ref_if_not_null(m_value.as_icon); AK::ref_if_not_null(m_value.as_icon);
} }
@ -398,7 +398,7 @@ String Variant::to_string() const
case Type::Bitmap: case Type::Bitmap:
return "[Gfx::Bitmap]"; return "[Gfx::Bitmap]";
case Type::Icon: case Type::Icon:
return "[GIcon]"; return "[GUI::Icon]";
case Type::Color: case Type::Color:
return as_color().to_string(); return as_color().to_string();
case Type::Point: case Type::Point:

View file

@ -44,7 +44,7 @@ public:
Variant(const char*); Variant(const char*);
Variant(const String&); Variant(const String&);
Variant(const Gfx::Bitmap&); Variant(const Gfx::Bitmap&);
Variant(const GIcon&); Variant(const GUI::Icon&);
Variant(const Gfx::Point&); Variant(const Gfx::Point&);
Variant(const Gfx::Size&); Variant(const Gfx::Size&);
Variant(const Gfx::Rect&); Variant(const Gfx::Rect&);
@ -207,10 +207,10 @@ public:
return *m_value.as_bitmap; return *m_value.as_bitmap;
} }
GIcon as_icon() const GUI::Icon as_icon() const
{ {
ASSERT(type() == Type::Icon); ASSERT(type() == Type::Icon);
return GIcon(*m_value.as_icon); return GUI::Icon(*m_value.as_icon);
} }
Color as_color() const Color as_color() const
@ -263,7 +263,7 @@ private:
union { union {
StringImpl* as_string; StringImpl* as_string;
Gfx::Bitmap* as_bitmap; Gfx::Bitmap* as_bitmap;
GIconImpl* as_icon; GUI::IconImpl* as_icon;
Gfx::Font* as_font; Gfx::Font* as_font;
bool as_bool; bool as_bool;
i32 as_i32; i32 as_i32;

View file

@ -51,7 +51,7 @@ private:
NonnullRefPtr<Document> m_document; NonnullRefPtr<Document> m_document;
GIcon m_document_icon; GUI::Icon m_document_icon;
GIcon m_element_icon; GUI::Icon m_element_icon;
GIcon m_text_icon; GUI::Icon m_text_icon;
}; };

View file

@ -26,7 +26,7 @@
#pragma once #pragma once
// Keep this in sync with GWindowType. // Keep this in sync with GUI::WindowType.
enum class WindowType { enum class WindowType {
Invalid = 0, Invalid = 0,
Normal, Normal,