33 lines
731 B
C++
33 lines
731 B
C++
#pragma once
|
|
|
|
#include "epdiy.h"
|
|
|
|
namespace ui {
|
|
|
|
struct BatteryProps {
|
|
bool valid;
|
|
int percent;
|
|
};
|
|
|
|
class BatteryView {
|
|
public:
|
|
void layout(int screen_width, int screen_height);
|
|
EpdRect dirty_bounds(const BatteryProps& props, int pad_x = 4, int pad_y = 4) const;
|
|
void render(uint8_t* framebuffer, const BatteryProps& props);
|
|
const EpdRect& bounds() const;
|
|
|
|
private:
|
|
EpdRect measure_text_bounds(const BatteryProps& props) const;
|
|
EpdRect measure_label_bounds() const;
|
|
|
|
EpdRect bounds_ = {0, 0, 0, 0};
|
|
int label_x_ = 0;
|
|
int label_y_ = 0;
|
|
int text_x_ = 0;
|
|
int text_y_ = 0;
|
|
EpdRect last_text_bounds_ = {0, 0, 0, 0};
|
|
bool has_last_text_bounds_ = false;
|
|
};
|
|
|
|
} // namespace ui
|