mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 15:07:45 +00:00
LibGUI: Put all classes in the GUI namespace and remove the leading G
This took me a moment. Welcome to the new world of GUI::Widget! :^)
This commit is contained in:
parent
2d39da5405
commit
c5bd9d4ed1
337 changed files with 5400 additions and 4816 deletions
|
@ -31,8 +31,8 @@
|
|||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
SnakeGame::SnakeGame(GWidget* parent)
|
||||
: GWidget(parent)
|
||||
SnakeGame::SnakeGame(GUI::Widget* parent)
|
||||
: GUI::Widget(parent)
|
||||
{
|
||||
set_font(GFontDatabase::the().get_by_name("Liza Regular"));
|
||||
m_fruit_bitmaps.append(*GraphicsBitmap::load_from_file("/res/icons/snake/paprika.png"));
|
||||
|
@ -161,7 +161,7 @@ void SnakeGame::timer_event(Core::TimerEvent&)
|
|||
}
|
||||
}
|
||||
|
||||
void SnakeGame::keydown_event(GKeyEvent& event)
|
||||
void SnakeGame::keydown_event(GUI::KeyEvent& event)
|
||||
{
|
||||
switch (event.key()) {
|
||||
case KeyCode::Key_A:
|
||||
|
@ -205,9 +205,9 @@ Rect SnakeGame::cell_rect(const Coordinate& coord) const
|
|||
};
|
||||
}
|
||||
|
||||
void SnakeGame::paint_event(GPaintEvent& event)
|
||||
void SnakeGame::paint_event(GUI::PaintEvent& event)
|
||||
{
|
||||
GPainter painter(*this);
|
||||
GUI::Painter painter(*this);
|
||||
painter.add_clip_rect(event.rect());
|
||||
painter.fill_rect(event.rect(), Color::Black);
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <AK/NonnullRefPtrVector.h>
|
||||
#include <LibGUI/GWidget.h>
|
||||
|
||||
class SnakeGame : public GWidget {
|
||||
class SnakeGame : public GUI::Widget {
|
||||
C_OBJECT(SnakeGame)
|
||||
public:
|
||||
virtual ~SnakeGame() override;
|
||||
|
@ -38,9 +38,9 @@ public:
|
|||
void reset();
|
||||
|
||||
private:
|
||||
explicit SnakeGame(GWidget* parent = nullptr);
|
||||
virtual void paint_event(GPaintEvent&) override;
|
||||
virtual void keydown_event(GKeyEvent&) override;
|
||||
explicit SnakeGame(GUI::Widget* parent = nullptr);
|
||||
virtual void paint_event(GUI::PaintEvent&) override;
|
||||
virtual void keydown_event(GUI::KeyEvent&) override;
|
||||
virtual void timer_event(Core::TimerEvent&) override;
|
||||
|
||||
struct Coordinate {
|
||||
|
|
|
@ -43,14 +43,14 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
GApplication app(argc, argv);
|
||||
GUI::Application app(argc, argv);
|
||||
|
||||
if (pledge("stdio rpath shared_buffer accept", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto window = GWindow::construct();
|
||||
auto window = GUI::Window::construct();
|
||||
|
||||
window->set_double_buffering_enabled(false);
|
||||
window->set_title("Snake");
|
||||
|
@ -59,22 +59,22 @@ int main(int argc, char** argv)
|
|||
auto game = SnakeGame::construct();
|
||||
window->set_main_widget(game);
|
||||
|
||||
auto menubar = make<GMenuBar>();
|
||||
auto menubar = make<GUI::MenuBar>();
|
||||
|
||||
auto app_menu = GMenu::construct("Snake");
|
||||
auto app_menu = GUI::Menu::construct("Snake");
|
||||
|
||||
app_menu->add_action(GAction::create("New game", { Mod_None, Key_F2 }, [&](const GAction&) {
|
||||
app_menu->add_action(GUI::Action::create("New game", { Mod_None, Key_F2 }, [&](const GUI::Action&) {
|
||||
game->reset();
|
||||
}));
|
||||
app_menu->add_action(GCommonActions::make_quit_action([](auto&) {
|
||||
GApplication::the().quit(0);
|
||||
app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the().quit(0);
|
||||
}));
|
||||
|
||||
menubar->add_menu(move(app_menu));
|
||||
|
||||
auto help_menu = GMenu::construct("Help");
|
||||
help_menu->add_action(GAction::create("About", [&](const GAction&) {
|
||||
GAboutDialog::show("Snake", load_png("/res/icons/32x32/app-snake.png"), window);
|
||||
auto help_menu = GUI::Menu::construct("Help");
|
||||
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
||||
GUI::AboutDialog::show("Snake", load_png("/res/icons/32x32/app-snake.png"), window);
|
||||
}));
|
||||
menubar->add_menu(move(help_menu));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue