Files
esDashboard/src/Display/Graphics/Renderer.cpp
T
2025-12-28 22:28:26 +00:00

46 lines
1.2 KiB
C++

#include "Renderer.h"
namespace Display::Graphics
{
Renderer::Renderer(Framebuffer &framebuffer, Model::HostRegistry &registry)
: framebuffer(framebuffer),
registry(registry)
{
}
void Renderer::render()
{
framebuffer.clear(Color{0, 0, 0});
header.draw(framebuffer, textRenderer, START_X, START_Y);
int blocksPerRow =
(SCREEN_WIDTH + BLOCK_GAP) / (Display::UI::HostBlock::BLOCK_WIDTH + BLOCK_GAP);
if (blocksPerRow < 1)
blocksPerRow = 1;
int index = 0;
for (auto &[host, m] : registry.snapshot())
{
int col = index % blocksPerRow;
int row = index / blocksPerRow;
int x = START_X + col * (Display::UI::HostBlock::BLOCK_WIDTH + BLOCK_GAP);
int y = START_Y + header.height() + BLOCK_GAP + row * (Display::UI::HostBlock::BLOCK_HEIGHT + BLOCK_GAP);
hostblock.draw(
framebuffer,
textRenderer,
x,
y,
host,
m);
++index;
}
framebuffer.present();
}
} // namespace Display::Graphics