mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-13 19:54:39 +00:00
Hide ui::Size implementation.
This commit is contained in:
parent
aac2d31548
commit
d15ace4676
@ -164,7 +164,7 @@ void RegistersWidget::update() {
|
||||
}
|
||||
|
||||
void RegistersWidget::paint(Painter& painter) {
|
||||
const Coord left = (size().w - config.row_width()) / 2;
|
||||
const Coord left = (size().width() - config.row_width()) / 2;
|
||||
|
||||
draw_legend(left, painter);
|
||||
draw_values(left, painter);
|
||||
|
@ -54,7 +54,7 @@ void MenuItemView::paint(Painter& painter) {
|
||||
);
|
||||
|
||||
painter.draw_string(
|
||||
{ r.pos.x() + 8, r.pos.y() + (r.size.h - font_height) / 2 },
|
||||
{ r.pos.x() + 8, r.pos.y() + (r.size.height() - font_height) / 2 },
|
||||
paint_style,
|
||||
item.text
|
||||
);
|
||||
@ -87,7 +87,7 @@ void MenuView::set_parent_rect(const Rect new_parent_rect) {
|
||||
for(auto child : children_) {
|
||||
child->set_parent_rect({
|
||||
{ 0, static_cast<ui::Coord>(i * item_height) },
|
||||
{ size().w, item_height }
|
||||
{ size().width(), item_height }
|
||||
});
|
||||
i++;
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ void FrequencyScale::draw_frequency_ticks(Painter& painter, const Rect r) {
|
||||
(magnitude_n >= 6) ? "M" :
|
||||
(magnitude_n >= 3) ? "k" : "";
|
||||
const std::string label = to_string_dec_uint(tick_offset) + zero_pad + unit;
|
||||
const auto label_width = style().font.size_of(label).w;
|
||||
const auto label_width = style().font.size_of(label).width();
|
||||
|
||||
const Coord offset_low = r.left() + x_center - pixel_offset;
|
||||
const Rect tick_low { offset_low, r.top(), 1, r.height() };
|
||||
|
@ -196,8 +196,8 @@ void lcd_start_ram_write(
|
||||
const ui::Point p,
|
||||
const ui::Size s
|
||||
) {
|
||||
lcd_caset(p.x(), p.x() + s.w - 1);
|
||||
lcd_paset(p.y(), p.y() + s.h - 1);
|
||||
lcd_caset(p.x(), p.x() + s.width() - 1);
|
||||
lcd_paset(p.y(), p.y() + s.height() - 1);
|
||||
lcd_ramwr_start();
|
||||
}
|
||||
|
||||
@ -205,8 +205,8 @@ void lcd_start_ram_read(
|
||||
const ui::Point p,
|
||||
const ui::Size s
|
||||
) {
|
||||
lcd_caset(p.x(), p.x() + s.w - 1);
|
||||
lcd_paset(p.y(), p.y() + s.h - 1);
|
||||
lcd_caset(p.x(), p.x() + s.width() - 1);
|
||||
lcd_paset(p.y(), p.y() + s.height() - 1);
|
||||
lcd_ramrd_start();
|
||||
}
|
||||
|
||||
@ -272,7 +272,7 @@ void ILI9341::fill_rectangle(ui::Rect r, const ui::Color c) {
|
||||
const auto r_clipped = r.intersect(screen_rect());
|
||||
if( !r_clipped.is_empty() ) {
|
||||
lcd_start_ram_write(r_clipped);
|
||||
size_t count = r_clipped.size.w * r_clipped.size.h;
|
||||
size_t count = r_clipped.size.width() * r_clipped.size.height();
|
||||
io.lcd_write_pixels(c, count);
|
||||
}
|
||||
}
|
||||
@ -341,7 +341,7 @@ void ILI9341::draw_bitmap(
|
||||
) {
|
||||
lcd_start_ram_write(p, size);
|
||||
|
||||
const size_t count = size.w * size.h;
|
||||
const size_t count = size.width() * size.height();
|
||||
for(size_t i=0; i<count; i++) {
|
||||
const auto pixel = pixels[i >> 3] & (1U << (i & 0x7));
|
||||
io.lcd_write_pixel(pixel ? foreground : background);
|
||||
|
@ -135,25 +135,35 @@ public:
|
||||
};
|
||||
|
||||
struct Size {
|
||||
Dim w;
|
||||
Dim h;
|
||||
private:
|
||||
Dim _w;
|
||||
Dim _h;
|
||||
|
||||
public:
|
||||
constexpr Size(
|
||||
) : w { 0 },
|
||||
h { 0 }
|
||||
) : _w { 0 },
|
||||
_h { 0 }
|
||||
{
|
||||
}
|
||||
|
||||
constexpr Size(
|
||||
int w,
|
||||
int h
|
||||
) : w { static_cast<Dim>(w) },
|
||||
h { static_cast<Dim>(h) }
|
||||
) : _w { static_cast<Dim>(w) },
|
||||
_h { static_cast<Dim>(h) }
|
||||
{
|
||||
}
|
||||
|
||||
int width() const {
|
||||
return _w;
|
||||
}
|
||||
|
||||
int height() const {
|
||||
return _h;
|
||||
}
|
||||
|
||||
bool is_empty() const {
|
||||
return (w < 1) || (h < 1);
|
||||
return (_w < 1) || (_h < 1);
|
||||
}
|
||||
};
|
||||
|
||||
@ -188,7 +198,7 @@ struct Rect {
|
||||
}
|
||||
|
||||
int bottom() const {
|
||||
return pos.y() + size.h;
|
||||
return pos.y() + size.height();
|
||||
}
|
||||
|
||||
int left() const {
|
||||
@ -196,19 +206,19 @@ struct Rect {
|
||||
}
|
||||
|
||||
int right() const {
|
||||
return pos.x() + size.w;
|
||||
return pos.x() + size.width();
|
||||
}
|
||||
|
||||
int width() const {
|
||||
return size.w;
|
||||
return size.width();
|
||||
}
|
||||
|
||||
int height() const {
|
||||
return size.h;
|
||||
return size.height();
|
||||
}
|
||||
|
||||
Point center() const {
|
||||
return { pos.x() + size.w / 2, pos.y() + size.h / 2 };
|
||||
return { pos.x() + size.width() / 2, pos.y() + size.height() / 2 };
|
||||
}
|
||||
|
||||
bool is_empty() const {
|
||||
|
@ -67,10 +67,10 @@ void Painter::draw_vline(Point p, int height, const Color c) {
|
||||
}
|
||||
|
||||
void Painter::draw_rectangle(const Rect r, const Color c) {
|
||||
draw_hline(r.pos, r.size.w, c);
|
||||
draw_vline({ r.pos.x(), r.pos.y() + 1 }, r.size.h - 2, c);
|
||||
draw_vline({ r.pos.x() + r.size.w - 1, r.pos.y() + 1 }, r.size.h - 2, c);
|
||||
draw_hline({ r.pos.x(), r.pos.y() + r.size.h - 1 }, r.size.w, c);
|
||||
draw_hline(r.pos, r.size.width(), c);
|
||||
draw_vline({ r.pos.x(), r.pos.y() + 1 }, r.size.height() - 2, c);
|
||||
draw_vline({ r.pos.x() + r.size.width() - 1, r.pos.y() + 1 }, r.size.height() - 2, c);
|
||||
draw_hline({ r.pos.x(), r.pos.y() + r.size.height() - 1 }, r.size.width(), c);
|
||||
}
|
||||
|
||||
void Painter::fill_rectangle(const Rect r, const Color c) {
|
||||
|
@ -44,8 +44,10 @@ Size Font::size_of(const std::string s) const {
|
||||
|
||||
for(const auto c : s) {
|
||||
const auto glyph_data = glyph(c);
|
||||
size.w += glyph_data.w();
|
||||
size.h = std::max(size.h, glyph_data.h());
|
||||
size = {
|
||||
size.width() + glyph_data.w(),
|
||||
std::max(size.height(), glyph_data.h())
|
||||
};
|
||||
}
|
||||
|
||||
return size;
|
||||
|
@ -42,11 +42,11 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
Dim w() const {
|
||||
int w() const {
|
||||
return w_;
|
||||
}
|
||||
|
||||
Dim h() const {
|
||||
int h() const {
|
||||
return h_;
|
||||
}
|
||||
|
||||
|
@ -351,13 +351,13 @@ void Button::paint(Painter& painter) {
|
||||
painter.draw_rectangle(r, style().foreground);
|
||||
|
||||
painter.fill_rectangle(
|
||||
{ r.pos.x() + 1, r.pos.y() + 1, r.size.w - 2, r.size.h - 2 },
|
||||
{ r.pos.x() + 1, r.pos.y() + 1, r.size.width() - 2, r.size.height() - 2 },
|
||||
paint_style.background
|
||||
);
|
||||
|
||||
const auto label_r = paint_style.font.size_of(text_);
|
||||
painter.draw_string(
|
||||
{ r.pos.x() + (r.size.w - label_r.w) / 2, r.pos.y() + (r.size.h - label_r.h) / 2 },
|
||||
{ r.pos.x() + (r.size.width() - label_r.width()) / 2, r.pos.y() + (r.size.height() - label_r.height()) / 2 },
|
||||
paint_style,
|
||||
text_
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user