diff --git a/dpf b/dpf index ea7545a..4281406 160000 --- a/dpf +++ b/dpf @@ -1 +1 @@ -Subproject commit ea7545a13ab9793b5608b13a82f1ad9cf9ec5e98 +Subproject commit 4281406e68aeef25c5e8a9dff5542f0e0eee337a diff --git a/plugins/Nekobi/DistrhoUINekobi.cpp b/plugins/Nekobi/DistrhoUINekobi.cpp index 7841f5d..bda008f 100644 --- a/plugins/Nekobi/DistrhoUINekobi.cpp +++ b/plugins/Nekobi/DistrhoUINekobi.cpp @@ -29,9 +29,6 @@ DistrhoUINekobi::DistrhoUINekobi() fImgBackground(Art::backgroundData, Art::backgroundWidth, Art::backgroundHeight, GL_BGR), fAboutWindow(this) { - // FIXME - fNeko.setTimerSpeed(5); - // about Image aboutImage(Art::aboutData, Art::aboutWidth, Art::aboutHeight, GL_BGR); fAboutWindow.setImage(aboutImage); @@ -127,6 +124,9 @@ DistrhoUINekobi::DistrhoUINekobi() fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover); fButtonAbout->setAbsolutePos(505, 5); 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 @@ -219,6 +210,15 @@ void DistrhoUINekobi::onDisplay() fNeko.draw(); } +// ----------------------------------------------------------------------- +// Other Callbacks + +void DistrhoUINekobi::idleCallback() +{ + if (fNeko.idle()) + repaint(); +} + // ----------------------------------------------------------------------- UI* createUI() diff --git a/plugins/Nekobi/DistrhoUINekobi.hpp b/plugins/Nekobi/DistrhoUINekobi.hpp index e74b855..7cfeb5c 100644 --- a/plugins/Nekobi/DistrhoUINekobi.hpp +++ b/plugins/Nekobi/DistrhoUINekobi.hpp @@ -37,7 +37,8 @@ START_NAMESPACE_DISTRHO class DistrhoUINekobi : public UI, public ImageButton::Callback, public ImageKnob::Callback, - public ImageSlider::Callback + public ImageSlider::Callback, + public IdleCallback { public: DistrhoUINekobi(); @@ -48,11 +49,6 @@ protected: void parameterChanged(uint32_t index, float value) override; - // ------------------------------------------------------------------- - // UI Callbacks - - void uiIdle() override; - // ------------------------------------------------------------------- // Widget Callbacks @@ -66,6 +62,11 @@ protected: void onDisplay() override; + // ------------------------------------------------------------------- + // Other Callbacks + + void idleCallback() override; + private: Image fImgBackground; ImageAboutWindow fAboutWindow; diff --git a/plugins/Nekobi/NekoWidget.hpp b/plugins/Nekobi/NekoWidget.hpp index 0b7775e..5f136f7 100644 --- a/plugins/Nekobi/NekoWidget.hpp +++ b/plugins/Nekobi/NekoWidget.hpp @@ -35,7 +35,6 @@ public: NekoWidget() : fPos(0), fTimer(0), - fTimerSpeed(20), fCurAction(kActionNone), fCurImage(&fImages.sit) { @@ -79,10 +78,7 @@ public: // returns true if needs repaint bool idle() { - if (++fTimer % fTimerSpeed != 0) // target is 20ms - return false; - - if (fTimer == fTimerSpeed*9) + if (++fTimer == 10) { if (fCurAction == kActionNone) fCurAction = static_cast(std::rand() % kActionCount); @@ -158,12 +154,6 @@ public: return true; } - void setTimerSpeed(int speed) - { - fTimer = 0; - fTimerSpeed = speed; - } - // ------------------------------------------------------------------- private: @@ -191,7 +181,6 @@ private: int fPos; int fTimer; - int fTimerSpeed; Action fCurAction; Image* fCurImage;