Reduce use of unsigned integers when signed will do fine.

This commit is contained in:
Jared Boone 2016-01-23 17:53:16 -08:00
parent ce481c0b5a
commit 14f18d5cf7
10 changed files with 59 additions and 58 deletions

View file

@ -209,27 +209,28 @@ struct Rect {
{
}
Coord top() const {
int top() const {
return pos.y;
}
Coord bottom() const {
int bottom() const {
return pos.y + size.h;
}
Coord left() const {
int left() const {
return pos.x;
}
Coord right() const {
int right() const {
return pos.x + size.w;
}
Dim width() const {
int width() const {
return size.w;
}
Dim height() const {
int height() const {
return size.h;
}

View file

@ -36,13 +36,13 @@ Style Style::invert() const {
};
}
size_t Painter::draw_char(const Point p, const Style& style, const char c) {
int Painter::draw_char(const Point p, const Style& style, const char c) {
const auto glyph = style.font.glyph(c);
display.draw_glyph(p, glyph, style.foreground, style.background);
return glyph.advance().x;
}
size_t Painter::draw_string(Point p, const Style& style, const std::string text) {
int Painter::draw_string(Point p, const Style& style, const std::string text) {
size_t width = 0;
for(const auto c : text) {
const auto glyph = style.font.glyph(c);
@ -54,11 +54,11 @@ size_t Painter::draw_string(Point p, const Style& style, const std::string text)
return width;
}
void Painter::draw_hline(Point p, size_t width, const Color c) {
void Painter::draw_hline(Point p, int width, const Color c) {
display.fill_rectangle({ p, { width, 1 } }, c);
}
void Painter::draw_vline(Point p, size_t height, const Color c) {
void Painter::draw_vline(Point p, int height, const Color c) {
display.fill_rectangle({ p, { 1, height } }, c);
}

View file

@ -46,9 +46,9 @@ public:
Painter(const Painter&) = delete;
Painter(Painter&&) = delete;
size_t draw_char(const Point p, const Style& style, const char c);
int draw_char(const Point p, const Style& style, const char c);
size_t draw_string(Point p, const Style& style, const std::string text);
int draw_string(Point p, const Style& style, const std::string text);
void draw_rectangle(const Rect r, const Color c);
void fill_rectangle(const Rect r, const Color c);
@ -56,8 +56,8 @@ public:
void paint_widget_tree(Widget* const w);
private:
void draw_hline(Point p, size_t width, const Color c);
void draw_vline(Point p, size_t height, const Color c);
void draw_hline(Point p, int width, const Color c);
void draw_vline(Point p, int height, const Color c);
void paint_widget(Widget* const w);
};