mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:07:47 +00:00
SystemMonitor: Use system color themes for graph widgets
This commit is contained in:
parent
feb66564d2
commit
e47af3044a
3 changed files with 10 additions and 16 deletions
|
@ -27,7 +27,9 @@
|
||||||
#include "GraphWidget.h"
|
#include "GraphWidget.h"
|
||||||
#include <LibGUI/Painter.h>
|
#include <LibGUI/Painter.h>
|
||||||
#include <LibGfx/Font.h>
|
#include <LibGfx/Font.h>
|
||||||
|
#include <LibGfx/Palette.h>
|
||||||
#include <LibGfx/Path.h>
|
#include <LibGfx/Path.h>
|
||||||
|
#include <LibGfx/SystemTheme.h>
|
||||||
|
|
||||||
GraphWidget::GraphWidget()
|
GraphWidget::GraphWidget()
|
||||||
{
|
{
|
||||||
|
@ -49,7 +51,7 @@ void GraphWidget::paint_event(GUI::PaintEvent& 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.add_clip_rect(frame_inner_rect());
|
||||||
painter.fill_rect(event.rect(), m_background_color);
|
painter.fill_rect(event.rect(), palette().base());
|
||||||
|
|
||||||
auto inner_rect = frame_inner_rect();
|
auto inner_rect = frame_inner_rect();
|
||||||
float scale = (float)inner_rect.height() / (float)m_max;
|
float scale = (float)inner_rect.height() / (float)m_max;
|
||||||
|
|
|
@ -39,8 +39,6 @@ public:
|
||||||
|
|
||||||
void add_value(Vector<int, 1>&&);
|
void add_value(Vector<int, 1>&&);
|
||||||
|
|
||||||
void set_background_color(Color color) { m_background_color = color; }
|
|
||||||
|
|
||||||
struct ValueFormat {
|
struct ValueFormat {
|
||||||
Color line_color { Color::Transparent };
|
Color line_color { Color::Transparent };
|
||||||
Color background_color { Color::Transparent };
|
Color background_color { Color::Transparent };
|
||||||
|
@ -63,7 +61,6 @@ private:
|
||||||
int m_max { 100 };
|
int m_max { 100 };
|
||||||
Vector<ValueFormat, 1> m_value_format;
|
Vector<ValueFormat, 1> m_value_format;
|
||||||
CircularQueue<Vector<int, 1>, 4000> m_values;
|
CircularQueue<Vector<int, 1>, 4000> m_values;
|
||||||
Color m_background_color { Color::Black };
|
|
||||||
bool m_stack_values { false };
|
bool m_stack_values { false };
|
||||||
|
|
||||||
Vector<Gfx::IntPoint, 1> m_calculated_points;
|
Vector<Gfx::IntPoint, 1> m_calculated_points;
|
||||||
|
|
|
@ -573,6 +573,8 @@ NonnullRefPtr<GUI::Widget> build_graphs_tab()
|
||||||
auto graphs_container = GUI::LazyWidget::construct();
|
auto graphs_container = GUI::LazyWidget::construct();
|
||||||
|
|
||||||
graphs_container->on_first_show = [](GUI::LazyWidget& self) {
|
graphs_container->on_first_show = [](GUI::LazyWidget& self) {
|
||||||
|
const auto system_palette = GUI::Application::the()->palette();
|
||||||
|
|
||||||
self.set_fill_with_background_color(true);
|
self.set_fill_with_background_color(true);
|
||||||
self.set_background_role(ColorRole::Button);
|
self.set_background_role(ColorRole::Button);
|
||||||
self.set_layout<GUI::VerticalBoxLayout>();
|
self.set_layout<GUI::VerticalBoxLayout>();
|
||||||
|
@ -586,17 +588,14 @@ NonnullRefPtr<GUI::Widget> build_graphs_tab()
|
||||||
for (size_t i = 0; i < ProcessModel::the().cpus().size(); i++) {
|
for (size_t i = 0; i < ProcessModel::the().cpus().size(); i++) {
|
||||||
auto& cpu_graph = cpu_graph_group_box.add<GraphWidget>();
|
auto& cpu_graph = cpu_graph_group_box.add<GraphWidget>();
|
||||||
cpu_graph.set_max(100);
|
cpu_graph.set_max(100);
|
||||||
cpu_graph.set_background_color(Color::White);
|
|
||||||
cpu_graph.set_value_format(0, {
|
cpu_graph.set_value_format(0, {
|
||||||
.line_color = Color::Blue,
|
.line_color = system_palette.syntax_preprocessor_statement(),
|
||||||
.background_color = Color::from_rgb(0xaaaaff),
|
|
||||||
.text_formatter = [](int value) {
|
.text_formatter = [](int value) {
|
||||||
return String::formatted("Total: {}%", value);
|
return String::formatted("Total: {}%", value);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
cpu_graph.set_value_format(1, {
|
cpu_graph.set_value_format(1, {
|
||||||
.line_color = Color::Red,
|
.line_color = system_palette.syntax_preprocessor_value(),
|
||||||
.background_color = Color::from_rgb(0xffaaaa),
|
|
||||||
.text_formatter = [](int value) {
|
.text_formatter = [](int value) {
|
||||||
return String::formatted("Kernel: {}%", value);
|
return String::formatted("Kernel: {}%", value);
|
||||||
},
|
},
|
||||||
|
@ -613,25 +612,21 @@ NonnullRefPtr<GUI::Widget> build_graphs_tab()
|
||||||
memory_graph_group_box.layout()->set_margins({ 6, 16, 6, 6 });
|
memory_graph_group_box.layout()->set_margins({ 6, 16, 6, 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<GraphWidget>();
|
||||||
memory_graph.set_background_color(Color::White);
|
|
||||||
memory_graph.set_stack_values(true);
|
memory_graph.set_stack_values(true);
|
||||||
memory_graph.set_value_format(0, {
|
memory_graph.set_value_format(0, {
|
||||||
.line_color = Color::from_rgb(0x619910),
|
.line_color = system_palette.syntax_comment(),
|
||||||
.background_color = Color::from_rgb(0xbbffbb),
|
|
||||||
.text_formatter = [&memory_graph](int value) {
|
.text_formatter = [&memory_graph](int value) {
|
||||||
return String::formatted("Committed: {} KiB", value);
|
return String::formatted("Committed: {} KiB", value);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
memory_graph.set_value_format(1, {
|
memory_graph.set_value_format(1, {
|
||||||
.line_color = Color::Blue,
|
.line_color = system_palette.syntax_preprocessor_statement(),
|
||||||
.background_color = Color::from_rgb(0xaaaaff),
|
|
||||||
.text_formatter = [&memory_graph](int value) {
|
.text_formatter = [&memory_graph](int value) {
|
||||||
return String::formatted("Allocated: {} KiB", value);
|
return String::formatted("Allocated: {} KiB", value);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
memory_graph.set_value_format(2, {
|
memory_graph.set_value_format(2, {
|
||||||
.line_color = Color::Red,
|
.line_color = system_palette.syntax_preprocessor_value(),
|
||||||
.background_color = Color::from_rgb(0xffaaaa),
|
|
||||||
.text_formatter = [&memory_graph](int value) {
|
.text_formatter = [&memory_graph](int value) {
|
||||||
return String::formatted("Kernel heap: {} KiB", value);
|
return String::formatted("Kernel heap: {} KiB", value);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue