summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugingui/drumkittab.cc7
-rw-r--r--plugingui/drumkittab.h3
2 files changed, 8 insertions, 2 deletions
diff --git a/plugingui/drumkittab.cc b/plugingui/drumkittab.cc
index 1dccb52..d9123ea 100644
--- a/plugingui/drumkittab.cc
+++ b/plugingui/drumkittab.cc
@@ -59,7 +59,10 @@ void DrumkitTab::resize(std::size_t width, std::size_t height)
if (drumkit_image) {
Painter painter(*this);
painter.clear();
- painter.drawImage(0 , 0, *drumkit_image);
+
+ drumkit_image_x = (this->width()-drumkit_image->width())/2;
+ drumkit_image_y = (this->height()-drumkit_image->height())/2;
+ painter.drawImage(drumkit_image_x, drumkit_image_y, *drumkit_image);
}
velocity_label.move(10, height-velocity_label.height()-5);
@@ -86,7 +89,7 @@ void DrumkitTab::scrollEvent(ScrollEvent* scrollEvent)
void DrumkitTab::triggerAudition(int x, int y)
{
- auto map_colour = map_image->getPixel(x, y);
+ auto map_colour = map_image->getPixel(x - drumkit_image_x, y - drumkit_image_y);
auto it = colour_to_instrument.find(map_colour);
if (it == colour_to_instrument.end())
diff --git a/plugingui/drumkittab.h b/plugingui/drumkittab.h
index 5fe234a..89f37be 100644
--- a/plugingui/drumkittab.h
+++ b/plugingui/drumkittab.h
@@ -64,6 +64,9 @@ private:
std::unique_ptr<Image> drumkit_image;
std::unique_ptr<Image> map_image;
+ int drumkit_image_x;
+ int drumkit_image_y;
+
Label velocity_label{this};
Settings& settings;