Browse Source

Consistent neko speed with new DPF

Signed-off-by: falkTX <falktx@falktx.com>
pull/16/head
falkTX 4 years ago
parent
commit
8c00761c4e
4 changed files with 21 additions and 31 deletions
  1. +1
    -1
      dpf
  2. +12
    -12
      plugins/Nekobi/DistrhoUINekobi.cpp
  3. +7
    -6
      plugins/Nekobi/DistrhoUINekobi.hpp
  4. +1
    -12
      plugins/Nekobi/NekoWidget.hpp

+ 1
- 1
dpf

@@ -1 +1 @@
Subproject commit ea7545a13ab9793b5608b13a82f1ad9cf9ec5e98
Subproject commit 4281406e68aeef25c5e8a9dff5542f0e0eee337a

+ 12
- 12
plugins/Nekobi/DistrhoUINekobi.cpp View File

@@ -29,9 +29,6 @@ DistrhoUINekobi::DistrhoUINekobi()
fImgBackground(Art::backgroundData, Art::backgroundWidth, Art::backgroundHeight, GL_BGR), fImgBackground(Art::backgroundData, Art::backgroundWidth, Art::backgroundHeight, GL_BGR),
fAboutWindow(this) fAboutWindow(this)
{ {
// FIXME
fNeko.setTimerSpeed(5);

// about // about
Image aboutImage(Art::aboutData, Art::aboutWidth, Art::aboutHeight, GL_BGR); Image aboutImage(Art::aboutData, Art::aboutWidth, Art::aboutHeight, GL_BGR);
fAboutWindow.setImage(aboutImage); fAboutWindow.setImage(aboutImage);
@@ -127,6 +124,9 @@ DistrhoUINekobi::DistrhoUINekobi()
fButtonAbout = new ImageButton(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);

// neko animation
addIdleCallback(this, 120);
} }


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -163,15 +163,6 @@ void DistrhoUINekobi::parameterChanged(uint32_t index, float value)
} }
} }


// -----------------------------------------------------------------------
// UI Callbacks

void DistrhoUINekobi::uiIdle()
{
if (fNeko.idle())
repaint();
}

// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Widget Callbacks // Widget Callbacks


@@ -219,6 +210,15 @@ void DistrhoUINekobi::onDisplay()
fNeko.draw(); fNeko.draw();
} }


// -----------------------------------------------------------------------
// Other Callbacks

void DistrhoUINekobi::idleCallback()
{
if (fNeko.idle())
repaint();
}

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


UI* createUI() UI* createUI()


+ 7
- 6
plugins/Nekobi/DistrhoUINekobi.hpp View File

@@ -37,7 +37,8 @@ START_NAMESPACE_DISTRHO
class DistrhoUINekobi : public UI, class DistrhoUINekobi : public UI,
public ImageButton::Callback, public ImageButton::Callback,
public ImageKnob::Callback, public ImageKnob::Callback,
public ImageSlider::Callback
public ImageSlider::Callback,
public IdleCallback
{ {
public: public:
DistrhoUINekobi(); DistrhoUINekobi();
@@ -48,11 +49,6 @@ protected:


void parameterChanged(uint32_t index, float value) override; void parameterChanged(uint32_t index, float value) override;


// -------------------------------------------------------------------
// UI Callbacks

void uiIdle() override;

// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Widget Callbacks // Widget Callbacks


@@ -66,6 +62,11 @@ protected:


void onDisplay() override; void onDisplay() override;


// -------------------------------------------------------------------
// Other Callbacks

void idleCallback() override;

private: private:
Image fImgBackground; Image fImgBackground;
ImageAboutWindow fAboutWindow; ImageAboutWindow fAboutWindow;


+ 1
- 12
plugins/Nekobi/NekoWidget.hpp View File

@@ -35,7 +35,6 @@ public:
NekoWidget() NekoWidget()
: fPos(0), : fPos(0),
fTimer(0), fTimer(0),
fTimerSpeed(20),
fCurAction(kActionNone), fCurAction(kActionNone),
fCurImage(&fImages.sit) fCurImage(&fImages.sit)
{ {
@@ -79,10 +78,7 @@ public:
// returns true if needs repaint // returns true if needs repaint
bool idle() bool idle()
{ {
if (++fTimer % fTimerSpeed != 0) // target is 20ms
return false;

if (fTimer == fTimerSpeed*9)
if (++fTimer == 10)
{ {
if (fCurAction == kActionNone) if (fCurAction == kActionNone)
fCurAction = static_cast<Action>(std::rand() % kActionCount); fCurAction = static_cast<Action>(std::rand() % kActionCount);
@@ -158,12 +154,6 @@ public:
return true; return true;
} }


void setTimerSpeed(int speed)
{
fTimer = 0;
fTimerSpeed = speed;
}

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


private: private:
@@ -191,7 +181,6 @@ private:


int fPos; int fPos;
int fTimer; int fTimer;
int fTimerSpeed;


Action fCurAction; Action fCurAction;
Image* fCurImage; Image* fCurImage;


Loading…
Cancel
Save