55 lines
1.5 KiB
C++
55 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "display/graphics/Framebuffer.h"
|
|
#include "display/graphics/Color.h"
|
|
#include "display/ui/text/Renderer.h"
|
|
#include "display/ui/bar/Bar.h"
|
|
#include "metrics/Host.h"
|
|
|
|
namespace display::ui::hostblock
|
|
{
|
|
// ===== Layout =====
|
|
constexpr int BLOCK_WIDTH = 118; // 118
|
|
constexpr int BLOCK_HEIGHT = 146; // 146
|
|
constexpr int PADDING = 5; // 5
|
|
|
|
constexpr int HEADER_HEIGHT = 12; // 12
|
|
constexpr std::string_view HEADER_FONT_NAME = "PixelFive-Regular";
|
|
constexpr int HEADER_FONT_SIZE = 5; // 10
|
|
constexpr int SECTION_GAP = 4; // 4
|
|
|
|
// ===== CPU bars =====
|
|
constexpr int CPU_BAR_WIDTH = 10; // 10
|
|
constexpr int CPU_BAR_GAP = 4; // 4
|
|
constexpr int CPU_BAR_HEIGHT = 16; // 16
|
|
constexpr int CPU_MAX_PER_ROW = 8; // 8
|
|
constexpr int CPU_ROWS = 2; // 2
|
|
|
|
// ===== Memory bar =====
|
|
constexpr int MEM_BAR_HEIGHT = 11; // 8
|
|
constexpr int MEM_BAR_TEXT_PADDING_X = PADDING + 3;
|
|
|
|
class HostBlock
|
|
{
|
|
public:
|
|
HostBlock();
|
|
|
|
static constexpr int width() { return BLOCK_WIDTH; }
|
|
static constexpr int height() { return BLOCK_HEIGHT; }
|
|
|
|
void draw(
|
|
display::graphics::Framebuffer &fb,
|
|
display::ui::text::Renderer &text,
|
|
int x, int y,
|
|
const std::string &hostname,
|
|
const metrics::Host &metrics);
|
|
|
|
private:
|
|
display::ui::bar::Bar cpuBar;
|
|
display::ui::bar::Bar memBar;
|
|
};
|
|
}
|