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

LibDraw: Put all classes in the Gfx namespace

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. :^)
This commit is contained in:
Andreas Kling 2020-02-06 11:56:38 +01:00
parent 939a605334
commit 11580babbf
269 changed files with 1513 additions and 1315 deletions

View file

@ -150,7 +150,7 @@ void CursorTool::on_keydown(GUI::KeyEvent& event)
}
}
void CursorTool::set_rubber_band_position(const Point& position)
void CursorTool::set_rubber_band_position(const Gfx::Point& position)
{
if (m_rubber_band_position == position)
return;

View file

@ -50,14 +50,14 @@ private:
virtual void on_keydown(GUI::KeyEvent&) override;
virtual void on_second_paint(GUI::Painter&, GUI::PaintEvent&) override;
void set_rubber_band_position(const Point&);
Rect rubber_band_rect() const;
void set_rubber_band_position(const Gfx::Point&);
Gfx::Rect rubber_band_rect() const;
Point m_drag_origin;
Gfx::Point m_drag_origin;
HashMap<GUI::Widget*, Point> m_positions_before_drag;
bool m_dragging { false };
bool m_rubber_banding { false };
Point m_rubber_band_origin;
Point m_rubber_band_position;
Gfx::Point m_rubber_band_origin;
Gfx::Point m_rubber_band_position;
};

View file

@ -114,7 +114,7 @@ static HashMap<String, String>& man_paths()
return paths;
}
void Editor::show_documentation_tooltip_if_available(const String& hovered_token, const Point& screen_location)
void Editor::show_documentation_tooltip_if_available(const String& hovered_token, const Gfx::Point& screen_location)
{
auto it = man_paths().find(hovered_token);
if (it == man_paths().end()) {

View file

@ -50,7 +50,7 @@ private:
virtual void mousemove_event(GUI::MouseEvent&) override;
virtual void cursor_did_change() override;
void show_documentation_tooltip_if_available(const String&, const Point& screen_location);
void show_documentation_tooltip_if_available(const String&, const Gfx::Point& screen_location);
void highlight_matching_token_pair();
explicit Editor(GUI::Widget* parent);

View file

@ -46,12 +46,12 @@ EditorWrapper::EditorWrapper(GUI::Widget* parent)
label_wrapper->layout()->set_margins({ 2, 0, 2, 0 });
m_filename_label = GUI::Label::construct("(Untitled)", label_wrapper);
m_filename_label->set_text_alignment(TextAlignment::CenterLeft);
m_filename_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
m_filename_label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
m_filename_label->set_preferred_size(0, 14);
m_cursor_label = GUI::Label::construct("(Cursor)", label_wrapper);
m_cursor_label->set_text_alignment(TextAlignment::CenterRight);
m_cursor_label->set_text_alignment(Gfx::TextAlignment::CenterRight);
m_cursor_label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
m_cursor_label->set_preferred_size(0, 14);
@ -75,5 +75,5 @@ EditorWrapper::~EditorWrapper()
void EditorWrapper::set_editor_has_focus(Badge<Editor>, bool focus)
{
m_filename_label->set_font(focus ? Font::default_bold_font() : Font::default_font());
m_filename_label->set_font(focus ? Gfx::Font::default_bold_font() : Gfx::Font::default_font());
}

View file

@ -92,7 +92,7 @@ public:
virtual ColumnMetadata column_metadata(int column) const override
{
if (column == Column::MatchedText) {
return { 0, TextAlignment::CenterLeft, &Font::default_fixed_width_font() };
return { 0, Gfx::TextAlignment::CenterLeft, &Gfx::Font::default_fixed_width_font() };
}
return {};
}

View file

@ -37,8 +37,8 @@ FormEditorWidget::FormEditorWidget(GUI::Widget* parent)
set_fill_with_background_color(true);
set_background_color(Color::MidGray);
set_frame_shape(FrameShape::Container);
set_frame_shadow(FrameShadow::Sunken);
set_frame_shape(Gfx::FrameShape::Container);
set_frame_shadow(Gfx::FrameShadow::Sunken);
set_frame_thickness(2);
m_form_widget = FormWidget::construct(*this);

View file

@ -33,9 +33,9 @@
extern RefPtr<Project> g_project;
extern void open_file(const String&);
static RefPtr<GraphicsBitmap> s_file_icon;
static RefPtr<GraphicsBitmap> s_cplusplus_icon;
static RefPtr<GraphicsBitmap> s_header_icon;
static RefPtr<Gfx::Bitmap> s_file_icon;
static RefPtr<Gfx::Bitmap> s_cplusplus_icon;
static RefPtr<Gfx::Bitmap> s_header_icon;
class LocatorSuggestionModel final : public GUI::Model {
public:
@ -102,9 +102,9 @@ Locator::Locator(GUI::Widget* parent)
: GUI::Widget(parent)
{
if (!s_cplusplus_icon) {
s_file_icon = GraphicsBitmap::load_from_file("/res/icons/16x16/filetype-unknown.png");
s_cplusplus_icon = GraphicsBitmap::load_from_file("/res/icons/16x16/filetype-cplusplus.png");
s_header_icon = GraphicsBitmap::load_from_file("/res/icons/16x16/filetype-header.png");
s_file_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-unknown.png");
s_cplusplus_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-cplusplus.png");
s_header_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-header.png");
}
set_layout(make<GUI::VBoxLayout>());

View file

@ -41,20 +41,20 @@ ProcessStateWidget::ProcessStateWidget(GUI::Widget* parent)
set_layout(make<GUI::HBoxLayout>());
auto pid_label_label = GUI::Label::construct("Process:", this);
pid_label_label->set_font(Font::default_bold_font());
pid_label_label->set_font(Gfx::Font::default_bold_font());
m_pid_label = GUI::Label::construct("", this);
auto state_label_label = GUI::Label::construct("State:", this);
state_label_label->set_font(Font::default_bold_font());
state_label_label->set_font(Gfx::Font::default_bold_font());
m_state_label = GUI::Label::construct("", this);
// FIXME: This should show CPU% instead.
auto cpu_label_label = GUI::Label::construct("Times scheduled:", this);
cpu_label_label->set_font(Font::default_bold_font());
cpu_label_label->set_font(Gfx::Font::default_bold_font());
m_cpu_label = GUI::Label::construct("", this);
auto memory_label_label = GUI::Label::construct("Memory (resident):", this);
memory_label_label->set_font(Font::default_bold_font());
memory_label_label->set_font(Gfx::Font::default_bold_font());
m_memory_label = GUI::Label::construct("", this);
m_timer = Core::Timer::construct(500, [this] {

View file

@ -117,7 +117,7 @@ public:
if (role == Role::Font) {
extern String g_currently_open_file;
if (node->name == g_currently_open_file)
return Font::default_bold_font();
return Gfx::Font::default_bold_font();
return {};
}
return {};
@ -169,11 +169,11 @@ Project::Project(const String& path, Vector<String>&& filenames)
{
m_name = FileSystemPath(m_path).basename();
m_file_icon = GIcon(GraphicsBitmap::load_from_file("/res/icons/16x16/filetype-unknown.png"));
m_cplusplus_icon = GIcon(GraphicsBitmap::load_from_file("/res/icons/16x16/filetype-cplusplus.png"));
m_header_icon = GIcon(GraphicsBitmap::load_from_file("/res/icons/16x16/filetype-header.png"));
m_directory_icon = GIcon(GraphicsBitmap::load_from_file("/res/icons/16x16/filetype-folder.png"));
m_project_icon = GIcon(GraphicsBitmap::load_from_file("/res/icons/16x16/app-hack-studio.png"));
m_file_icon = GIcon(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_header_icon = GIcon(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_project_icon = GIcon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-hack-studio.png"));
for (auto& filename : filenames) {
m_files.append(ProjectFile::construct_with_name(filename));

View file

@ -32,7 +32,7 @@
WidgetTreeModel::WidgetTreeModel(GUI::Widget& root)
: m_root(root)
{
m_widget_icon.set_bitmap_for_size(16, GraphicsBitmap::load_from_file("/res/icons/16x16/inspector-object.png"));
m_widget_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/inspector-object.png"));
}
WidgetTreeModel::~WidgetTreeModel()

View file

@ -175,7 +175,7 @@ int main(int argc, char** argv)
return files;
};
auto new_action = GUI::Action::create("Add new file to project...", { Mod_Ctrl, Key_N }, GraphicsBitmap::load_from_file("/res/icons/16x16/new.png"), [&](const GUI::Action&) {
auto new_action = GUI::Action::create("Add new file to project...", { Mod_Ctrl, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"), [&](const GUI::Action&) {
auto input_box = GUI::InputBox::construct("Enter name of new file:", "Add new file to project", g_window);
if (input_box->exec() == GUI::InputBox::ExecCancel)
return;
@ -193,7 +193,7 @@ int main(int argc, char** argv)
open_file(filename);
});
auto add_existing_file_action = GUI::Action::create("Add existing file to project...", GraphicsBitmap::load_from_file("/res/icons/16x16/open.png"), [&](auto&) {
auto add_existing_file_action = GUI::Action::create("Add existing file to project...", Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"), [&](auto&) {
auto result = GUI::FilePicker::get_open_filepath("Add existing file to project");
if (!result.has_value())
return;
@ -273,7 +273,7 @@ int main(int argc, char** argv)
GUI::ActionGroup tool_actions;
tool_actions.set_exclusive(true);
auto cursor_tool_action = GUI::Action::create("Cursor", GraphicsBitmap::load_from_file("/res/icons/widgets/Cursor.png"), [&](auto&) {
auto cursor_tool_action = GUI::Action::create("Cursor", Gfx::Bitmap::load_from_file("/res/icons/widgets/Cursor.png"), [&](auto&) {
g_form_editor_widget->set_tool(make<CursorTool>(*g_form_editor_widget));
});
cursor_tool_action->set_checkable(true);
@ -284,7 +284,7 @@ int main(int argc, char** argv)
GUI::WidgetClassRegistration::for_each([&](const GUI::WidgetClassRegistration& reg) {
auto icon_path = String::format("/res/icons/widgets/%s.png", reg.class_name().characters());
auto action = GUI::Action::create(reg.class_name(), GraphicsBitmap::load_from_file(icon_path), [&reg](auto&) {
auto action = GUI::Action::create(reg.class_name(), Gfx::Bitmap::load_from_file(icon_path), [&reg](auto&) {
g_form_editor_widget->set_tool(make<WidgetTool>(*g_form_editor_widget, reg));
auto widget = reg.construct(&g_form_editor_widget->form_widget());
widget->set_relative_rect(30, 30, 30, 30);
@ -310,8 +310,8 @@ int main(int argc, char** argv)
wrapper->set_layout(make<GUI::VBoxLayout>());
auto label = GUI::Label::construct(text, wrapper);
label->set_fill_with_background_color(true);
label->set_text_alignment(TextAlignment::CenterLeft);
label->set_font(Font::default_bold_font());
label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
label->set_font(Gfx::Font::default_bold_font());
label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
label->set_preferred_size(0, 16);
wrapper->add_child(pane_widget);
@ -395,7 +395,7 @@ int main(int argc, char** argv)
update_actions();
});
auto save_action = GUI::Action::create("Save", { Mod_Ctrl, Key_S }, GraphicsBitmap::load_from_file("/res/icons/16x16/save.png"), [&](auto&) {
auto save_action = GUI::Action::create("Save", { Mod_Ctrl, Key_S }, Gfx::Bitmap::load_from_file("/res/icons/16x16/save.png"), [&](auto&) {
if (g_currently_open_file.is_empty())
return;
current_editor().write_to_file(g_currently_open_file);
@ -476,7 +476,7 @@ int main(int argc, char** argv)
}));
menubar->add_menu(move(edit_menu));
auto stop_action = GUI::Action::create("Stop", GraphicsBitmap::load_from_file("/res/icons/16x16/stop.png"), [&](auto&) {
auto stop_action = GUI::Action::create("Stop", Gfx::Bitmap::load_from_file("/res/icons/16x16/stop.png"), [&](auto&) {
terminal_wrapper->kill_running_command();
});
@ -485,14 +485,14 @@ int main(int argc, char** argv)
stop_action->set_enabled(false);
};
auto build_action = GUI::Action::create("Build", { Mod_Ctrl, Key_B }, GraphicsBitmap::load_from_file("/res/icons/16x16/build.png"), [&](auto&) {
auto build_action = GUI::Action::create("Build", { Mod_Ctrl, Key_B }, Gfx::Bitmap::load_from_file("/res/icons/16x16/build.png"), [&](auto&) {
reveal_action_tab(terminal_wrapper);
build(terminal_wrapper);
stop_action->set_enabled(true);
});
toolbar->add_action(build_action);
auto run_action = GUI::Action::create("Run", { Mod_Ctrl, Key_R }, GraphicsBitmap::load_from_file("/res/icons/16x16/play.png"), [&](auto&) {
auto run_action = GUI::Action::create("Run", { Mod_Ctrl, Key_R }, Gfx::Bitmap::load_from_file("/res/icons/16x16/play.png"), [&](auto&) {
reveal_action_tab(terminal_wrapper);
run(terminal_wrapper);
stop_action->set_enabled(true);
@ -514,7 +514,7 @@ int main(int argc, char** argv)
view_menu->add_action(remove_current_editor_action);
menubar->add_menu(move(view_menu));
auto small_icon = GraphicsBitmap::load_from_file("/res/icons/16x16/app-hack-studio.png");
auto small_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/app-hack-studio.png");
auto help_menu = GUI::Menu::construct("Help");
help_menu->add_action(GUI::Action::create("About", [&](auto&) {
@ -550,16 +550,16 @@ void run(TerminalWrapper& wrapper)
struct TextStyle {
Color color;
const Font* font { nullptr };
const Gfx::Font* font { nullptr };
};
static TextStyle style_for_token_type(CppToken::Type type)
{
switch (type) {
case CppToken::Type::Keyword:
return { Color::Black, &Font::default_bold_fixed_width_font() };
return { Color::Black, &Gfx::Font::default_bold_fixed_width_font() };
case CppToken::Type::KnownType:
return { Color::from_rgb(0x929200), &Font::default_bold_fixed_width_font() };
return { Color::from_rgb(0x929200), &Gfx::Font::default_bold_fixed_width_font() };
case CppToken::Type::Identifier:
return { Color::from_rgb(0x000092) };
case CppToken::Type::DoubleQuotedString: