summaryrefslogtreecommitdiff
path: root/plugingui/drumkittab.cc
diff options
context:
space:
mode:
authorAndré Nusser <andre.nusser@googlemail.com>2018-06-10 15:13:53 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2018-08-12 11:13:52 +0200
commit3f259e92bf1a25a8db521a587b6d612e356b22bc (patch)
tree4c3d312028bcad0b0586003ed9702d4e6c38d1f8 /plugingui/drumkittab.cc
parentd5c2ccc687a38e607b3532f4eb3eafa95d3b887a (diff)
Add highlight of single instruments on hits.
Diffstat (limited to 'plugingui/drumkittab.cc')
-rw-r--r--plugingui/drumkittab.cc36
1 files changed, 30 insertions, 6 deletions
diff --git a/plugingui/drumkittab.cc b/plugingui/drumkittab.cc
index c371dc9..f132aed 100644
--- a/plugingui/drumkittab.cc
+++ b/plugingui/drumkittab.cc
@@ -96,10 +96,25 @@ void DrumkitTab::buttonEvent(ButtonEvent* buttonEvent)
}
}
- if (buttonEvent->button == MouseButton::left &&
- buttonEvent->direction == GUI::Direction::down)
+ if (buttonEvent->button == MouseButton::left)
{
- triggerAudition(buttonEvent->x, buttonEvent->y);
+ if (buttonEvent->direction == GUI::Direction::down)
+ {
+ triggerAudition(buttonEvent->x, buttonEvent->y);
+ }
+ if (buttonEvent->direction == GUI::Direction::up)
+ {
+ if (shows_instrument_overlay) {
+ Painter painter(*this);
+ painter.clear();
+ painter.drawImage(drumkit_image_x, drumkit_image_y, *drumkit_image);
+ if (shows_overlay) {
+ painter.drawImage(drumkit_image_x, drumkit_image_y, *map_image);
+ }
+ redraw();
+ }
+ shows_instrument_overlay = false;
+ }
}
}
@@ -110,12 +125,12 @@ void DrumkitTab::scrollEvent(ScrollEvent* scrollEvent)
updateVelocityLabel();
velocity_label.resizeToText();
- triggerAudition(scrollEvent->x, scrollEvent->y);
+ triggerAudition(scrollEvent->x, scrollEvent->y, false);
}
void DrumkitTab::mouseLeaveEvent()
{
- if (map_image && shows_overlay) {
+ if (map_image && (shows_overlay || shows_instrument_overlay)) {
Painter painter(*this);
painter.clear();
painter.drawImage(drumkit_image_x, drumkit_image_y, *drumkit_image);
@@ -125,7 +140,7 @@ void DrumkitTab::mouseLeaveEvent()
}
}
-void DrumkitTab::triggerAudition(int x, int y)
+void DrumkitTab::triggerAudition(int x, int y, bool show_hit)
{
auto map_colour = map_image->getPixel(x - drumkit_image_x, y - drumkit_image_y);
if (map_colour.alpha() == 0.0) { return; }
@@ -140,8 +155,17 @@ void DrumkitTab::triggerAudition(int x, int y)
settings.audition_instrument = it->second;
settings.audition_velocity = current_velocity;
+ if (show_hit)
+ {
+ Painter painter(*this);
+ painter.drawRestrictedImage(drumkit_image_x, drumkit_image_y, map_colour, *map_image);
+ shows_instrument_overlay = true;
+ }
+
current_instrument = it->second;
updateInstrumentLabel();
+
+ redraw();
}
void DrumkitTab::updateVelocityLabel()