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

LibGUI: Add GHBoxLayout and GVBoxLayout convenience classes

This commit is contained in:
Andreas Kling 2020-02-02 09:48:11 +01:00
parent 63364f8a5d
commit d67da8c101
50 changed files with 128 additions and 114 deletions

View file

@ -52,13 +52,13 @@ MemoryStatsWidget::MemoryStatsWidget(GraphWidget& graph, GWidget* parent)
set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
set_preferred_size(0, 72);
set_layout(make<GBoxLayout>(Orientation::Vertical));
set_layout(make<GVBoxLayout>());
layout()->set_margins({ 0, 8, 0, 0 });
layout()->set_spacing(3);
auto build_widgets_for_label = [this](const String& description) -> RefPtr<GLabel> {
auto container = GWidget::construct(this);
container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
container->set_layout(make<GHBoxLayout>());
container->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
container->set_preferred_size(275, 12);
auto description_label = GLabel::construct(description, container);

View file

@ -34,12 +34,12 @@ NetworkStatisticsWidget::NetworkStatisticsWidget(GWidget* parent)
: GLazyWidget(parent)
{
on_first_show = [this](auto&) {
set_layout(make<GBoxLayout>(Orientation::Vertical));
set_layout(make<GVBoxLayout>());
layout()->set_margins({ 4, 4, 4, 4 });
set_fill_with_background_color(true);
auto adapters_group_box = GGroupBox::construct("Adapters", this);
adapters_group_box->set_layout(make<GBoxLayout>(Orientation::Vertical));
adapters_group_box->set_layout(make<GVBoxLayout>());
adapters_group_box->layout()->set_margins({ 6, 16, 6, 6 });
adapters_group_box->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
adapters_group_box->set_preferred_size(0, 120);
@ -59,7 +59,7 @@ NetworkStatisticsWidget::NetworkStatisticsWidget(GWidget* parent)
m_adapter_table_view->set_model(GJsonArrayModel::create("/proc/net/adapters", move(net_adapters_fields)));
auto sockets_group_box = GGroupBox::construct("Sockets", this);
sockets_group_box->set_layout(make<GBoxLayout>(Orientation::Vertical));
sockets_group_box->set_layout(make<GVBoxLayout>());
sockets_group_box->layout()->set_margins({ 6, 16, 6, 6 });
sockets_group_box->set_size_policy(SizePolicy::Fill, SizePolicy::Fill);
sockets_group_box->set_preferred_size(0, 0);

View file

@ -32,7 +32,7 @@
ProcessFileDescriptorMapWidget::ProcessFileDescriptorMapWidget(GWidget* parent)
: GWidget(parent)
{
set_layout(make<GBoxLayout>(Orientation::Vertical));
set_layout(make<GVBoxLayout>());
layout()->set_margins({ 4, 4, 4, 4 });
m_table_view = GTableView::construct(this);
m_table_view->set_size_columns_to_fit_content(true);

View file

@ -34,7 +34,7 @@
ProcessMemoryMapWidget::ProcessMemoryMapWidget(GWidget* parent)
: GWidget(parent)
{
set_layout(make<GBoxLayout>(Orientation::Vertical));
set_layout(make<GVBoxLayout>());
layout()->set_margins({ 4, 4, 4, 4 });
m_table_view = GTableView::construct(this);
m_table_view->set_size_columns_to_fit_content(true);

View file

@ -32,7 +32,7 @@
ProcessStacksWidget::ProcessStacksWidget(GWidget* parent)
: GWidget(parent)
{
set_layout(make<GBoxLayout>(Orientation::Vertical));
set_layout(make<GVBoxLayout>());
layout()->set_margins({ 4, 4, 4, 4 });
m_stacks_editor = GTextEditor::construct(GTextEditor::Type::MultiLine, this);
m_stacks_editor->set_readonly(true);

View file

@ -32,7 +32,7 @@
ProcessUnveiledPathsWidget::ProcessUnveiledPathsWidget(GWidget* parent)
: GWidget(parent)
{
set_layout(make<GBoxLayout>(Orientation::Vertical));
set_layout(make<GVBoxLayout>());
layout()->set_margins({ 4, 4, 4, 4 });
m_table_view = GTableView::construct(this);
m_table_view->set_size_columns_to_fit_content(true);

View file

@ -116,7 +116,7 @@ int main(int argc, char** argv)
auto keeper = GWidget::construct();
window->set_main_widget(keeper);
keeper->set_layout(make<GBoxLayout>(Orientation::Vertical));
keeper->set_layout(make<GVBoxLayout>());
keeper->set_fill_with_background_color(true);
keeper->layout()->set_margins({ 4, 4, 4, 4 });
@ -138,7 +138,7 @@ int main(int argc, char** argv)
auto network_stats_widget = NetworkStatisticsWidget::construct(nullptr);
tabwidget->add_widget("Network", network_stats_widget);
process_table_container->set_layout(make<GBoxLayout>(Orientation::Vertical));
process_table_container->set_layout(make<GVBoxLayout>());
process_table_container->layout()->set_margins({ 4, 0, 4, 4 });
process_table_container->layout()->set_spacing(0);
@ -279,7 +279,7 @@ RefPtr<GWidget> build_file_systems_tab()
auto fs_widget = GLazyWidget::construct();
fs_widget->on_first_show = [](auto& self) {
self.set_layout(make<GBoxLayout>(Orientation::Vertical));
self.set_layout(make<GVBoxLayout>());
self.layout()->set_margins({ 4, 4, 4, 4 });
auto fs_table_view = GTableView::construct(&self);
fs_table_view->set_size_columns_to_fit_content(true);
@ -368,7 +368,7 @@ RefPtr<GWidget> build_pci_devices_tab()
auto pci_widget = GLazyWidget::construct();
pci_widget->on_first_show = [](auto& self) {
self.set_layout(make<GBoxLayout>(Orientation::Vertical));
self.set_layout(make<GVBoxLayout>());
self.layout()->set_margins({ 4, 4, 4, 4 });
auto pci_table_view = GTableView::construct(&self);
pci_table_view->set_size_columns_to_fit_content(true);
@ -426,7 +426,7 @@ RefPtr<GWidget> build_devices_tab()
auto devices_widget = GLazyWidget::construct();
devices_widget->on_first_show = [](auto& self) {
self.set_layout(make<GBoxLayout>(Orientation::Vertical));
self.set_layout(make<GVBoxLayout>());
self.layout()->set_margins({ 4, 4, 4, 4 });
auto devices_table_view = GTableView::construct(&self);
@ -445,11 +445,11 @@ NonnullRefPtr<GWidget> build_graphs_tab()
graphs_container->on_first_show = [](auto& self) {
self.set_fill_with_background_color(true);
self.set_background_role(ColorRole::Button);
self.set_layout(make<GBoxLayout>(Orientation::Vertical));
self.set_layout(make<GVBoxLayout>());
self.layout()->set_margins({ 4, 4, 4, 4 });
auto cpu_graph_group_box = GGroupBox::construct("CPU usage", &self);
cpu_graph_group_box->set_layout(make<GBoxLayout>(Orientation::Vertical));
cpu_graph_group_box->set_layout(make<GVBoxLayout>());
cpu_graph_group_box->layout()->set_margins({ 6, 16, 6, 6 });
cpu_graph_group_box->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
cpu_graph_group_box->set_preferred_size(0, 120);
@ -466,7 +466,7 @@ NonnullRefPtr<GWidget> build_graphs_tab()
};
auto memory_graph_group_box = GGroupBox::construct("Memory usage", &self);
memory_graph_group_box->set_layout(make<GBoxLayout>(Orientation::Vertical));
memory_graph_group_box->set_layout(make<GVBoxLayout>());
memory_graph_group_box->layout()->set_margins({ 6, 16, 6, 6 });
memory_graph_group_box->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
memory_graph_group_box->set_preferred_size(0, 120);