From b36ac88349a2b9c7c8400e07c84431495927e4ee Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 21 Aug 2020 16:07:21 +0200 Subject: [PATCH] ResourceGraph: Keep the graph inside the GUI::Frame rect Part of the graph was hidden under the frame rect, which had the effect of delaying the appearance of spikes (well, all changes really.) --- MenuApplets/ResourceGraph/main.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/MenuApplets/ResourceGraph/main.cpp b/MenuApplets/ResourceGraph/main.cpp index ad2e97d892c113..6f856791a0a313 100644 --- a/MenuApplets/ResourceGraph/main.cpp +++ b/MenuApplets/ResourceGraph/main.cpp @@ -48,6 +48,8 @@ class GraphWidget final : public GUI::Frame { C_OBJECT(GraphWidget); public: + static constexpr size_t history_size = 30; + GraphWidget(GraphType graph_type, Optional graph_color) : m_graph_type(graph_type) { @@ -101,8 +103,8 @@ class GraphWidget final : public GUI::Frame { auto rect = frame_inner_rect(); for (auto value : m_history) { painter.draw_line( - { i, rect.bottom() }, - { i, (int)(rect.height() - (value * (float)rect.height())) }, + { rect.x() + i, rect.bottom() }, + { rect.x() + i, (int)(rect.height() - (value * (float)rect.height())) }, m_graph_color); ++i; } @@ -156,7 +158,7 @@ class GraphWidget final : public GUI::Frame { GraphType m_graph_type; Gfx::Color m_graph_color; - CircularQueue m_history; + CircularQueue m_history; unsigned m_last_cpu_busy { 0 }; unsigned m_last_cpu_idle { 0 }; String m_tooltip; @@ -211,7 +213,7 @@ int main(int argc, char** argv) auto window = GUI::Window::construct(); window->set_title(name); window->set_window_type(GUI::WindowType::MenuApplet); - window->resize(30, 16); + window->resize(GraphWidget::history_size + 2, 16); window->set_main_widget(graph_type, graph_color); window->show();