summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2020-03-07 21:08:29 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2020-03-07 21:08:29 +0100
commit1fe164e36f0996fb07f62de0ac38199943818095 (patch)
tree852ffb547abd220e53128d78e777b33c4c08899c
parentd9d7188ad7b22e8991a9ef685840ac0e88566b39 (diff)
Re-enable drumkit image hover effect.
-rw-r--r--plugingui/drumkittab.cc2
-rw-r--r--plugingui/painter.cc72
-rw-r--r--plugingui/painter.h3
3 files changed, 20 insertions, 57 deletions
diff --git a/plugingui/drumkittab.cc b/plugingui/drumkittab.cc
index c3ee62e..8d85f1e 100644
--- a/plugingui/drumkittab.cc
+++ b/plugingui/drumkittab.cc
@@ -270,7 +270,7 @@ void DrumkitTab::init(std::string const& image_file,
if(it == colours.end())
{
// XXX: avoids low alpha values due to feathering of edges
- colours.emplace_back(colour.red(), colour.green(), colour.blue(), 0.7);
+ colours.emplace_back(colour.red(), colour.green(), colour.blue(), 178);
colour_index_to_positions.emplace_back();
}
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)
diff --git a/plugingui/painter.h b/plugingui/painter.h
index 2630b0c..d1a8e56 100644
--- a/plugingui/painter.h
+++ b/plugingui/painter.h
@@ -56,7 +56,8 @@ public:
void drawCircle(int x, int y, double r);
void drawFilledCircle(int x, int y, int r);
void drawImage(int x, int y, const Drawable& image);
- void drawRestrictedImage(int x0, int y0, Colour const& colour, const Drawable& image);
+ void drawRestrictedImage(int x0, int y0, const Colour& restriction_colour,
+ const Drawable& image);
void drawImageStretched(int x, int y, const Drawable& image,
int width, int height);