1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 22:38:12 +00:00

SystemMonitor: Use new-style widget size constraints

This is a lot more expressive in C++ as well, not just in GML. :^)
This commit is contained in:
Andreas Kling 2020-12-29 18:57:29 +01:00
parent ee85713e52
commit 881379e324
3 changed files with 5 additions and 12 deletions

View file

@ -50,8 +50,7 @@ MemoryStatsWidget::MemoryStatsWidget(GraphWidget& graph)
ASSERT(!s_the);
s_the = this;
set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
set_preferred_size(0, 110);
set_fixed_height(110);
set_layout<GUI::VerticalBoxLayout>();
layout()->set_margins({ 0, 8, 0, 0 });
@ -60,8 +59,7 @@ MemoryStatsWidget::MemoryStatsWidget(GraphWidget& graph)
auto build_widgets_for_label = [this](const String& description) -> RefPtr<GUI::Label> {
auto& container = add<GUI::Widget>();
container.set_layout<GUI::HorizontalBoxLayout>();
container.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
container.set_preferred_size(275, 12);
container.set_fixed_size(275, 12);
auto& description_label = container.add<GUI::Label>(description);
description_label.set_font(Gfx::Font::default_bold_font());
description_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);

View file

@ -41,8 +41,7 @@ NetworkStatisticsWidget::NetworkStatisticsWidget()
auto& adapters_group_box = add<GUI::GroupBox>("Adapters");
adapters_group_box.set_layout<GUI::VerticalBoxLayout>();
adapters_group_box.layout()->set_margins({ 6, 16, 6, 6 });
adapters_group_box.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
adapters_group_box.set_preferred_size(0, 120);
adapters_group_box.set_fixed_height(120);
m_adapter_table_view = adapters_group_box.add<GUI::TableView>();
@ -61,8 +60,6 @@ NetworkStatisticsWidget::NetworkStatisticsWidget()
auto& sockets_group_box = add<GUI::GroupBox>("Sockets");
sockets_group_box.set_layout<GUI::VerticalBoxLayout>();
sockets_group_box.layout()->set_margins({ 6, 16, 6, 6 });
sockets_group_box.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill);
sockets_group_box.set_preferred_size(0, 0);
m_socket_table_view = sockets_group_box.add<GUI::TableView>();

View file

@ -547,8 +547,7 @@ NonnullRefPtr<GUI::Widget> build_graphs_tab()
auto& cpu_graph_group_box = self.add<GUI::GroupBox>("CPU usage");
cpu_graph_group_box.set_layout<GUI::HorizontalBoxLayout>();
cpu_graph_group_box.layout()->set_margins({ 6, 16, 6, 6 });
cpu_graph_group_box.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
cpu_graph_group_box.set_preferred_size(0, 120);
cpu_graph_group_box.set_fixed_height(120);
Vector<GraphWidget*> cpu_graphs;
for (size_t i = 0; i < ProcessModel::the().cpus().size(); i++) {
auto& cpu_graph = cpu_graph_group_box.add<GraphWidget>();
@ -568,8 +567,7 @@ NonnullRefPtr<GUI::Widget> build_graphs_tab()
auto& memory_graph_group_box = self.add<GUI::GroupBox>("Memory usage");
memory_graph_group_box.set_layout<GUI::VerticalBoxLayout>();
memory_graph_group_box.layout()->set_margins({ 6, 16, 6, 6 });
memory_graph_group_box.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
memory_graph_group_box.set_preferred_size(0, 120);
memory_graph_group_box.set_fixed_height(120);
auto& memory_graph = memory_graph_group_box.add<GraphWidget>();
memory_graph.set_text_color(Color::Cyan);
memory_graph.set_graph_color(Color::from_rgb(0x00bbbb));