mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:48:12 +00:00
ResourceGraph: Add a thin frame around the graphs
Make the graph widgets into 1px GUI::Frames for a pleasant 90's feel.
This commit is contained in:
parent
57b86fd082
commit
21cfa9acd4
1 changed files with 10 additions and 7 deletions
|
@ -31,8 +31,8 @@
|
||||||
#include <LibCore/File.h>
|
#include <LibCore/File.h>
|
||||||
#include <LibCore/ProcessStatisticsReader.h>
|
#include <LibCore/ProcessStatisticsReader.h>
|
||||||
#include <LibGUI/Application.h>
|
#include <LibGUI/Application.h>
|
||||||
|
#include <LibGUI/Frame.h>
|
||||||
#include <LibGUI/Painter.h>
|
#include <LibGUI/Painter.h>
|
||||||
#include <LibGUI/Widget.h>
|
|
||||||
#include <LibGUI/Window.h>
|
#include <LibGUI/Window.h>
|
||||||
#include <LibGfx/Palette.h>
|
#include <LibGfx/Palette.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -42,18 +42,18 @@ enum class GraphType {
|
||||||
Memory,
|
Memory,
|
||||||
};
|
};
|
||||||
|
|
||||||
class GraphWidget final : public GUI::Widget {
|
class GraphWidget final : public GUI::Frame {
|
||||||
C_OBJECT(GraphWidget)
|
C_OBJECT(GraphWidget);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GraphWidget(GraphType graph_type, Optional<Gfx::Color> graph_color)
|
GraphWidget(GraphType graph_type, Optional<Gfx::Color> graph_color)
|
||||||
: m_graph_type(graph_type)
|
: m_graph_type(graph_type)
|
||||||
{
|
{
|
||||||
|
set_frame_thickness(1);
|
||||||
m_graph_color = graph_color.value_or(palette().menu_selection());
|
m_graph_color = graph_color.value_or(palette().menu_selection());
|
||||||
start_timer(1000);
|
start_timer(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~GraphWidget() override {}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void timer_event(Core::TimerEvent&) override
|
virtual void timer_event(Core::TimerEvent&) override
|
||||||
{
|
{
|
||||||
|
@ -86,14 +86,17 @@ private:
|
||||||
|
|
||||||
virtual void paint_event(GUI::PaintEvent& event) override
|
virtual void paint_event(GUI::PaintEvent& event) override
|
||||||
{
|
{
|
||||||
|
GUI::Frame::paint_event(event);
|
||||||
GUI::Painter painter(*this);
|
GUI::Painter painter(*this);
|
||||||
painter.add_clip_rect(event.rect());
|
painter.add_clip_rect(event.rect());
|
||||||
|
painter.add_clip_rect(frame_inner_rect());
|
||||||
painter.fill_rect(event.rect(), Color::Black);
|
painter.fill_rect(event.rect(), Color::Black);
|
||||||
int i = m_history.capacity() - m_history.size();
|
int i = m_history.capacity() - m_history.size();
|
||||||
|
auto rect = frame_inner_rect();
|
||||||
for (auto value : m_history) {
|
for (auto value : m_history) {
|
||||||
painter.draw_line(
|
painter.draw_line(
|
||||||
{ i, rect().bottom() },
|
{ i, rect.bottom() },
|
||||||
{ i, (int)(height() - (value * (float)height())) },
|
{ i, (int)(rect.height() - (value * (float)rect.height())) },
|
||||||
m_graph_color);
|
m_graph_color);
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue