Skip to content

Commit

Permalink
LibDraw: Put all classes in the Gfx namespace
Browse files Browse the repository at this point in the history
I started adding things to a Draw namespace, but it somehow felt really
wrong seeing Draw::Rect and Draw::Bitmap, etc. So instead, let's rename
the library to LibGfx. :^)
  • Loading branch information
awesomekling committed Feb 6, 2020
1 parent 939a605 commit 11580ba
Show file tree
Hide file tree
Showing 269 changed files with 1,513 additions and 1,315 deletions.
4 changes: 2 additions & 2 deletions Applications/About/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ int main(int argc, char** argv)
widget->layout()->set_spacing(8);

auto icon_label = GUI::Label::construct(widget);
icon_label->set_icon(GraphicsBitmap::load_from_file("/res/icons/serenity.png"));
icon_label->set_icon(Gfx::Bitmap::load_from_file("/res/icons/serenity.png"));
icon_label->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
icon_label->set_preferred_size(icon_label->icon()->size());

auto label = GUI::Label::construct(widget);
label->set_font(Font::default_bold_font());
label->set_font(Gfx::Font::default_bold_font());
label->set_text("SerenityOS");
label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
label->set_preferred_size(0, 11);
Expand Down
4 changes: 2 additions & 2 deletions Applications/Browser/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,13 @@ int main(int argc, char** argv)

auto help_menu = GUI::Menu::construct("Help");
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
GUI::AboutDialog::show("Browser", GraphicsBitmap::load_from_file("/res/icons/32x32/filetype-html.png"), window);
GUI::AboutDialog::show("Browser", Gfx::Bitmap::load_from_file("/res/icons/32x32/filetype-html.png"), window);
}));
menubar->add_menu(move(help_menu));

app.set_menubar(move(menubar));

window->set_icon(GraphicsBitmap::load_from_file("/res/icons/16x16/filetype-html.png"));
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-html.png"));

window->set_title("Browser");
window->set_main_widget(widget);
Expand Down
6 changes: 3 additions & 3 deletions Applications/Calculator/CalculatorWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ CalculatorWidget::CalculatorWidget(GUI::Widget* parent)

m_entry = GUI::TextBox::construct(this);
m_entry->set_relative_rect(5, 5, 244, 26);
m_entry->set_text_alignment(TextAlignment::CenterRight);
m_entry->set_text_alignment(Gfx::TextAlignment::CenterRight);

m_label = GUI::Label::construct(this);
m_label->set_relative_rect(12, 42, 27, 27);
m_label->set_foreground_color(Color::NamedColor::Red);
m_label->set_frame_shadow(FrameShadow::Sunken);
m_label->set_frame_shape(FrameShape::Container);
m_label->set_frame_shadow(Gfx::FrameShadow::Sunken);
m_label->set_frame_shape(Gfx::FrameShape::Container);
m_label->set_frame_thickness(2);

update_display();
Expand Down
4 changes: 2 additions & 2 deletions Applications/Calculator/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ int main(int argc, char** argv)
window->set_main_widget(calc_widget);

window->show();
window->set_icon(GraphicsBitmap::load_from_file("/res/icons/16x16/app-calculator.png"));
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-calculator.png"));

auto menubar = make<GUI::MenuBar>();

Expand All @@ -76,7 +76,7 @@ int main(int argc, char** argv)

auto help_menu = GUI::Menu::construct("Help");
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
GUI::AboutDialog::show("Calculator", load_png("/res/icons/16x16/app-calculator.png"), window);
GUI::AboutDialog::show("Calculator", Gfx::load_png("/res/icons/16x16/app-calculator.png"), window);
}));
menubar->add_menu(move(help_menu));

Expand Down
12 changes: 6 additions & 6 deletions Applications/ChanViewer/ThreadCatalogModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,17 @@ GUI::Model::ColumnMetadata ThreadCatalogModel::column_metadata(int column) const
{
switch (column) {
case Column::ThreadNumber:
return { 70, TextAlignment::CenterRight };
return { 70, Gfx::TextAlignment::CenterRight };
case Column::Subject:
return { 170, TextAlignment::CenterLeft };
return { 170, Gfx::TextAlignment::CenterLeft };
case Column::Text:
return { 270, TextAlignment::CenterLeft };
return { 270, Gfx::TextAlignment::CenterLeft };
case Column::ReplyCount:
return { 45, TextAlignment::CenterRight };
return { 45, Gfx::TextAlignment::CenterRight };
case Column::ImageCount:
return { 40, TextAlignment::CenterRight };
return { 40, Gfx::TextAlignment::CenterRight };
case Column::PostTime:
return { 120, TextAlignment::CenterLeft };
return { 120, Gfx::TextAlignment::CenterLeft };
default:
ASSERT_NOT_REACHED();
}
Expand Down
4 changes: 2 additions & 2 deletions Applications/ChanViewer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ int main(int argc, char** argv)
auto window = GUI::Window::construct();
window->set_title("ChanViewer");
window->set_rect(100, 100, 800, 500);
window->set_icon(load_png("/res/icons/16x16/app-chanviewer.png"));
window->set_icon(Gfx::load_png("/res/icons/16x16/app-chanviewer.png"));

auto widget = GUI::Widget::construct();
window->set_main_widget(widget);
Expand Down Expand Up @@ -104,7 +104,7 @@ int main(int argc, char** argv)

auto help_menu = GUI::Menu::construct("Help");
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
GUI::AboutDialog::show("ChanViewer", load_png("/res/icons/32x32/app-chanviewer.png"), window);
GUI::AboutDialog::show("ChanViewer", Gfx::load_png("/res/icons/32x32/app-chanviewer.png"), window);
}));
menubar->add_menu(move(help_menu));

Expand Down
2 changes: 1 addition & 1 deletion Applications/DisplayProperties/DisplayProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void DisplayPropertiesWidget::create_frame()
m_selected_wallpaper = m_wallpapers.at(index.row());
builder.append("/res/wallpapers/");
builder.append(m_selected_wallpaper);
m_wallpaper_preview->set_icon(load_png(builder.to_string()));
m_wallpaper_preview->set_icon(Gfx::load_png(builder.to_string()));
m_wallpaper_preview->set_should_stretch_icon(true);
};

Expand Down
2 changes: 1 addition & 1 deletion Applications/DisplayProperties/DisplayProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ class DisplayPropertiesWidget final {
Vector<String> m_wallpapers;
RefPtr<GUI::Label> m_wallpaper_preview;

Size m_selected_resolution;
Gfx::Size m_selected_resolution;
String m_selected_wallpaper;
};
2 changes: 1 addition & 1 deletion Applications/DisplayProperties/ItemListModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ItemListModel final : public GUI::Model {

virtual ColumnMetadata column_metadata(int) const override
{
return { 70, TextAlignment::CenterLeft };
return { 70, Gfx::TextAlignment::CenterLeft };
}

virtual GUI::Variant data(const GUI::ModelIndex& index, Role role = Role::Display) const override
Expand Down
4 changes: 2 additions & 2 deletions Applications/DisplayProperties/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ int main(int argc, char** argv)
window->resize(400, 448);
window->set_resizable(false);
window->set_main_widget(instance.root_widget());
window->set_icon(load_png("/res/icons/16x16/app-display-properties.png"));
window->set_icon(Gfx::load_png("/res/icons/16x16/app-display-properties.png"));

// Let's create the menubar first
auto menubar = make<GUI::MenuBar>();
Expand All @@ -71,7 +71,7 @@ int main(int argc, char** argv)

auto help_menu = GUI::Menu::construct("Help");
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
GUI::AboutDialog::show("Display Properties", load_png("/res/icons/32x32/app-display-properties.png"), window);
GUI::AboutDialog::show("Display Properties", Gfx::load_png("/res/icons/32x32/app-display-properties.png"), window);
}));
menubar->add_menu(move(help_menu));

Expand Down
14 changes: 7 additions & 7 deletions Applications/FileManager/PropertiesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ PropertiesDialog::PropertiesDialog(GUI::FileSystemModel& model, String path, boo
}
};

set_icon(GraphicsBitmap::load_from_file("/res/icons/16x16/properties.png"));
set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/properties.png"));
make_divider(general_tab);

struct stat st;
Expand Down Expand Up @@ -154,7 +154,7 @@ PropertiesDialog::~PropertiesDialog() {}

void PropertiesDialog::update()
{
m_icon->set_icon(const_cast<GraphicsBitmap*>(m_model.icon_for_file(m_mode, m_name).bitmap_for_size(32)));
m_icon->set_icon(const_cast<Gfx::Bitmap*>(m_model.icon_for_file(m_mode, m_name).bitmap_for_size(32)));
set_title(String::format("Properties of \"%s\"", m_name.characters()));
}

Expand Down Expand Up @@ -219,7 +219,7 @@ void PropertiesDialog::make_permission_checkboxes(NonnullRefPtr<GUI::Widget>& pa
widget->layout()->set_spacing(10);

auto label = GUI::Label::construct(label_string, widget);
label->set_text_alignment(TextAlignment::CenterLeft);
label->set_text_alignment(Gfx::TextAlignment::CenterLeft);

auto box_read = GUI::CheckBox::construct("Read", widget);
box_read->set_checked(mode & masks.read);
Expand Down Expand Up @@ -248,10 +248,10 @@ void PropertiesDialog::make_property_value_pairs(const Vector<PropertyValuePair>
label_container->layout()->set_spacing(12);

auto label_property = GUI::Label::construct(pair.property, label_container);
label_property->set_text_alignment(TextAlignment::CenterLeft);
label_property->set_text_alignment(Gfx::TextAlignment::CenterLeft);
label_property->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);

GUI::Label::construct(pair.value, label_container)->set_text_alignment(TextAlignment::CenterLeft);
GUI::Label::construct(pair.value, label_container)->set_text_alignment(Gfx::TextAlignment::CenterLeft);

max_width = max(max_width, label_property->font().width(pair.property));
property_labels.append(label_property);
Expand All @@ -276,8 +276,8 @@ void PropertiesDialog::make_divider(NonnullRefPtr<GUI::Widget>& parent)
auto divider = GUI::Frame::construct(parent.ptr());
divider->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
divider->set_preferred_size({ 0, 2 });
divider->set_frame_shape(FrameShape::HorizontalLine);
divider->set_frame_shadow(FrameShadow::Sunken);
divider->set_frame_shape(Gfx::FrameShape::HorizontalLine);
divider->set_frame_shadow(Gfx::FrameShadow::Sunken);
divider->set_frame_thickness(2);

parent->layout()->add_spacer();
Expand Down
22 changes: 11 additions & 11 deletions Applications/FileManager/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ int main(int argc, char** argv)
progressbar->set_caption("Generating thumbnails: ");
progressbar->set_format(GUI::ProgressBar::Format::ValueSlashMax);
progressbar->set_visible(false);
progressbar->set_frame_shape(FrameShape::Panel);
progressbar->set_frame_shadow(FrameShadow::Sunken);
progressbar->set_frame_shape(Gfx::FrameShape::Panel);
progressbar->set_frame_shadow(Gfx::FrameShadow::Sunken);
progressbar->set_frame_thickness(1);

location_textbox->on_return_pressed = [&] {
Expand Down Expand Up @@ -164,11 +164,11 @@ int main(int argc, char** argv)
auto tree_view_directory_context_menu = GUI::Menu::construct("Tree View Directory");
auto tree_view_context_menu = GUI::Menu::construct("Tree View");

auto open_parent_directory_action = GUI::Action::create("Open parent directory", { Mod_Alt, Key_Up }, GraphicsBitmap::load_from_file("/res/icons/16x16/open-parent-directory.png"), [&](const GUI::Action&) {
auto open_parent_directory_action = GUI::Action::create("Open parent directory", { Mod_Alt, Key_Up }, Gfx::Bitmap::load_from_file("/res/icons/16x16/open-parent-directory.png"), [&](const GUI::Action&) {
directory_view->open_parent_directory();
});

auto mkdir_action = GUI::Action::create("New directory...", { Mod_Ctrl | Mod_Shift, Key_N }, GraphicsBitmap::load_from_file("/res/icons/16x16/mkdir.png"), [&](const GUI::Action&) {
auto mkdir_action = GUI::Action::create("New directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/mkdir.png"), [&](const GUI::Action&) {
auto input_box = GUI::InputBox::construct("Enter name:", "New directory", window);
if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) {
auto new_dir_path = canonicalized_path(
Expand All @@ -188,7 +188,7 @@ int main(int argc, char** argv)
RefPtr<GUI::Action> view_as_icons_action;
RefPtr<GUI::Action> view_as_columns_action;

view_as_table_action = GUI::Action::create("Table view", { Mod_Ctrl, KeyCode::Key_L }, GraphicsBitmap::load_from_file("/res/icons/16x16/table-view.png"), [&](const GUI::Action&) {
view_as_table_action = GUI::Action::create("Table view", { Mod_Ctrl, KeyCode::Key_L }, Gfx::Bitmap::load_from_file("/res/icons/16x16/table-view.png"), [&](const GUI::Action&) {
directory_view->set_view_mode(DirectoryView::ViewMode::List);
view_as_table_action->set_checked(true);

Expand All @@ -197,7 +197,7 @@ int main(int argc, char** argv)
}, window);
view_as_table_action->set_checkable(true);

view_as_icons_action = GUI::Action::create("Icon view", { Mod_Ctrl, KeyCode::Key_I }, GraphicsBitmap::load_from_file("/res/icons/16x16/icon-view.png"), [&](const GUI::Action&) {
view_as_icons_action = GUI::Action::create("Icon view", { Mod_Ctrl, KeyCode::Key_I }, Gfx::Bitmap::load_from_file("/res/icons/16x16/icon-view.png"), [&](const GUI::Action&) {
directory_view->set_view_mode(DirectoryView::ViewMode::Icon);
view_as_icons_action->set_checked(true);

Expand All @@ -206,7 +206,7 @@ int main(int argc, char** argv)
}, window);
view_as_icons_action->set_checkable(true);

view_as_columns_action = GUI::Action::create("Columns view", GraphicsBitmap::load_from_file("/res/icons/16x16/columns-view.png"), [&](const GUI::Action&) {
view_as_columns_action = GUI::Action::create("Columns view", Gfx::Bitmap::load_from_file("/res/icons/16x16/columns-view.png"), [&](const GUI::Action&) {
directory_view->set_view_mode(DirectoryView::ViewMode::Columns);
view_as_columns_action->set_checked(true);

Expand Down Expand Up @@ -298,7 +298,7 @@ int main(int argc, char** argv)
};

auto properties_action
= GUI::Action::create("Properties...", { Mod_Alt, Key_Return }, GraphicsBitmap::load_from_file("/res/icons/16x16/properties.png"), [&](const GUI::Action& action) {
= GUI::Action::create("Properties...", { Mod_Alt, Key_Return }, Gfx::Bitmap::load_from_file("/res/icons/16x16/properties.png"), [&](const GUI::Action& action) {
auto& model = directory_view->model();
String path;
Vector<String> selected;
Expand Down Expand Up @@ -445,7 +445,7 @@ int main(int argc, char** argv)

auto help_menu = GUI::Menu::construct("Help");
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
GUI::AboutDialog::show("File Manager", load_png("/res/icons/32x32/filetype-folder.png"), window);
GUI::AboutDialog::show("File Manager", Gfx::load_png("/res/icons/32x32/filetype-folder.png"), window);
}));
menubar->add_menu(move(help_menu));

Expand Down Expand Up @@ -502,7 +502,7 @@ int main(int argc, char** argv)
delete_action->set_enabled(!view.selection().is_empty());
};

auto open_in_text_editor_action = GUI::Action::create("Open in TextEditor...", GraphicsBitmap::load_from_file("/res/icons/TextEditor16.png"), [&](auto&) {
auto open_in_text_editor_action = GUI::Action::create("Open in TextEditor...", Gfx::Bitmap::load_from_file("/res/icons/TextEditor16.png"), [&](auto&) {
for (auto& path : selected_file_paths()) {
if (!fork()) {
int rc = execl("/bin/TextEditor", "TextEditor", path.characters(), nullptr);
Expand Down Expand Up @@ -587,7 +587,7 @@ int main(int argc, char** argv)
window->set_main_widget(widget);
window->show();

window->set_icon(load_png("/res/icons/16x16/filetype-folder.png"));
window->set_icon(Gfx::load_png("/res/icons/16x16/filetype-folder.png"));

// Read direcory read mode from config.
auto dir_view_mode = config->read_entry("DirectoryView", "ViewMode", "Icon");
Expand Down
4 changes: 2 additions & 2 deletions Applications/FontEditor/FontEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include <LibGUI/GTextBox.h>
#include <stdlib.h>

FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Font>&& edited_font, GUI::Widget* parent)
FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::Font>&& edited_font, GUI::Widget* parent)
: GUI::Widget(parent)
, m_edited_font(move(edited_font))
{
Expand Down Expand Up @@ -85,7 +85,7 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Font>&& edited_fon
exit(0);
};

m_ui->info_label->set_text_alignment(TextAlignment::CenterLeft);
m_ui->info_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);

m_ui->demo_label_1->set_font(m_edited_font);
m_ui->demo_label_1->set_text("quick fox jumps nightly above wizard.");
Expand Down
4 changes: 2 additions & 2 deletions Applications/FontEditor/FontEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class FontEditorWidget final : public GUI::Widget {
virtual ~FontEditorWidget() override;

private:
FontEditorWidget(const String& path, RefPtr<Font>&&, GUI::Widget* parent = nullptr);
RefPtr<Font> m_edited_font;
FontEditorWidget(const String& path, RefPtr<Gfx::Font>&&, GUI::Widget* parent = nullptr);
RefPtr<Gfx::Font> m_edited_font;

GlyphMapWidget* m_glyph_map_widget { nullptr };
GlyphEditorWidget* m_glyph_editor_widget { nullptr };
Expand Down
6 changes: 3 additions & 3 deletions Applications/FontEditor/GlyphEditorWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
#include "GlyphEditorWidget.h"
#include <LibGUI/GPainter.h>

GlyphEditorWidget::GlyphEditorWidget(Font& mutable_font, GUI::Widget* parent)
GlyphEditorWidget::GlyphEditorWidget(Gfx::Font& mutable_font, GUI::Widget* parent)
: GUI::Frame(parent)
, m_font(mutable_font)
{
set_frame_thickness(2);
set_frame_shadow(FrameShadow::Sunken);
set_frame_shape(FrameShape::Container);
set_frame_shadow(Gfx::FrameShadow::Sunken);
set_frame_shape(Gfx::FrameShape::Container);
set_relative_rect({ 0, 0, preferred_width(), preferred_height() });
}

Expand Down
8 changes: 4 additions & 4 deletions Applications/FontEditor/GlyphEditorWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@ class GlyphEditorWidget final : public GUI::Frame {
int preferred_width() const;
int preferred_height() const;

Font& font() { return *m_font; }
const Font& font() const { return *m_font; }
Gfx::Font& font() { return *m_font; }
const Gfx::Font& font() const { return *m_font; }

Function<void(u8)> on_glyph_altered;

private:
GlyphEditorWidget(Font&, GUI::Widget* parent);
GlyphEditorWidget(Gfx::Font&, GUI::Widget* parent);
virtual void paint_event(GUI::PaintEvent&) override;
virtual void mousedown_event(GUI::MouseEvent&) override;
virtual void mousemove_event(GUI::MouseEvent&) override;

void draw_at_mouse(const GUI::MouseEvent&);

RefPtr<Font> m_font;
RefPtr<Gfx::Font> m_font;
u8 m_glyph { 0 };
int m_scale { 10 };
};
6 changes: 3 additions & 3 deletions Applications/FontEditor/GlyphMapWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
#include <LibDraw/Palette.h>
#include <LibGUI/GPainter.h>

GlyphMapWidget::GlyphMapWidget(Font& mutable_font, GUI::Widget* parent)
GlyphMapWidget::GlyphMapWidget(Gfx::Font& mutable_font, GUI::Widget* parent)
: GUI::Frame(parent)
, m_font(mutable_font)
{
set_frame_thickness(2);
set_frame_shape(FrameShape::Container);
set_frame_shadow(FrameShadow::Sunken);
set_frame_shape(Gfx::FrameShape::Container);
set_frame_shadow(Gfx::FrameShadow::Sunken);
set_relative_rect({ 0, 0, preferred_width(), preferred_height() });
}

Expand Down
Loading

0 comments on commit 11580ba

Please sign in to comment.