summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugin/Makefile.mingw32.in1
-rw-r--r--plugingui/Makefile.am1
-rw-r--r--plugingui/drumkitimage.cc141
-rw-r--r--plugingui/drumkitimage.h78
-rw-r--r--plugingui/drumkittab.cc20
-rw-r--r--plugingui/drumkittab.h3
6 files changed, 241 insertions, 3 deletions
diff --git a/plugin/Makefile.mingw32.in b/plugin/Makefile.mingw32.in
index 570ecd7..e126ab5 100644
--- a/plugin/Makefile.mingw32.in
+++ b/plugin/Makefile.mingw32.in
@@ -61,6 +61,7 @@ GUI_SRC = \
@top_srcdir@/plugingui/dialog.cc \
@top_srcdir@/plugingui/diskstreamingframecontent.cc \
@top_srcdir@/plugingui/drumkitframecontent.cc \
+ @top_srcdir@/plugingui/drumkitimage.cc \
@top_srcdir@/plugingui/drumkittab.cc \
@top_srcdir@/plugingui/eventhandler.cc \
@top_srcdir@/plugingui/filebrowser.cc \
diff --git a/plugingui/Makefile.am b/plugingui/Makefile.am
index 91e95bf..5fba821 100644
--- a/plugingui/Makefile.am
+++ b/plugingui/Makefile.am
@@ -67,6 +67,7 @@ nodist_libdggui_la_SOURCES = \
dialog.cc \
diskstreamingframecontent.cc \
drumkitframecontent.cc \
+ drumkitimage.cc \
drumkittab.cc \
eventhandler.cc \
filebrowser.cc \
diff --git a/plugingui/drumkitimage.cc b/plugingui/drumkitimage.cc
new file mode 100644
index 0000000..95f4054
--- /dev/null
+++ b/plugingui/drumkitimage.cc
@@ -0,0 +1,141 @@
+/* -*- Mode: c++ -*- */
+/***************************************************************************
+ * drumkitimage.cc
+ *
+ * Sun Mar 8 18:30:17 CET 2020
+ * Copyright 2020 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of DrumGizmo.
+ *
+ * DrumGizmo is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * DrumGizmo is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with DrumGizmo; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#include "drumkitimage.h"
+
+#include "painter.h"
+#include <cpp11fix.h>
+
+namespace GUI
+{
+
+DrumKitImage::DrumKitImage(Widget* parent)
+ : Widget(parent)
+{
+}
+
+void DrumKitImage::setImages(const std::string& imagefile,
+ const std::string& overlayfile)
+{
+ overlay.setOverlay(overlayfile);
+ image = std::make_unique<Image>(imagefile);
+ redraw();
+}
+
+void DrumKitImage::clearImages()
+{
+ overlay.clearOverlay();
+ image.reset();
+ redraw();
+}
+
+void DrumKitImage::resize(std::size_t width, std::size_t height)
+{
+ Widget::resize(width, height);
+ overlay.resize(width, height);
+}
+
+void DrumKitImage::buttonEvent(ButtonEvent* buttonEvent)
+{
+}
+
+void DrumKitImage::scrollEvent(ScrollEvent* scrollEvent)
+{
+}
+
+void DrumKitImage::mouseMoveEvent(MouseMoveEvent* mouseMoveEvent)
+{
+ Widget::mouseMoveEvent(mouseMoveEvent);
+ //redraw();
+}
+
+void DrumKitImage::mouseLeaveEvent()
+{
+}
+
+void DrumKitImage::repaintEvent(RepaintEvent* repaintEvent)
+{
+ Painter painter(*this);
+ painter.clear();
+
+ auto drumkit_scale = (float)width() / image->width();
+
+ if(image)
+ {
+ painter.drawImageStretched(0, 0, *image,
+ image->width() * drumkit_scale,
+ image->height() * drumkit_scale,
+ Filter::Linear);
+ }
+}
+
+DrumKitImage::Overlay::Overlay(Widget* parent)
+ : Widget(parent)
+{
+}
+
+void DrumKitImage::Overlay::setOverlay(const std::string& overlayfile)
+{
+ overlay = std::make_unique<Image>(overlayfile);
+ redraw();
+}
+
+void DrumKitImage::Overlay::clearOverlay()
+{
+ overlay.reset();
+ redraw();
+}
+
+static auto has_highlight_colour = false;
+
+void DrumKitImage::Overlay::buttonEvent(ButtonEvent* buttonEvent)
+{
+ has_highlight_colour = !has_highlight_colour;
+ redraw();
+}
+
+void DrumKitImage::Overlay::mouseMoveEvent(MouseMoveEvent* mouseMoveEvent)
+{
+}
+
+void DrumKitImage::Overlay::repaintEvent(RepaintEvent* repaintEvent)
+{
+ Painter painter(*this);
+ painter.clear();
+
+ auto drumkit_scale = (float)width() / overlay->width();
+ auto colour = Colour(0.0f, 0, 0, .8f);
+
+ if(overlay && has_highlight_colour)
+ {
+ painter.drawRestrictedImageStretched(0, 0, colour, *overlay,
+ overlay->width() * drumkit_scale,
+ overlay->height() * drumkit_scale,
+ Filter::Nearest);
+ }
+}
+
+} // GUI::
diff --git a/plugingui/drumkitimage.h b/plugingui/drumkitimage.h
new file mode 100644
index 0000000..2a9f27a
--- /dev/null
+++ b/plugingui/drumkitimage.h
@@ -0,0 +1,78 @@
+/* -*- Mode: c++ -*- */
+/***************************************************************************
+ * drumkitimage.h
+ *
+ * Sun Mar 8 18:30:17 CET 2020
+ * Copyright 2020 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of DrumGizmo.
+ *
+ * DrumGizmo is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * DrumGizmo is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with DrumGizmo; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#pragma once
+
+#include <cstdint>
+#include <memory>
+
+#include "widget.h"
+#include "image.h"
+
+namespace GUI
+{
+
+class DrumKitImage
+ : public Widget
+{
+public:
+ DrumKitImage(Widget* parent);
+
+ void setImages(const std::string& imagefile, const std::string& overlayfile);
+ void clearImages();
+
+ // From Widget:
+ void resize(std::size_t width, std::size_t height) override;
+ void buttonEvent(ButtonEvent* buttonEvent) override;
+ void scrollEvent(ScrollEvent* scrollEvent) override;
+ void mouseMoveEvent(MouseMoveEvent* mouseMoveEvent) override;
+ void mouseLeaveEvent() override;
+ void repaintEvent(RepaintEvent* repaintEvent) override;
+
+private:
+ class Overlay
+ : public Widget
+ {
+ public:
+ Overlay(Widget* parent);
+
+ void setOverlay(const std::string& overlayfile);
+ void clearOverlay();
+
+ // From Widget:
+ void buttonEvent(ButtonEvent* buttonEvent) override;
+ void mouseMoveEvent(MouseMoveEvent* mouseMoveEvent) override;
+ void repaintEvent(RepaintEvent* repaintEvent) override;
+
+ private:
+ std::unique_ptr<Image> overlay;
+ };
+
+ Overlay overlay{this};
+ std::unique_ptr<Image> image;
+};
+
+} // GUI::
diff --git a/plugingui/drumkittab.cc b/plugingui/drumkittab.cc
index 7be0562..58482e9 100644
--- a/plugingui/drumkittab.cc
+++ b/plugingui/drumkittab.cc
@@ -59,12 +59,16 @@ DrumkitTab::DrumkitTab(Widget* parent,
CONNECT(this, settings_notifier.drumkit_file,
this, &DrumkitTab::drumkitFileChanged);
+
+ settings.drumkit_file.store("/mnt/atuin/misc/stuff/deva/CrocellKit/CrocellKit_full.xml");
}
void DrumkitTab::resize(std::size_t width, std::size_t height)
{
Widget::resize(width, height);
-
+ drumkit_image2.resize(width, height);
+ drumkit_image2.move(0, height / 2 - drumkit_image2.height() / 2);
+/*
if(drumkit_image)
{
Painter painter(*this);
@@ -82,7 +86,7 @@ void DrumkitTab::resize(std::size_t width, std::size_t height)
drumkit_image->height() * drumkit_scale,
Filter::Nearest);
}
-
+*/
velocity_label.move(10, height-velocity_label.height()-5);
instrument_name_label.move(velocity_label.width()+30,
height-instrument_name_label.height()-5);
@@ -90,6 +94,7 @@ void DrumkitTab::resize(std::size_t width, std::size_t height)
void DrumkitTab::buttonEvent(ButtonEvent* buttonEvent)
{
+ /*
if(map_image)
{
if(buttonEvent->button == MouseButton::right)
@@ -160,6 +165,7 @@ void DrumkitTab::buttonEvent(ButtonEvent* buttonEvent)
shows_instrument_overlay = false;
}
}
+ */
}
void DrumkitTab::scrollEvent(ScrollEvent* scrollEvent)
@@ -182,7 +188,7 @@ void DrumkitTab::mouseMoveEvent(MouseMoveEvent* mouseMoveEvent)
if(index == current_index) { return; }
current_index = index;
-
+/*
Painter painter(*this);
painter.clear();
painter.drawImageStretched(drumkit_image_x, drumkit_image_y,
@@ -203,10 +209,13 @@ void DrumkitTab::mouseMoveEvent(MouseMoveEvent* mouseMoveEvent)
highlightInstrument(index);
updateInstrumentLabel(index);
redraw();
+*/
+ Widget::mouseMoveEvent(mouseMoveEvent);
}
void DrumkitTab::mouseLeaveEvent()
{
+ /*
if(map_image && (shows_overlay || shows_instrument_overlay))
{
Painter painter(*this);
@@ -220,6 +229,7 @@ void DrumkitTab::mouseLeaveEvent()
shows_overlay = false;
redraw();
}
+ */
}
void DrumkitTab::triggerAudition(int x, int y)
@@ -245,6 +255,7 @@ void DrumkitTab::triggerAudition(int x, int y)
void DrumkitTab::highlightInstrument(int index)
{
+ /*
if(index != -1)
{
Painter painter(*this);
@@ -267,6 +278,7 @@ void DrumkitTab::highlightInstrument(int index)
{
shows_instrument_overlay = false;
}
+ */
}
void DrumkitTab::updateVelocityLabel()
@@ -289,6 +301,8 @@ void DrumkitTab::init(std::string const& image_file,
drumkit_image = std::make_unique<Image>(image_file);
map_image = std::make_unique<Image>(map_file);
+ drumkit_image2.setImages(image_file, map_file);
+
// collect all colours and build lookup table
auto const height = map_image->height();
auto const width = map_image->width();
diff --git a/plugingui/drumkittab.h b/plugingui/drumkittab.h
index d56bc5a..50fc421 100644
--- a/plugingui/drumkittab.h
+++ b/plugingui/drumkittab.h
@@ -35,6 +35,7 @@
#include "image.h"
#include "label.h"
#include "widget.h"
+#include "drumkitimage.h"
struct Settings;
class SettingsNotifier;
@@ -112,6 +113,8 @@ private:
void updateInstrumentLabel(int index);
void drumkitFileChanged(const std::string& drumkit_file);
+
+ DrumKitImage drumkit_image2{this};
};
} // GUI::