| @@ -47,9 +47,6 @@ public: | |||||
| ImageKnob& operator=(const ImageKnob& imageKnob); | ImageKnob& operator=(const ImageKnob& imageKnob); | ||||
| ~ImageKnob() override; | ~ImageKnob() override; | ||||
| int getId() const noexcept; | |||||
| void setId(int id) noexcept; | |||||
| float getValue() const noexcept; | float getValue() const noexcept; | ||||
| void setDefault(float def) noexcept; | void setDefault(float def) noexcept; | ||||
| @@ -70,7 +67,6 @@ protected: | |||||
| private: | private: | ||||
| Image fImage; | Image fImage; | ||||
| int fId; | |||||
| float fMinimum; | float fMinimum; | ||||
| float fMaximum; | float fMaximum; | ||||
| float fStep; | float fStep; | ||||
| @@ -36,14 +36,11 @@ public: | |||||
| virtual void imageSliderValueChanged(ImageSlider* imageSlider, float value) = 0; | virtual void imageSliderValueChanged(ImageSlider* imageSlider, float value) = 0; | ||||
| }; | }; | ||||
| explicit ImageSlider(Window& parent, const Image& image, int id = 0) noexcept; | |||||
| explicit ImageSlider(Widget* widget, const Image& image, int id = 0) noexcept; | |||||
| explicit ImageSlider(Window& parent, const Image& image) noexcept; | |||||
| explicit ImageSlider(Widget* widget, const Image& image) noexcept; | |||||
| explicit ImageSlider(const ImageSlider& imageSlider) noexcept; | explicit ImageSlider(const ImageSlider& imageSlider) noexcept; | ||||
| ImageSlider& operator=(const ImageSlider& imageSlider) noexcept; | ImageSlider& operator=(const ImageSlider& imageSlider) noexcept; | ||||
| int getId() const noexcept; | |||||
| void setId(int id) noexcept; | |||||
| float getValue() const noexcept; | float getValue() const noexcept; | ||||
| void setStartPos(const Point<int>& startPos) noexcept; | void setStartPos(const Point<int>& startPos) noexcept; | ||||
| @@ -65,7 +62,6 @@ protected: | |||||
| private: | private: | ||||
| Image fImage; | Image fImage; | ||||
| int fId; | |||||
| float fMinimum; | float fMinimum; | ||||
| float fMaximum; | float fMaximum; | ||||
| float fStep; | float fStep; | ||||
| @@ -39,9 +39,6 @@ public: | |||||
| explicit ImageSwitch(const ImageSwitch& imageSwitch) noexcept; | explicit ImageSwitch(const ImageSwitch& imageSwitch) noexcept; | ||||
| ImageSwitch& operator=(const ImageSwitch& imageSwitch) noexcept; | ImageSwitch& operator=(const ImageSwitch& imageSwitch) noexcept; | ||||
| int getId() const noexcept; | |||||
| void setId(int id) noexcept; | |||||
| bool isDown() const noexcept; | bool isDown() const noexcept; | ||||
| void setDown(bool down) noexcept; | void setDown(bool down) noexcept; | ||||
| @@ -55,7 +52,6 @@ private: | |||||
| Image fImageNormal; | Image fImageNormal; | ||||
| Image fImageDown; | Image fImageDown; | ||||
| bool fIsDown; | bool fIsDown; | ||||
| int fId; | |||||
| Callback* fCallback; | Callback* fCallback; | ||||
| @@ -641,7 +641,7 @@ public: | |||||
| Creates font by loading it from the specified memory chunk. | Creates font by loading it from the specified memory chunk. | ||||
| Returns handle to the font. | Returns handle to the font. | ||||
| */ | */ | ||||
| FontId createFontMem(const char* name, uchar* data, int ndata, bool freeData); | |||||
| FontId createFontMem(const char* name, const uchar* data, int ndata, bool freeData); | |||||
| /** | /** | ||||
| Finds a loaded font of specified name, and returns handle to it, or -1 if the font is not found. | Finds a loaded font of specified name, and returns handle to it, or -1 if the font is not found. | ||||
| @@ -256,6 +256,18 @@ public: | |||||
| */ | */ | ||||
| void repaint() noexcept; | void repaint() noexcept; | ||||
| /** | |||||
| Get the Id associated with this widget. | |||||
| @see setId | |||||
| */ | |||||
| uint getId() const noexcept; | |||||
| /** | |||||
| Set an Id to be associated with this widget. | |||||
| @see getId | |||||
| */ | |||||
| void setId(uint id) noexcept; | |||||
| protected: | protected: | ||||
| /** | /** | ||||
| A function called to draw the view contents with OpenGL. | A function called to draw the view contents with OpenGL. | ||||
| @@ -318,6 +330,7 @@ private: | |||||
| bool fNeedsFullViewport; | bool fNeedsFullViewport; | ||||
| bool fNeedsScaling; | bool fNeedsScaling; | ||||
| bool fVisible; | bool fVisible; | ||||
| uint fId; | |||||
| Point<int> fAbsolutePos; | Point<int> fAbsolutePos; | ||||
| Size<uint> fSize; | Size<uint> fSize; | ||||
| @@ -56,7 +56,7 @@ public: | |||||
| void setTitle(const char* title); | void setTitle(const char* title); | ||||
| void setTransientWinId(intptr_t winId); | |||||
| void setTransientWinId(uintptr_t winId); | |||||
| App& getApp() const noexcept; | App& getApp() const noexcept; | ||||
| intptr_t getWindowId() const noexcept; | intptr_t getWindowId() const noexcept; | ||||
| @@ -22,7 +22,7 @@ START_NAMESPACE_DGL | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| ImageKnob::ImageKnob(Window& parent, const Image& image, Orientation orientation, int id) noexcept | |||||
| ImageKnob::ImageKnob(Window& parent, const Image& image, Orientation orientation) noexcept | |||||
| : Widget(parent), | : Widget(parent), | ||||
| fImage(image), | fImage(image), | ||||
| fId(id), | fId(id), | ||||
| @@ -52,10 +52,9 @@ ImageKnob::ImageKnob(Window& parent, const Image& image, Orientation orientation | |||||
| setSize(fImgLayerSize, fImgLayerSize); | setSize(fImgLayerSize, fImgLayerSize); | ||||
| } | } | ||||
| ImageKnob::ImageKnob(Widget* widget, const Image& image, Orientation orientation, int id) noexcept | |||||
| ImageKnob::ImageKnob(Widget* widget, const Image& image, Orientation orientation) noexcept | |||||
| : Widget(widget->getParentWindow()), | : Widget(widget->getParentWindow()), | ||||
| fImage(image), | fImage(image), | ||||
| fId(id), | |||||
| fMinimum(0.0f), | fMinimum(0.0f), | ||||
| fMaximum(1.0f), | fMaximum(1.0f), | ||||
| fStep(0.0f), | fStep(0.0f), | ||||
| @@ -85,7 +84,6 @@ ImageKnob::ImageKnob(Widget* widget, const Image& image, Orientation orientation | |||||
| ImageKnob::ImageKnob(const ImageKnob& imageKnob) | ImageKnob::ImageKnob(const ImageKnob& imageKnob) | ||||
| : Widget(imageKnob.getParentWindow()), | : Widget(imageKnob.getParentWindow()), | ||||
| fImage(imageKnob.fImage), | fImage(imageKnob.fImage), | ||||
| fId(imageKnob.fId), | |||||
| fMinimum(imageKnob.fMinimum), | fMinimum(imageKnob.fMinimum), | ||||
| fMaximum(imageKnob.fMaximum), | fMaximum(imageKnob.fMaximum), | ||||
| fStep(imageKnob.fStep), | fStep(imageKnob.fStep), | ||||
| @@ -115,7 +113,6 @@ ImageKnob::ImageKnob(const ImageKnob& imageKnob) | |||||
| ImageKnob& ImageKnob::operator=(const ImageKnob& imageKnob) | ImageKnob& ImageKnob::operator=(const ImageKnob& imageKnob) | ||||
| { | { | ||||
| fImage = imageKnob.fImage; | fImage = imageKnob.fImage; | ||||
| fId = imageKnob.fId; | |||||
| fMinimum = imageKnob.fMinimum; | fMinimum = imageKnob.fMinimum; | ||||
| fMaximum = imageKnob.fMaximum; | fMaximum = imageKnob.fMaximum; | ||||
| fStep = imageKnob.fStep; | fStep = imageKnob.fStep; | ||||
| @@ -157,16 +154,6 @@ ImageKnob::~ImageKnob() | |||||
| } | } | ||||
| } | } | ||||
| int ImageKnob::getId() const noexcept | |||||
| { | |||||
| return fId; | |||||
| } | |||||
| void ImageKnob::setId(int id) noexcept | |||||
| { | |||||
| fId = id; | |||||
| } | |||||
| float ImageKnob::getValue() const noexcept | float ImageKnob::getValue() const noexcept | ||||
| { | { | ||||
| return fValue; | return fValue; | ||||
| @@ -22,10 +22,9 @@ START_NAMESPACE_DGL | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| ImageSlider::ImageSlider(Window& parent, const Image& image, int id) noexcept | |||||
| ImageSlider::ImageSlider(Window& parent, const Image& image) noexcept | |||||
| : Widget(parent), | : Widget(parent), | ||||
| fImage(image), | fImage(image), | ||||
| fId(id), | |||||
| fMinimum(0.0f), | fMinimum(0.0f), | ||||
| fMaximum(1.0f), | fMaximum(1.0f), | ||||
| fStep(0.0f), | fStep(0.0f), | ||||
| @@ -44,10 +43,9 @@ ImageSlider::ImageSlider(Window& parent, const Image& image, int id) noexcept | |||||
| Widget::setNeedsFullViewport(true); | Widget::setNeedsFullViewport(true); | ||||
| } | } | ||||
| ImageSlider::ImageSlider(Widget* widget, const Image& image, int id) noexcept | |||||
| ImageSlider::ImageSlider(Widget* widget, const Image& image) noexcept | |||||
| : Widget(widget->getParentWindow()), | : Widget(widget->getParentWindow()), | ||||
| fImage(image), | fImage(image), | ||||
| fId(id), | |||||
| fMinimum(0.0f), | fMinimum(0.0f), | ||||
| fMaximum(1.0f), | fMaximum(1.0f), | ||||
| fStep(0.0f), | fStep(0.0f), | ||||
| @@ -69,7 +67,6 @@ ImageSlider::ImageSlider(Widget* widget, const Image& image, int id) noexcept | |||||
| ImageSlider::ImageSlider(const ImageSlider& imageSlider) noexcept | ImageSlider::ImageSlider(const ImageSlider& imageSlider) noexcept | ||||
| : Widget(imageSlider.getParentWindow()), | : Widget(imageSlider.getParentWindow()), | ||||
| fImage(imageSlider.fImage), | fImage(imageSlider.fImage), | ||||
| fId(imageSlider.fId), | |||||
| fMinimum(imageSlider.fMinimum), | fMinimum(imageSlider.fMinimum), | ||||
| fMaximum(imageSlider.fMaximum), | fMaximum(imageSlider.fMaximum), | ||||
| fStep(imageSlider.fStep), | fStep(imageSlider.fStep), | ||||
| @@ -91,7 +88,6 @@ ImageSlider::ImageSlider(const ImageSlider& imageSlider) noexcept | |||||
| ImageSlider& ImageSlider::operator=(const ImageSlider& imageSlider) noexcept | ImageSlider& ImageSlider::operator=(const ImageSlider& imageSlider) noexcept | ||||
| { | { | ||||
| fImage = imageSlider.fImage; | fImage = imageSlider.fImage; | ||||
| fId = imageSlider.fId; | |||||
| fMinimum = imageSlider.fMinimum; | fMinimum = imageSlider.fMinimum; | ||||
| fMaximum = imageSlider.fMaximum; | fMaximum = imageSlider.fMaximum; | ||||
| fStep = imageSlider.fStep; | fStep = imageSlider.fStep; | ||||
| @@ -109,16 +105,6 @@ ImageSlider& ImageSlider::operator=(const ImageSlider& imageSlider) noexcept | |||||
| return *this; | return *this; | ||||
| } | } | ||||
| int ImageSlider::getId() const noexcept | |||||
| { | |||||
| return fId; | |||||
| } | |||||
| void ImageSlider::setId(int id) noexcept | |||||
| { | |||||
| fId = id; | |||||
| } | |||||
| float ImageSlider::getValue() const noexcept | float ImageSlider::getValue() const noexcept | ||||
| { | { | ||||
| return fValue; | return fValue; | ||||
| @@ -20,12 +20,11 @@ START_NAMESPACE_DGL | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| ImageSwitch::ImageSwitch(Window& parent, const Image& imageNormal, const Image& imageDown, int id) noexcept | |||||
| ImageSwitch::ImageSwitch(Window& parent, const Image& imageNormal, const Image& imageDown) noexcept | |||||
| : Widget(parent), | : Widget(parent), | ||||
| fImageNormal(imageNormal), | fImageNormal(imageNormal), | ||||
| fImageDown(imageDown), | fImageDown(imageDown), | ||||
| fIsDown(false), | fIsDown(false), | ||||
| fId(id), | |||||
| fCallback(nullptr), | fCallback(nullptr), | ||||
| leakDetector_ImageSwitch() | leakDetector_ImageSwitch() | ||||
| { | { | ||||
| @@ -34,12 +33,11 @@ ImageSwitch::ImageSwitch(Window& parent, const Image& imageNormal, const Image& | |||||
| setSize(fImageNormal.getSize()); | setSize(fImageNormal.getSize()); | ||||
| } | } | ||||
| ImageSwitch::ImageSwitch(Widget* widget, const Image& imageNormal, const Image& imageDown, int id) noexcept | |||||
| ImageSwitch::ImageSwitch(Widget* widget, const Image& imageNormal, const Image& imageDown) noexcept | |||||
| : Widget(widget->getParentWindow()), | : Widget(widget->getParentWindow()), | ||||
| fImageNormal(imageNormal), | fImageNormal(imageNormal), | ||||
| fImageDown(imageDown), | fImageDown(imageDown), | ||||
| fIsDown(false), | fIsDown(false), | ||||
| fId(id), | |||||
| fCallback(nullptr), | fCallback(nullptr), | ||||
| leakDetector_ImageSwitch() | leakDetector_ImageSwitch() | ||||
| { | { | ||||
| @@ -53,7 +51,6 @@ ImageSwitch::ImageSwitch(const ImageSwitch& imageSwitch) noexcept | |||||
| fImageNormal(imageSwitch.fImageNormal), | fImageNormal(imageSwitch.fImageNormal), | ||||
| fImageDown(imageSwitch.fImageDown), | fImageDown(imageSwitch.fImageDown), | ||||
| fIsDown(imageSwitch.fIsDown), | fIsDown(imageSwitch.fIsDown), | ||||
| fId(imageSwitch.fId), | |||||
| fCallback(imageSwitch.fCallback), | fCallback(imageSwitch.fCallback), | ||||
| leakDetector_ImageSwitch() | leakDetector_ImageSwitch() | ||||
| { | { | ||||
| @@ -67,7 +64,6 @@ ImageSwitch& ImageSwitch::operator=(const ImageSwitch& imageSwitch) noexcept | |||||
| fImageNormal = imageSwitch.fImageNormal; | fImageNormal = imageSwitch.fImageNormal; | ||||
| fImageDown = imageSwitch.fImageDown; | fImageDown = imageSwitch.fImageDown; | ||||
| fIsDown = imageSwitch.fIsDown; | fIsDown = imageSwitch.fIsDown; | ||||
| fId = imageSwitch.fId; | |||||
| fCallback = imageSwitch.fCallback; | fCallback = imageSwitch.fCallback; | ||||
| DISTRHO_SAFE_ASSERT(fImageNormal.getSize() == fImageDown.getSize()); | DISTRHO_SAFE_ASSERT(fImageNormal.getSize() == fImageDown.getSize()); | ||||
| @@ -77,16 +73,6 @@ ImageSwitch& ImageSwitch::operator=(const ImageSwitch& imageSwitch) noexcept | |||||
| return *this; | return *this; | ||||
| } | } | ||||
| int ImageSwitch::getId() const noexcept | |||||
| { | |||||
| return fId; | |||||
| } | |||||
| void ImageSwitch::setId(int id) noexcept | |||||
| { | |||||
| fId = id;; | |||||
| } | |||||
| bool ImageSwitch::isDown() const noexcept | bool ImageSwitch::isDown() const noexcept | ||||
| { | { | ||||
| return fIsDown; | return fIsDown; | ||||
| @@ -27,6 +27,7 @@ Widget::Widget(Window& parent) | |||||
| fNeedsFullViewport(false), | fNeedsFullViewport(false), | ||||
| fNeedsScaling(false), | fNeedsScaling(false), | ||||
| fVisible(true), | fVisible(true), | ||||
| fId(0), | |||||
| fAbsolutePos(0, 0), | fAbsolutePos(0, 0), | ||||
| fSize(0, 0), | fSize(0, 0), | ||||
| leakDetector_Widget() | leakDetector_Widget() | ||||
| @@ -200,6 +201,16 @@ void Widget::repaint() noexcept | |||||
| fParent.repaint(); | fParent.repaint(); | ||||
| } | } | ||||
| uint Widget::getId() const noexcept | |||||
| { | |||||
| return fId; | |||||
| } | |||||
| void Widget::setId(uint id) noexcept | |||||
| { | |||||
| fId = id; | |||||
| } | |||||
| bool Widget::onKeyboard(const KeyboardEvent&) | bool Widget::onKeyboard(const KeyboardEvent&) | ||||
| { | { | ||||
| return false; | return false; | ||||
| @@ -554,7 +554,7 @@ struct Window::PrivateData { | |||||
| #endif | #endif | ||||
| } | } | ||||
| void setTransientWinId(const intptr_t winId) | |||||
| void setTransientWinId(const uintptr_t winId) | |||||
| { | { | ||||
| #if defined(DISTRHO_OS_LINUX) | #if defined(DISTRHO_OS_LINUX) | ||||
| XSetTransientForHint(xDisplay, xWindow, static_cast< ::Window>(winId)); | XSetTransientForHint(xDisplay, xWindow, static_cast< ::Window>(winId)); | ||||
| @@ -1010,7 +1010,7 @@ void Window::setTitle(const char* title) | |||||
| pData->setTitle(title); | pData->setTitle(title); | ||||
| } | } | ||||
| void Window::setTransientWinId(intptr_t winId) | |||||
| void Window::setTransientWinId(uintptr_t winId) | |||||
| { | { | ||||
| pData->setTransientWinId(winId); | pData->setTransientWinId(winId); | ||||
| } | } | ||||
| @@ -1074,8 +1074,8 @@ void Window::onReshape(uint width, uint height) | |||||
| glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | ||||
| glMatrixMode(GL_PROJECTION); | glMatrixMode(GL_PROJECTION); | ||||
| glLoadIdentity(); | glLoadIdentity(); | ||||
| glOrtho(0, width, height, 0, 0.0f, 1.0f); | |||||
| glViewport(0, 0, width, height); | |||||
| glOrtho(0.0, static_cast<GLdouble>(width), static_cast<GLdouble>(height), 0.0, 0.0, 1.0); | |||||
| glViewport(0, 0, static_cast<GLsizei>(width), static_cast<GLsizei>(height)); | |||||
| glMatrixMode(GL_MODELVIEW); | glMatrixMode(GL_MODELVIEW); | ||||
| glLoadIdentity(); | glLoadIdentity(); | ||||
| } | } | ||||
| @@ -24,6 +24,9 @@ | |||||
| #include <cstdlib> | #include <cstdlib> | ||||
| #include <cstring> | #include <cstring> | ||||
| #include <cmath> | |||||
| #include <limits> | |||||
| #ifdef DISTRHO_PROPER_CPP11_SUPPORT | #ifdef DISTRHO_PROPER_CPP11_SUPPORT | ||||
| # include <cstdint> | # include <cstdint> | ||||
| #else | #else | ||||
| @@ -46,18 +49,28 @@ inline float round(float __x) | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| // misc functions | // misc functions | ||||
| /* | |||||
| * Return a 64-bit number from 4 8-bit numbers. | |||||
| */ | |||||
| static inline | static inline | ||||
| int64_t d_cconst(const int a, const int b, const int c, const int d) noexcept | |||||
| int64_t d_cconst(const uint8_t a, const uint8_t b, const uint8_t c, const uint8_t d) noexcept | |||||
| { | { | ||||
| return (a << 24) | (b << 16) | (c << 8) | (d << 0); | return (a << 24) | (b << 16) | (c << 8) | (d << 0); | ||||
| } | } | ||||
| /* | |||||
| * Dummy function. | |||||
| */ | |||||
| static inline | static inline | ||||
| void d_pass() noexcept {} | void d_pass() noexcept {} | ||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| // string print functions | // string print functions | ||||
| /* | |||||
| * Print a string to stdout with newline (gray color). | |||||
| * Does nothing if DEBUG is not defined. | |||||
| */ | |||||
| #ifndef DEBUG | #ifndef DEBUG | ||||
| # define d_debug(...) | # define d_debug(...) | ||||
| #else | #else | ||||
| @@ -75,6 +88,9 @@ void d_debug(const char* const fmt, ...) noexcept | |||||
| } | } | ||||
| #endif | #endif | ||||
| /* | |||||
| * Print a string to stdout with newline. | |||||
| */ | |||||
| static inline | static inline | ||||
| void d_stdout(const char* const fmt, ...) noexcept | void d_stdout(const char* const fmt, ...) noexcept | ||||
| { | { | ||||
| @@ -87,6 +103,9 @@ void d_stdout(const char* const fmt, ...) noexcept | |||||
| } catch (...) {} | } catch (...) {} | ||||
| } | } | ||||
| /* | |||||
| * Print a string to stderr with newline. | |||||
| */ | |||||
| static inline | static inline | ||||
| void d_stderr(const char* const fmt, ...) noexcept | void d_stderr(const char* const fmt, ...) noexcept | ||||
| { | { | ||||
| @@ -99,6 +118,9 @@ void d_stderr(const char* const fmt, ...) noexcept | |||||
| } catch (...) {} | } catch (...) {} | ||||
| } | } | ||||
| /* | |||||
| * Print a string to stderr with newline (red color). | |||||
| */ | |||||
| static inline | static inline | ||||
| void d_stderr2(const char* const fmt, ...) noexcept | void d_stderr2(const char* const fmt, ...) noexcept | ||||
| { | { | ||||
| @@ -112,18 +134,58 @@ void d_stderr2(const char* const fmt, ...) noexcept | |||||
| } catch (...) {} | } catch (...) {} | ||||
| } | } | ||||
| /* | |||||
| * Print a safe assertion error message. | |||||
| */ | |||||
| static inline | static inline | ||||
| void d_safe_assert(const char* const assertion, const char* const file, const int line) noexcept | void d_safe_assert(const char* const assertion, const char* const file, const int line) noexcept | ||||
| { | { | ||||
| d_stderr2("assertion failure: \"%s\" in file %s, line %i", assertion, file, line); | d_stderr2("assertion failure: \"%s\" in file %s, line %i", assertion, file, line); | ||||
| } | } | ||||
| /* | |||||
| * Print a safe exception error message. | |||||
| */ | |||||
| static inline | static inline | ||||
| void d_safe_exception(const char* const exception, const char* const file, const int line) noexcept | void d_safe_exception(const char* const exception, const char* const file, const int line) noexcept | ||||
| { | { | ||||
| d_stderr2("exception caught: \"%s\" in file %s, line %i", exception, file, line); | d_stderr2("exception caught: \"%s\" in file %s, line %i", exception, file, line); | ||||
| } | } | ||||
| // ----------------------------------------------------------------------- | |||||
| // math functions | |||||
| /* | |||||
| * Safely compare two floating point numbers. | |||||
| * Returns true if they match. | |||||
| */ | |||||
| template<typename T> | |||||
| static inline | |||||
| bool d_isEqual(const T& v1, const T& v2) | |||||
| { | |||||
| return std::abs(v1-v2) < std::numeric_limits<T>::epsilon(); | |||||
| } | |||||
| /* | |||||
| * Safely check if a floating point number is zero. | |||||
| */ | |||||
| template<typename T> | |||||
| static inline | |||||
| bool d_isZero(const T& value) | |||||
| { | |||||
| return std::abs(value) < std::numeric_limits<T>::epsilon(); | |||||
| } | |||||
| /* | |||||
| * Safely check if a floating point number is not zero. | |||||
| */ | |||||
| template<typename T> | |||||
| static inline | |||||
| bool d_isNotZero(const T& value) | |||||
| { | |||||
| return std::abs(value) >= std::numeric_limits<T>::epsilon(); | |||||
| } | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| #endif // DISTRHO_UTILS_HPP_INCLUDED | #endif // DISTRHO_UTILS_HPP_INCLUDED | ||||
| @@ -83,7 +83,7 @@ struct Plugin::PrivateData { | |||||
| sampleRate(d_lastSampleRate) | sampleRate(d_lastSampleRate) | ||||
| { | { | ||||
| DISTRHO_SAFE_ASSERT(bufferSize != 0); | DISTRHO_SAFE_ASSERT(bufferSize != 0); | ||||
| DISTRHO_SAFE_ASSERT(sampleRate != 0.0); | |||||
| DISTRHO_SAFE_ASSERT(d_isNotZero(sampleRate)); | |||||
| } | } | ||||
| ~PrivateData() noexcept | ~PrivateData() noexcept | ||||
| @@ -433,7 +433,7 @@ public: | |||||
| DISTRHO_SAFE_ASSERT_RETURN(fPlugin != nullptr,); | DISTRHO_SAFE_ASSERT_RETURN(fPlugin != nullptr,); | ||||
| DISTRHO_SAFE_ASSERT(sampleRate > 0.0); | DISTRHO_SAFE_ASSERT(sampleRate > 0.0); | ||||
| if (fData->sampleRate == sampleRate) | |||||
| if (d_isEqual(fData->sampleRate, sampleRate)) | |||||
| return; | return; | ||||
| fData->sampleRate = sampleRate; | fData->sampleRate = sampleRate; | ||||
| @@ -96,8 +96,8 @@ void UI::d_uiReshape(uint width, uint height) | |||||
| glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | ||||
| glMatrixMode(GL_PROJECTION); | glMatrixMode(GL_PROJECTION); | ||||
| glLoadIdentity(); | glLoadIdentity(); | ||||
| glOrtho(0, width, height, 0, 0.0f, 1.0f); | |||||
| glViewport(0, 0, width, height); | |||||
| glOrtho(0.0, static_cast<GLdouble>(width), static_cast<GLdouble>(height), 0.0, 0.0, 1.0); | |||||
| glViewport(0, 0, static_cast<GLsizei>(width), static_cast<GLsizei>(height)); | |||||
| glMatrixMode(GL_MODELVIEW); | glMatrixMode(GL_MODELVIEW); | ||||
| glLoadIdentity(); | glLoadIdentity(); | ||||
| } | } | ||||
| @@ -75,7 +75,7 @@ struct UI::PrivateData { | |||||
| setSizeCallbackFunc(nullptr), | setSizeCallbackFunc(nullptr), | ||||
| ptr(nullptr) | ptr(nullptr) | ||||
| { | { | ||||
| DISTRHO_SAFE_ASSERT(sampleRate != 0.0); | |||||
| DISTRHO_SAFE_ASSERT(d_isNotZero(sampleRate)); | |||||
| #if defined(DISTRHO_PLUGIN_TARGET_DSSI) || defined(DISTRHO_PLUGIN_TARGET_LV2) | #if defined(DISTRHO_PLUGIN_TARGET_DSSI) || defined(DISTRHO_PLUGIN_TARGET_LV2) | ||||
| parameterOffset += DISTRHO_PLUGIN_NUM_INPUTS + DISTRHO_PLUGIN_NUM_OUTPUTS; | parameterOffset += DISTRHO_PLUGIN_NUM_INPUTS + DISTRHO_PLUGIN_NUM_OUTPUTS; | ||||
| @@ -331,7 +331,7 @@ public: | |||||
| glWindow.setTitle(uiTitle); | glWindow.setTitle(uiTitle); | ||||
| } | } | ||||
| void setWindowTransientWinId(const intptr_t winId) | |||||
| void setWindowTransientWinId(const uintptr_t winId) | |||||
| { | { | ||||
| glWindow.setTransientWinId(winId); | glWindow.setTransientWinId(winId); | ||||
| } | } | ||||
| @@ -351,7 +351,7 @@ public: | |||||
| DISTRHO_SAFE_ASSERT_RETURN(fUI != nullptr,); | DISTRHO_SAFE_ASSERT_RETURN(fUI != nullptr,); | ||||
| DISTRHO_SAFE_ASSERT(sampleRate > 0.0); | DISTRHO_SAFE_ASSERT(sampleRate > 0.0); | ||||
| if (fData->sampleRate == sampleRate) | |||||
| if (d_isEqual(fData->sampleRate, sampleRate)) | |||||
| return; | return; | ||||
| fData->sampleRate = sampleRate; | fData->sampleRate = sampleRate; | ||||
| @@ -192,13 +192,15 @@ $(OBJDIR)/distrho-3bandsplitter.cpp.o: distrho-3bandsplitter.cpp | |||||
| $(OBJDIR)/distrho-mverb.cpp.o: distrho-mverb.cpp | $(OBJDIR)/distrho-mverb.cpp.o: distrho-mverb.cpp | ||||
| -@mkdir -p $(OBJDIR) | -@mkdir -p $(OBJDIR) | ||||
| # FIXME - fix mverb strict warnings | |||||
| @echo "Compiling $<" | @echo "Compiling $<" | ||||
| @$(CXX) $< $(BUILD_CXX_FLAGS) -DDISTRHO_NAMESPACE=DISTRHO_MVerb -Idistrho-mverb -I$(CWD)/modules/dgl -Wno-effc++ -c -o $@ | |||||
| @$(CXX) $< $(BUILD_CXX_FLAGS) -DDISTRHO_NAMESPACE=DISTRHO_MVerb -Idistrho-mverb -I$(CWD)/modules/dgl -Wno-conversion -Wno-effc++ -Wno-shadow -c -o $@ | |||||
| $(OBJDIR)/distrho-nekobi.cpp.o: distrho-nekobi.cpp | $(OBJDIR)/distrho-nekobi.cpp.o: distrho-nekobi.cpp | ||||
| -@mkdir -p $(OBJDIR) | -@mkdir -p $(OBJDIR) | ||||
| # FIXME - fix nekobi strict warnings | |||||
| @echo "Compiling $<" | @echo "Compiling $<" | ||||
| @$(CXX) $< $(BUILD_CXX_FLAGS) -DDISTRHO_NAMESPACE=DISTRHO_Nekobi -Idistrho-nekobi -I$(CWD)/modules/dgl -Wno-effc++ -c -o $@ | |||||
| @$(CXX) $< $(BUILD_CXX_FLAGS) -DDISTRHO_NAMESPACE=DISTRHO_Nekobi -Idistrho-nekobi -I$(CWD)/modules/dgl -w -c -o $@ | |||||
| $(OBJDIR)/distrho-pingpongpan.cpp.o: distrho-pingpongpan.cpp | $(OBJDIR)/distrho-pingpongpan.cpp.o: distrho-pingpongpan.cpp | ||||
| -@mkdir -p $(OBJDIR) | -@mkdir -p $(OBJDIR) | ||||
| @@ -128,12 +128,12 @@ void DistrhoPluginMVerb::d_initProgramName(uint32_t index, d_string& programName | |||||
| float DistrhoPluginMVerb::d_getParameterValue(uint32_t index) const | float DistrhoPluginMVerb::d_getParameterValue(uint32_t index) const | ||||
| { | { | ||||
| return fVerb.getParameter(index) * 100.0f; | |||||
| return fVerb.getParameter(static_cast<int>(index)) * 100.0f; | |||||
| } | } | ||||
| void DistrhoPluginMVerb::d_setParameterValue(uint32_t index, float value) | void DistrhoPluginMVerb::d_setParameterValue(uint32_t index, float value) | ||||
| { | { | ||||
| fVerb.setParameter(index, value / 100.0f); | |||||
| fVerb.setParameter(static_cast<int>(index), value / 100.0f); | |||||
| } | } | ||||
| void DistrhoPluginMVerb::d_setProgram(uint32_t index) | void DistrhoPluginMVerb::d_setProgram(uint32_t index) | ||||
| @@ -212,7 +212,7 @@ void DistrhoPluginMVerb::d_activate() | |||||
| void DistrhoPluginMVerb::d_run(const float** inputs, float** outputs, uint32_t frames) | void DistrhoPluginMVerb::d_run(const float** inputs, float** outputs, uint32_t frames) | ||||
| { | { | ||||
| fVerb.process(inputs, outputs, frames); | |||||
| fVerb.process(inputs, outputs, static_cast<int>(frames)); | |||||
| } | } | ||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| @@ -37,7 +37,7 @@ DistrhoUIMVerb::DistrhoUIMVerb() | |||||
| fImgBackground = Image(DistrhoArtworkMVerb::backgroundData, DistrhoArtworkMVerb::backgroundWidth, DistrhoArtworkMVerb::backgroundHeight, GL_BGR); | fImgBackground = Image(DistrhoArtworkMVerb::backgroundData, DistrhoArtworkMVerb::backgroundWidth, DistrhoArtworkMVerb::backgroundHeight, GL_BGR); | ||||
| // text | // text | ||||
| fNanoText.createFontMem("kh", (uchar*)khkangrey_ttf, khkangrey_ttfSize, false); | |||||
| fNanoText.createFontMem("kh", (const uchar*)khkangrey_ttf, khkangrey_ttfSize, false); | |||||
| // knobs | // knobs | ||||
| Image knobImage(DistrhoArtworkMVerb::knobData, DistrhoArtworkMVerb::knobWidth, DistrhoArtworkMVerb::knobHeight); | Image knobImage(DistrhoArtworkMVerb::knobData, DistrhoArtworkMVerb::knobWidth, DistrhoArtworkMVerb::knobHeight); | ||||
| @@ -233,7 +233,7 @@ void DistrhoUIMVerb::onDisplay() | |||||
| char strBuf[32+1]; | char strBuf[32+1]; | ||||
| strBuf[32] = '\0'; | strBuf[32] = '\0'; | ||||
| for (int i=0; i<MVerb<float>::NUM_PARAMS; ++i) | |||||
| for (std::size_t i=0; i<MVerb<float>::NUM_PARAMS; ++i) | |||||
| { | { | ||||
| std::snprintf(strBuf, 32, "%i%%", int(fKnobs[i]->getValue())); | std::snprintf(strBuf, 32, "%i%%", int(fKnobs[i]->getValue())); | ||||
| fNanoText.textBox(58 + fKnobs[i]->getAbsoluteX()-56, 73, 30.0f, strBuf, nullptr); | fNanoText.textBox(58 + fKnobs[i]->getAbsoluteX()-56, 73, 30.0f, strBuf, nullptr); | ||||
| @@ -41,7 +41,8 @@ DistrhoUINekobi::DistrhoUINekobi() | |||||
| // slider | // slider | ||||
| Image sliderImage(DistrhoArtworkNekobi::sliderData, DistrhoArtworkNekobi::sliderWidth, DistrhoArtworkNekobi::sliderHeight); | Image sliderImage(DistrhoArtworkNekobi::sliderData, DistrhoArtworkNekobi::sliderWidth, DistrhoArtworkNekobi::sliderHeight); | ||||
| fSliderWaveform = new ImageSlider(this, sliderImage, DistrhoPluginNekobi::paramWaveform); | |||||
| fSliderWaveform = new ImageSlider(this, sliderImage); | |||||
| fSliderWaveform->setId(DistrhoPluginNekobi::paramWaveform); | |||||
| fSliderWaveform->setStartPos(133, 40); | fSliderWaveform->setStartPos(133, 40); | ||||
| fSliderWaveform->setEndPos(133, 60); | fSliderWaveform->setEndPos(133, 60); | ||||
| fSliderWaveform->setRange(0.0f, 1.0f); | fSliderWaveform->setRange(0.0f, 1.0f); | ||||
| @@ -53,7 +54,8 @@ DistrhoUINekobi::DistrhoUINekobi() | |||||
| Image knobImage(DistrhoArtworkNekobi::knobData, DistrhoArtworkNekobi::knobWidth, DistrhoArtworkNekobi::knobHeight); | Image knobImage(DistrhoArtworkNekobi::knobData, DistrhoArtworkNekobi::knobWidth, DistrhoArtworkNekobi::knobHeight); | ||||
| // knob Tuning | // knob Tuning | ||||
| fKnobTuning = new ImageKnob(this, knobImage, ImageKnob::Vertical, DistrhoPluginNekobi::paramTuning); | |||||
| fKnobTuning = new ImageKnob(this, knobImage, ImageKnob::Vertical); | |||||
| fKnobTuning->setId(DistrhoPluginNekobi::paramTuning); | |||||
| fKnobTuning->setAbsolutePos(41, 43); | fKnobTuning->setAbsolutePos(41, 43); | ||||
| fKnobTuning->setRange(-12.0f, 12.0f); | fKnobTuning->setRange(-12.0f, 12.0f); | ||||
| fKnobTuning->setDefault(0.0f); | fKnobTuning->setDefault(0.0f); | ||||
| @@ -62,7 +64,8 @@ DistrhoUINekobi::DistrhoUINekobi() | |||||
| fKnobTuning->setCallback(this); | fKnobTuning->setCallback(this); | ||||
| // knob Cutoff | // knob Cutoff | ||||
| fKnobCutoff = new ImageKnob(this, knobImage, ImageKnob::Vertical, DistrhoPluginNekobi::paramCutoff); | |||||
| fKnobCutoff = new ImageKnob(this, knobImage, ImageKnob::Vertical); | |||||
| fKnobCutoff->setId(DistrhoPluginNekobi::paramCutoff); | |||||
| fKnobCutoff->setAbsolutePos(185, 43); | fKnobCutoff->setAbsolutePos(185, 43); | ||||
| fKnobCutoff->setRange(0.0f, 100.0f); | fKnobCutoff->setRange(0.0f, 100.0f); | ||||
| fKnobCutoff->setDefault(25.0f); | fKnobCutoff->setDefault(25.0f); | ||||
| @@ -71,7 +74,8 @@ DistrhoUINekobi::DistrhoUINekobi() | |||||
| fKnobCutoff->setCallback(this); | fKnobCutoff->setCallback(this); | ||||
| // knob Resonance | // knob Resonance | ||||
| fKnobResonance = new ImageKnob(this, knobImage, ImageKnob::Vertical, DistrhoPluginNekobi::paramResonance); | |||||
| fKnobResonance = new ImageKnob(this, knobImage, ImageKnob::Vertical); | |||||
| fKnobResonance->setId(DistrhoPluginNekobi::paramResonance); | |||||
| fKnobResonance->setAbsolutePos(257, 43); | fKnobResonance->setAbsolutePos(257, 43); | ||||
| fKnobResonance->setRange(0.0f, 95.0f); | fKnobResonance->setRange(0.0f, 95.0f); | ||||
| fKnobResonance->setDefault(25.0f); | fKnobResonance->setDefault(25.0f); | ||||
| @@ -80,7 +84,8 @@ DistrhoUINekobi::DistrhoUINekobi() | |||||
| fKnobResonance->setCallback(this); | fKnobResonance->setCallback(this); | ||||
| // knob Env Mod | // knob Env Mod | ||||
| fKnobEnvMod = new ImageKnob(this, knobImage, ImageKnob::Vertical, DistrhoPluginNekobi::paramEnvMod); | |||||
| fKnobEnvMod = new ImageKnob(this, knobImage, ImageKnob::Vertical); | |||||
| fKnobEnvMod->setId(DistrhoPluginNekobi::paramEnvMod); | |||||
| fKnobEnvMod->setAbsolutePos(329, 43); | fKnobEnvMod->setAbsolutePos(329, 43); | ||||
| fKnobEnvMod->setRange(0.0f, 100.0f); | fKnobEnvMod->setRange(0.0f, 100.0f); | ||||
| fKnobEnvMod->setDefault(50.0f); | fKnobEnvMod->setDefault(50.0f); | ||||
| @@ -89,7 +94,8 @@ DistrhoUINekobi::DistrhoUINekobi() | |||||
| fKnobEnvMod->setCallback(this); | fKnobEnvMod->setCallback(this); | ||||
| // knob Decay | // knob Decay | ||||
| fKnobDecay = new ImageKnob(this, knobImage, ImageKnob::Vertical, DistrhoPluginNekobi::paramDecay); | |||||
| fKnobDecay = new ImageKnob(this, knobImage, ImageKnob::Vertical); | |||||
| fKnobDecay->setId(DistrhoPluginNekobi::paramDecay); | |||||
| fKnobDecay->setAbsolutePos(400, 43); | fKnobDecay->setAbsolutePos(400, 43); | ||||
| fKnobDecay->setRange(0.0f, 100.0f); | fKnobDecay->setRange(0.0f, 100.0f); | ||||
| fKnobDecay->setDefault(75.0f); | fKnobDecay->setDefault(75.0f); | ||||
| @@ -98,7 +104,8 @@ DistrhoUINekobi::DistrhoUINekobi() | |||||
| fKnobDecay->setCallback(this); | fKnobDecay->setCallback(this); | ||||
| // knob Accent | // knob Accent | ||||
| fKnobAccent = new ImageKnob(this, knobImage, ImageKnob::Vertical, DistrhoPluginNekobi::paramAccent); | |||||
| fKnobAccent = new ImageKnob(this, knobImage, ImageKnob::Vertical); | |||||
| fKnobAccent->setId(DistrhoPluginNekobi::paramAccent); | |||||
| fKnobAccent->setAbsolutePos(473, 43); | fKnobAccent->setAbsolutePos(473, 43); | ||||
| fKnobAccent->setRange(0.0f, 100.0f); | fKnobAccent->setRange(0.0f, 100.0f); | ||||
| fKnobAccent->setDefault(25.0f); | fKnobAccent->setDefault(25.0f); | ||||
| @@ -107,7 +114,8 @@ DistrhoUINekobi::DistrhoUINekobi() | |||||
| fKnobAccent->setCallback(this); | fKnobAccent->setCallback(this); | ||||
| // knob Volume | // knob Volume | ||||
| fKnobVolume = new ImageKnob(this, knobImage, ImageKnob::Vertical, DistrhoPluginNekobi::paramVolume); | |||||
| fKnobVolume = new ImageKnob(this, knobImage, ImageKnob::Vertical); | |||||
| fKnobVolume->setId(DistrhoPluginNekobi::paramVolume); | |||||
| fKnobVolume->setAbsolutePos(545, 43); | fKnobVolume->setAbsolutePos(545, 43); | ||||
| fKnobVolume->setRange(0.0f, 100.0f); | fKnobVolume->setRange(0.0f, 100.0f); | ||||
| fKnobVolume->setDefault(75.0f); | fKnobVolume->setDefault(75.0f); | ||||
| @@ -197,17 +197,13 @@ void carla_zeroFloat(float* const data, const std::size_t numSamples) noexcept | |||||
| // Missing functions in OSX. | // Missing functions in OSX. | ||||
| namespace std { | namespace std { | ||||
| inline float | |||||
| fmin(float __x, float __y) | |||||
| inline float fmin(float __x, float __y) | |||||
| { return __builtin_fminf(__x, __y); } | { return __builtin_fminf(__x, __y); } | ||||
| inline float | |||||
| fmax(float __x, float __y) | |||||
| inline float fmax(float __x, float __y) | |||||
| { return __builtin_fmaxf(__x, __y); } | { return __builtin_fmaxf(__x, __y); } | ||||
| inline float | |||||
| rint(float __x) | |||||
| inline float rint(float __x) | |||||
| { return __builtin_rintf(__x); } | { return __builtin_rintf(__x); } | ||||
| inline float | |||||
| round(float __x) | |||||
| inline float round(float __x) | |||||
| { return __builtin_roundf(__x); } | { return __builtin_roundf(__x); } | ||||
| } | } | ||||
| #endif | #endif | ||||