From 1fe164e36f0996fb07f62de0ac38199943818095 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 7 Mar 2020 21:08:29 +0100 Subject: Re-enable drumkit image hover effect. --- plugingui/painter.cc | 72 +++++++++++++--------------------------------------- 1 file changed, 17 insertions(+), 55 deletions(-) (limited to 'plugingui/painter.cc') diff --git a/plugingui/painter.cc b/plugingui/painter.cc index d3f28ff..bad5318 100644 --- a/plugingui/painter.cc +++ b/plugingui/painter.cc @@ -389,10 +389,7 @@ void Painter::drawImage(int x0, int y0, const Drawable& image) assert(x0 + x < pixbuf.width); assert(y0 + y < pixbuf.height); - if (!has_restriction || c == restriction_colour) - { - pixbuf.addPixel(x0 + x, y0 + y, c); - } + pixbuf.addPixel(x0 + x, y0 + y, c); } } } @@ -417,8 +414,9 @@ void Painter::drawImage(int x0, int y0, const Drawable& image) } } -#if 0 -void Painter::drawImage(int x0, int y0, const Drawable& image) +void Painter::drawRestrictedImage(int x0, int y0, + const Colour& restriction_colour, + const Drawable& image) { int fw = image.width(); int fh = image.height(); @@ -439,64 +437,28 @@ void Painter::drawImage(int x0, int y0, const Drawable& image) return; } - if(image.hasAlpha()) + for(std::size_t y = -1 * std::min(0, y0); y < (std::size_t)fh; ++y) { - for(std::size_t y = -1 * std::min(0, y0); y < (std::size_t)fh; ++y) + for(std::size_t x = -1 * std::min(0, x0); x < (std::size_t)fw; ++x) { - for(std::size_t x = -1 * std::min(0, x0); x < (std::size_t)fw; ++x) - { - assert(x >= 0); - assert(y >= 0); - assert(x < image.width()); - assert(y < image.height()); - auto& c = image.getPixel(x, y); + assert(x >= 0); + assert(y >= 0); + assert(x < image.width()); + assert(y < image.height()); + auto& c = image.getPixel(x, y); - assert(x0 + x >= 0); - assert(y0 + y >= 0); - assert(x0 + x < pixbuf.width); - assert(y0 + y < pixbuf.height); + assert(x0 + x >= 0); + assert(y0 + y >= 0); + assert(x0 + x < pixbuf.width); + assert(y0 + y < pixbuf.height); - if (!has_restriction || c == restriction_colour) - { - pixbuf.addPixel(x0 + x, y0 + y, c); - } - } - } - } - else - { - for(std::size_t y = -1 * std::min(0, y0); y < (std::size_t)fh; ++y) - { - for(std::size_t x = -1 * std::min(0, x0); x < (std::size_t)fw; ++x) + if(c == restriction_colour) { - assert(x >= 0); - assert(y >= 0); - assert(x < image.width()); - assert(y < image.height()); - auto& c = image.getPixel(x, y); - - assert(x0 + x >= 0); - assert(y0 + y >= 0); - assert(x0 + x < pixbuf.width); - assert(y0 + y < pixbuf.height); - - if (!has_restriction || c == restriction_colour) - { - pixbuf.setPixel(x0 + x, y0 + y, c); - } + pixbuf.setPixel(x0 + x, y0 + y, c); } } } } -#endif - -void Painter::drawRestrictedImage(int x0, int y0, Colour const& colour, const Drawable& image) -{ - has_restriction = true; - restriction_colour = colour; - drawImage(x0, y0, image); - has_restriction = false; -} void Painter::drawImageStretched(int x0, int y0, const Drawable& image, int width, int height) -- cgit v1.2.3