Revert "Make UI code cairo compatible"

This reverts commit 3fce1eb8b0.

Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
falkTX 2021-06-14 13:36:01 +01:00
parent 564a070e42
commit b5aa7b7c13
No known key found for this signature in database
GPG Key ID: CDBAA37ABC74FBA0
4 changed files with 68 additions and 79 deletions

View File

@ -1,6 +1,6 @@
/* /*
* DISTRHO Nekobi Plugin, based on Nekobee by Sean Bolton and others. * DISTRHO Nekobi Plugin, based on Nekobee by Sean Bolton and others.
* Copyright (C) 2013-2021 Filipe Coelho <falktx@falktx.com> * Copyright (C) 2013-2015 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
@ -26,17 +26,17 @@ namespace Art = DistrhoArtworkNekobi;
DistrhoUINekobi::DistrhoUINekobi() DistrhoUINekobi::DistrhoUINekobi()
: UI(Art::backgroundWidth, Art::backgroundHeight), : UI(Art::backgroundWidth, Art::backgroundHeight),
fImgBackground(Art::backgroundData, Art::backgroundWidth, Art::backgroundHeight, kImageFormatBGR), fImgBackground(Art::backgroundData, Art::backgroundWidth, Art::backgroundHeight, GL_BGR),
fAboutWindow(this) fAboutWindow(this)
{ {
// about // about
NekoImage aboutImage(Art::aboutData, Art::aboutWidth, Art::aboutHeight, kImageFormatBGR); Image aboutImage(Art::aboutData, Art::aboutWidth, Art::aboutHeight, GL_BGR);
fAboutWindow.setImage(aboutImage); fAboutWindow.setImage(aboutImage);
// slider // slider
NekoImage sliderImage(Art::sliderData, Art::sliderWidth, Art::sliderHeight, kImageFormatBGRA); Image sliderImage(Art::sliderData, Art::sliderWidth, Art::sliderHeight);
fSliderWaveform = new NekoImageSlider(this, sliderImage); fSliderWaveform = new ImageSlider(this, sliderImage);
fSliderWaveform->setId(DistrhoPluginNekobi::paramWaveform); fSliderWaveform->setId(DistrhoPluginNekobi::paramWaveform);
fSliderWaveform->setStartPos(133, 40); fSliderWaveform->setStartPos(133, 40);
fSliderWaveform->setEndPos(133, 60); fSliderWaveform->setEndPos(133, 60);
@ -46,10 +46,10 @@ DistrhoUINekobi::DistrhoUINekobi()
fSliderWaveform->setCallback(this); fSliderWaveform->setCallback(this);
// knobs // knobs
NekoImage knobImage(Art::knobData, Art::knobWidth, Art::knobHeight, kImageFormatBGRA); Image knobImage(Art::knobData, Art::knobWidth, Art::knobHeight);
// knob Tuning // knob Tuning
fKnobTuning = new NekoImageKnob(this, knobImage, NekoImageKnob::Vertical); fKnobTuning = new ImageKnob(this, knobImage, ImageKnob::Vertical);
fKnobTuning->setId(DistrhoPluginNekobi::paramTuning); fKnobTuning->setId(DistrhoPluginNekobi::paramTuning);
fKnobTuning->setAbsolutePos(41, 43); fKnobTuning->setAbsolutePos(41, 43);
fKnobTuning->setRange(-12.0f, 12.0f); fKnobTuning->setRange(-12.0f, 12.0f);
@ -59,7 +59,7 @@ DistrhoUINekobi::DistrhoUINekobi()
fKnobTuning->setCallback(this); fKnobTuning->setCallback(this);
// knob Cutoff // knob Cutoff
fKnobCutoff = new NekoImageKnob(this, knobImage, NekoImageKnob::Vertical); fKnobCutoff = new ImageKnob(this, knobImage, ImageKnob::Vertical);
fKnobCutoff->setId(DistrhoPluginNekobi::paramCutoff); fKnobCutoff->setId(DistrhoPluginNekobi::paramCutoff);
fKnobCutoff->setAbsolutePos(185, 43); fKnobCutoff->setAbsolutePos(185, 43);
fKnobCutoff->setRange(0.0f, 100.0f); fKnobCutoff->setRange(0.0f, 100.0f);
@ -69,7 +69,7 @@ DistrhoUINekobi::DistrhoUINekobi()
fKnobCutoff->setCallback(this); fKnobCutoff->setCallback(this);
// knob Resonance // knob Resonance
fKnobResonance = new NekoImageKnob(this, knobImage, NekoImageKnob::Vertical); fKnobResonance = new ImageKnob(this, knobImage, ImageKnob::Vertical);
fKnobResonance->setId(DistrhoPluginNekobi::paramResonance); fKnobResonance->setId(DistrhoPluginNekobi::paramResonance);
fKnobResonance->setAbsolutePos(257, 43); fKnobResonance->setAbsolutePos(257, 43);
fKnobResonance->setRange(0.0f, 95.0f); fKnobResonance->setRange(0.0f, 95.0f);
@ -79,7 +79,7 @@ DistrhoUINekobi::DistrhoUINekobi()
fKnobResonance->setCallback(this); fKnobResonance->setCallback(this);
// knob Env Mod // knob Env Mod
fKnobEnvMod = new NekoImageKnob(this, knobImage, NekoImageKnob::Vertical); fKnobEnvMod = new ImageKnob(this, knobImage, ImageKnob::Vertical);
fKnobEnvMod->setId(DistrhoPluginNekobi::paramEnvMod); fKnobEnvMod->setId(DistrhoPluginNekobi::paramEnvMod);
fKnobEnvMod->setAbsolutePos(329, 43); fKnobEnvMod->setAbsolutePos(329, 43);
fKnobEnvMod->setRange(0.0f, 100.0f); fKnobEnvMod->setRange(0.0f, 100.0f);
@ -89,7 +89,7 @@ DistrhoUINekobi::DistrhoUINekobi()
fKnobEnvMod->setCallback(this); fKnobEnvMod->setCallback(this);
// knob Decay // knob Decay
fKnobDecay = new NekoImageKnob(this, knobImage, NekoImageKnob::Vertical); fKnobDecay = new ImageKnob(this, knobImage, ImageKnob::Vertical);
fKnobDecay->setId(DistrhoPluginNekobi::paramDecay); fKnobDecay->setId(DistrhoPluginNekobi::paramDecay);
fKnobDecay->setAbsolutePos(400, 43); fKnobDecay->setAbsolutePos(400, 43);
fKnobDecay->setRange(0.0f, 100.0f); fKnobDecay->setRange(0.0f, 100.0f);
@ -99,7 +99,7 @@ DistrhoUINekobi::DistrhoUINekobi()
fKnobDecay->setCallback(this); fKnobDecay->setCallback(this);
// knob Accent // knob Accent
fKnobAccent = new NekoImageKnob(this, knobImage, NekoImageKnob::Vertical); fKnobAccent = new ImageKnob(this, knobImage, ImageKnob::Vertical);
fKnobAccent->setId(DistrhoPluginNekobi::paramAccent); fKnobAccent->setId(DistrhoPluginNekobi::paramAccent);
fKnobAccent->setAbsolutePos(473, 43); fKnobAccent->setAbsolutePos(473, 43);
fKnobAccent->setRange(0.0f, 100.0f); fKnobAccent->setRange(0.0f, 100.0f);
@ -109,7 +109,7 @@ DistrhoUINekobi::DistrhoUINekobi()
fKnobAccent->setCallback(this); fKnobAccent->setCallback(this);
// knob Volume // knob Volume
fKnobVolume = new NekoImageKnob(this, knobImage, NekoImageKnob::Vertical); fKnobVolume = new ImageKnob(this, knobImage, ImageKnob::Vertical);
fKnobVolume->setId(DistrhoPluginNekobi::paramVolume); fKnobVolume->setId(DistrhoPluginNekobi::paramVolume);
fKnobVolume->setAbsolutePos(545, 43); fKnobVolume->setAbsolutePos(545, 43);
fKnobVolume->setRange(0.0f, 100.0f); fKnobVolume->setRange(0.0f, 100.0f);
@ -119,9 +119,9 @@ DistrhoUINekobi::DistrhoUINekobi()
fKnobVolume->setCallback(this); fKnobVolume->setCallback(this);
// about button // about button
NekoImage aboutImageNormal(Art::aboutButtonNormalData, Art::aboutButtonNormalWidth, Art::aboutButtonNormalHeight, kImageFormatBGRA); Image aboutImageNormal(Art::aboutButtonNormalData, Art::aboutButtonNormalWidth, Art::aboutButtonNormalHeight);
NekoImage aboutImageHover(Art::aboutButtonHoverData, Art::aboutButtonHoverWidth, Art::aboutButtonHoverHeight, kImageFormatBGRA); Image aboutImageHover(Art::aboutButtonHoverData, Art::aboutButtonHoverWidth, Art::aboutButtonHoverHeight);
fButtonAbout = new NekoImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover); fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover);
fButtonAbout->setAbsolutePos(505, 5); fButtonAbout->setAbsolutePos(505, 5);
fButtonAbout->setCallback(this); fButtonAbout->setCallback(this);
@ -166,50 +166,48 @@ void DistrhoUINekobi::parameterChanged(uint32_t index, float value)
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Widget Callbacks // Widget Callbacks
void DistrhoUINekobi::imageButtonClicked(NekoImageButton* button, int) void DistrhoUINekobi::imageButtonClicked(ImageButton* button, int)
{ {
if (button != fButtonAbout) if (button != fButtonAbout)
return; return;
fAboutWindow.runAsModal(); fAboutWindow.exec();
} }
void DistrhoUINekobi::imageKnobDragStarted(NekoImageKnob* knob) void DistrhoUINekobi::imageKnobDragStarted(ImageKnob* knob)
{ {
editParameter(knob->getId(), true); editParameter(knob->getId(), true);
} }
void DistrhoUINekobi::imageKnobDragFinished(NekoImageKnob* knob) void DistrhoUINekobi::imageKnobDragFinished(ImageKnob* knob)
{ {
editParameter(knob->getId(), false); editParameter(knob->getId(), false);
} }
void DistrhoUINekobi::imageKnobValueChanged(NekoImageKnob* knob, float value) void DistrhoUINekobi::imageKnobValueChanged(ImageKnob* knob, float value)
{ {
setParameterValue(knob->getId(), value); setParameterValue(knob->getId(), value);
} }
void DistrhoUINekobi::imageSliderDragStarted(NekoImageSlider* slider) void DistrhoUINekobi::imageSliderDragStarted(ImageSlider* slider)
{ {
editParameter(slider->getId(), true); editParameter(slider->getId(), true);
} }
void DistrhoUINekobi::imageSliderDragFinished(NekoImageSlider* slider) void DistrhoUINekobi::imageSliderDragFinished(ImageSlider* slider)
{ {
editParameter(slider->getId(), false); editParameter(slider->getId(), false);
} }
void DistrhoUINekobi::imageSliderValueChanged(NekoImageSlider* slider, float value) void DistrhoUINekobi::imageSliderValueChanged(ImageSlider* slider, float value)
{ {
setParameterValue(slider->getId(), value); setParameterValue(slider->getId(), value);
} }
void DistrhoUINekobi::onDisplay() void DistrhoUINekobi::onDisplay()
{ {
const GraphicsContext& context(getGraphicsContext()); fImgBackground.draw();
fNeko.draw();
fImgBackground.draw(context);
fNeko.draw(context);
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------

View File

@ -1,6 +1,6 @@
/* /*
* DISTRHO Nekobi Plugin, based on Nekobee by Sean Bolton and others. * DISTRHO Nekobi Plugin, based on Nekobee by Sean Bolton and others.
* Copyright (C) 2013-2021 Filipe Coelho <falktx@falktx.com> * Copyright (C) 2013-2015 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
@ -20,29 +20,24 @@
#include "DistrhoUI.hpp" #include "DistrhoUI.hpp"
#include "ImageWidgets.hpp"
#include "DistrhoArtworkNekobi.hpp" #include "DistrhoArtworkNekobi.hpp"
#include "NekoWidget.hpp" #include "NekoWidget.hpp"
#include "ImageBaseWidgets.hpp"
#ifdef DGL_CAIRO using DGL_NAMESPACE::ImageAboutWindow;
typedef DGL_NAMESPACE::CairoImage NekoImage; using DGL_NAMESPACE::ImageButton;
#else using DGL_NAMESPACE::ImageKnob;
typedef DGL_NAMESPACE::OpenGLImage NekoImage; using DGL_NAMESPACE::ImageSlider;
#endif
typedef DGL_NAMESPACE::ImageBaseAboutWindow<NekoImage> NekoImageAboutWindow;
typedef DGL_NAMESPACE::ImageBaseButton<NekoImage> NekoImageButton;
typedef DGL_NAMESPACE::ImageBaseKnob<NekoImage> NekoImageKnob;
typedef DGL_NAMESPACE::ImageBaseSlider<NekoImage> NekoImageSlider;
START_NAMESPACE_DISTRHO START_NAMESPACE_DISTRHO
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
class DistrhoUINekobi : public UI, class DistrhoUINekobi : public UI,
public NekoImageButton::Callback, public ImageButton::Callback,
public NekoImageKnob::Callback, public ImageKnob::Callback,
public NekoImageSlider::Callback, public ImageSlider::Callback,
public IdleCallback public IdleCallback
{ {
public: public:
@ -57,13 +52,13 @@ protected:
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Widget Callbacks // Widget Callbacks
void imageButtonClicked(NekoImageButton* button, int) override; void imageButtonClicked(ImageButton* button, int) override;
void imageKnobDragStarted(NekoImageKnob* knob) override; void imageKnobDragStarted(ImageKnob* knob) override;
void imageKnobDragFinished(NekoImageKnob* knob) override; void imageKnobDragFinished(ImageKnob* knob) override;
void imageKnobValueChanged(NekoImageKnob* knob, float value) override; void imageKnobValueChanged(ImageKnob* knob, float value) override;
void imageSliderDragStarted(NekoImageSlider* slider) override; void imageSliderDragStarted(ImageSlider* slider) override;
void imageSliderDragFinished(NekoImageSlider* slider) override; void imageSliderDragFinished(ImageSlider* slider) override;
void imageSliderValueChanged(NekoImageSlider* slider, float value) override; void imageSliderValueChanged(ImageSlider* slider, float value) override;
void onDisplay() override; void onDisplay() override;
@ -73,14 +68,14 @@ protected:
void idleCallback() override; void idleCallback() override;
private: private:
NekoImage fImgBackground; Image fImgBackground;
NekoImageAboutWindow fAboutWindow; ImageAboutWindow fAboutWindow;
NekoWidget fNeko; NekoWidget fNeko;
ScopedPointer<NekoImageButton> fButtonAbout; ScopedPointer<ImageButton> fButtonAbout;
ScopedPointer<NekoImageSlider> fSliderWaveform; ScopedPointer<ImageSlider> fSliderWaveform;
ScopedPointer<NekoImageKnob> fKnobTuning, fKnobCutoff, fKnobResonance; ScopedPointer<ImageKnob> fKnobTuning, fKnobCutoff, fKnobResonance;
ScopedPointer<NekoImageKnob> fKnobEnvMod, fKnobDecay, fKnobAccent, fKnobVolume; ScopedPointer<ImageKnob> fKnobEnvMod, fKnobDecay, fKnobAccent, fKnobVolume;
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DistrhoUINekobi) DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DistrhoUINekobi)
}; };

View File

@ -22,7 +22,6 @@ FILES_UI = \
# -------------------------------------------------------------- # --------------------------------------------------------------
# Do some magic # Do some magic
# UI_TYPE = cairo
include ../../dpf/Makefile.plugins.mk include ../../dpf/Makefile.plugins.mk
# -------------------------------------------------------------- # --------------------------------------------------------------

View File

@ -1,6 +1,6 @@
/* /*
* Neko widget animation * Neko widget animation
* Copyright (C) 2013-2021 Filipe Coelho <falktx@falktx.com> * Copyright (C) 2013-2015 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
@ -20,16 +20,13 @@
#include "DistrhoArtworkNekobi.hpp" #include "DistrhoArtworkNekobi.hpp"
#ifdef DGL_CAIRO #include "Image.hpp"
#include "Cairo.hpp" #include "Widget.hpp"
typedef DGL_NAMESPACE::CairoImage NekoImage;
#else
#include "OpenGL.hpp"
typedef DGL_NAMESPACE::OpenGLImage NekoImage;
#endif
#include <cstdlib> // rand #include <cstdlib> // rand
using DGL_NAMESPACE::Image;
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
class NekoWidget class NekoWidget
@ -64,7 +61,7 @@ public:
} }
} }
void draw(const GraphicsContext& context) void draw()
{ {
int x = fPos+108; int x = fPos+108;
int y = -2; int y = -2;
@ -75,7 +72,7 @@ public:
y += 12; y += 12;
} }
fCurImage->drawAt(context, x, y); fCurImage->drawAt(x, y);
} }
// returns true if needs repaint // returns true if needs repaint
@ -170,23 +167,23 @@ private:
}; };
struct Images { struct Images {
NekoImage sit; Image sit;
NekoImage tail; Image tail;
NekoImage claw1; Image claw1;
NekoImage claw2; Image claw2;
NekoImage scratch1; Image scratch1;
NekoImage scratch2; Image scratch2;
NekoImage run1; Image run1;
NekoImage run2; Image run2;
NekoImage run3; Image run3;
NekoImage run4; Image run4;
} fImages; } fImages;
int fPos; int fPos;
int fTimer; int fTimer;
Action fCurAction; Action fCurAction;
NekoImage* fCurImage; Image* fCurImage;
}; };
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------