Smallcase folders part 1
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
#include "Display/UI/Header/Header.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <ctime>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
#include "Display/UI/Bar/Orientation.h"
|
||||
#include "Display/UI/Bar/Style.h"
|
||||
#include "Display/UI/Theme/Theme.h"
|
||||
#include "Display/Graphics/Color.h"
|
||||
|
||||
namespace display::ui::header
|
||||
{
|
||||
Header::Header()
|
||||
{
|
||||
}
|
||||
|
||||
void Header::draw(
|
||||
display::graphics::Framebuffer &fb,
|
||||
display::ui::text::Renderer &text,
|
||||
int x, int y)
|
||||
{
|
||||
// ===== Block background =====
|
||||
fb.fillRect(x, y, HEADER_WIDTH, HEADER_HEIGHT, display::ui::theme::header::BACKGROUND);
|
||||
fb.drawRect(x, y, HEADER_WIDTH, HEADER_HEIGHT, display::ui::theme::header::BORDER);
|
||||
|
||||
int cursorY = y + PADDING;
|
||||
|
||||
text.drawTextOutlined(
|
||||
fb,
|
||||
x + PADDING + 120 - 2,
|
||||
cursorY + 8,
|
||||
getCurrentDateTime(),
|
||||
display::ui::theme::text::TEXT,
|
||||
display::ui::theme::text::OUTLINE,
|
||||
display::ui::text::Font{std::string(HEADER_FONT_NAME.begin(), HEADER_FONT_NAME.end()), HEADER_FONT_SIZE});
|
||||
}
|
||||
|
||||
std::string Header::getCurrentDateTime()
|
||||
{
|
||||
auto now = std::chrono::system_clock::now();
|
||||
std::time_t t = std::chrono::system_clock::to_time_t(now);
|
||||
std::tm tm{};
|
||||
localtime_r(&t, &tm);
|
||||
|
||||
std::ostringstream oss;
|
||||
oss << std::setfill('0')
|
||||
<< std::setw(2) << tm.tm_mday << '/'
|
||||
<< std::setw(2) << tm.tm_mon + 1 << '/'
|
||||
<< tm.tm_year + 1900 << ' '
|
||||
<< std::setw(2) << tm.tm_hour << ':'
|
||||
<< std::setw(2) << tm.tm_min << ':'
|
||||
<< std::setw(2) << tm.tm_sec;
|
||||
return oss.str();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user