mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-01-12 11:03:50 +00:00
Hide ui::Rect implementation.
This commit is contained in:
parent
d15ace4676
commit
e820bed097
@ -200,7 +200,7 @@ void RecentEntriesTable<AISRecentEntries>::draw(
|
||||
}
|
||||
|
||||
line.resize(target_rect.width() / 8, ' ');
|
||||
painter.draw_string(target_rect.pos, style, line);
|
||||
painter.draw_string(target_rect.location(), style, line);
|
||||
}
|
||||
|
||||
AISRecentEntryDetailView::AISRecentEntryDetailView() {
|
||||
|
@ -91,7 +91,7 @@ void RecentEntriesTable<ERTRecentEntries>::draw(
|
||||
}
|
||||
|
||||
line.resize(target_rect.width() / 8, ' ');
|
||||
painter.draw_string(target_rect.pos, style, line);
|
||||
painter.draw_string(target_rect.location(), style, line);
|
||||
}
|
||||
|
||||
ERTAppView::ERTAppView(NavigationView&) {
|
||||
|
@ -45,7 +45,7 @@ void RecentEntriesHeader::paint(Painter& painter) {
|
||||
.foreground = parent_style.foreground,
|
||||
};
|
||||
|
||||
auto p = r.pos;
|
||||
auto p = r.location();
|
||||
for(const auto& column : _columns) {
|
||||
const auto width = column.second;
|
||||
auto text = column.first;
|
||||
|
@ -140,7 +140,7 @@ public:
|
||||
const auto r = screen_rect();
|
||||
const auto& s = style();
|
||||
|
||||
Rect target_rect { r.pos, { r.width(), s.font.line_height() }};
|
||||
Rect target_rect { r.location(), { r.width(), s.font.line_height() }};
|
||||
const size_t visible_item_count = r.height() / s.font.line_height();
|
||||
|
||||
auto selected = find(recent, selected_key);
|
||||
|
@ -129,7 +129,7 @@ void RecentEntriesTable<TPMSRecentEntries>::draw(
|
||||
}
|
||||
|
||||
line.resize(target_rect.width() / 8, ' ');
|
||||
painter.draw_string(target_rect.pos, style, line);
|
||||
painter.draw_string(target_rect.location(), style, line);
|
||||
}
|
||||
|
||||
TPMSAppView::TPMSAppView(NavigationView&) {
|
||||
|
@ -49,7 +49,7 @@ void Console::write(const std::string& message) {
|
||||
crlf();
|
||||
}
|
||||
const Point pos_glyph {
|
||||
rect.pos.x() + pos.x(),
|
||||
rect.left() + pos.x(),
|
||||
display.scroll_area_y(pos.y())
|
||||
};
|
||||
display.draw_glyph(pos_glyph, glyph, s.foreground, s.background);
|
||||
|
@ -54,7 +54,7 @@ void MenuItemView::paint(Painter& painter) {
|
||||
);
|
||||
|
||||
painter.draw_string(
|
||||
{ r.pos.x() + 8, r.pos.y() + (r.size.height() - font_height) / 2 },
|
||||
{ r.left() + 8, r.top() + (r.height() - font_height) / 2 },
|
||||
paint_style,
|
||||
item.text
|
||||
);
|
||||
|
@ -213,13 +213,13 @@ void lcd_start_ram_read(
|
||||
void lcd_start_ram_write(
|
||||
const ui::Rect& r
|
||||
) {
|
||||
lcd_start_ram_write(r.pos, r.size);
|
||||
lcd_start_ram_write(r.location(), r.size());
|
||||
}
|
||||
|
||||
void lcd_start_ram_read(
|
||||
const ui::Rect& r
|
||||
) {
|
||||
lcd_start_ram_read(r.pos, r.size);
|
||||
lcd_start_ram_read(r.location(), r.size());
|
||||
}
|
||||
|
||||
void lcd_vertical_scrolling_definition(
|
||||
@ -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.width() * r_clipped.size.height();
|
||||
size_t count = r_clipped.width() * r_clipped.height();
|
||||
io.lcd_write_pixels(c, count);
|
||||
}
|
||||
}
|
||||
@ -315,7 +315,7 @@ void ILI9341::draw_pixels(
|
||||
const size_t count
|
||||
) {
|
||||
/* TODO: Assert that rectangle width x height < count */
|
||||
lcd_start_ram_write(r.pos, r.size);
|
||||
lcd_start_ram_write(r);
|
||||
io.lcd_write_pixels(colors, count);
|
||||
}
|
||||
|
||||
|
@ -51,21 +51,21 @@ Rect& Rect::operator+=(const Rect& p) {
|
||||
if( !p.is_empty() ) {
|
||||
const auto x1 = std::min(left(), p.left());
|
||||
const auto y1 = std::min(top(), p.top());
|
||||
pos = { x1, y1 };
|
||||
_pos = { x1, y1 };
|
||||
const auto x2 = std::max(right(), p.right());
|
||||
const auto y2 = std::max(bottom(), p.bottom());
|
||||
size = { x2 - x1, y2 - y1 };
|
||||
_size = { x2 - x1, y2 - y1 };
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
Rect& Rect::operator+=(const Point& p) {
|
||||
pos += p;
|
||||
_pos += p;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Rect& Rect::operator-=(const Point& p) {
|
||||
pos -= p;
|
||||
_pos -= p;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -168,61 +168,71 @@ public:
|
||||
};
|
||||
|
||||
struct Rect {
|
||||
Point pos;
|
||||
Size size;
|
||||
private:
|
||||
Point _pos;
|
||||
Size _size;
|
||||
|
||||
public:
|
||||
constexpr Rect(
|
||||
) : pos { },
|
||||
size { }
|
||||
) : _pos { },
|
||||
_size { }
|
||||
{
|
||||
}
|
||||
|
||||
constexpr Rect(
|
||||
int x, int y,
|
||||
int w, int h
|
||||
) : pos { x, y },
|
||||
size { w, h }
|
||||
) : _pos { x, y },
|
||||
_size { w, h }
|
||||
{
|
||||
}
|
||||
|
||||
constexpr Rect(
|
||||
Point pos,
|
||||
Size size
|
||||
) : pos(pos),
|
||||
size(size)
|
||||
) : _pos(pos),
|
||||
_size(size)
|
||||
{
|
||||
}
|
||||
|
||||
Point location() const {
|
||||
return _pos;
|
||||
}
|
||||
|
||||
Size size() const {
|
||||
return _size;
|
||||
}
|
||||
|
||||
int top() const {
|
||||
return pos.y();
|
||||
return _pos.y();
|
||||
}
|
||||
|
||||
int bottom() const {
|
||||
return pos.y() + size.height();
|
||||
return _pos.y() + _size.height();
|
||||
}
|
||||
|
||||
int left() const {
|
||||
return pos.x();
|
||||
return _pos.x();
|
||||
}
|
||||
|
||||
int right() const {
|
||||
return pos.x() + size.width();
|
||||
return _pos.x() + _size.width();
|
||||
}
|
||||
|
||||
int width() const {
|
||||
return size.width();
|
||||
return _size.width();
|
||||
}
|
||||
|
||||
int height() const {
|
||||
return size.height();
|
||||
return _size.height();
|
||||
}
|
||||
|
||||
Point center() const {
|
||||
return { pos.x() + size.width() / 2, pos.y() + size.height() / 2 };
|
||||
return { _pos.x() + _size.width() / 2, _pos.y() + _size.height() / 2 };
|
||||
}
|
||||
|
||||
bool is_empty() const {
|
||||
return size.is_empty();
|
||||
return _size.is_empty();
|
||||
}
|
||||
|
||||
bool contains(const Point p) const;
|
||||
@ -230,7 +240,7 @@ struct Rect {
|
||||
Rect intersect(const Rect& o) const;
|
||||
|
||||
Rect operator+(const Point& p) const {
|
||||
return { pos + p, size };
|
||||
return { _pos + p, _size };
|
||||
}
|
||||
|
||||
Rect& operator+=(const Rect& p);
|
||||
@ -238,7 +248,7 @@ struct Rect {
|
||||
Rect& operator-=(const Point& p);
|
||||
|
||||
operator bool() const {
|
||||
return !size.is_empty();
|
||||
return !_size.is_empty();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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.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);
|
||||
draw_hline(r.location(), r.width(), c);
|
||||
draw_vline({ r.left(), r.top() + 1 }, r.height() - 2, c);
|
||||
draw_vline({ r.left() + r.width() - 1, r.top() + 1 }, r.height() - 2, c);
|
||||
draw_hline({ r.left(), r.top() + r.height() - 1 }, r.width(), c);
|
||||
}
|
||||
|
||||
void Painter::fill_rectangle(const Rect r, const Color c) {
|
||||
|
@ -49,11 +49,11 @@ bool is_dirty() {
|
||||
const std::vector<Widget*> Widget::no_children { };
|
||||
|
||||
Point Widget::screen_pos() {
|
||||
return screen_rect().pos;
|
||||
return screen_rect().location();
|
||||
}
|
||||
|
||||
Size Widget::size() const {
|
||||
return parent_rect.size;
|
||||
return parent_rect.size();
|
||||
}
|
||||
|
||||
Rect Widget::screen_rect() const {
|
||||
@ -317,7 +317,7 @@ void Text::paint(Painter& painter) {
|
||||
painter.fill_rectangle(rect, s.background);
|
||||
|
||||
painter.draw_string(
|
||||
rect.pos,
|
||||
rect.location(),
|
||||
s,
|
||||
text
|
||||
);
|
||||
@ -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.width() - 2, r.size.height() - 2 },
|
||||
{ r.left() + 1, r.top() + 1, r.width() - 2, r.height() - 2 },
|
||||
paint_style.background
|
||||
);
|
||||
|
||||
const auto label_r = paint_style.font.size_of(text_);
|
||||
painter.draw_string(
|
||||
{ r.pos.x() + (r.size.width() - label_r.width()) / 2, r.pos.y() + (r.size.height() - label_r.height()) / 2 },
|
||||
{ r.left() + (r.width() - label_r.width()) / 2, r.top() + (r.height() - label_r.height()) / 2 },
|
||||
paint_style,
|
||||
text_
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user