diff --git a/Widgets/Button.cpp b/Widgets/Button.cpp index ad3754bb8e..9f6bd54edb 100644 --- a/Widgets/Button.cpp +++ b/Widgets/Button.cpp @@ -38,7 +38,7 @@ void Button::paintEvent(PaintEvent&) if (m_beingPressed) { // Base - painter.fill_rect({ 1, 1, width() - 1, height() - 1 }, buttonColor); + painter.fill_rect({ 1, 1, width() - 2, height() - 2 }, buttonColor); // Sunken shadow painter.draw_line({ 1, 1 }, { width() - 2, 1 }, shadowColor); diff --git a/Widgets/Painter.cpp b/Widgets/Painter.cpp index c702f1dee1..1c50881480 100644 --- a/Widgets/Painter.cpp +++ b/Widgets/Painter.cpp @@ -5,6 +5,8 @@ #include #include +#define DEBUG_WIDGET_UNDERDRAW + Painter::Painter(GraphicsBitmap& bitmap) { m_font = &Font::defaultFont(); @@ -21,6 +23,10 @@ Painter::Painter(Widget& widget) m_translation.moveBy(widget.relativePosition()); // NOTE: m_clip_rect is in Window coordinates since we are painting into its backing store. m_clip_rect = widget.relativeRect(); + +#ifdef DEBUG_WIDGET_UNDERDRAW + fill_rect(widget.rect(), Color::Red); +#endif } Painter::~Painter() @@ -66,12 +72,12 @@ void Painter::draw_bitmap(const Point& p, const CharacterBitmap& bitmap, Color c point.moveBy(m_translation); for (unsigned row = 0; row < bitmap.height(); ++row) { int y = point.y() + row; - if (y < m_clip_rect.top() || y >= m_clip_rect.bottom()) + if (y < m_clip_rect.top() || y > m_clip_rect.bottom()) break; auto* bits = m_target->scanline(y); for (unsigned j = 0; j < bitmap.width(); ++j) { int x = point.x() + j; - if (x < m_clip_rect.left() || x >= m_clip_rect.right()) + if (x < m_clip_rect.left() || x > m_clip_rect.right()) break; char fc = bitmap.bits()[row * bitmap.width() + j]; if (fc == '#') @@ -139,7 +145,7 @@ void Painter::draw_line(const Point& p1, const Point& p2, Color color) // Special case: vertical line. if (point1.x() == point2.x()) { const int x = point1.x(); - if (x < m_clip_rect.left() || x >= m_clip_rect.right()) + if (x < m_clip_rect.left() || x > m_clip_rect.right()) return; if (point1.y() > point2.y()) swap(point1, point2); @@ -156,7 +162,7 @@ void Painter::draw_line(const Point& p1, const Point& p2, Color color) // Special case: horizontal line. if (point1.y() == point2.y()) { const int y = point1.y(); - if (y < m_clip_rect.top() || y >= m_clip_rect.bottom()) + if (y < m_clip_rect.top() || y > m_clip_rect.bottom()) return; if (point1.x() > point2.x()) swap(point1, point2); diff --git a/Widgets/Rect.h b/Widgets/Rect.h index 301c891da1..6e6ef85c76 100644 --- a/Widgets/Rect.h +++ b/Widgets/Rect.h @@ -55,7 +55,7 @@ public: bool contains(int x, int y) const { - return x >= m_location.x() && x < right() && y >= m_location.y() && y < bottom(); + return x >= m_location.x() && x <= right() && y >= m_location.y() && y <= bottom(); } bool contains(const Point& point) const