Browse Source

Cleanup; Some fixes for -Weffc++

gh-pages
falkTX 7 years ago
parent
commit
73b18ec998
19 changed files with 308 additions and 116 deletions
  1. +21
    -7
      dgl/Geometry.hpp
  2. +1
    -0
      dgl/ImageButton.hpp
  3. +1
    -0
      dgl/ImageKnob.hpp
  4. +1
    -0
      dgl/ImageSlider.hpp
  5. +1
    -0
      dgl/ImageSwitch.hpp
  6. +23
    -0
      dgl/Makefile.mk
  7. +2
    -2
      dgl/Widget.hpp
  8. +2
    -3
      dgl/src/App.cpp
  9. +4
    -2
      dgl/src/AppPrivateData.hpp
  10. +101
    -59
      dgl/src/Geometry.cpp
  11. +4
    -2
      dgl/src/ImageAboutWindow.cpp
  12. +26
    -9
      dgl/src/ImageButton.cpp
  13. +42
    -3
      dgl/src/ImageKnob.cpp
  14. +33
    -3
      dgl/src/ImageSlider.cpp
  15. +21
    -3
      dgl/src/ImageSwitch.cpp
  16. +3
    -1
      dgl/src/Widget.cpp
  17. +14
    -17
      dgl/src/Window.cpp
  18. +6
    -1
      distrho/DistrhoPlugin.hpp
  19. +2
    -4
      distrho/extra/d_leakdetector.hpp

+ 21
- 7
dgl/Geometry.hpp View File

@@ -91,6 +91,8 @@ public:
*/
void moveBy(const Point<T>& pos) noexcept;

Point<T> operator+(const Point<T>& pos) noexcept;
Point<T> operator-(const Point<T>& pos) noexcept;
Point<T>& operator=(const Point<T>& pos) noexcept;
Point<T>& operator+=(const Point<T>& pos) noexcept;
Point<T>& operator-=(const Point<T>& pos) noexcept;
@@ -167,6 +169,8 @@ public:
*/
void shrinkBy(const T& divider) noexcept;

Size<T> operator+(const Size<T>& size) noexcept;
Size<T> operator-(const Size<T>& size) noexcept;
Size<T>& operator=(const Size<T>& size) noexcept;
Size<T>& operator+=(const Size<T>& size) noexcept;
Size<T>& operator-=(const Size<T>& size) noexcept;
@@ -325,12 +329,12 @@ public:
/**
Constructor using custom X, Y and size values.
*/
Circle(const T& x, const T& y, float size, int numSegments = 300);
Circle(const T& x, const T& y, const float size, const uint numSegments = 300);

/**
Constructor using custom position and size values.
*/
Circle(const Point<T>& pos, float size, int numSegments = 300);
Circle(const Point<T>& pos, const float size, const uint numSegments = 300);

/**
Constructor using another Circle class values.
@@ -379,20 +383,20 @@ public:

/**
Set size.
@note Must always be > 0.0f
@note Must always be > 0
*/
void setSize(float size) noexcept;
void setSize(const float size) noexcept;

/**
Get the current number of line segments that make this circle.
*/
int getNumSegments() const noexcept;
uint getNumSegments() const noexcept;

/**
Set the number of line segments that will make this circle.
@note Must always be >= 3
*/
void setNumSegments(int num);
void setNumSegments(const uint num);

/**
Draw this circle using the current OpenGL state.
@@ -411,7 +415,7 @@ public:
private:
Point<T> fPos;
float fSize;
int fNumSegments;
uint fNumSegments;

// cached values
float fTheta, fCos, fSin;
@@ -593,6 +597,16 @@ public:
*/
void shrinkBy(const T& divider) noexcept;

/**
Set rectangle using @a pos and @a size.
*/
void setRectangle(const Point<T>& pos, const Size<T>& size) noexcept;

/**
Set rectangle.
*/
void setRectangle(const Rectangle<T>& rect) noexcept;

/**
Check if this rectangle contains the point defined by @a X and @a Y.
*/


+ 1
- 0
dgl/ImageButton.hpp View File

@@ -39,6 +39,7 @@ public:
explicit ImageButton(Widget* widget, const Image& image) noexcept;
explicit ImageButton(Widget* widget, const Image& imageNormal, const Image& imageHover, const Image& imageDown) noexcept;
explicit ImageButton(const ImageButton& imageButton) noexcept;
ImageButton& operator=(const ImageButton& imageButton) noexcept;

void setCallback(Callback* callback) noexcept;



+ 1
- 0
dgl/ImageKnob.hpp View File

@@ -44,6 +44,7 @@ public:
explicit ImageKnob(Window& parent, const Image& image, Orientation orientation = Vertical, int id = 0) noexcept;
explicit ImageKnob(Widget* widget, const Image& image, Orientation orientation = Vertical, int id = 0) noexcept;
explicit ImageKnob(const ImageKnob& imageKnob);
ImageKnob& operator=(const ImageKnob& imageKnob);
~ImageKnob() override;

int getId() const noexcept;


+ 1
- 0
dgl/ImageSlider.hpp View File

@@ -39,6 +39,7 @@ public:
explicit ImageSlider(Window& parent, const Image& image, int id = 0) noexcept;
explicit ImageSlider(Widget* widget, const Image& image, int id = 0) noexcept;
explicit ImageSlider(const ImageSlider& imageSlider) noexcept;
ImageSlider& operator=(const ImageSlider& imageSlider) noexcept;

int getId() const noexcept;
void setId(int id) noexcept;


+ 1
- 0
dgl/ImageSwitch.hpp View File

@@ -37,6 +37,7 @@ public:
explicit ImageSwitch(Window& parent, const Image& imageNormal, const Image& imageDown, int id = 0) noexcept;
explicit ImageSwitch(Widget* widget, const Image& imageNormal, const Image& imageDown, int id = 0) noexcept;
explicit ImageSwitch(const ImageSwitch& imageSwitch) noexcept;
ImageSwitch& operator=(const ImageSwitch& imageSwitch) noexcept;

int getId() const noexcept;
void setId(int id) noexcept;


+ 23
- 0
dgl/Makefile.mk View File

@@ -74,6 +74,29 @@ BUILD_CXX_FLAGS = $(BASE_FLAGS) $(CXXFLAGS) $(CPPFLAGS)
LINK_FLAGS = $(LINK_OPTS) $(LDFLAGS)
endif

# --------------------------------------------------------------
# Strict test build

ifeq ($(TESTBUILD),true)
BASE_FLAGS += -Werror -Wcast-qual -Wconversion -Wformat -Wformat-security -Wredundant-decls -Wshadow -Wstrict-overflow -fstrict-overflow -Wundef -Wwrite-strings
BASE_FLAGS += -Wpointer-arith -Wabi -Winit-self -Wuninitialized -Wstrict-overflow=5
# BASE_FLAGS += -Wfloat-equal
ifeq ($(CC),clang)
# BASE_FLAGS += -Wdocumentation -Wdocumentation-unknown-command
# BASE_FLAGS += -Weverything
else
BASE_FLAGS += -Wcast-align -Wunsafe-loop-optimizations
endif
ifneq ($(MACOS),true)
BASE_FLAGS += -Wmissing-declarations -Wsign-conversion
ifneq ($(CC),clang)
BASE_FLAGS += -Wlogical-op
endif
endif
CFLAGS += -Wold-style-definition -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes
CXXFLAGS += -Weffc++ -Wnon-virtual-dtor -Woverloaded-virtual
endif

# --------------------------------------------------------------
# Check for required libs



+ 2
- 2
dgl/Widget.hpp View File

@@ -241,7 +241,7 @@ public:
Window& getParentWindow() const noexcept;

/**
Check if this widget contains the point defined by @a X and @a Y.
Check if this widget contains the point defined by @a x and @a y.
*/
bool contains(int x, int y) const noexcept;

@@ -306,7 +306,7 @@ protected:

/**
Tell the parent window this widget needs scaling.
When enabled, the widget viewport is scaled to match width&height.
When enabled, the widget viewport is scaled to match width and height.
@note: This is an internal function;
You do not need it under normal circumstances.
*/


+ 2
- 3
dgl/src/App.cpp View File

@@ -22,9 +22,8 @@ START_NAMESPACE_DGL
// -----------------------------------------------------------------------

App::App()
: pData(new PrivateData())
{
}
: pData(new PrivateData()),
leakDetector_App() {}

App::~App()
{


+ 4
- 2
dgl/src/AppPrivateData.hpp View File

@@ -33,8 +33,10 @@ struct App::PrivateData {
std::list<IdleCallback*> idleCallbacks;

PrivateData()
: doLoop(false),
visibleWindows(0) {}
: doLoop(true),
visibleWindows(0),
windows(),
idleCallbacks() {}

~PrivateData()
{


+ 101
- 59
dgl/src/Geometry.cpp View File

@@ -16,10 +16,10 @@

#include "../Geometry.hpp"

#include <cmath>

START_NAMESPACE_DGL

static const float M_2PIf = 3.14159265358979323846f*2.0f;

// -----------------------------------------------------------------------
// Point

@@ -79,15 +79,28 @@ void Point<T>::setPos(const Point<T>& pos) noexcept
template<typename T>
void Point<T>::moveBy(const T& x, const T& y) noexcept
{
fX += x;
fY += y;
fX = static_cast<T>(fX+x);
fY = static_cast<T>(fY+y);
}

template<typename T>
void Point<T>::moveBy(const Point<T>& pos) noexcept
{
fX += pos.fX;
fY += pos.fY;
fX = static_cast<T>(fX+pos.fX);
fY = static_cast<T>(fY+pos.fY);
}


template<typename T>
Point<T> Point<T>::operator+(const Point<T>& pos) noexcept
{
return Point<T>(fX+pos.fX, fY+pos.fY);
}

template<typename T>
Point<T> Point<T>::operator-(const Point<T>& pos) noexcept
{
return Point<T>(fX-pos.fX, fY-pos.fY);
}

template<typename T>
@@ -101,29 +114,29 @@ Point<T>& Point<T>::operator=(const Point<T>& pos) noexcept
template<typename T>
Point<T>& Point<T>::operator+=(const Point<T>& pos) noexcept
{
fX += pos.fX;
fY += pos.fY;
fX = static_cast<T>(fX+pos.fX);
fY = static_cast<T>(fY+pos.fY);
return *this;
}

template<typename T>
Point<T>& Point<T>::operator-=(const Point<T>& pos) noexcept
{
fX -= pos.fX;
fY -= pos.fY;
fX = static_cast<T>(fX-pos.fX);
fY = static_cast<T>(fY-pos.fY);
return *this;
}

template<typename T>
bool Point<T>::operator==(const Point<T>& pos) const noexcept
{
return (fX == pos.fX && fY== pos.fY);
return (fX == pos.fX && fY == pos.fY);
}

template<typename T>
bool Point<T>::operator!=(const Point<T>& pos) const noexcept
{
return !operator==(pos);
return (fX != pos.fX || fY != pos.fY);
}

// -----------------------------------------------------------------------
@@ -185,15 +198,27 @@ void Size<T>::setSize(const Size<T>& size) noexcept
template<typename T>
void Size<T>::growBy(const T& multiplier) noexcept
{
fWidth *= multiplier;
fHeight *= multiplier;
fWidth = static_cast<T>(fWidth*multiplier);
fHeight = static_cast<T>(fHeight*multiplier);
}

template<typename T>
void Size<T>::shrinkBy(const T& divider) noexcept
{
fWidth /= divider;
fHeight /= divider;
fWidth = static_cast<T>(fWidth/divider);
fHeight = static_cast<T>(fHeight/divider);
}

template<typename T>
Size<T> Size<T>::operator+(const Size<T>& size) noexcept
{
return Size<T>(fWidth+size.fWidth, fHeight+size.fHeight);
}

template<typename T>
Size<T> Size<T>::operator-(const Size<T>& size) noexcept
{
return Size<T>(fWidth-size.fWidth, fHeight-size.fHeight);
}

template<typename T>
@@ -207,32 +232,32 @@ Size<T>& Size<T>::operator=(const Size<T>& size) noexcept
template<typename T>
Size<T>& Size<T>::operator+=(const Size<T>& size) noexcept
{
fWidth += size.fWidth;
fHeight += size.fHeight;
fWidth = static_cast<T>(fWidth+size.fWidth);
fHeight = static_cast<T>(fHeight+size.fHeight);
return *this;
}

template<typename T>
Size<T>& Size<T>::operator-=(const Size<T>& size) noexcept
{
fWidth -= size.fWidth;
fHeight -= size.fHeight;
fWidth = static_cast<T>(fWidth-size.fWidth);
fHeight = static_cast<T>(fHeight-size.fHeight);
return *this;
}

template<typename T>
Size<T>& Size<T>::operator*=(const T& m) noexcept
{
fWidth *= m;
fHeight *= m;
fWidth = static_cast<T>(fWidth*m);
fHeight = static_cast<T>(fHeight*m);
return *this;
}

template<typename T>
Size<T>& Size<T>::operator/=(const T& d) noexcept
{
fWidth /= d;
fHeight /= d;
fWidth = static_cast<T>(fWidth/d);
fHeight = static_cast<T>(fHeight/d);
return *this;
}

@@ -245,7 +270,7 @@ bool Size<T>::operator==(const Size<T>& size) const noexcept
template<typename T>
bool Size<T>::operator!=(const Size<T>& size) const noexcept
{
return !operator==(size);
return (fWidth != size.fWidth || fHeight != size.fHeight);
}

// -----------------------------------------------------------------------
@@ -368,17 +393,15 @@ void Line<T>::setEndPos(const Point<T>& pos) noexcept
template<typename T>
void Line<T>::moveBy(const T& x, const T& y) noexcept
{
fPosStart.fX += x;
fPosStart.fY += y;
fPosEnd.fX += x;
fPosEnd.fY += y;
fPosStart.moveBy(x, y);
fPosEnd.moveBy(x, y);
}

template<typename T>
void Line<T>::moveBy(const Point<T>& pos) noexcept
{
fPosStart += pos;
fPosEnd += pos;
fPosStart.moveBy(pos);
fPosEnd.moveBy(pos);
}

template<typename T>
@@ -386,10 +409,12 @@ void Line<T>::draw()
{
glBegin(GL_LINES);

#if 0
{
glVertex2i(fPosStart.fX, fPosStart.fY);
glVertex2i(fPosEnd.fX, fPosEnd.fY);
}
#endif

glEnd();
}
@@ -411,7 +436,7 @@ bool Line<T>::operator==(const Line<T>& line) const noexcept
template<typename T>
bool Line<T>::operator!=(const Line<T>& line) const noexcept
{
return !operator==(line);
return (fPosStart != line.fPosStart || fPosEnd != line.fPosEnd);
}

// -----------------------------------------------------------------------
@@ -424,16 +449,14 @@ Circle<T>::Circle() noexcept
fNumSegments(0),
fTheta(0.0f),
fCos(0.0f),
fSin(0.0f)
{
}
fSin(0.0f) {}

template<typename T>
Circle<T>::Circle(const T& x, const T& y, float size, int numSegments)
Circle<T>::Circle(const T& x, const T& y, const float size, const uint numSegments)
: fPos(x, y),
fSize(size),
fNumSegments(numSegments >= 3 ? numSegments : 3),
fTheta(2.0f * M_PI / float(fNumSegments)),
fTheta(M_2PIf / static_cast<float>(fNumSegments)),
fCos(std::cos(fTheta)),
fSin(std::sin(fTheta))
{
@@ -441,11 +464,11 @@ Circle<T>::Circle(const T& x, const T& y, float size, int numSegments)
}

template<typename T>
Circle<T>::Circle(const Point<T>& pos, float size, int numSegments)
Circle<T>::Circle(const Point<T>& pos, const float size, const uint numSegments)
: fPos(pos),
fSize(size),
fNumSegments(numSegments >= 3 ? numSegments : 3),
fTheta(2.0f * M_PI / float(fNumSegments)),
fTheta(M_2PIf / static_cast<float>(fNumSegments)),
fCos(std::cos(fTheta)),
fSin(std::sin(fTheta))
{
@@ -514,26 +537,30 @@ float Circle<T>::getSize() const noexcept
}

template<typename T>
void Circle<T>::setSize(float size) noexcept
void Circle<T>::setSize(const float size) noexcept
{
DISTRHO_SAFE_ASSERT_RETURN(size > 0.0f,);

fSize = size;
}

template<typename T>
int Circle<T>::getNumSegments() const noexcept
uint Circle<T>::getNumSegments() const noexcept
{
return fNumSegments;
}

template<typename T>
void Circle<T>::setNumSegments(int num)
void Circle<T>::setNumSegments(const uint num)
{
DISTRHO_SAFE_ASSERT_RETURN(num >= 3,);

if (fNumSegments == num)
return;

fNumSegments = num;

fTheta = 2.0f * M_PI / float(fNumSegments);
fTheta = M_2PIf / static_cast<float>(fNumSegments);
fCos = std::cos(fTheta);
fSin = std::sin(fTheta);
}
@@ -571,15 +598,17 @@ bool Circle<T>::operator==(const Circle<T>& cir) const noexcept
template<typename T>
bool Circle<T>::operator!=(const Circle<T>& cir) const noexcept
{
return !operator==(cir);
return (fPos != cir.fPos || fSize != cir.fSize || fNumSegments != cir.fNumSegments);
}

template<typename T>
void Circle<T>::_draw(const bool isOutline)
{
if (fNumSegments == 0 && fSize > 0.0f)
if (fNumSegments < 3 || fSize <= 0.0f)
return;

(void)isOutline;
#if 0
float t, x = fSize, y = 0;

glBegin(isOutline ? GL_LINE_LOOP : GL_POLYGON);
@@ -594,6 +623,7 @@ void Circle<T>::_draw(const bool isOutline)
}

glEnd();
#endif
}

// -----------------------------------------------------------------------
@@ -653,7 +683,7 @@ bool Triangle<T>::operator==(const Triangle<T>& tri) const noexcept
template<typename T>
bool Triangle<T>::operator!=(const Triangle<T>& tri) const noexcept
{
return !operator==(tri);
return (fPos1 != tri.fPos1 || fPos2 != tri.fPos2 || fPos3 != tri.fPos3);
}

template<typename T>
@@ -661,11 +691,13 @@ void Triangle<T>::_draw(const bool isOutline)
{
glBegin(isOutline ? GL_LINE_LOOP : GL_TRIANGLES);

#if 0
{
glVertex2i(fPos1.fX, fPos1.fY);
glVertex2i(fPos2.fX, fPos2.fY);
glVertex2i(fPos3.fX, fPos3.fY);
}
#endif

glEnd();
}
@@ -767,14 +799,13 @@ void Rectangle<T>::setPos(const Point<T>& pos) noexcept
template<typename T>
void Rectangle<T>::moveBy(const T& x, const T& y) noexcept
{
fPos.fX += x;
fPos.fY += y;
fPos.moveBy(x, y);
}

template<typename T>
void Rectangle<T>::moveBy(const Point<T>& pos) noexcept
{
fPos += pos;
fPos.moveBy(pos);
}

template<typename T>
@@ -805,15 +836,27 @@ void Rectangle<T>::setSize(const Size<T>& size) noexcept
template<typename T>
void Rectangle<T>::growBy(const T& multiplier) noexcept
{
fSize.fWidth *= multiplier;
fSize.fHeight *= multiplier;
fSize.growBy(multiplier);
}

template<typename T>
void Rectangle<T>::shrinkBy(const T& divider) noexcept
{
fSize.fWidth /= divider;
fSize.fHeight /= divider;
fSize.shrinkBy(divider);
}

template<typename T>
void Rectangle<T>::setRectangle(const Point<T>& pos, const Size<T>& size) noexcept
{
fPos = pos;
fSize = size;
}

template<typename T>
void Rectangle<T>::setRectangle(const Rectangle<T>& rect) noexcept
{
fPos = rect.fPos;
fSize = rect.fSize;
}

template<typename T>
@@ -863,16 +906,14 @@ Rectangle<T>& Rectangle<T>::operator=(const Rectangle<T>& rect) noexcept
template<typename T>
Rectangle<T>& Rectangle<T>::operator*=(const T& m) noexcept
{
fSize.fWidth *= m;
fSize.fHeight *= m;
fSize *= m;
return *this;
}

template<typename T>
Rectangle<T>& Rectangle<T>::operator/=(const T& d) noexcept
{
fSize.fWidth /= d;
fSize.fHeight /= d;
fSize /= d;
return *this;
}

@@ -885,7 +926,7 @@ bool Rectangle<T>::operator==(const Rectangle<T>& rect) const noexcept
template<typename T>
bool Rectangle<T>::operator!=(const Rectangle<T>& rect) const noexcept
{
return !operator==(rect);
return (fPos != rect.fPos || fSize != rect.fSize);
}

template<typename T>
@@ -893,6 +934,7 @@ void Rectangle<T>::_draw(const bool isOutline)
{
glBegin(isOutline ? GL_LINE_LOOP : GL_QUADS);

#if 0
{
glTexCoord2f(0.0f, 0.0f);
glVertex2i(fPos.fX, fPos.fY);
@@ -906,6 +948,7 @@ void Rectangle<T>::_draw(const bool isOutline)
glTexCoord2f(0.0f, 1.0f);
glVertex2i(fPos.fX, fPos.fY+fSize.fHeight);
}
#endif

glEnd();
}
@@ -958,4 +1001,3 @@ template class Rectangle<ushort>;
// -----------------------------------------------------------------------

END_NAMESPACE_DGL


+ 4
- 2
dgl/src/ImageAboutWindow.cpp View File

@@ -23,7 +23,8 @@ START_NAMESPACE_DGL
ImageAboutWindow::ImageAboutWindow(Window& parent, const Image& image)
: Window(parent.getApp(), parent),
Widget((Window&)*this),
fImgBackground(image)
fImgBackground(image),
leakDetector_ImageAboutWindow()
{
Window::setResizable(false);
Window::setSize(static_cast<uint>(image.getWidth()), static_cast<uint>(image.getHeight()));
@@ -33,7 +34,8 @@ ImageAboutWindow::ImageAboutWindow(Window& parent, const Image& image)
ImageAboutWindow::ImageAboutWindow(Widget* widget, const Image& image)
: Window(widget->getParentApp(), widget->getParentWindow()),
Widget((Window&)*this),
fImgBackground(image)
fImgBackground(image),
leakDetector_ImageAboutWindow()
{
Window::setResizable(false);
Window::setSize(static_cast<uint>(image.getWidth()), static_cast<uint>(image.getHeight()));


+ 26
- 9
dgl/src/ImageButton.cpp View File

@@ -27,9 +27,8 @@ ImageButton::ImageButton(Window& parent, const Image& image) noexcept
fImageDown(image),
fCurImage(&fImageNormal),
fCurButton(-1),
fCallback(nullptr)
{
}
fCallback(nullptr),
leakDetector_ImageButton() {}

ImageButton::ImageButton(Window& parent, const Image& imageNormal, const Image& imageHover, const Image& imageDown) noexcept
: Widget(parent),
@@ -38,7 +37,8 @@ ImageButton::ImageButton(Window& parent, const Image& imageNormal, const Image&
fImageDown(imageDown),
fCurImage(&fImageNormal),
fCurButton(-1),
fCallback(nullptr)
fCallback(nullptr),
leakDetector_ImageButton()
{
DISTRHO_SAFE_ASSERT(fImageNormal.getSize() == fImageHover.getSize() && fImageHover.getSize() == fImageDown.getSize());

@@ -52,9 +52,8 @@ ImageButton::ImageButton(Widget* widget, const Image& image) noexcept
fImageDown(image),
fCurImage(&fImageNormal),
fCurButton(-1),
fCallback(nullptr)
{
}
fCallback(nullptr),
leakDetector_ImageButton() {}

ImageButton::ImageButton(Widget* widget, const Image& imageNormal, const Image& imageHover, const Image& imageDown) noexcept
: Widget(widget->getParentWindow()),
@@ -63,7 +62,8 @@ ImageButton::ImageButton(Widget* widget, const Image& imageNormal, const Image&
fImageDown(imageDown),
fCurImage(&fImageNormal),
fCurButton(-1),
fCallback(nullptr)
fCallback(nullptr),
leakDetector_ImageButton()
{
DISTRHO_SAFE_ASSERT(fImageNormal.getSize() == fImageHover.getSize() && fImageHover.getSize() == fImageDown.getSize());

@@ -77,11 +77,28 @@ ImageButton::ImageButton(const ImageButton& imageButton) noexcept
fImageDown(imageButton.fImageDown),
fCurImage(&fImageNormal),
fCurButton(-1),
fCallback(imageButton.fCallback)
fCallback(imageButton.fCallback),
leakDetector_ImageButton()
{
DISTRHO_SAFE_ASSERT(fImageNormal.getSize() == fImageHover.getSize() && fImageHover.getSize() == fImageDown.getSize());

setSize(fCurImage->getSize());
}

ImageButton& ImageButton::operator=(const ImageButton& imageButton) noexcept
{
fImageNormal = imageButton.fImageNormal;
fImageHover = imageButton.fImageHover;
fImageDown = imageButton.fImageDown;
fCurImage = &fImageNormal;
fCurButton = -1;
fCallback = imageButton.fCallback;

DISTRHO_SAFE_ASSERT(fImageNormal.getSize() == fImageHover.getSize() && fImageHover.getSize() == fImageDown.getSize());

setSize(fCurImage->getSize());

return *this;
}

void ImageButton::setCallback(Callback* callback) noexcept


+ 42
- 3
dgl/src/ImageKnob.cpp View File

@@ -45,7 +45,8 @@ ImageKnob::ImageKnob(Window& parent, const Image& image, Orientation orientation
fImgLayerCount(fIsImgVertical ? image.getHeight()/fImgLayerSize : image.getWidth()/fImgLayerSize),
fKnobArea(0, 0, fImgLayerSize, fImgLayerSize),
fTextureId(0),
fIsReady(false)
fIsReady(false),
leakDetector_ImageKnob()
{
glGenTextures(1, &fTextureId);
setSize(fImgLayerSize, fImgLayerSize);
@@ -74,7 +75,8 @@ ImageKnob::ImageKnob(Widget* widget, const Image& image, Orientation orientation
fImgLayerCount(fIsImgVertical ? image.getHeight()/fImgLayerSize : image.getWidth()/fImgLayerSize),
fKnobArea(0, 0, fImgLayerSize, fImgLayerSize),
fTextureId(0),
fIsReady(false)
fIsReady(false),
leakDetector_ImageKnob()
{
glGenTextures(1, &fTextureId);
setSize(fImgLayerSize, fImgLayerSize);
@@ -103,12 +105,49 @@ ImageKnob::ImageKnob(const ImageKnob& imageKnob)
fImgLayerCount(imageKnob.fImgLayerCount),
fKnobArea(imageKnob.fKnobArea),
fTextureId(0),
fIsReady(false)
fIsReady(false),
leakDetector_ImageKnob()
{
glGenTextures(1, &fTextureId);
setSize(fImgLayerSize, fImgLayerSize);
}

ImageKnob& ImageKnob::operator=(const ImageKnob& imageKnob)
{
fImage = imageKnob.fImage;
fId = imageKnob.fId;
fMinimum = imageKnob.fMinimum;
fMaximum = imageKnob.fMaximum;
fStep = imageKnob.fStep;
fValue = imageKnob.fValue;
fValueDef = imageKnob.fValueDef;
fValueTmp = fValue;
fUsingDefault = imageKnob.fUsingDefault;
fUsingLog = imageKnob.fUsingLog;
fOrientation = imageKnob.fOrientation;
fRotationAngle = imageKnob.fRotationAngle;
fDragging = false;
fLastX = 0;
fLastY = 0;
fCallback = imageKnob.fCallback;
fIsImgVertical = imageKnob.fIsImgVertical;
fImgLayerSize = imageKnob.fImgLayerSize;
fImgLayerCount = imageKnob.fImgLayerCount;
fKnobArea = imageKnob.fKnobArea;
fIsReady = false;

if (fTextureId != 0)
{
glDeleteTextures(1, &fTextureId);
fTextureId = 0;
}

glGenTextures(1, &fTextureId);
setSize(fImgLayerSize, fImgLayerSize);

return *this;
}

ImageKnob::~ImageKnob()
{
if (fTextureId != 0)


+ 33
- 3
dgl/src/ImageSlider.cpp View File

@@ -35,7 +35,11 @@ ImageSlider::ImageSlider(Window& parent, const Image& image, int id) noexcept
fInverted(false),
fStartedX(0),
fStartedY(0),
fCallback(nullptr)
fCallback(nullptr),
fStartPos(),
fEndPos(),
fSliderArea(),
leakDetector_ImageSlider()
{
Widget::setNeedsFullViewport(true);
}
@@ -53,7 +57,11 @@ ImageSlider::ImageSlider(Widget* widget, const Image& image, int id) noexcept
fInverted(false),
fStartedX(0),
fStartedY(0),
fCallback(nullptr)
fCallback(nullptr),
fStartPos(),
fEndPos(),
fSliderArea(),
leakDetector_ImageSlider()
{
Widget::setNeedsFullViewport(true);
}
@@ -74,11 +82,33 @@ ImageSlider::ImageSlider(const ImageSlider& imageSlider) noexcept
fCallback(imageSlider.fCallback),
fStartPos(imageSlider.fStartPos),
fEndPos(imageSlider.fEndPos),
fSliderArea(imageSlider.fSliderArea)
fSliderArea(imageSlider.fSliderArea),
leakDetector_ImageSlider()
{
Widget::setNeedsFullViewport(true);
}

ImageSlider& ImageSlider::operator=(const ImageSlider& imageSlider) noexcept
{
fImage = imageSlider.fImage;
fId = imageSlider.fId;
fMinimum = imageSlider.fMinimum;
fMaximum = imageSlider.fMaximum;
fStep = imageSlider.fStep;
fValue = imageSlider.fValue;
fValueTmp = fValue;
fDragging = false;
fInverted = imageSlider.fInverted;
fStartedX = 0;
fStartedY = 0;
fCallback = imageSlider.fCallback;
fStartPos = imageSlider.fStartPos;
fEndPos = imageSlider.fEndPos;
fSliderArea = imageSlider.fSliderArea;

return *this;
}

int ImageSlider::getId() const noexcept
{
return fId;


+ 21
- 3
dgl/src/ImageSwitch.cpp View File

@@ -26,7 +26,8 @@ ImageSwitch::ImageSwitch(Window& parent, const Image& imageNormal, const Image&
fImageDown(imageDown),
fIsDown(false),
fId(id),
fCallback(nullptr)
fCallback(nullptr),
leakDetector_ImageSwitch()
{
DISTRHO_SAFE_ASSERT(fImageNormal.getSize() == fImageDown.getSize());

@@ -39,7 +40,8 @@ ImageSwitch::ImageSwitch(Widget* widget, const Image& imageNormal, const Image&
fImageDown(imageDown),
fIsDown(false),
fId(id),
fCallback(nullptr)
fCallback(nullptr),
leakDetector_ImageSwitch()
{
DISTRHO_SAFE_ASSERT(fImageNormal.getSize() == fImageDown.getSize());

@@ -52,13 +54,29 @@ ImageSwitch::ImageSwitch(const ImageSwitch& imageSwitch) noexcept
fImageDown(imageSwitch.fImageDown),
fIsDown(imageSwitch.fIsDown),
fId(imageSwitch.fId),
fCallback(imageSwitch.fCallback)
fCallback(imageSwitch.fCallback),
leakDetector_ImageSwitch()
{
DISTRHO_SAFE_ASSERT(fImageNormal.getSize() == fImageDown.getSize());

setSize(fImageNormal.getSize());
}

ImageSwitch& ImageSwitch::operator=(const ImageSwitch& imageSwitch) noexcept
{
fImageNormal = imageSwitch.fImageNormal;
fImageDown = imageSwitch.fImageDown;
fIsDown = imageSwitch.fIsDown;
fId = imageSwitch.fId;
fCallback = imageSwitch.fCallback;

DISTRHO_SAFE_ASSERT(fImageNormal.getSize() == fImageDown.getSize());

setSize(fImageNormal.getSize());

return *this;
}

int ImageSwitch::getId() const noexcept
{
return fId;


+ 3
- 1
dgl/src/Widget.cpp View File

@@ -26,7 +26,9 @@ Widget::Widget(Window& parent)
: fParent(parent),
fNeedsFullViewport(false),
fNeedsScaling(false),
fVisible(true)
fVisible(true),
fArea(),
leakDetector_Widget()
{
fParent._addWidget(this);
}


+ 14
- 17
dgl/src/Window.cpp View File

@@ -68,16 +68,15 @@ struct Window::PrivateData {
fResizable(true),
fUsingEmbed(false),
#if defined(DISTRHO_OS_WINDOWS)
hwnd(0)
hwnd(0),
#elif defined(DISTRHO_OS_LINUX)
xDisplay(nullptr),
xWindow(0)
xWindow(0),
#elif defined(DISTRHO_OS_MAC)
fNeedsIdle(true),
xWindow(nullptr)
#else
_dummy('\0')
xWindow(nullptr),
#endif
leakDetector_PrivateData()
{
DBG("Creating window without parent..."); DBGF;
init();
@@ -93,16 +92,15 @@ struct Window::PrivateData {
fUsingEmbed(false),
fModal(parent.pData),
#if defined(DISTRHO_OS_WINDOWS)
hwnd(0)
hwnd(0),
#elif defined(DISTRHO_OS_LINUX)
xDisplay(nullptr),
xWindow(0)
xWindow(0),
#elif defined(DISTRHO_OS_MAC)
fNeedsIdle(false),
xWindow(nullptr)
#else
_dummy('\0')
xWindow(nullptr),
#endif
leakDetector_PrivateData()
{
DBG("Creating window with parent..."); DBGF;
init();
@@ -123,16 +121,15 @@ struct Window::PrivateData {
fResizable(parentId == 0),
fUsingEmbed(parentId != 0),
#if defined(DISTRHO_OS_WINDOWS)
hwnd(0)
hwnd(0),
#elif defined(DISTRHO_OS_LINUX)
xDisplay(nullptr),
xWindow(0)
xWindow(0),
#elif defined(DISTRHO_OS_MAC)
fNeedsIdle(false),
xWindow(nullptr)
#else
_dummy('\0')
xWindow(nullptr),
#endif
leakDetector_PrivateData()
{
if (parentId != 0)
{
@@ -793,8 +790,6 @@ struct Window::PrivateData {
#elif defined(DISTRHO_OS_MAC)
bool fNeedsIdle;
id xWindow;
#else
char _dummy;
#endif

// -------------------------------------------------------------------
@@ -843,6 +838,8 @@ struct Window::PrivateData {
}

#undef handlePtr

DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PrivateData)
};

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


+ 6
- 1
distrho/DistrhoPlugin.hpp View File

@@ -92,7 +92,7 @@ struct ParameterRanges {
/*!
* Get a fixed value within range.
*/
float getFixedValue(const float& value) const noexcept
const float& getFixedValue(const float& value) const noexcept
{
if (value <= min)
return min;
@@ -140,6 +140,11 @@ struct ParameterRanges {
*/
float getUnnormalizedValue(const float& value) const noexcept
{
if (value <= 0.0f)
return min;
if (value >= 1.0f)
return max;

return value * (max - min) + min;
}
};


+ 2
- 4
distrho/extra/d_leakdetector.hpp View File

@@ -48,7 +48,7 @@
#define DISTRHO_LEAK_DETECTOR(ClassName) \
friend class ::DistrhoLeakedObjectDetector<ClassName>; \
static const char* getLeakedObjectClassName() noexcept { return #ClassName; } \
::DistrhoLeakedObjectDetector<ClassName> DISTRHO_JOIN_MACRO(leakDetector, __LINE__);
::DistrhoLeakedObjectDetector<ClassName> DISTRHO_JOIN_MACRO(leakDetector_, ClassName);

#define DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ClassName) \
DISTRHO_DECLARE_NON_COPY_CLASS(ClassName) \
@@ -99,9 +99,7 @@ private:
{
public:
LeakCounter() noexcept
{
numObjects = 0;
}
: numObjects(0) {}

~LeakCounter() noexcept
{


Loading…
Cancel
Save