summaryrefslogtreecommitdiff
path: root/Applications/ProcessManager
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-05-07 17:11:48 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-05-07 17:11:48 +0200
commit1598a0a5cbec9fd63bf383dc727a13110579ddd6 (patch)
tree6eb5f40a5e775024ed632151f8c95b4c11f19bc7 /Applications/ProcessManager
parent5b2e1226247a50cc23bd281de3d9d2038f8fa17b (diff)
downloadserenity-1598a0a5cbec9fd63bf383dc727a13110579ddd6.zip
ProcessManager: Draw the graphs as lines.
This looks pretty neat. Also it exercises the diagonal line drawing code so we get 2-for-1. :^)
Diffstat (limited to 'Applications/ProcessManager')
-rw-r--r--Applications/ProcessManager/GraphWidget.cpp10
-rw-r--r--Applications/ProcessManager/main.cpp3
2 files changed, 9 insertions, 4 deletions
diff --git a/Applications/ProcessManager/GraphWidget.cpp b/Applications/ProcessManager/GraphWidget.cpp
index a854137e77..3266e5526d 100644
--- a/Applications/ProcessManager/GraphWidget.cpp
+++ b/Applications/ProcessManager/GraphWidget.cpp
@@ -30,12 +30,16 @@ void GraphWidget::paint_event(GPaintEvent& event)
auto inner_rect = frame_inner_rect();
float scale = (float)inner_rect.height() / (float)m_max;
+ Point prev_point;
for (int i = 0; i < m_values.size(); ++i) {
- int x = inner_rect.right() - i + 1;
+ int x = inner_rect.right() - (i * 2) + 1;
if (x < 0)
break;
- float scaled_value = (float)m_values.at(m_values.size() - i) * scale;
- painter.draw_line({ x, inner_rect.bottom() }, { x, inner_rect.bottom() - (int)scaled_value }, m_graph_color);
+ float scaled_value = (float)m_values.at(m_values.size() - i - 1) * scale;
+ Point point = { x, inner_rect.bottom() - (int)scaled_value };
+ if (i != 0)
+ painter.draw_line(prev_point, point, m_graph_color);
+ prev_point = point;
}
if (!m_values.is_empty() && text_formatter) {
diff --git a/Applications/ProcessManager/main.cpp b/Applications/ProcessManager/main.cpp
index 1d243b9467..6c1b1e7caa 100644
--- a/Applications/ProcessManager/main.cpp
+++ b/Applications/ProcessManager/main.cpp
@@ -54,7 +54,6 @@ int main(int argc, char** argv)
auto* memory_graph_group_box = new GGroupBox("Memory usage", graphs_container);
memory_graph_group_box->set_layout(make<GBoxLayout>(Orientation::Vertical));
memory_graph_group_box->layout()->set_margins({ 6, 16, 6, 6 });
- tabwidget->add_widget("Graphs", graphs_container);
memory_graph_group_box->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
memory_graph_group_box->set_preferred_size({ 0, 120 });
auto* memory_graph = new GraphWidget(memory_graph_group_box);
@@ -64,6 +63,8 @@ int main(int argc, char** argv)
return String::format("%d / %d KB", value, max);
};
+ tabwidget->add_widget("Graphs", graphs_container);
+
widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
auto* toolbar = new GToolBar(widget);