Browse Source

Make UI code cairo compatible

master
falkTX 1 month ago
parent
commit
3fce1eb8b0
5 changed files with 81 additions and 70 deletions
  1. +1
    -1
      dpf
  2. +28
    -26
      plugins/Nekobi/DistrhoUINekobi.cpp
  3. +30
    -25
      plugins/Nekobi/DistrhoUINekobi.hpp
  4. +1
    -0
      plugins/Nekobi/Makefile
  5. +21
    -18
      plugins/Nekobi/NekoWidget.hpp

+ 1
- 1
dpf

@@ -1 +1 @@
Subproject commit 4281406e68aeef25c5e8a9dff5542f0e0eee337a
Subproject commit 4e84c35a098b31b1f33d24d995e0edbe4dadf974

+ 28
- 26
plugins/Nekobi/DistrhoUINekobi.cpp View File

@@ -1,6 +1,6 @@
/*
* DISTRHO Nekobi Plugin, based on Nekobee by Sean Bolton and others.
* Copyright (C) 2013-2015 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2013-2021 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -26,17 +26,17 @@ namespace Art = DistrhoArtworkNekobi;

DistrhoUINekobi::DistrhoUINekobi()
: UI(Art::backgroundWidth, Art::backgroundHeight),
fImgBackground(Art::backgroundData, Art::backgroundWidth, Art::backgroundHeight, GL_BGR),
fImgBackground(Art::backgroundData, Art::backgroundWidth, Art::backgroundHeight, kImageFormatBGR),
fAboutWindow(this)
{
// about
Image aboutImage(Art::aboutData, Art::aboutWidth, Art::aboutHeight, GL_BGR);
NekoImage aboutImage(Art::aboutData, Art::aboutWidth, Art::aboutHeight, kImageFormatBGR);
fAboutWindow.setImage(aboutImage);

// slider
Image sliderImage(Art::sliderData, Art::sliderWidth, Art::sliderHeight);
NekoImage sliderImage(Art::sliderData, Art::sliderWidth, Art::sliderHeight, kImageFormatBGRA);

fSliderWaveform = new ImageSlider(this, sliderImage);
fSliderWaveform = new NekoImageSlider(this, sliderImage);
fSliderWaveform->setId(DistrhoPluginNekobi::paramWaveform);
fSliderWaveform->setStartPos(133, 40);
fSliderWaveform->setEndPos(133, 60);
@@ -46,10 +46,10 @@ DistrhoUINekobi::DistrhoUINekobi()
fSliderWaveform->setCallback(this);

// knobs
Image knobImage(Art::knobData, Art::knobWidth, Art::knobHeight);
NekoImage knobImage(Art::knobData, Art::knobWidth, Art::knobHeight, kImageFormatBGRA);

// knob Tuning
fKnobTuning = new ImageKnob(this, knobImage, ImageKnob::Vertical);
fKnobTuning = new NekoImageKnob(this, knobImage, NekoImageKnob::Vertical);
fKnobTuning->setId(DistrhoPluginNekobi::paramTuning);
fKnobTuning->setAbsolutePos(41, 43);
fKnobTuning->setRange(-12.0f, 12.0f);
@@ -59,7 +59,7 @@ DistrhoUINekobi::DistrhoUINekobi()
fKnobTuning->setCallback(this);

// knob Cutoff
fKnobCutoff = new ImageKnob(this, knobImage, ImageKnob::Vertical);
fKnobCutoff = new NekoImageKnob(this, knobImage, NekoImageKnob::Vertical);
fKnobCutoff->setId(DistrhoPluginNekobi::paramCutoff);
fKnobCutoff->setAbsolutePos(185, 43);
fKnobCutoff->setRange(0.0f, 100.0f);
@@ -69,7 +69,7 @@ DistrhoUINekobi::DistrhoUINekobi()
fKnobCutoff->setCallback(this);

// knob Resonance
fKnobResonance = new ImageKnob(this, knobImage, ImageKnob::Vertical);
fKnobResonance = new NekoImageKnob(this, knobImage, NekoImageKnob::Vertical);
fKnobResonance->setId(DistrhoPluginNekobi::paramResonance);
fKnobResonance->setAbsolutePos(257, 43);
fKnobResonance->setRange(0.0f, 95.0f);
@@ -79,7 +79,7 @@ DistrhoUINekobi::DistrhoUINekobi()
fKnobResonance->setCallback(this);

// knob Env Mod
fKnobEnvMod = new ImageKnob(this, knobImage, ImageKnob::Vertical);
fKnobEnvMod = new NekoImageKnob(this, knobImage, NekoImageKnob::Vertical);
fKnobEnvMod->setId(DistrhoPluginNekobi::paramEnvMod);
fKnobEnvMod->setAbsolutePos(329, 43);
fKnobEnvMod->setRange(0.0f, 100.0f);
@@ -89,7 +89,7 @@ DistrhoUINekobi::DistrhoUINekobi()
fKnobEnvMod->setCallback(this);

// knob Decay
fKnobDecay = new ImageKnob(this, knobImage, ImageKnob::Vertical);
fKnobDecay = new NekoImageKnob(this, knobImage, NekoImageKnob::Vertical);
fKnobDecay->setId(DistrhoPluginNekobi::paramDecay);
fKnobDecay->setAbsolutePos(400, 43);
fKnobDecay->setRange(0.0f, 100.0f);
@@ -99,7 +99,7 @@ DistrhoUINekobi::DistrhoUINekobi()
fKnobDecay->setCallback(this);

// knob Accent
fKnobAccent = new ImageKnob(this, knobImage, ImageKnob::Vertical);
fKnobAccent = new NekoImageKnob(this, knobImage, NekoImageKnob::Vertical);
fKnobAccent->setId(DistrhoPluginNekobi::paramAccent);
fKnobAccent->setAbsolutePos(473, 43);
fKnobAccent->setRange(0.0f, 100.0f);
@@ -109,7 +109,7 @@ DistrhoUINekobi::DistrhoUINekobi()
fKnobAccent->setCallback(this);

// knob Volume
fKnobVolume = new ImageKnob(this, knobImage, ImageKnob::Vertical);
fKnobVolume = new NekoImageKnob(this, knobImage, NekoImageKnob::Vertical);
fKnobVolume->setId(DistrhoPluginNekobi::paramVolume);
fKnobVolume->setAbsolutePos(545, 43);
fKnobVolume->setRange(0.0f, 100.0f);
@@ -119,9 +119,9 @@ DistrhoUINekobi::DistrhoUINekobi()
fKnobVolume->setCallback(this);

// about button
Image aboutImageNormal(Art::aboutButtonNormalData, Art::aboutButtonNormalWidth, Art::aboutButtonNormalHeight);
Image aboutImageHover(Art::aboutButtonHoverData, Art::aboutButtonHoverWidth, Art::aboutButtonHoverHeight);
fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover);
NekoImage aboutImageNormal(Art::aboutButtonNormalData, Art::aboutButtonNormalWidth, Art::aboutButtonNormalHeight, kImageFormatBGRA);
NekoImage aboutImageHover(Art::aboutButtonHoverData, Art::aboutButtonHoverWidth, Art::aboutButtonHoverHeight, kImageFormatBGRA);
fButtonAbout = new NekoImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover);
fButtonAbout->setAbsolutePos(505, 5);
fButtonAbout->setCallback(this);

@@ -166,48 +166,50 @@ void DistrhoUINekobi::parameterChanged(uint32_t index, float value)
// -----------------------------------------------------------------------
// Widget Callbacks

void DistrhoUINekobi::imageButtonClicked(ImageButton* button, int)
void DistrhoUINekobi::imageButtonClicked(NekoImageButton* button, int)
{
if (button != fButtonAbout)
return;

fAboutWindow.exec();
fAboutWindow.runAsModal();
}

void DistrhoUINekobi::imageKnobDragStarted(ImageKnob* knob)
void DistrhoUINekobi::imageKnobDragStarted(NekoImageKnob* knob)
{
editParameter(knob->getId(), true);
}

void DistrhoUINekobi::imageKnobDragFinished(ImageKnob* knob)
void DistrhoUINekobi::imageKnobDragFinished(NekoImageKnob* knob)
{
editParameter(knob->getId(), false);
}

void DistrhoUINekobi::imageKnobValueChanged(ImageKnob* knob, float value)
void DistrhoUINekobi::imageKnobValueChanged(NekoImageKnob* knob, float value)
{
setParameterValue(knob->getId(), value);
}

void DistrhoUINekobi::imageSliderDragStarted(ImageSlider* slider)
void DistrhoUINekobi::imageSliderDragStarted(NekoImageSlider* slider)
{
editParameter(slider->getId(), true);
}

void DistrhoUINekobi::imageSliderDragFinished(ImageSlider* slider)
void DistrhoUINekobi::imageSliderDragFinished(NekoImageSlider* slider)
{
editParameter(slider->getId(), false);
}

void DistrhoUINekobi::imageSliderValueChanged(ImageSlider* slider, float value)
void DistrhoUINekobi::imageSliderValueChanged(NekoImageSlider* slider, float value)
{
setParameterValue(slider->getId(), value);
}

void DistrhoUINekobi::onDisplay()
{
fImgBackground.draw();
fNeko.draw();
const GraphicsContext& context(getGraphicsContext());

fImgBackground.draw(context);
fNeko.draw(context);
}

// -----------------------------------------------------------------------


+ 30
- 25
plugins/Nekobi/DistrhoUINekobi.hpp View File

@@ -1,6 +1,6 @@
/*
* DISTRHO Nekobi Plugin, based on Nekobee by Sean Bolton and others.
* Copyright (C) 2013-2015 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2013-2021 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -20,24 +20,29 @@

#include "DistrhoUI.hpp"

#include "ImageWidgets.hpp"

#include "DistrhoArtworkNekobi.hpp"
#include "NekoWidget.hpp"
#include "ImageBaseWidgets.hpp"

#ifdef DGL_CAIRO
typedef DGL_NAMESPACE::CairoImage NekoImage;
#else
typedef DGL_NAMESPACE::OpenGLImage NekoImage;
#endif

using DGL_NAMESPACE::ImageAboutWindow;
using DGL_NAMESPACE::ImageButton;
using DGL_NAMESPACE::ImageKnob;
using DGL_NAMESPACE::ImageSlider;
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

// -----------------------------------------------------------------------

class DistrhoUINekobi : public UI,
public ImageButton::Callback,
public ImageKnob::Callback,
public ImageSlider::Callback,
public NekoImageButton::Callback,
public NekoImageKnob::Callback,
public NekoImageSlider::Callback,
public IdleCallback
{
public:
@@ -52,13 +57,13 @@ protected:
// -------------------------------------------------------------------
// Widget Callbacks

void imageButtonClicked(ImageButton* button, int) override;
void imageKnobDragStarted(ImageKnob* knob) override;
void imageKnobDragFinished(ImageKnob* knob) override;
void imageKnobValueChanged(ImageKnob* knob, float value) override;
void imageSliderDragStarted(ImageSlider* slider) override;
void imageSliderDragFinished(ImageSlider* slider) override;
void imageSliderValueChanged(ImageSlider* slider, float value) override;
void imageButtonClicked(NekoImageButton* button, int) override;
void imageKnobDragStarted(NekoImageKnob* knob) override;
void imageKnobDragFinished(NekoImageKnob* knob) override;
void imageKnobValueChanged(NekoImageKnob* knob, float value) override;
void imageSliderDragStarted(NekoImageSlider* slider) override;
void imageSliderDragFinished(NekoImageSlider* slider) override;
void imageSliderValueChanged(NekoImageSlider* slider, float value) override;

void onDisplay() override;

@@ -68,14 +73,14 @@ protected:
void idleCallback() override;

private:
Image fImgBackground;
ImageAboutWindow fAboutWindow;
NekoWidget fNeko;
ScopedPointer<ImageButton> fButtonAbout;
ScopedPointer<ImageSlider> fSliderWaveform;
ScopedPointer<ImageKnob> fKnobTuning, fKnobCutoff, fKnobResonance;
ScopedPointer<ImageKnob> fKnobEnvMod, fKnobDecay, fKnobAccent, fKnobVolume;
NekoImage fImgBackground;
NekoImageAboutWindow fAboutWindow;
NekoWidget fNeko;
ScopedPointer<NekoImageButton> fButtonAbout;
ScopedPointer<NekoImageSlider> fSliderWaveform;
ScopedPointer<NekoImageKnob> fKnobTuning, fKnobCutoff, fKnobResonance;
ScopedPointer<NekoImageKnob> fKnobEnvMod, fKnobDecay, fKnobAccent, fKnobVolume;

DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DistrhoUINekobi)
};


+ 1
- 0
plugins/Nekobi/Makefile View File

@@ -22,6 +22,7 @@ FILES_UI = \
# --------------------------------------------------------------
# Do some magic

# UI_TYPE = cairo
include ../../dpf/Makefile.plugins.mk

# --------------------------------------------------------------


+ 21
- 18
plugins/Nekobi/NekoWidget.hpp View File

@@ -1,6 +1,6 @@
/*
* Neko widget animation
* Copyright (C) 2013-2015 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2013-2021 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -20,13 +20,16 @@

#include "DistrhoArtworkNekobi.hpp"

#include "Image.hpp"
#include "Widget.hpp"
#ifdef DGL_CAIRO
#include "Cairo.hpp"
typedef DGL_NAMESPACE::CairoImage NekoImage;
#else
#include "OpenGL.hpp"
typedef DGL_NAMESPACE::OpenGLImage NekoImage;
#endif

#include <cstdlib> // rand

using DGL_NAMESPACE::Image;

// -----------------------------------------------------------------------

class NekoWidget
@@ -61,7 +64,7 @@ public:
}
}

void draw()
void draw(const GraphicsContext& context)
{
int x = fPos+108;
int y = -2;
@@ -72,7 +75,7 @@ public:
y += 12;
}

fCurImage->drawAt(x, y);
fCurImage->drawAt(context, x, y);
}

// returns true if needs repaint
@@ -167,23 +170,23 @@ private:
};

struct Images {
Image sit;
Image tail;
Image claw1;
Image claw2;
Image scratch1;
Image scratch2;
Image run1;
Image run2;
Image run3;
Image run4;
NekoImage sit;
NekoImage tail;
NekoImage claw1;
NekoImage claw2;
NekoImage scratch1;
NekoImage scratch2;
NekoImage run1;
NekoImage run2;
NekoImage run3;
NekoImage run4;
} fImages;

int fPos;
int fTimer;

Action fCurAction;
Image* fCurImage;
NekoImage* fCurImage;
};

// -----------------------------------------------------------------------


Loading…
Cancel
Save