mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:07:45 +00:00
SystemMonitor: Register GraphWidget
This commit is contained in:
parent
e6fe66594e
commit
abf2ed4c52
5 changed files with 18 additions and 6 deletions
|
@ -13,6 +13,10 @@
|
||||||
#include <LibGfx/Path.h>
|
#include <LibGfx/Path.h>
|
||||||
#include <LibGfx/SystemTheme.h>
|
#include <LibGfx/SystemTheme.h>
|
||||||
|
|
||||||
|
REGISTER_WIDGET(SystemMonitor, GraphWidget)
|
||||||
|
|
||||||
|
namespace SystemMonitor {
|
||||||
|
|
||||||
void GraphWidget::add_value(Vector<u64, 1>&& value)
|
void GraphWidget::add_value(Vector<u64, 1>&& value)
|
||||||
{
|
{
|
||||||
m_values.enqueue(move(value));
|
m_values.enqueue(move(value));
|
||||||
|
@ -143,3 +147,5 @@ void GraphWidget::paint_event(GUI::PaintEvent& event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
#include <LibGUI/Frame.h>
|
#include <LibGUI/Frame.h>
|
||||||
#include <LibGfx/SystemTheme.h>
|
#include <LibGfx/SystemTheme.h>
|
||||||
|
|
||||||
|
namespace SystemMonitor {
|
||||||
|
|
||||||
class GraphWidget final : public GUI::Frame {
|
class GraphWidget final : public GUI::Frame {
|
||||||
C_OBJECT(GraphWidget)
|
C_OBJECT(GraphWidget)
|
||||||
public:
|
public:
|
||||||
|
@ -46,3 +48,5 @@ private:
|
||||||
|
|
||||||
Vector<Gfx::IntPoint, 1> m_calculated_points;
|
Vector<Gfx::IntPoint, 1> m_calculated_points;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ MemoryStatsWidget* MemoryStatsWidget::the()
|
||||||
return s_the;
|
return s_the;
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryStatsWidget::MemoryStatsWidget(GraphWidget& graph)
|
MemoryStatsWidget::MemoryStatsWidget(SystemMonitor::GraphWidget& graph)
|
||||||
: m_graph(graph)
|
: m_graph(graph)
|
||||||
{
|
{
|
||||||
VERIFY(!s_the);
|
VERIFY(!s_the);
|
||||||
|
|
|
@ -9,7 +9,9 @@
|
||||||
|
|
||||||
#include <LibGUI/Widget.h>
|
#include <LibGUI/Widget.h>
|
||||||
|
|
||||||
|
namespace SystemMonitor {
|
||||||
class GraphWidget;
|
class GraphWidget;
|
||||||
|
}
|
||||||
|
|
||||||
class MemoryStatsWidget final : public GUI::Widget {
|
class MemoryStatsWidget final : public GUI::Widget {
|
||||||
C_OBJECT(MemoryStatsWidget)
|
C_OBJECT(MemoryStatsWidget)
|
||||||
|
@ -21,9 +23,9 @@ public:
|
||||||
void refresh();
|
void refresh();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MemoryStatsWidget(GraphWidget& graph);
|
MemoryStatsWidget(SystemMonitor::GraphWidget& graph);
|
||||||
|
|
||||||
GraphWidget& m_graph;
|
SystemMonitor::GraphWidget& m_graph;
|
||||||
RefPtr<GUI::Label> m_user_physical_pages_label;
|
RefPtr<GUI::Label> m_user_physical_pages_label;
|
||||||
RefPtr<GUI::Label> m_user_physical_pages_committed_label;
|
RefPtr<GUI::Label> m_user_physical_pages_committed_label;
|
||||||
RefPtr<GUI::Label> m_supervisor_physical_pages_label;
|
RefPtr<GUI::Label> m_supervisor_physical_pages_label;
|
||||||
|
|
|
@ -687,14 +687,14 @@ NonnullRefPtr<GUI::Widget> build_performance_tab()
|
||||||
auto cpu_graph_rows = ceil_div(ProcessModel::the().cpus().size(), cpu_graphs_per_row);
|
auto cpu_graph_rows = ceil_div(ProcessModel::the().cpus().size(), cpu_graphs_per_row);
|
||||||
cpu_graph_group_box.set_fixed_height(120u * cpu_graph_rows);
|
cpu_graph_group_box.set_fixed_height(120u * cpu_graph_rows);
|
||||||
|
|
||||||
Vector<GraphWidget&> cpu_graphs;
|
Vector<SystemMonitor::GraphWidget&> cpu_graphs;
|
||||||
for (auto row = 0u; row < cpu_graph_rows; ++row) {
|
for (auto row = 0u; row < cpu_graph_rows; ++row) {
|
||||||
auto& cpu_graph_row = cpu_graph_group_box.add<GUI::Widget>();
|
auto& cpu_graph_row = cpu_graph_group_box.add<GUI::Widget>();
|
||||||
cpu_graph_row.set_layout<GUI::HorizontalBoxLayout>();
|
cpu_graph_row.set_layout<GUI::HorizontalBoxLayout>();
|
||||||
cpu_graph_row.layout()->set_margins(6);
|
cpu_graph_row.layout()->set_margins(6);
|
||||||
cpu_graph_row.set_fixed_height(108);
|
cpu_graph_row.set_fixed_height(108);
|
||||||
for (auto i = 0u; i < cpu_graphs_per_row; ++i) {
|
for (auto i = 0u; i < cpu_graphs_per_row; ++i) {
|
||||||
auto& cpu_graph = cpu_graph_row.add<GraphWidget>();
|
auto& cpu_graph = cpu_graph_row.add<SystemMonitor::GraphWidget>();
|
||||||
cpu_graph.set_max(100);
|
cpu_graph.set_max(100);
|
||||||
cpu_graph.set_value_format(0, {
|
cpu_graph.set_value_format(0, {
|
||||||
.graph_color_role = ColorRole::SyntaxPreprocessorStatement,
|
.graph_color_role = ColorRole::SyntaxPreprocessorStatement,
|
||||||
|
@ -725,7 +725,7 @@ NonnullRefPtr<GUI::Widget> build_performance_tab()
|
||||||
memory_graph_group_box.set_layout<GUI::VerticalBoxLayout>();
|
memory_graph_group_box.set_layout<GUI::VerticalBoxLayout>();
|
||||||
memory_graph_group_box.layout()->set_margins(6);
|
memory_graph_group_box.layout()->set_margins(6);
|
||||||
memory_graph_group_box.set_fixed_height(120);
|
memory_graph_group_box.set_fixed_height(120);
|
||||||
auto& memory_graph = memory_graph_group_box.add<GraphWidget>();
|
auto& memory_graph = memory_graph_group_box.add<SystemMonitor::GraphWidget>();
|
||||||
memory_graph.set_stack_values(true);
|
memory_graph.set_stack_values(true);
|
||||||
memory_graph.set_value_format(0, {
|
memory_graph.set_value_format(0, {
|
||||||
.graph_color_role = ColorRole::SyntaxComment,
|
.graph_color_role = ColorRole::SyntaxComment,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue