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

@ -86,7 +86,7 @@ Profile::~Profile()
{
}
GModel& Profile::model()
GUI::Model& Profile::model()
{
return *m_model;
}

View file

@ -32,7 +32,10 @@
#include <AK/NonnullRefPtrVector.h>
#include <AK/OwnPtr.h>
class GModel;
namespace GUI {
class Model;
}
class ProfileModel;
class ProfileNode : public RefCounted<ProfileNode> {
@ -104,7 +107,7 @@ public:
static OwnPtr<Profile> load_from_file(const StringView& path);
~Profile();
GModel& model();
GUI::Model& model();
const Vector<NonnullRefPtr<ProfileNode>>& roots() const { return m_roots; }

View file

@ -41,7 +41,7 @@ ProfileModel::~ProfileModel()
{
}
GModelIndex ProfileModel::index(int row, int column, const GModelIndex& parent) const
GUI::ModelIndex ProfileModel::index(int row, int column, const GUI::ModelIndex& parent) const
{
if (!parent.is_valid()) {
if (m_profile.roots().is_empty())
@ -52,7 +52,7 @@ GModelIndex ProfileModel::index(int row, int column, const GModelIndex& parent)
return create_index(row, column, remote_parent.children().at(row).ptr());
}
GModelIndex ProfileModel::parent_index(const GModelIndex& index) const
GUI::ModelIndex ProfileModel::parent_index(const GUI::ModelIndex& index) const
{
if (!index.is_valid())
return {};
@ -80,7 +80,7 @@ GModelIndex ProfileModel::parent_index(const GModelIndex& index) const
return {};
}
int ProfileModel::row_count(const GModelIndex& index) const
int ProfileModel::row_count(const GUI::ModelIndex& index) const
{
if (!index.is_valid())
return m_profile.roots().size();
@ -88,7 +88,7 @@ int ProfileModel::row_count(const GModelIndex& index) const
return node.children().size();
}
int ProfileModel::column_count(const GModelIndex&) const
int ProfileModel::column_count(const GUI::ModelIndex&) const
{
return Column::__Count;
}
@ -106,14 +106,14 @@ String ProfileModel::column_name(int column) const
}
}
GModel::ColumnMetadata ProfileModel::column_metadata(int column) const
GUI::Model::ColumnMetadata ProfileModel::column_metadata(int column) const
{
if (column == Column::SampleCount)
return ColumnMetadata { 0, TextAlignment::CenterRight };
return {};
}
GVariant ProfileModel::data(const GModelIndex& index, Role role) const
GUI::Variant ProfileModel::data(const GUI::ModelIndex& index, Role role) const
{
auto* node = static_cast<ProfileNode*>(index.internal_data());
if (role == Role::Icon) {

View file

@ -30,7 +30,7 @@
class Profile;
class ProfileModel final : public GModel {
class ProfileModel final : public GUI::Model {
public:
static NonnullRefPtr<ProfileModel> create(Profile& profile)
{
@ -45,13 +45,13 @@ public:
virtual ~ProfileModel() override;
virtual int row_count(const GModelIndex& = GModelIndex()) const override;
virtual int column_count(const GModelIndex& = GModelIndex()) const override;
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
virtual String column_name(int) const override;
virtual ColumnMetadata column_metadata(int) const override;
virtual GVariant data(const GModelIndex&, Role = Role::Display) const override;
virtual GModelIndex index(int row, int column, const GModelIndex& parent = GModelIndex()) const override;
virtual GModelIndex parent_index(const GModelIndex&) const override;
virtual GUI::Variant data(const GUI::ModelIndex&, Role = Role::Display) const override;
virtual GUI::ModelIndex index(int row, int column, const GUI::ModelIndex& parent = GUI::ModelIndex()) const override;
virtual GUI::ModelIndex parent_index(const GUI::ModelIndex&) const override;
virtual void update() override;
virtual int tree_column() const override { return Column::StackFrame; }

View file

@ -28,8 +28,8 @@
#include "Profile.h"
#include <LibGUI/GPainter.h>
ProfileTimelineWidget::ProfileTimelineWidget(Profile& profile, GWidget* parent)
: GFrame(parent)
ProfileTimelineWidget::ProfileTimelineWidget(Profile& profile, GUI::Widget* parent)
: GUI::Frame(parent)
, m_profile(profile)
{
set_frame_thickness(2);
@ -37,7 +37,7 @@ ProfileTimelineWidget::ProfileTimelineWidget(Profile& profile, GWidget* parent)
set_frame_shape(FrameShape::Container);
set_background_color(Color::White);
set_fill_with_background_color(true);
set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
set_preferred_size(0, 80);
}
@ -45,11 +45,11 @@ ProfileTimelineWidget::~ProfileTimelineWidget()
{
}
void ProfileTimelineWidget::paint_event(GPaintEvent& event)
void ProfileTimelineWidget::paint_event(GUI::PaintEvent& event)
{
GFrame::paint_event(event);
GUI::Frame::paint_event(event);
GPainter painter(*this);
GUI::Painter painter(*this);
painter.add_clip_rect(event.rect());
float column_width = (float)frame_inner_rect().width() / (float)m_profile.length_in_ms();
@ -83,9 +83,9 @@ u64 ProfileTimelineWidget::timestamp_at_x(int x) const
return m_profile.first_timestamp() + (u64)ms_into_profile;
}
void ProfileTimelineWidget::mousedown_event(GMouseEvent& event)
void ProfileTimelineWidget::mousedown_event(GUI::MouseEvent& event)
{
if (event.button() != GMouseButton::Left)
if (event.button() != GUI::MouseButton::Left)
return;
m_selecting = true;
@ -95,7 +95,7 @@ void ProfileTimelineWidget::mousedown_event(GMouseEvent& event)
update();
}
void ProfileTimelineWidget::mousemove_event(GMouseEvent& event)
void ProfileTimelineWidget::mousemove_event(GUI::MouseEvent& event)
{
if (!m_selecting)
return;
@ -105,9 +105,9 @@ void ProfileTimelineWidget::mousemove_event(GMouseEvent& event)
update();
}
void ProfileTimelineWidget::mouseup_event(GMouseEvent& event)
void ProfileTimelineWidget::mouseup_event(GUI::MouseEvent& event)
{
if (event.button() != GMouseButton::Left)
if (event.button() != GUI::MouseButton::Left)
return;
m_selecting = false;

View file

@ -28,18 +28,18 @@
class Profile;
class ProfileTimelineWidget final : public GFrame {
class ProfileTimelineWidget final : public GUI::Frame {
C_OBJECT(ProfileTimelineWidget)
public:
virtual ~ProfileTimelineWidget() override;
private:
virtual void paint_event(GPaintEvent&) override;
virtual void mousedown_event(GMouseEvent&) override;
virtual void mousemove_event(GMouseEvent&) override;
virtual void mouseup_event(GMouseEvent&) override;
virtual void paint_event(GUI::PaintEvent&) override;
virtual void mousedown_event(GUI::MouseEvent&) override;
virtual void mousemove_event(GUI::MouseEvent&) override;
virtual void mouseup_event(GUI::MouseEvent&) override;
ProfileTimelineWidget(Profile&, GWidget* parent);
ProfileTimelineWidget(Profile&, GUI::Widget* parent);
u64 timestamp_at_x(int x) const;

View file

@ -50,32 +50,32 @@ int main(int argc, char** argv)
return 1;
}
GApplication app(argc, argv);
GUI::Application app(argc, argv);
auto window = GWindow::construct();
auto window = GUI::Window::construct();
window->set_title("ProfileViewer");
window->set_rect(100, 100, 800, 600);
auto main_widget = GWidget::construct();
auto main_widget = GUI::Widget::construct();
window->set_main_widget(main_widget);
main_widget->set_fill_with_background_color(true);
main_widget->set_layout(make<GVBoxLayout>());
main_widget->set_layout(make<GUI::VBoxLayout>());
auto timeline_widget = ProfileTimelineWidget::construct(*profile, main_widget);
auto tree_view = GTreeView::construct(main_widget);
auto tree_view = GUI::TreeView::construct(main_widget);
tree_view->set_headers_visible(true);
tree_view->set_size_columns_to_fit_content(true);
tree_view->set_model(profile->model());
auto menubar = make<GMenuBar>();
auto app_menu = GMenu::construct("ProfileViewer");
app_menu->add_action(GCommonActions::make_quit_action([&](auto&) { app.quit(); }));
auto menubar = make<GUI::MenuBar>();
auto app_menu = GUI::Menu::construct("ProfileViewer");
app_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) { app.quit(); }));
menubar->add_menu(move(app_menu));
auto view_menu = GMenu::construct("View");
auto invert_action = GAction::create("Invert tree", { Mod_Ctrl, Key_I }, [&](auto& action) {
auto view_menu = GUI::Menu::construct("View");
auto invert_action = GUI::Action::create("Invert tree", { Mod_Ctrl, Key_I }, [&](auto& action) {
action.set_checked(!action.is_checked());
profile->set_inverted(action.is_checked());
});