summaryrefslogtreecommitdiff
path: root/plugingui
diff options
context:
space:
mode:
authorAndré Nusser <andre.nusser@googlemail.com>2018-06-16 17:26:09 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2018-08-12 11:13:53 +0200
commit874fb66295fe5811016c6c5fe0e86a3d0cf9b109 (patch)
treec5454cfe5b9383f250bf7b03d3abe80a1a860aaf /plugingui
parent8ad5f7c39db55cab3f78fdefab323435261941fd (diff)
Fix issues when having several visualizations.
Diffstat (limited to 'plugingui')
-rw-r--r--plugingui/drumkittab.cc36
1 files changed, 21 insertions, 15 deletions
diff --git a/plugingui/drumkittab.cc b/plugingui/drumkittab.cc
index acc2c89..90f6d67 100644
--- a/plugingui/drumkittab.cc
+++ b/plugingui/drumkittab.cc
@@ -34,9 +34,6 @@
#include "painter.h"
#include "settings.h"
-// TODO:
-// make consistent with clicks etc
-
namespace GUI
{
@@ -85,18 +82,19 @@ void DrumkitTab::buttonEvent(ButtonEvent* buttonEvent)
if (buttonEvent->direction == GUI::Direction::down) {
Painter painter(*this);
painter.drawImage(drumkit_image_x, drumkit_image_y, *map_image);
- redraw();
-
shows_overlay = true;
+ redraw();
return;
}
if (buttonEvent->direction == GUI::Direction::up) {
Painter painter(*this);
painter.clear();
painter.drawImage(drumkit_image_x, drumkit_image_y, *drumkit_image);
- redraw();
+
+ highlightInstrument(current_index);
shows_overlay = false;
+ redraw();
return;
}
}
@@ -107,6 +105,8 @@ void DrumkitTab::buttonEvent(ButtonEvent* buttonEvent)
if (buttonEvent->direction == GUI::Direction::down)
{
triggerAudition(buttonEvent->x, buttonEvent->y);
+ highlightInstrument(current_index);
+ redraw();
}
if (buttonEvent->direction == GUI::Direction::up)
{
@@ -117,6 +117,7 @@ void DrumkitTab::buttonEvent(ButtonEvent* buttonEvent)
if (shows_overlay) {
painter.drawImage(drumkit_image_x, drumkit_image_y, *map_image);
}
+ highlightInstrument(current_index);
redraw();
}
shows_instrument_overlay = false;
@@ -142,6 +143,16 @@ void DrumkitTab::mouseMoveEvent(MouseMoveEvent* mouseMoveEvent)
auto index = pos_to_colour_index(x, y);
+ if (index == current_index) { return; }
+ current_index = index;
+
+ 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);
+ }
+
highlightInstrument(index);
updateInstrumentLabel(index);
redraw();
@@ -177,21 +188,16 @@ void DrumkitTab::triggerAudition(int x, int y)
void DrumkitTab::highlightInstrument(int index)
{
- if (index == current_index) { return; }
- current_index = index;
-
- Painter painter(*this);
- painter.clear();
- painter.drawImage(drumkit_image_x, drumkit_image_y, *drumkit_image);
- shows_overlay = false;
-
if (index != -1) {
+ Painter painter(*this);
auto const& colour = colours[index];
auto const& positions = colour_index_to_positions[index];
painter.draw(positions.begin(), positions.end(), drumkit_image_x, drumkit_image_y, colour);
-
shows_instrument_overlay = true;
}
+ else {
+ shows_instrument_overlay = false;
+ }
}
void DrumkitTab::updateVelocityLabel()