| @@ -85,11 +85,10 @@ private: | |||
| Callback* fCallback; | |||
| bool fIsImgVertical; | |||
| int fImgLayerSize; | |||
| int fImgLayerCount; | |||
| Rectangle<int> fKnobArea; | |||
| GLuint fTextureId; | |||
| uint fImgLayerSize; | |||
| uint fImgLayerCount; | |||
| bool fIsReady; | |||
| GLuint fTextureId; | |||
| float _logscale(float value) const; | |||
| float _invlogscale(float value) const; | |||
| @@ -258,7 +258,7 @@ public: | |||
| /** | |||
| Destructor. | |||
| */ | |||
| ~NanoVG(); | |||
| virtual ~NanoVG(); | |||
| /** | |||
| Get the NanoVG context. | |||
| @@ -761,7 +761,8 @@ public: | |||
| */ | |||
| NanoWidget(Window& parent) | |||
| : Widget(parent), | |||
| NanoVG() | |||
| NanoVG(), | |||
| leakDetector_NanoWidget() | |||
| { | |||
| setNeedsScaling(true); | |||
| } | |||
| @@ -53,14 +53,17 @@ class Widget | |||
| public: | |||
| /** | |||
| Base event data. | |||
| @a mod The currently active keyboard modifiers. | |||
| @a mod The currently active keyboard modifiers, @see Modifier. | |||
| @a time The timestamp (if any). | |||
| */ | |||
| struct BaseEvent { | |||
| Modifier mod; | |||
| uint mod; | |||
| uint32_t time; | |||
| // make -Weffc++ happy | |||
| virtual ~BaseEvent() {} | |||
| /** Constuctor */ | |||
| BaseEvent() noexcept : mod(0x0), time(0) {} | |||
| /** Destuctor */ | |||
| virtual ~BaseEvent() noexcept {} | |||
| }; | |||
| /** | |||
| @@ -72,6 +75,12 @@ public: | |||
| struct KeyboardEvent : BaseEvent { | |||
| bool press; | |||
| uint key; | |||
| /** Constuctor */ | |||
| KeyboardEvent() noexcept | |||
| : BaseEvent(), | |||
| press(false), | |||
| key(0) {} | |||
| }; | |||
| /** | |||
| @@ -82,7 +91,13 @@ public: | |||
| */ | |||
| struct SpecialEvent : BaseEvent { | |||
| bool press; | |||
| Key key; | |||
| Key key; | |||
| /** Constuctor */ | |||
| SpecialEvent() noexcept | |||
| : BaseEvent(), | |||
| press(false), | |||
| key(Key(0)) {} | |||
| }; | |||
| /** | |||
| @@ -93,9 +108,16 @@ public: | |||
| @see onMouse | |||
| */ | |||
| struct MouseEvent : BaseEvent { | |||
| int button; | |||
| int button; | |||
| bool press; | |||
| Point<int> pos; | |||
| /** Constuctor */ | |||
| MouseEvent() noexcept | |||
| : BaseEvent(), | |||
| button(0), | |||
| press(false), | |||
| pos(0, 0) {} | |||
| }; | |||
| /** | |||
| @@ -105,6 +127,11 @@ public: | |||
| */ | |||
| struct MotionEvent : BaseEvent { | |||
| Point<int> pos; | |||
| /** Constuctor */ | |||
| MotionEvent() noexcept | |||
| : BaseEvent(), | |||
| pos(0, 0) {} | |||
| }; | |||
| /** | |||
| @@ -116,6 +143,12 @@ public: | |||
| struct ScrollEvent : BaseEvent { | |||
| Point<int> pos; | |||
| Point<float> delta; | |||
| /** Constuctor */ | |||
| ScrollEvent() noexcept | |||
| : BaseEvent(), | |||
| pos(0, 0), | |||
| delta(0.0f, 0.0f) {} | |||
| }; | |||
| /** | |||
| @@ -127,6 +160,11 @@ public: | |||
| struct ResizeEvent { | |||
| Size<uint> size; | |||
| Size<uint> oldSize; | |||
| /** Constuctor */ | |||
| ResizeEvent() noexcept | |||
| : size(0, 0), | |||
| oldSize(0, 0) {} | |||
| }; | |||
| /** | |||
| @@ -42,9 +42,8 @@ ImageKnob::ImageKnob(Window& parent, const Image& image, Orientation orientation | |||
| fIsImgVertical(image.getHeight() > image.getWidth()), | |||
| fImgLayerSize(fIsImgVertical ? image.getWidth() : image.getHeight()), | |||
| fImgLayerCount(fIsImgVertical ? image.getHeight()/fImgLayerSize : image.getWidth()/fImgLayerSize), | |||
| fKnobArea(0, 0, fImgLayerSize, fImgLayerSize), | |||
| fTextureId(0), | |||
| fIsReady(false), | |||
| fTextureId(0), | |||
| leakDetector_ImageKnob() | |||
| { | |||
| glGenTextures(1, &fTextureId); | |||
| @@ -71,9 +70,8 @@ ImageKnob::ImageKnob(Widget* widget, const Image& image, Orientation orientation | |||
| fIsImgVertical(image.getHeight() > image.getWidth()), | |||
| fImgLayerSize(fIsImgVertical ? image.getWidth() : image.getHeight()), | |||
| fImgLayerCount(fIsImgVertical ? image.getHeight()/fImgLayerSize : image.getWidth()/fImgLayerSize), | |||
| fKnobArea(0, 0, fImgLayerSize, fImgLayerSize), | |||
| fTextureId(0), | |||
| fIsReady(false), | |||
| fTextureId(0), | |||
| leakDetector_ImageKnob() | |||
| { | |||
| glGenTextures(1, &fTextureId); | |||
| @@ -100,9 +98,8 @@ ImageKnob::ImageKnob(const ImageKnob& imageKnob) | |||
| fIsImgVertical(imageKnob.fIsImgVertical), | |||
| fImgLayerSize(imageKnob.fImgLayerSize), | |||
| fImgLayerCount(imageKnob.fImgLayerCount), | |||
| fKnobArea(imageKnob.fKnobArea), | |||
| fTextureId(0), | |||
| fIsReady(false), | |||
| fTextureId(0), | |||
| leakDetector_ImageKnob() | |||
| { | |||
| glGenTextures(1, &fTextureId); | |||
| @@ -129,7 +126,6 @@ ImageKnob& ImageKnob::operator=(const ImageKnob& imageKnob) | |||
| fIsImgVertical = imageKnob.fIsImgVertical; | |||
| fImgLayerSize = imageKnob.fImgLayerSize; | |||
| fImgLayerCount = imageKnob.fImgLayerCount; | |||
| fKnobArea = imageKnob.fKnobArea; | |||
| fIsReady = false; | |||
| if (fTextureId != 0) | |||
| @@ -206,12 +202,12 @@ void ImageKnob::setStep(float step) noexcept | |||
| // NOTE: value is assumed to be scaled if using log | |||
| void ImageKnob::setValue(float value, bool sendCallback) noexcept | |||
| { | |||
| if (fValue == value) | |||
| if (d_isEqual(fValue, value)) | |||
| return; | |||
| fValue = value; | |||
| if (fStep == 0.0f) | |||
| if (d_isZero(fStep)) | |||
| fValueTmp = value; | |||
| if (fRotationAngle == 0) | |||
| @@ -274,36 +270,44 @@ void ImageKnob::onDisplay() | |||
| glPixelStorei(GL_PACK_ALIGNMENT, 1); | |||
| glPixelStorei(GL_UNPACK_ALIGNMENT, 1); | |||
| int imageDataOffset = 0; | |||
| uint imageDataOffset = 0; | |||
| if (fRotationAngle == 0) | |||
| { | |||
| int layerDataSize = fImgLayerSize * fImgLayerSize * ((fImage.getFormat() == GL_BGRA || fImage.getFormat() == GL_RGBA) ? 4 : 3); | |||
| imageDataOffset = layerDataSize * int(normValue * float(fImgLayerCount-1)); | |||
| DISTRHO_SAFE_ASSERT_RETURN(fImgLayerCount > 0,); | |||
| DISTRHO_SAFE_ASSERT_RETURN(normValue >= 0.0f,); | |||
| const uint layerDataSize = fImgLayerSize * fImgLayerSize * ((fImage.getFormat() == GL_BGRA || fImage.getFormat() == GL_RGBA) ? 4 : 3); | |||
| /* */ imageDataOffset = layerDataSize * uint(normValue * float(fImgLayerCount-1)); | |||
| } | |||
| glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getWidth(), getHeight(), 0, fImage.getFormat(), fImage.getType(), fImage.getRawData() + imageDataOffset); | |||
| glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, | |||
| static_cast<GLsizei>(getWidth()), static_cast<GLsizei>(getHeight()), 0, | |||
| fImage.getFormat(), fImage.getType(), fImage.getRawData() + imageDataOffset); | |||
| fIsReady = true; | |||
| } | |||
| const int w = static_cast<int>(getWidth()); | |||
| const int h = static_cast<int>(getHeight()); | |||
| if (fRotationAngle != 0) | |||
| { | |||
| glPushMatrix(); | |||
| const GLint w2 = getWidth()/2; | |||
| const GLint h2 = getHeight()/2; | |||
| const int w2 = w/2; | |||
| const int h2 = h/2; | |||
| glTranslatef(static_cast<float>(w2), static_cast<float>(h2), 0.0f); | |||
| glRotatef(normValue*static_cast<float>(fRotationAngle), 0.0f, 0.0f, 1.0f); | |||
| Rectangle<int>(-w2, -h2, getWidth(), getHeight()).draw(); | |||
| Rectangle<int>(-w2, -h2, w, h).draw(); | |||
| glPopMatrix(); | |||
| } | |||
| else | |||
| { | |||
| Rectangle<int>(0, 0, getWidth(), getHeight()).draw(); | |||
| Rectangle<int>(0, 0, w, h).draw(); | |||
| } | |||
| glBindTexture(GL_TEXTURE_2D, 0); | |||
| @@ -389,7 +393,7 @@ bool ImageKnob::onMotion(const MotionEvent& ev) | |||
| { | |||
| fValueTmp = value = fMaximum; | |||
| } | |||
| else if (fStep != 0.0f) | |||
| else if (d_isNotZero(fStep)) | |||
| { | |||
| fValueTmp = value; | |||
| const float rest = std::fmod(value, fStep); | |||
| @@ -423,7 +427,7 @@ bool ImageKnob::onScroll(const ScrollEvent& ev) | |||
| { | |||
| fValueTmp = value = fMaximum; | |||
| } | |||
| else if (fStep != 0.0f) | |||
| else if (d_isNotZero(fStep)) | |||
| { | |||
| fValueTmp = value; | |||
| const float rest = std::fmod(value, fStep); | |||
| @@ -179,12 +179,12 @@ void ImageSlider::setStep(float step) noexcept | |||
| void ImageSlider::setValue(float value, bool sendCallback) noexcept | |||
| { | |||
| if (fValue == value) | |||
| if (d_isEqual(fValue, value)) | |||
| return; | |||
| fValue = value; | |||
| if (fStep == 0.0f) | |||
| if (d_isZero(fStep)) | |||
| fValueTmp = value; | |||
| repaint(); | |||
| @@ -210,7 +210,7 @@ void ImageSlider::onDisplay() | |||
| glColor4f(1.0f, 1.0f, 1.0f, 1.0f); | |||
| #endif | |||
| float normValue = (fValue - fMinimum) / (fMaximum - fMinimum); | |||
| const float normValue = (fValue - fMinimum) / (fMaximum - fMinimum); | |||
| int x, y; | |||
| @@ -278,7 +278,7 @@ bool ImageSlider::onMouse(const MouseEvent& ev) | |||
| { | |||
| fValueTmp = value = fMaximum; | |||
| } | |||
| else if (fStep != 0.0f) | |||
| else if (d_isNotZero(fStep)) | |||
| { | |||
| fValueTmp = value; | |||
| const float rest = std::fmod(value, fStep); | |||
| @@ -347,7 +347,7 @@ bool ImageSlider::onMotion(const MotionEvent& ev) | |||
| { | |||
| fValueTmp = value = fMaximum; | |||
| } | |||
| else if (fStep != 0.0f) | |||
| else if (d_isNotZero(fStep)) | |||
| { | |||
| fValueTmp = value; | |||
| const float rest = std::fmod(value, fStep); | |||
| @@ -381,16 +381,16 @@ void ImageSlider::_recheckArea() noexcept | |||
| // horizontal | |||
| fSliderArea = Rectangle<int>(fStartPos.getX(), | |||
| fStartPos.getY(), | |||
| fEndPos.getX() + fImage.getWidth() - fStartPos.getX(), | |||
| fImage.getHeight()); | |||
| fEndPos.getX() + static_cast<int>(fImage.getWidth()) - fStartPos.getX(), | |||
| static_cast<int>(fImage.getHeight())); | |||
| } | |||
| else | |||
| { | |||
| // vertical | |||
| fSliderArea = Rectangle<int>(fStartPos.getX(), | |||
| fStartPos.getY(), | |||
| fImage.getWidth(), | |||
| fEndPos.getY() + fImage.getHeight() - fStartPos.getY()); | |||
| static_cast<int>(fImage.getWidth()), | |||
| fEndPos.getY() + static_cast<int>(fImage.getHeight()) - fStartPos.getY()); | |||
| } | |||
| } | |||
| @@ -18,8 +18,32 @@ | |||
| #include "../Window.hpp" | |||
| // ----------------------------------------------------------------------- | |||
| // Ignore some warnings if debugging | |||
| #ifdef DEBUG | |||
| # define NANOVG_GL3 0 | |||
| # define NANOVG_GLES2 0 | |||
| # define NANOVG_GLES3 0 | |||
| # define NANOVG_GL_USE_UNIFORMBUFFER 0 | |||
| # if defined(__clang__) | |||
| # pragma clang diagnostic push | |||
| # pragma clang diagnostic ignored "-Weverything" | |||
| # elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) | |||
| # pragma GCC diagnostic push | |||
| # pragma GCC diagnostic ignored "-Wall" | |||
| # pragma GCC diagnostic ignored "-Wextra" | |||
| # pragma GCC diagnostic ignored "-Wconversion" | |||
| # pragma GCC diagnostic ignored "-Weffc++" | |||
| # pragma GCC diagnostic ignored "-Wsign-conversion" | |||
| # pragma GCC diagnostic ignored "-Wundef" | |||
| # pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" | |||
| # endif | |||
| #endif | |||
| // ----------------------------------------------------------------------- | |||
| // Include NanoVG OpenGL implementation | |||
| #define NANOVG_GL2_IMPLEMENTATION | |||
| #define NANOVG_GL2_IMPLEMENTATION 1 | |||
| #include "nanovg/nanovg_gl.h" | |||
| #if defined(NANOVG_GL2) | |||
| @@ -36,6 +60,19 @@ | |||
| # define nvgDeleteGL nvgDeleteGLES3 | |||
| #endif | |||
| // ----------------------------------------------------------------------- | |||
| // Restore normal state if debugging | |||
| #ifdef DEBUG | |||
| # if defined(__clang__) | |||
| # pragma clang diagnostic pop | |||
| # elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) | |||
| # pragma GCC diagnostic pop | |||
| # endif | |||
| #endif | |||
| // ----------------------------------------------------------------------- | |||
| START_NAMESPACE_DGL | |||
| // ----------------------------------------------------------------------- | |||
| @@ -75,7 +112,8 @@ NanoVG::Paint::operator NVGpaint() const noexcept | |||
| NanoImage::NanoImage(NVGcontext* const context, const int imageId) noexcept | |||
| : fContext(context), | |||
| fImageId(imageId), | |||
| fSize() | |||
| fSize(), | |||
| leakDetector_NanoImage() | |||
| { | |||
| _updateSize(); | |||
| } | |||
| @@ -114,7 +152,7 @@ void NanoImage::_updateSize() | |||
| if (h < 0) h = 0; | |||
| } | |||
| fSize.setSize(w, h); | |||
| fSize.setSize(static_cast<uint>(w), static_cast<uint>(h)); | |||
| } | |||
| // ----------------------------------------------------------------------- | |||
| @@ -122,14 +160,16 @@ void NanoImage::_updateSize() | |||
| NanoVG::NanoVG() | |||
| : fContext(nvgCreateGL(512, 512, NVG_ANTIALIAS)), | |||
| fInFrame(false) | |||
| fInFrame(false), | |||
| leakDetector_NanoVG() | |||
| { | |||
| DISTRHO_SAFE_ASSERT_RETURN(fContext != nullptr,); | |||
| } | |||
| NanoVG::NanoVG(const int textAtlasWidth, const int textAtlasHeight) | |||
| : fContext(nvgCreateGL(textAtlasWidth, textAtlasHeight, NVG_ANTIALIAS)), | |||
| fInFrame(false) | |||
| fInFrame(false), | |||
| leakDetector_NanoVG() | |||
| { | |||
| DISTRHO_SAFE_ASSERT_RETURN(fContext != nullptr,); | |||
| } | |||
| @@ -151,7 +191,7 @@ void NanoVG::beginFrame(const uint width, const uint height, const float scaleFa | |||
| DISTRHO_SAFE_ASSERT_RETURN(! fInFrame,); | |||
| fInFrame = true; | |||
| nvgBeginFrame(fContext, width, height, scaleFactor, static_cast<NVGalpha>(alpha)); | |||
| nvgBeginFrame(fContext, static_cast<int>(width), static_cast<int>(height), scaleFactor, static_cast<NVGalpha>(alpha)); | |||
| } | |||
| void NanoVG::beginFrame(Widget* const widget) | |||
| @@ -163,7 +203,7 @@ void NanoVG::beginFrame(Widget* const widget) | |||
| Window& window(widget->getParentWindow()); | |||
| fInFrame = true; | |||
| nvgBeginFrame(fContext, window.getWidth(), window.getHeight(), 1.0f, NVG_PREMULTIPLIED_ALPHA); | |||
| nvgBeginFrame(fContext, static_cast<int>(window.getWidth()), static_cast<int>(window.getHeight()), 1.0f, NVG_PREMULTIPLIED_ALPHA); | |||
| } | |||
| void NanoVG::endFrame() | |||
| @@ -209,7 +249,17 @@ void NanoVG::strokeColor(const Color& color) | |||
| void NanoVG::strokeColor(const int red, const int green, const int blue, const int alpha) | |||
| { | |||
| if (fContext != nullptr) | |||
| nvgStrokeColor(fContext, nvgRGBA(red, green, blue, alpha)); | |||
| { | |||
| DISTRHO_SAFE_ASSERT_RETURN(red >= 0 && red <= 255,); | |||
| DISTRHO_SAFE_ASSERT_RETURN(green >= 0 && green <= 255,); | |||
| DISTRHO_SAFE_ASSERT_RETURN(blue >= 0 && blue <= 255,); | |||
| DISTRHO_SAFE_ASSERT_RETURN(alpha >= 0 && alpha <= 255,); | |||
| nvgStrokeColor(fContext, nvgRGBA(static_cast<uchar>(red), | |||
| static_cast<uchar>(green), | |||
| static_cast<uchar>(blue), | |||
| static_cast<uchar>(alpha))); | |||
| } | |||
| } | |||
| void NanoVG::strokeColor(const float red, const float green, const float blue, const float alpha) | |||
| @@ -233,7 +283,17 @@ void NanoVG::fillColor(const Color& color) | |||
| void NanoVG::fillColor(const int red, const int green, const int blue, const int alpha) | |||
| { | |||
| if (fContext != nullptr) | |||
| nvgFillColor(fContext, nvgRGBA(red, green, blue, alpha)); | |||
| { | |||
| DISTRHO_SAFE_ASSERT_RETURN(red >= 0 && red <= 255,); | |||
| DISTRHO_SAFE_ASSERT_RETURN(green >= 0 && green <= 255,); | |||
| DISTRHO_SAFE_ASSERT_RETURN(blue >= 0 && blue <= 255,); | |||
| DISTRHO_SAFE_ASSERT_RETURN(alpha >= 0 && alpha <= 255,); | |||
| nvgFillColor(fContext, nvgRGBA(static_cast<uchar>(red), | |||
| static_cast<uchar>(green), | |||
| static_cast<uchar>(blue), | |||
| static_cast<uchar>(alpha))); | |||
| } | |||
| } | |||
| void NanoVG::fillColor(const float red, const float green, const float blue, const float alpha) | |||
| @@ -427,7 +487,7 @@ NanoImage* NanoVG::createImageRGBA(uint w, uint h, const uchar* data) | |||
| if (fContext == nullptr) return nullptr; | |||
| DISTRHO_SAFE_ASSERT_RETURN(data != nullptr, nullptr); | |||
| if (const int imageId = nvgCreateImageRGBA(fContext, w, h, data)) | |||
| if (const int imageId = nvgCreateImageRGBA(fContext, static_cast<int>(w), static_cast<int>(h), data)) | |||
| return new NanoImage(fContext, imageId); | |||
| return nullptr; | |||
| @@ -70,6 +70,7 @@ struct Window::PrivateData { | |||
| fUsingEmbed(false), | |||
| fWidth(1), | |||
| fHeight(1), | |||
| fWidgets(), | |||
| fModal(), | |||
| #if defined(DISTRHO_OS_WINDOWS) | |||
| hwnd(0), | |||
| @@ -97,6 +98,7 @@ struct Window::PrivateData { | |||
| fUsingEmbed(false), | |||
| fWidth(1), | |||
| fHeight(1), | |||
| fWidgets(), | |||
| fModal(parent.pData), | |||
| #if defined(DISTRHO_OS_WINDOWS) | |||
| hwnd(0), | |||
| @@ -134,6 +136,7 @@ struct Window::PrivateData { | |||
| fUsingEmbed(parentId != 0), | |||
| fWidth(1), | |||
| fHeight(1), | |||
| fWidgets(), | |||
| fModal(), | |||
| #if defined(DISTRHO_OS_WINDOWS) | |||
| hwnd(0), | |||
| @@ -177,7 +180,7 @@ struct Window::PrivateData { | |||
| } | |||
| puglInitResizable(fView, fResizable); | |||
| puglInitWindowSize(fView, fWidth, fHeight); | |||
| puglInitWindowSize(fView, static_cast<int>(fWidth), static_cast<int>(fHeight)); | |||
| puglSetHandle(fView, this); | |||
| puglSetDisplayFunc(fView, onDisplayCallback); | |||
| @@ -611,7 +614,7 @@ struct Window::PrivateData { | |||
| // ------------------------------------------------------------------- | |||
| void onDisplay() | |||
| void onPuglDisplay() | |||
| { | |||
| fSelf->onDisplayBefore(); | |||
| @@ -629,22 +632,35 @@ struct Window::PrivateData { | |||
| if (widget->fNeedsFullViewport || (widget->fAbsolutePos.isZero() && widget->fSize == Size<uint>(fWidth, fHeight))) | |||
| { | |||
| // full viewport size | |||
| glViewport(0, 0, fWidth, fHeight); | |||
| glViewport(0, | |||
| 0, | |||
| static_cast<GLsizei>(fWidth), | |||
| static_cast<GLsizei>(fHeight)); | |||
| } | |||
| else if (! widget->fNeedsScaling) | |||
| { | |||
| // only set viewport pos | |||
| glViewport(widget->getAbsoluteX(), /*fView->height - widget->getHeight()*/ - widget->getAbsoluteY(), fWidth, fHeight); | |||
| glViewport(widget->getAbsoluteX(), | |||
| /*fView->height - static_cast<int>(widget->getHeight())*/ - widget->getAbsoluteY(), | |||
| static_cast<GLsizei>(fWidth), | |||
| static_cast<GLsizei>(fHeight)); | |||
| // then cut the outer bounds | |||
| glScissor(widget->getAbsoluteX(), fView->height - widget->getHeight() - widget->getAbsoluteY(), widget->getWidth(), widget->getHeight()); | |||
| glScissor(widget->getAbsoluteX(), | |||
| fView->height - static_cast<int>(widget->getHeight()) - widget->getAbsoluteY(), | |||
| static_cast<GLsizei>(widget->getWidth()), | |||
| static_cast<GLsizei>(widget->getHeight())); | |||
| glEnable(GL_SCISSOR_TEST); | |||
| needsDisableScissor = true; | |||
| } | |||
| else | |||
| { | |||
| // limit viewport to widget bounds | |||
| glViewport(widget->getAbsoluteX(), fView->height - widget->getHeight() - widget->getAbsoluteY(), widget->getWidth(), widget->getHeight()); | |||
| glViewport(widget->getAbsoluteX(), | |||
| fView->height - static_cast<int>(widget->getHeight()) - widget->getAbsoluteY(), | |||
| static_cast<GLsizei>(widget->getWidth()), | |||
| static_cast<GLsizei>(widget->getHeight())); | |||
| } | |||
| // display widget | |||
| @@ -661,7 +677,7 @@ struct Window::PrivateData { | |||
| fSelf->onDisplayAfter(); | |||
| } | |||
| void onKeyboard(const bool press, const uint key) | |||
| void onPuglKeyboard(const bool press, const uint key) | |||
| { | |||
| DBGp("PUGL: onKeyboard : %i %i\n", press, key); | |||
| @@ -683,7 +699,7 @@ struct Window::PrivateData { | |||
| } | |||
| } | |||
| void onSpecial(const bool press, const Key key) | |||
| void onPuglSpecial(const bool press, const Key key) | |||
| { | |||
| DBGp("PUGL: onSpecial : %i %i\n", press, key); | |||
| @@ -705,7 +721,7 @@ struct Window::PrivateData { | |||
| } | |||
| } | |||
| void onMouse(const int button, const bool press, const int x, const int y) | |||
| void onPuglMouse(const int button, const bool press, const int x, const int y) | |||
| { | |||
| DBGp("PUGL: onMouse : %i %i %i %i\n", button, press, x, y); | |||
| @@ -732,7 +748,7 @@ struct Window::PrivateData { | |||
| } | |||
| } | |||
| void onMotion(const int x, const int y) | |||
| void onPuglMotion(const int x, const int y) | |||
| { | |||
| DBGp("PUGL: onMotion : %i %i\n", x, y); | |||
| @@ -754,7 +770,7 @@ struct Window::PrivateData { | |||
| } | |||
| } | |||
| void onScroll(const int x, const int y, const float dx, const float dy) | |||
| void onPuglScroll(const int x, const int y, const float dx, const float dy) | |||
| { | |||
| DBGp("PUGL: onScroll : %i %i %f %f\n", x, y, dx, dy); | |||
| @@ -777,28 +793,28 @@ struct Window::PrivateData { | |||
| } | |||
| } | |||
| void onReshape(const int width, const int height) | |||
| void onPuglReshape(const int width, const int height) | |||
| { | |||
| DBGp("PUGL: onReshape : %i %i\n", width, height); | |||
| if (width <= 1 && height <= 1) | |||
| return; | |||
| fWidth = width; | |||
| fHeight = height; | |||
| fWidth = static_cast<uint>(width); | |||
| fHeight = static_cast<uint>(height); | |||
| fSelf->onReshape(width, height); | |||
| fSelf->onReshape(fWidth, fHeight); | |||
| FOR_EACH_WIDGET(it) | |||
| { | |||
| Widget* const widget(*it); | |||
| if (widget->fNeedsFullViewport) | |||
| widget->setSize(width, height); | |||
| widget->setSize(fWidth, fHeight); | |||
| } | |||
| } | |||
| void onClose() | |||
| void onPuglClose() | |||
| { | |||
| DBG("PUGL: onClose\n"); | |||
| @@ -808,7 +824,7 @@ struct Window::PrivateData { | |||
| fSelf->onClose(); | |||
| if (fModal.childFocus != nullptr) | |||
| fModal.childFocus->onClose(); | |||
| fModal.childFocus->fSelf->onClose(); | |||
| close(); | |||
| } | |||
| @@ -847,6 +863,8 @@ struct Window::PrivateData { | |||
| DISTRHO_SAFE_ASSERT(! enabled); | |||
| DISTRHO_SAFE_ASSERT(childFocus == nullptr); | |||
| } | |||
| DISTRHO_DECLARE_NON_COPY_STRUCT(Modal) | |||
| } fModal; | |||
| #if defined(DISTRHO_OS_WINDOWS) | |||
| @@ -867,42 +885,42 @@ struct Window::PrivateData { | |||
| static void onDisplayCallback(PuglView* view) | |||
| { | |||
| handlePtr->onDisplay(); | |||
| handlePtr->onPuglDisplay(); | |||
| } | |||
| static void onKeyboardCallback(PuglView* view, bool press, uint32_t key) | |||
| { | |||
| handlePtr->onKeyboard(press, key); | |||
| handlePtr->onPuglKeyboard(press, key); | |||
| } | |||
| static void onSpecialCallback(PuglView* view, bool press, PuglKey key) | |||
| { | |||
| handlePtr->onSpecial(press, static_cast<Key>(key)); | |||
| handlePtr->onPuglSpecial(press, static_cast<Key>(key)); | |||
| } | |||
| static void onMouseCallback(PuglView* view, int button, bool press, int x, int y) | |||
| { | |||
| handlePtr->onMouse(button, press, x, y); | |||
| handlePtr->onPuglMouse(button, press, x, y); | |||
| } | |||
| static void onMotionCallback(PuglView* view, int x, int y) | |||
| { | |||
| handlePtr->onMotion(x, y); | |||
| handlePtr->onPuglMotion(x, y); | |||
| } | |||
| static void onScrollCallback(PuglView* view, int x, int y, float dx, float dy) | |||
| { | |||
| handlePtr->onScroll(x, y, dx, dy); | |||
| handlePtr->onPuglScroll(x, y, dx, dy); | |||
| } | |||
| static void onReshapeCallback(PuglView* view, int width, int height) | |||
| { | |||
| handlePtr->onReshape(width, height); | |||
| handlePtr->onPuglReshape(width, height); | |||
| } | |||
| static void onCloseCallback(PuglView* view) | |||
| { | |||
| handlePtr->onClose(); | |||
| handlePtr->onPuglClose(); | |||
| } | |||
| #undef handlePtr | |||