diff options
author | André Nusser <andre.nusser@googlemail.com> | 2018-06-09 19:26:20 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2018-08-12 11:13:52 +0200 |
commit | 3d218d5991a253f8d6a12db73908bead34d3e2da (patch) | |
tree | 4b95c29a35917a6fb6b27b88ea4d88ef67ec37a3 /plugingui | |
parent | 31dd927c43f72e76ecb61ea02a7832698b7a9496 (diff) |
Center drumkit image of drumkit tab.
Diffstat (limited to 'plugingui')
-rw-r--r-- | plugingui/drumkittab.cc | 7 | ||||
-rw-r--r-- | plugingui/drumkittab.h | 3 |
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; |