1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-16 08:27:35 +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:
Andreas Kling 2020-02-02 15:07:41 +01:00
parent 2d39da5405
commit c5bd9d4ed1
337 changed files with 5400 additions and 4816 deletions

View file

@ -32,13 +32,15 @@
#include <LibGUI/GPainter.h>
#include <LibGUI/GToolBar.h>
GToolBar::GToolBar(GWidget* parent)
: GToolBar(Orientation::Horizontal, 16, parent)
namespace GUI {
ToolBar::ToolBar(Widget* parent)
: ToolBar(Orientation::Horizontal, 16, parent)
{
}
GToolBar::GToolBar(Orientation orientation, int button_size, GWidget* parent)
: GWidget(parent)
ToolBar::ToolBar(Orientation orientation, int button_size, Widget* parent)
: Widget(parent)
, m_button_size(button_size)
{
if (orientation == Orientation::Horizontal) {
@ -48,22 +50,22 @@ GToolBar::GToolBar(Orientation orientation, int button_size, GWidget* parent)
set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
set_preferred_size(button_size + 12, 0);
}
set_layout(make<GBoxLayout>(orientation));
set_layout(make<BoxLayout>(orientation));
layout()->set_spacing(0);
layout()->set_margins({ 2, 2, 2, 2 });
}
GToolBar::~GToolBar()
ToolBar::~ToolBar()
{
}
void GToolBar::add_action(GAction& action)
void ToolBar::add_action(Action& action)
{
auto item = make<Item>();
item->type = Item::Action;
item->type = Item::Type::Action;
item->action = action;
auto button = GButton::construct(this);
auto button = Button::construct(this);
if (action.group() && action.group()->is_exclusive())
button->set_exclusive(true);
button->set_action(*item->action);
@ -82,20 +84,20 @@ void GToolBar::add_action(GAction& action)
m_items.append(move(item));
}
class SeparatorWidget final : public GWidget {
class SeparatorWidget final : public Widget {
C_OBJECT(SeparatorWidget)
public:
SeparatorWidget(GWidget* parent)
: GWidget(parent)
SeparatorWidget(Widget* parent)
: Widget(parent)
{
set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
set_preferred_size(8, 22);
}
virtual ~SeparatorWidget() override {}
virtual void paint_event(GPaintEvent& event) override
virtual void paint_event(PaintEvent& event) override
{
GPainter painter(*this);
Painter painter(*this);
painter.add_clip_rect(event.rect());
painter.translate(rect().center().x() - 1, 0);
painter.draw_line({ 0, 0 }, { 0, rect().bottom() }, palette().threed_shadow1());
@ -103,17 +105,17 @@ public:
}
};
void GToolBar::add_separator()
void ToolBar::add_separator()
{
auto item = make<Item>();
item->type = Item::Separator;
item->type = Item::Type::Separator;
new SeparatorWidget(this);
m_items.append(move(item));
}
void GToolBar::paint_event(GPaintEvent& event)
void ToolBar::paint_event(PaintEvent& event)
{
GPainter painter(*this);
Painter painter(*this);
painter.add_clip_rect(event.rect());
if (m_has_frame)
@ -121,3 +123,5 @@ void GToolBar::paint_event(GPaintEvent& event)
else
painter.fill_rect(event.rect(), palette().button());
}
}