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