mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
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.)
This commit is contained in:
parent
30554c969c
commit
b36ac88349
Notes:
sideshowbarker
2024-07-19 03:21:19 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/b36ac88349a
1 changed files with 6 additions and 4 deletions
|
@ -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<Gfx::Color> graph_color)
|
||||
: m_graph_type(graph_type)
|
||||
{
|
||||
|
@ -101,8 +103,8 @@ private:
|
|||
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 @@ private:
|
|||
|
||||
GraphType m_graph_type;
|
||||
Gfx::Color m_graph_color;
|
||||
CircularQueue<float, 30> m_history;
|
||||
CircularQueue<float, history_size> 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<GraphWidget>(graph_type, graph_color);
|
||||
window->show();
|
||||
|
|
Loading…
Reference in a new issue