Browse Source

Update DPT API and code, add quick test file

tags/1.9.4
falkTX 12 years ago
parent
commit
df02e63fac
27 changed files with 788 additions and 543 deletions
  1. +10
    -8
      source/modules/carla_native/distrho/DistrhoPluginCarla.cpp
  2. +8
    -1
      source/modules/distrho/dgl/App.hpp
  3. +2
    -2
      source/modules/distrho/dgl/Base.hpp
  4. +62
    -62
      source/modules/distrho/dgl/Geometry.hpp
  5. +16
    -16
      source/modules/distrho/dgl/Image.hpp
  6. +1
    -1
      source/modules/distrho/dgl/ImageAboutWindow.hpp
  7. +2
    -2
      source/modules/distrho/dgl/ImageButton.hpp
  8. +1
    -1
      source/modules/distrho/dgl/ImageKnob.hpp
  9. +1
    -1
      source/modules/distrho/dgl/ImageSlider.hpp
  10. +4
    -4
      source/modules/distrho/dgl/StandaloneWindow.hpp
  11. +21
    -20
      source/modules/distrho/dgl/Widget.hpp
  12. +27
    -12
      source/modules/distrho/dgl/Window.hpp
  13. +49
    -9
      source/modules/distrho/dgl/src/App.cpp
  14. +22
    -54
      source/modules/distrho/dgl/src/Base.cpp
  15. +55
    -55
      source/modules/distrho/dgl/src/Geometry.cpp
  16. +16
    -16
      source/modules/distrho/dgl/src/Image.cpp
  17. +7
    -7
      source/modules/distrho/dgl/src/ImageAboutWindow.cpp
  18. +5
    -5
      source/modules/distrho/dgl/src/ImageButton.cpp
  19. +5
    -5
      source/modules/distrho/dgl/src/ImageKnob.cpp
  20. +3
    -3
      source/modules/distrho/dgl/src/ImageSlider.cpp
  21. +32
    -23
      source/modules/distrho/dgl/src/Widget.cpp
  22. +340
    -228
      source/modules/distrho/dgl/src/Window.cpp
  23. +3
    -3
      source/modules/distrho/src/DistrhoUIDSSI.cpp
  24. +2
    -1
      source/modules/distrho/src/DistrhoUIInternal.hpp
  25. +1
    -1
      source/modules/distrho/src/DistrhoUIOpenGL.cpp
  26. +88
    -0
      source/tests/DGL.cpp
  27. +5
    -3
      source/tests/Makefile

+ 10
- 8
source/modules/carla_native/distrho/DistrhoPluginCarla.cpp View File

@@ -18,7 +18,7 @@
# error We do not want Qt in the engine code! # error We do not want Qt in the engine code!
#endif #endif


#include "../CarlaNative.hpp"
#include "CarlaNative.hpp"
#include "CarlaString.hpp" #include "CarlaString.hpp"


#include "DistrhoPluginMain.cpp" #include "DistrhoPluginMain.cpp"
@@ -33,8 +33,6 @@
# endif # endif
#endif #endif


using juce::ScopedPointer;

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


START_NAMESPACE_DISTRHO START_NAMESPACE_DISTRHO
@@ -59,8 +57,8 @@ public:
#endif #endif
{ {
#ifdef DISTRHO_UI_OPENGL #ifdef DISTRHO_UI_OPENGL
glWindow.setSize(fUi.getWidth(), fUi.getHeight());
glWindow.setWindowTitle(host->uiName);
//glWindow.setSize(fUi.getWidth(), fUi.getHeight());
glWindow.setTitle(host->uiName);
#else #else
CarlaString filename; CarlaString filename;
filename += fHost->resourceDir; filename += fHost->resourceDir;
@@ -202,7 +200,7 @@ public:
void carla_setUiTitle(const char* const uiTitle) void carla_setUiTitle(const char* const uiTitle)
{ {
#ifdef DISTRHO_UI_OPENGL #ifdef DISTRHO_UI_OPENGL
glWindow.setWindowTitle(uiTitle);
glWindow.setTitle(uiTitle);
#else #else
writeMsg("uiTitle\n", 8); writeMsg("uiTitle\n", 8);
writeAndFixMsg(uiTitle); writeAndFixMsg(uiTitle);
@@ -321,7 +319,11 @@ public:
~PluginCarla() override ~PluginCarla() override
{ {
#if DISTRHO_PLUGIN_HAS_UI #if DISTRHO_PLUGIN_HAS_UI
fUiPtr = nullptr;
if (fUiPtr != nullptr)
{
delete fUiPtr;
fUiPtr = nullptr;
}
#endif #endif
} }


@@ -574,7 +576,7 @@ private:


#if DISTRHO_PLUGIN_HAS_UI #if DISTRHO_PLUGIN_HAS_UI
// UI // UI
ScopedPointer<UICarla> fUiPtr;
UICarla* fUiPtr;


void createUiIfNeeded() void createUiIfNeeded()
{ {


+ 8
- 1
source/modules/distrho/dgl/App.hpp View File

@@ -21,6 +21,8 @@


START_NAMESPACE_DGL START_NAMESPACE_DGL


class Window;

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


class App class App
@@ -35,9 +37,14 @@ public:
bool isQuiting() const; bool isQuiting() const;


private: private:
class PrivateData;
struct PrivateData;
PrivateData* const pData; PrivateData* const pData;
friend class Window; friend class Window;

void addWindow(Window* const window);
void removeWindow(Window* const window);
void oneShown();
void oneHidden();
}; };


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


+ 2
- 2
source/modules/distrho/dgl/Base.hpp View File

@@ -53,9 +53,9 @@
#define USE_NAMESPACE_DGL using namespace DGL_NAMESPACE; #define USE_NAMESPACE_DGL using namespace DGL_NAMESPACE;


#if DGL_OS_MAC #if DGL_OS_MAC
# include <OpenGL/glu.h>
# include <OpenGL/gl.h>
#else #else
# include <GL/glu.h>
# include <GL/gl.h>
#endif #endif


#if defined(GL_BGR_EXT) && ! defined(GL_BGR) #if defined(GL_BGR_EXT) && ! defined(GL_BGR)


+ 62
- 62
source/modules/distrho/dgl/Geometry.hpp View File

@@ -27,24 +27,24 @@ template<typename T>
class Point class Point
{ {
public: public:
Point();
Point(T x, T y);
Point(const Point<T>& pos);
Point() noexcept;
Point(T x, T y) noexcept;
Point(const Point<T>& pos) noexcept;


T getX() const;
T getY() const;
T getX() const noexcept;
T getY() const noexcept;


void setX(T x);
void setY(T y);
void setX(T x) noexcept;
void setY(T y) noexcept;


void move(T x, T y);
void move(const Point<T>& pos);
void move(T x, T y) noexcept;
void move(const Point<T>& pos) noexcept;


Point<T>& operator=(const Point<T>& pos);
Point<T>& operator+=(const Point<T>& pos);
Point<T>& operator-=(const Point<T>& pos);
bool operator==(const Point<T>& pos) const;
bool operator!=(const Point<T>& pos) const;
Point<T>& operator=(const Point<T>& pos) noexcept;
Point<T>& operator+=(const Point<T>& pos) noexcept;
Point<T>& operator-=(const Point<T>& pos) noexcept;
bool operator==(const Point<T>& pos) const noexcept;
bool operator!=(const Point<T>& pos) const noexcept;


private: private:
T fX, fY; T fX, fY;
@@ -57,23 +57,23 @@ template<typename T>
class Size class Size
{ {
public: public:
Size();
Size(T width, T height);
Size(const Size<T>& size);
Size() noexcept;
Size(T width, T height) noexcept;
Size(const Size<T>& size) noexcept;


T getWidth() const;
T getHeight() const;
T getWidth() const noexcept;
T getHeight() const noexcept;


void setWidth(T width);
void setHeight(T height);
void setWidth(T width) noexcept;
void setHeight(T height) noexcept;


Size<T>& operator=(const Size<T>& size);
Size<T>& operator+=(const Size<T>& size);
Size<T>& operator-=(const Size<T>& size);
Size<T>& operator*=(T m);
Size<T>& operator/=(T d);
bool operator==(const Size<T>& size) const;
bool operator!=(const Size<T>& size) const;
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*=(T m) noexcept;
Size<T>& operator/=(T d) noexcept;
bool operator==(const Size<T>& size) const noexcept;
bool operator!=(const Size<T>& size) const noexcept;


private: private:
T fWidth, fHeight; T fWidth, fHeight;
@@ -86,40 +86,40 @@ template<typename T>
class Rectangle class Rectangle
{ {
public: public:
Rectangle();
Rectangle(T x, T y, T width, T height);
Rectangle(T x, T y, const Size<T>& size);
Rectangle(const Point<T>& pos, T width, T height);
Rectangle(const Point<T>& pos, const Size<T>& size);
Rectangle(const Rectangle<T>& rect);
T getX() const;
T getY() const;
T getWidth() const;
T getHeight() const;
const Point<T>& getPos() const;
const Size<T>& getSize() const;
bool contains(T x, T y) const;
bool contains(const Point<T>& pos) const;
bool containsX(T x) const;
bool containsY(T y) const;
void setX(T x);
void setY(T y);
void setPos(T x, T y);
void setPos(const Point<T>& pos);
void move(T x, T y);
void move(const Point<T>& pos);
void setWidth(T width);
void setHeight(T height);
void setSize(T width, T height);
void setSize(const Size<T>& size);
Rectangle<T>& operator=(const Rectangle<T>& rect);
Rectangle() noexcept;
Rectangle(T x, T y, T width, T height) noexcept;
Rectangle(T x, T y, const Size<T>& size) noexcept;
Rectangle(const Point<T>& pos, T width, T height) noexcept;
Rectangle(const Point<T>& pos, const Size<T>& size) noexcept;
Rectangle(const Rectangle<T>& rect) noexcept;
T getX() const noexcept;
T getY() const noexcept;
T getWidth() const noexcept;
T getHeight() const noexcept;
const Point<T>& getPos() const noexcept;
const Size<T>& getSize() const noexcept;
bool contains(T x, T y) const noexcept;
bool contains(const Point<T>& pos) const noexcept;
bool containsX(T x) const noexcept;
bool containsY(T y) const noexcept;
void setX(T x) noexcept;
void setY(T y) noexcept;
void setPos(T x, T y) noexcept;
void setPos(const Point<T>& pos) noexcept;
void move(T x, T y) noexcept;
void move(const Point<T>& pos) noexcept;
void setWidth(T width) noexcept;
void setHeight(T height) noexcept;
void setSize(T width, T height) noexcept;
void setSize(const Size<T>& size) noexcept;
Rectangle<T>& operator=(const Rectangle<T>& rect) noexcept;


private: private:
Point<T> fPos; Point<T> fPos;


+ 16
- 16
source/modules/distrho/dgl/Image.hpp View File

@@ -26,31 +26,31 @@ START_NAMESPACE_DGL
class Image class Image
{ {
public: public:
Image();
Image(const char* rawData, int width, int height, GLenum format = GL_BGRA, GLenum type = GL_UNSIGNED_BYTE);
Image(const char* rawData, const Size<int>& size, GLenum format = GL_BGRA, GLenum type = GL_UNSIGNED_BYTE);
Image(const Image& image);
Image() noexcept;
Image(const char* rawData, int width, int height, GLenum format = GL_BGRA, GLenum type = GL_UNSIGNED_BYTE) noexcept;
Image(const char* rawData, const Size<int>& size, GLenum format = GL_BGRA, GLenum type = GL_UNSIGNED_BYTE) noexcept;
Image(const Image& image) noexcept;


void loadFromMemory(const char* rawData, int width, int height, GLenum format = GL_BGRA, GLenum type = GL_UNSIGNED_BYTE);
void loadFromMemory(const char* rawData, const Size<int>& size, GLenum format = GL_BGRA, GLenum type = GL_UNSIGNED_BYTE);
void loadFromMemory(const char* rawData, int width, int height, GLenum format = GL_BGRA, GLenum type = GL_UNSIGNED_BYTE) noexcept;
void loadFromMemory(const char* rawData, const Size<int>& size, GLenum format = GL_BGRA, GLenum type = GL_UNSIGNED_BYTE) noexcept;


bool isValid() const;
bool isValid() const noexcept;


int getWidth() const;
int getHeight() const;
const Size<int>& getSize() const;
int getWidth() const noexcept;
int getHeight() const noexcept;
const Size<int>& getSize() const noexcept;


const char* getRawData() const;
GLenum getFormat() const;
GLenum getType() const;
const char* getRawData() const noexcept;
GLenum getFormat() const noexcept;
GLenum getType() const noexcept;


void draw() const; void draw() const;
void draw(int x, int y) const; void draw(int x, int y) const;
void draw(const Point<int>& pos) const; void draw(const Point<int>& pos) const;


Image& operator=(const Image& image);
bool operator==(const Image& image) const;
bool operator!=(const Image& image) const;
Image& operator=(const Image& image) noexcept;
bool operator==(const Image& image) const noexcept;
bool operator!=(const Image& image) const noexcept;


private: private:
const char* fRawData; const char* fRawData;


+ 1
- 1
source/modules/distrho/dgl/ImageAboutWindow.hpp View File

@@ -35,7 +35,7 @@ class ImageAboutWindow : public Window,
public Widget public Widget
{ {
public: public:
ImageAboutWindow(App* app, Window* parent, const Image& image = Image());
ImageAboutWindow(App& app, Window& parent, const Image& image = Image());
ImageAboutWindow(Widget* widget, const Image& image = Image()); ImageAboutWindow(Widget* widget, const Image& image = Image());


void setImage(const Image& image); void setImage(const Image& image);


+ 2
- 2
source/modules/distrho/dgl/ImageButton.hpp View File

@@ -34,9 +34,9 @@ public:
virtual void imageButtonClicked(ImageButton* imageButton, int button) = 0; virtual void imageButtonClicked(ImageButton* imageButton, int button) = 0;
}; };


ImageButton(Window* parent, const Image& image);
ImageButton(Window& parent, const Image& image);
ImageButton(Widget* widget, const Image& image); ImageButton(Widget* widget, const Image& image);
ImageButton(Window* parent, const Image& imageNormal, const Image& imageHover, const Image& imageDown);
ImageButton(Window& parent, const Image& imageNormal, const Image& imageHover, const Image& imageDown);
ImageButton(Widget* widget, const Image& imageNormal, const Image& imageHover, const Image& imageDown); ImageButton(Widget* widget, const Image& imageNormal, const Image& imageHover, const Image& imageDown);
ImageButton(const ImageButton& imageButton); ImageButton(const ImageButton& imageButton);




+ 1
- 1
source/modules/distrho/dgl/ImageKnob.hpp View File

@@ -41,7 +41,7 @@ public:
virtual void imageKnobValueChanged(ImageKnob* imageKnob, float value) = 0; virtual void imageKnobValueChanged(ImageKnob* imageKnob, float value) = 0;
}; };


ImageKnob(Window* parent, const Image& image, Orientation orientation = Vertical);
ImageKnob(Window& parent, const Image& image, Orientation orientation = Vertical);
ImageKnob(Widget* widget, const Image& image, Orientation orientation = Vertical); ImageKnob(Widget* widget, const Image& image, Orientation orientation = Vertical);
ImageKnob(const ImageKnob& imageKnob); ImageKnob(const ImageKnob& imageKnob);




+ 1
- 1
source/modules/distrho/dgl/ImageSlider.hpp View File

@@ -36,7 +36,7 @@ public:
virtual void imageSliderValueChanged(ImageSlider* imageSlider, float value) = 0; virtual void imageSliderValueChanged(ImageSlider* imageSlider, float value) = 0;
}; };


ImageSlider(Window* parent, const Image& image);
ImageSlider(Window& parent, const Image& image);
ImageSlider(Widget* widget, const Image& image); ImageSlider(Widget* widget, const Image& image);
ImageSlider(const ImageSlider& imageSlider); ImageSlider(const ImageSlider& imageSlider);




+ 4
- 4
source/modules/distrho/dgl/StandaloneWindow.hpp View File

@@ -34,12 +34,12 @@ public:
{ {
} }


App& getApp() const
App& getApp() const noexcept
{ {
return fApp; return fApp;
} }


Window& getWindow() const
Window& getWindow() const noexcept
{ {
return fWindow; return fWindow;
} }
@@ -63,9 +63,9 @@ public:
fWindow.setSize(width, height); fWindow.setSize(width, height);
} }


void setWindowTitle(const char* title)
void setTitle(const char* title)
{ {
fWindow.setWindowTitle(title);
fWindow.setTitle(title);
} }


private: private:


+ 21
- 20
source/modules/distrho/dgl/Widget.hpp View File

@@ -19,6 +19,12 @@


#include "Geometry.hpp" #include "Geometry.hpp"


#ifdef PROPER_CPP11_SUPPORT
# include <cstdint>
#else
# include <stdint.h>
#endif

START_NAMESPACE_DGL START_NAMESPACE_DGL


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -32,22 +38,15 @@ public:
Widget(Window& parent); Widget(Window& parent);
virtual ~Widget(); virtual ~Widget();


bool isVisible() const;
bool isVisible() const noexcept;
void setVisible(bool yesNo); void setVisible(bool yesNo);


void show()
{
setVisible(true);
}

void hide()
{
setVisible(false);
}
void show();
void hide();


int getX() const;
int getY() const;
const Point<int>& getPos() const;
int getX() const noexcept;
int getY() const noexcept;
const Point<int>& getPos() const noexcept;


void setX(int x); void setX(int x);
void setY(int y); void setY(int y);
@@ -57,26 +56,28 @@ public:
void move(int x, int y); void move(int x, int y);
void move(const Point<int>& pos); void move(const Point<int>& pos);


int getWidth() const;
int getHeight() const;
const Size<int>& getSize() const;
int getWidth() const noexcept;
int getHeight() const noexcept;
const Size<int>& getSize() const noexcept;


void setWidth(int width); void setWidth(int width);
void setHeight(int height); void setHeight(int height);
void setSize(int width, int height); void setSize(int width, int height);
void setSize(const Size<int>& size); void setSize(const Size<int>& size);


const Rectangle<int>& getArea() const;
const Rectangle<int>& getArea() const noexcept;


uint32_t getEventTimestamp();
int getModifiers(); int getModifiers();


App* getApp() const;
Window* getParent() const;
App& getParentApp() const noexcept;
Window& getParentWindow() const noexcept;

void repaint(); void repaint();


protected: protected:
virtual void onDisplay(); virtual void onDisplay();
virtual bool onKeyboard(bool press, unsigned key);
virtual bool onKeyboard(bool press, uint32_t key);
virtual bool onMouse(int button, bool press, int x, int y); virtual bool onMouse(int button, bool press, int x, int y);
virtual bool onMotion(int x, int y); virtual bool onMotion(int x, int y);
virtual bool onScroll(float dx, float dy); virtual bool onScroll(float dx, float dy);


+ 27
- 12
source/modules/distrho/dgl/Window.hpp View File

@@ -17,7 +17,13 @@
#ifndef DGL_WINDOW_HPP_INCLUDED #ifndef DGL_WINDOW_HPP_INCLUDED
#define DGL_WINDOW_HPP_INCLUDED #define DGL_WINDOW_HPP_INCLUDED


#include "Base.hpp"
#include "Geometry.hpp"

#ifdef PROPER_CPP11_SUPPORT
# include <cstdint>
#else
# include <stdint.h>
#endif


START_NAMESPACE_DGL START_NAMESPACE_DGL


@@ -34,31 +40,40 @@ public:
Window(App& app, intptr_t parentId); Window(App& app, intptr_t parentId);
virtual ~Window(); virtual ~Window();


void show();
void hide();
void close();
void exec(bool lockWait = false); void exec(bool lockWait = false);

void focus(); void focus();
void idle(); void idle();
void repaint(); void repaint();


bool isVisible();
bool isVisible() const noexcept;
void setVisible(bool yesNo); void setVisible(bool yesNo);

bool isResizable() const noexcept;
void setResizable(bool yesNo); void setResizable(bool yesNo);
void setSize(unsigned int width, unsigned int height);
void setWindowTitle(const char* title);


App& getApp() const;
int getModifiers() const;
intptr_t getWindowId() const;
int getWidth() const noexcept;
int getHeight() const noexcept;
Size<int> getSize() const noexcept;
void setSize(unsigned int width, unsigned int height);


void addWidget(Widget* widget);
void removeWidget(Widget* widget);
void setTitle(const char* title);


void show();
void hide();
void close();
App& getApp() const noexcept;
uint32_t getEventTimestamp() const;
int getModifiers() const;
intptr_t getWindowId() const;


private: private:
class PrivateData; class PrivateData;
PrivateData* const pData; PrivateData* const pData;
friend class Widget;

void addWidget(Widget* const widget);
void removeWidget(Widget* const widget);
}; };


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


+ 49
- 9
source/modules/distrho/dgl/src/App.cpp View File

@@ -14,27 +14,41 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */


#include "AppPrivate.hpp"

#include "../App.hpp"
#include "../Window.hpp" #include "../Window.hpp"


#include <list>

START_NAMESPACE_DGL START_NAMESPACE_DGL


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


struct App::PrivateData {
bool doLoop;
unsigned visibleWindows;
std::list<Window*> windows;

PrivateData()
: doLoop(false),
visibleWindows(0) {}
};

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

App::App() App::App()
: pData(new Private())
: pData(new PrivateData())
{ {
} }


App::~App() App::~App()
{ {
pData->windows.clear();
delete pData; delete pData;
} }


void App::idle() void App::idle()
{ {
for (std::list<Window*>::iterator it = pData->fWindows.begin(); it != pData->fWindows.end(); ++it)
for (std::list<Window*>::iterator it = pData->windows.begin(); it != pData->windows.end(); ++it)
{ {
Window* const window(*it); Window* const window(*it);
window->idle(); window->idle();
@@ -43,7 +57,7 @@ void App::idle()


void App::exec() void App::exec()
{ {
while (pData->fDoLoop)
while (pData->doLoop)
{ {
idle(); idle();
msleep(10); msleep(10);
@@ -52,18 +66,44 @@ void App::exec()


void App::quit() void App::quit()
{ {
pData->fDoLoop = false;
pData->doLoop = false;


for (std::list<Window*>::iterator it = pData->fWindows.begin(); it != pData->fWindows.end(); ++it)
for (std::list<Window*>::reverse_iterator rit = pData->windows.rbegin(); rit != pData->windows.rend(); ++rit)
{ {
Window* const window(*it);
Window* const window(*rit);
window->close(); window->close();
} }
} }


bool App::isQuiting() const bool App::isQuiting() const
{ {
return !pData->fDoLoop;
return !pData->doLoop;
}

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

void App::addWindow(Window* const window)
{
if (window != nullptr)
pData->windows.push_back(window);
}

void App::removeWindow(Window* const window)
{
if (window != nullptr)
pData->windows.remove(window);
}

void App::oneShown()
{
if (++pData->visibleWindows == 1)
pData->doLoop = true;
}

void App::oneHidden()
{
if (--pData->visibleWindows == 0)
pData->doLoop = false;
} }


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


source/modules/distrho/dgl/src/AppPrivate.hpp → source/modules/distrho/dgl/src/Base.cpp View File

@@ -14,68 +14,36 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */


#ifndef DGL_APP_PRIVATE_HPP_INCLUDED
#define DGL_APP_PRIVATE_HPP_INCLUDED
#include "../Base.hpp"


#include "../App.hpp"

#include <list>
#if DGL_OS_WINDOWS
# include <windows.h>
#else
# include <unistd.h>
#endif


START_NAMESPACE_DGL START_NAMESPACE_DGL


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


class Window;

class App::PrivateData
void sleep(unsigned int secs)
{ {
public:
Private()
: fDoLoop(true),
fVisibleWindows(0)
{
}

~Private()
{
fWindows.clear();
}

void addWindow(Window* const window)
{
if (window != nullptr)
fWindows.push_back(window);
}

void removeWindow(Window* const window)
{
if (window != nullptr)
fWindows.remove(window);
}

void oneShown()
{
if (++fVisibleWindows == 1)
fDoLoop = true;
}

void oneHidden()
{
if (--fVisibleWindows == 0)
fDoLoop = false;
}

private:
bool fDoLoop;
unsigned fVisibleWindows;

std::list<Window*> fWindows;

friend class App;
};
#ifdef DGL_OS_WINDOWS
::Sleep(secs * 1000);
#else
::sleep(secs);
#endif
}

void msleep(unsigned int msecs)
{
#ifdef DGL_OS_WINDOWS
::Sleep(msecs);
#else
::usleep(msecs * 1000);
#endif
}


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


END_NAMESPACE_DGL END_NAMESPACE_DGL

#endif // DGL_APP_PRIVATE_HPP_INCLUDED

+ 55
- 55
source/modules/distrho/dgl/src/Geometry.cpp View File

@@ -22,66 +22,66 @@ START_NAMESPACE_DGL
// Point // Point


template<typename T> template<typename T>
Point<T>::Point()
Point<T>::Point() noexcept
: fX(0), : fX(0),
fY(0) fY(0)
{ {
} }


template<typename T> template<typename T>
Point<T>::Point(T x, T y)
Point<T>::Point(T x, T y) noexcept
: fX(x), : fX(x),
fY(y) fY(y)
{ {
} }


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


template<typename T> template<typename T>
T Point<T>::getX() const
T Point<T>::getX() const noexcept
{ {
return fX; return fX;
} }


template<typename T> template<typename T>
T Point<T>::getY() const
T Point<T>::getY() const noexcept
{ {
return fY; return fY;
} }


template<typename T> template<typename T>
void Point<T>::setX(T x)
void Point<T>::setX(T x) noexcept
{ {
fX = x; fX = x;
} }


template<typename T> template<typename T>
void Point<T>::setY(T y)
void Point<T>::setY(T y) noexcept
{ {
fY = y; fY = y;
} }


template<typename T> template<typename T>
void Point<T>::move(T x, T y)
void Point<T>::move(T x, T y) noexcept
{ {
fX += x; fX += x;
fY += y; fY += y;
} }


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


template<typename T> template<typename T>
Point<T>& Point<T>::operator=(const Point<T>& pos)
Point<T>& Point<T>::operator=(const Point<T>& pos) noexcept
{ {
fX = pos.fX; fX = pos.fX;
fY = pos.fY; fY = pos.fY;
@@ -89,7 +89,7 @@ Point<T>& Point<T>::operator=(const Point<T>& pos)
} }


template<typename T> template<typename T>
Point<T>& Point<T>::operator+=(const Point<T>& pos)
Point<T>& Point<T>::operator+=(const Point<T>& pos) noexcept
{ {
fX += pos.fX; fX += pos.fX;
fY += pos.fY; fY += pos.fY;
@@ -97,7 +97,7 @@ Point<T>& Point<T>::operator+=(const Point<T>& pos)
} }


template<typename T> template<typename T>
Point<T>& Point<T>::operator-=(const Point<T>& pos)
Point<T>& Point<T>::operator-=(const Point<T>& pos) noexcept
{ {
fX -= pos.fX; fX -= pos.fX;
fY -= pos.fY; fY -= pos.fY;
@@ -105,13 +105,13 @@ Point<T>& Point<T>::operator-=(const Point<T>& pos)
} }


template<typename T> template<typename T>
bool Point<T>::operator==(const Point<T>& pos) const
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> template<typename T>
bool Point<T>::operator!=(const Point<T>& pos) const
bool Point<T>::operator!=(const Point<T>& pos) const noexcept
{ {
return !operator==(pos); return !operator==(pos);
} }
@@ -120,52 +120,52 @@ bool Point<T>::operator!=(const Point<T>& pos) const
// Size // Size


template<typename T> template<typename T>
Size<T>::Size()
Size<T>::Size() noexcept
: fWidth(0), : fWidth(0),
fHeight(0) fHeight(0)
{ {
} }


template<typename T> template<typename T>
Size<T>::Size(T width, T height)
Size<T>::Size(T width, T height) noexcept
: fWidth(width), : fWidth(width),
fHeight(height) fHeight(height)
{ {
} }


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


template<typename T> template<typename T>
T Size<T>::getWidth() const
T Size<T>::getWidth() const noexcept
{ {
return fWidth; return fWidth;
} }


template<typename T> template<typename T>
T Size<T>::getHeight() const
T Size<T>::getHeight() const noexcept
{ {
return fHeight; return fHeight;
} }


template<typename T> template<typename T>
void Size<T>::setWidth(T width)
void Size<T>::setWidth(T width) noexcept
{ {
fWidth = width; fWidth = width;
} }


template<typename T> template<typename T>
void Size<T>::setHeight(T height)
void Size<T>::setHeight(T height) noexcept
{ {
fHeight = height; fHeight = height;
} }


template<typename T> template<typename T>
Size<T>& Size<T>::operator=(const Size<T>& size)
Size<T>& Size<T>::operator=(const Size<T>& size) noexcept
{ {
fWidth = size.fWidth; fWidth = size.fWidth;
fHeight = size.fHeight; fHeight = size.fHeight;
@@ -173,7 +173,7 @@ Size<T>& Size<T>::operator=(const Size<T>& size)
} }


template<typename T> template<typename T>
Size<T>& Size<T>::operator+=(const Size<T>& size)
Size<T>& Size<T>::operator+=(const Size<T>& size) noexcept
{ {
fWidth += size.fWidth; fWidth += size.fWidth;
fHeight += size.fHeight; fHeight += size.fHeight;
@@ -181,7 +181,7 @@ Size<T>& Size<T>::operator+=(const Size<T>& size)
} }


template<typename T> template<typename T>
Size<T>& Size<T>::operator-=(const Size<T>& size)
Size<T>& Size<T>::operator-=(const Size<T>& size) noexcept
{ {
fWidth -= size.fWidth; fWidth -= size.fWidth;
fHeight -= size.fHeight; fHeight -= size.fHeight;
@@ -189,7 +189,7 @@ Size<T>& Size<T>::operator-=(const Size<T>& size)
} }


template<typename T> template<typename T>
Size<T>& Size<T>::operator*=(T m)
Size<T>& Size<T>::operator*=(T m) noexcept
{ {
fWidth *= m; fWidth *= m;
fHeight *= m; fHeight *= m;
@@ -197,7 +197,7 @@ Size<T>& Size<T>::operator*=(T m)
} }


template<typename T> template<typename T>
Size<T>& Size<T>::operator/=(T d)
Size<T>& Size<T>::operator/=(T d) noexcept
{ {
fWidth /= d; fWidth /= d;
fHeight /= d; fHeight /= d;
@@ -205,13 +205,13 @@ Size<T>& Size<T>::operator/=(T d)
} }


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


template<typename T> template<typename T>
bool Size<T>::operator!=(const Size<T>& size) const
bool Size<T>::operator!=(const Size<T>& size) const noexcept
{ {
return !operator==(size); return !operator==(size);
} }
@@ -220,172 +220,172 @@ bool Size<T>::operator!=(const Size<T>& size) const
// Rectangle // Rectangle


template<typename T> template<typename T>
Rectangle<T>::Rectangle()
Rectangle<T>::Rectangle() noexcept
: fPos(0, 0), : fPos(0, 0),
fSize(0, 0) fSize(0, 0)
{ {
} }


template<typename T> template<typename T>
Rectangle<T>::Rectangle(T x, T y, T width, T height)
Rectangle<T>::Rectangle(T x, T y, T width, T height) noexcept
: fPos(x, y), : fPos(x, y),
fSize(width, height) fSize(width, height)
{ {
} }


template<typename T> template<typename T>
Rectangle<T>::Rectangle(T x, T y, const Size<T>& size)
Rectangle<T>::Rectangle(T x, T y, const Size<T>& size) noexcept
: fPos(x, y), : fPos(x, y),
fSize(size) fSize(size)
{ {
} }


template<typename T> template<typename T>
Rectangle<T>::Rectangle(const Point<T>& pos, T width, T height)
Rectangle<T>::Rectangle(const Point<T>& pos, T width, T height) noexcept
: fPos(pos), : fPos(pos),
fSize(width, height) fSize(width, height)
{ {
} }


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


template<typename T> template<typename T>
Rectangle<T>::Rectangle(const Rectangle<T>& rect)
Rectangle<T>::Rectangle(const Rectangle<T>& rect) noexcept
: fPos(rect.fPos), : fPos(rect.fPos),
fSize(rect.fSize) fSize(rect.fSize)
{ {
} }


template<typename T> template<typename T>
T Rectangle<T>::getX() const
T Rectangle<T>::getX() const noexcept
{ {
return fPos.fX; return fPos.fX;
} }


template<typename T> template<typename T>
T Rectangle<T>::getY() const
T Rectangle<T>::getY() const noexcept
{ {
return fPos.fY; return fPos.fY;
} }


template<typename T> template<typename T>
T Rectangle<T>::getWidth() const
T Rectangle<T>::getWidth() const noexcept
{ {
return fSize.fWidth; return fSize.fWidth;
} }


template<typename T> template<typename T>
T Rectangle<T>::getHeight() const
T Rectangle<T>::getHeight() const noexcept
{ {
return fSize.fHeight; return fSize.fHeight;
} }


template<typename T> template<typename T>
const Point<T>& Rectangle<T>::getPos() const
const Point<T>& Rectangle<T>::getPos() const noexcept
{ {
return fPos; return fPos;
} }


template<typename T> template<typename T>
const Size<T>& Rectangle<T>::getSize() const
const Size<T>& Rectangle<T>::getSize() const noexcept
{ {
return fSize; return fSize;
} }


template<typename T> template<typename T>
bool Rectangle<T>::contains(T x, T y) const
bool Rectangle<T>::contains(T x, T y) const noexcept
{ {
return (x >= fPos.fX && y >= fPos.fY && x <= fPos.fX+fSize.fWidth && y <= fPos.fY+fSize.fHeight); return (x >= fPos.fX && y >= fPos.fY && x <= fPos.fX+fSize.fWidth && y <= fPos.fY+fSize.fHeight);
} }


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


template<typename T> template<typename T>
bool Rectangle<T>::containsX(T x) const
bool Rectangle<T>::containsX(T x) const noexcept
{ {
return (x >= fPos.fX && x <= fPos.fX + fSize.fWidth); return (x >= fPos.fX && x <= fPos.fX + fSize.fWidth);
} }


template<typename T> template<typename T>
bool Rectangle<T>::containsY(T y) const
bool Rectangle<T>::containsY(T y) const noexcept
{ {
return (y >= fPos.fY && y <= fPos.fY + fSize.fHeight); return (y >= fPos.fY && y <= fPos.fY + fSize.fHeight);
} }


template<typename T> template<typename T>
void Rectangle<T>::setX(T x)
void Rectangle<T>::setX(T x) noexcept
{ {
fPos.fX = x; fPos.fX = x;
} }


template<typename T> template<typename T>
void Rectangle<T>::setY(T y)
void Rectangle<T>::setY(T y) noexcept
{ {
fPos.fY = y; fPos.fY = y;
} }


template<typename T> template<typename T>
void Rectangle<T>::setPos(T x, T y)
void Rectangle<T>::setPos(T x, T y) noexcept
{ {
fPos.fX = x; fPos.fX = x;
fPos.fY = y; fPos.fY = y;
} }


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


template<typename T> template<typename T>
void Rectangle<T>::move(T x, T y)
void Rectangle<T>::move(T x, T y) noexcept
{ {
fPos.fX += x; fPos.fX += x;
fPos.fY += y; fPos.fY += y;
} }


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


template<typename T> template<typename T>
void Rectangle<T>::setWidth(T width)
void Rectangle<T>::setWidth(T width) noexcept
{ {
fSize.fWidth = width; fSize.fWidth = width;
} }


template<typename T> template<typename T>
void Rectangle<T>::setHeight(T height)
void Rectangle<T>::setHeight(T height) noexcept
{ {
fSize.fHeight = height; fSize.fHeight = height;
} }


template<typename T> template<typename T>
void Rectangle<T>::setSize(T width, T height)
void Rectangle<T>::setSize(T width, T height) noexcept
{ {
fSize.fWidth = width; fSize.fWidth = width;
fSize.fHeight = height; fSize.fHeight = height;
} }


template<typename T> template<typename T>
void Rectangle<T>::setSize(const Size<T>& size)
void Rectangle<T>::setSize(const Size<T>& size) noexcept
{ {
fSize = size; fSize = size;
} }


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


+ 16
- 16
source/modules/distrho/dgl/src/Image.cpp View File

@@ -20,7 +20,7 @@ START_NAMESPACE_DGL


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


Image::Image()
Image::Image() noexcept
: fRawData(nullptr), : fRawData(nullptr),
fSize(0, 0), fSize(0, 0),
fFormat(0), fFormat(0),
@@ -28,7 +28,7 @@ Image::Image()
{ {
} }


Image::Image(const char* rawData, int width, int height, GLenum format, GLenum type)
Image::Image(const char* rawData, int width, int height, GLenum format, GLenum type) noexcept
: fRawData(rawData), : fRawData(rawData),
fSize(width, height), fSize(width, height),
fFormat(format), fFormat(format),
@@ -36,7 +36,7 @@ Image::Image(const char* rawData, int width, int height, GLenum format, GLenum t
{ {
} }


Image::Image(const char* rawData, const Size<int>& size, GLenum format, GLenum type)
Image::Image(const char* rawData, const Size<int>& size, GLenum format, GLenum type) noexcept
: fRawData(rawData), : fRawData(rawData),
fSize(size), fSize(size),
fFormat(format), fFormat(format),
@@ -44,7 +44,7 @@ Image::Image(const char* rawData, const Size<int>& size, GLenum format, GLenum t
{ {
} }


Image::Image(const Image& image)
Image::Image(const Image& image) noexcept
: fRawData(image.fRawData), : fRawData(image.fRawData),
fSize(image.fSize), fSize(image.fSize),
fFormat(image.fFormat), fFormat(image.fFormat),
@@ -52,12 +52,12 @@ Image::Image(const Image& image)
{ {
} }


void Image::loadFromMemory(const char* rawData, int width, int height, GLenum format, GLenum type)
void Image::loadFromMemory(const char* rawData, int width, int height, GLenum format, GLenum type) noexcept
{ {
loadFromMemory(rawData, Size<int>(width, height), format, type); loadFromMemory(rawData, Size<int>(width, height), format, type);
} }


void Image::loadFromMemory(const char* rawData, const Size<int>& size, GLenum format, GLenum type)
void Image::loadFromMemory(const char* rawData, const Size<int>& size, GLenum format, GLenum type) noexcept
{ {
fRawData = rawData; fRawData = rawData;
fSize = size; fSize = size;
@@ -65,37 +65,37 @@ void Image::loadFromMemory(const char* rawData, const Size<int>& size, GLenum fo
fType = type; fType = type;
} }


bool Image::isValid() const
bool Image::isValid() const noexcept
{ {
return (fRawData != nullptr && getWidth() > 0 && getHeight() > 0); return (fRawData != nullptr && getWidth() > 0 && getHeight() > 0);
} }


int Image::getWidth() const
int Image::getWidth() const noexcept
{ {
return fSize.getWidth(); return fSize.getWidth();
} }


int Image::getHeight() const
int Image::getHeight() const noexcept
{ {
return fSize.getHeight(); return fSize.getHeight();
} }


const Size<int>& Image::getSize() const
const Size<int>& Image::getSize() const noexcept
{ {
return fSize; return fSize;
} }


const char* Image::getRawData() const
const char* Image::getRawData() const noexcept
{ {
return fRawData; return fRawData;
} }


GLenum Image::getFormat() const
GLenum Image::getFormat() const noexcept
{ {
return fFormat; return fFormat;
} }


GLenum Image::getType() const
GLenum Image::getType() const noexcept
{ {
return fType; return fType;
} }
@@ -121,7 +121,7 @@ void Image::draw(const Point<int>& pos) const
draw(pos.getX(), pos.getY()); draw(pos.getX(), pos.getY());
} }


Image& Image::operator=(const Image& image)
Image& Image::operator=(const Image& image) noexcept
{ {
fRawData = image.fRawData; fRawData = image.fRawData;
fSize = image.fSize; fSize = image.fSize;
@@ -130,12 +130,12 @@ Image& Image::operator=(const Image& image)
return *this; return *this;
} }


bool Image::operator==(const Image& image) const
bool Image::operator==(const Image& image) const noexcept
{ {
return (fRawData == image.fRawData); return (fRawData == image.fRawData);
} }


bool Image::operator!=(const Image& image) const
bool Image::operator!=(const Image& image) const noexcept
{ {
return (fRawData != image.fRawData); return (fRawData != image.fRawData);
} }


+ 7
- 7
source/modules/distrho/dgl/src/ImageAboutWindow.cpp View File

@@ -27,22 +27,22 @@ START_NAMESPACE_DGL


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


ImageAboutWindow::ImageAboutWindow(App* app, Window* parent, const Image& image)
ImageAboutWindow::ImageAboutWindow(App& app, Window& parent, const Image& image)
: Window(app, parent), : Window(app, parent),
Widget(this),
Widget((Window&)*this),
fImgBackground(image) fImgBackground(image)
{ {
Window::setSize(image.getWidth(), image.getHeight() PAD_SIZE); Window::setSize(image.getWidth(), image.getHeight() PAD_SIZE);
Window::setWindowTitle("About");
Window::setTitle("About");
} }


ImageAboutWindow::ImageAboutWindow(Widget* widget, const Image& image) ImageAboutWindow::ImageAboutWindow(Widget* widget, const Image& image)
: Window(widget->getApp(), widget->getParent()),
Widget(this),
: Window(widget->getParentApp(), widget->getParentWindow()),
Widget((Window&)*this),
fImgBackground(image) fImgBackground(image)
{ {
Window::setSize(image.getWidth(), image.getHeight() PAD_SIZE); Window::setSize(image.getWidth(), image.getHeight() PAD_SIZE);
Window::setWindowTitle("About");
Window::setTitle("About");
} }


void ImageAboutWindow::setImage(const Image& image) void ImageAboutWindow::setImage(const Image& image)
@@ -69,7 +69,7 @@ bool ImageAboutWindow::onMouse(int, bool press, int, int)


bool ImageAboutWindow::onKeyboard(bool press, uint32_t key) bool ImageAboutWindow::onKeyboard(bool press, uint32_t key)
{ {
if (press && key == DGL_CHAR_ESCAPE)
if (press && key == CHAR_ESCAPE)
{ {
Window::close(); Window::close();
return true; return true;


+ 5
- 5
source/modules/distrho/dgl/src/ImageButton.cpp View File

@@ -22,7 +22,7 @@ START_NAMESPACE_DGL


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


ImageButton::ImageButton(Window* parent, const Image& image)
ImageButton::ImageButton(Window& parent, const Image& image)
: Widget(parent), : Widget(parent),
fImageNormal(image), fImageNormal(image),
fImageHover(image), fImageHover(image),
@@ -34,7 +34,7 @@ ImageButton::ImageButton(Window* parent, const Image& image)
} }


ImageButton::ImageButton(Widget* widget, const Image& image) ImageButton::ImageButton(Widget* widget, const Image& image)
: Widget(widget->getParent()),
: Widget(widget->getParentWindow()),
fImageNormal(image), fImageNormal(image),
fImageHover(image), fImageHover(image),
fImageDown(image), fImageDown(image),
@@ -44,7 +44,7 @@ ImageButton::ImageButton(Widget* widget, const Image& image)
{ {
} }


ImageButton::ImageButton(Window* parent, const Image& imageNormal, const Image& imageHover, const Image& imageDown)
ImageButton::ImageButton(Window& parent, const Image& imageNormal, const Image& imageHover, const Image& imageDown)
: Widget(parent), : Widget(parent),
fImageNormal(imageNormal), fImageNormal(imageNormal),
fImageHover(imageHover), fImageHover(imageHover),
@@ -59,7 +59,7 @@ ImageButton::ImageButton(Window* parent, const Image& imageNormal, const Image&
} }


ImageButton::ImageButton(Widget* widget, const Image& imageNormal, const Image& imageHover, const Image& imageDown) ImageButton::ImageButton(Widget* widget, const Image& imageNormal, const Image& imageHover, const Image& imageDown)
: Widget(widget->getParent()),
: Widget(widget->getParentWindow()),
fImageNormal(imageNormal), fImageNormal(imageNormal),
fImageHover(imageHover), fImageHover(imageHover),
fImageDown(imageDown), fImageDown(imageDown),
@@ -73,7 +73,7 @@ ImageButton::ImageButton(Widget* widget, const Image& imageNormal, const Image&
} }


ImageButton::ImageButton(const ImageButton& imageButton) ImageButton::ImageButton(const ImageButton& imageButton)
: Widget(imageButton.getParent()),
: Widget(imageButton.getParentWindow()),
fImageNormal(imageButton.fImageNormal), fImageNormal(imageButton.fImageNormal),
fImageHover(imageButton.fImageHover), fImageHover(imageButton.fImageHover),
fImageDown(imageButton.fImageDown), fImageDown(imageButton.fImageDown),


+ 5
- 5
source/modules/distrho/dgl/src/ImageKnob.cpp View File

@@ -23,7 +23,7 @@ START_NAMESPACE_DGL


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


ImageKnob::ImageKnob(Window* parent, const Image& image, Orientation orientation)
ImageKnob::ImageKnob(Window& parent, const Image& image, Orientation orientation)
: Widget(parent), : Widget(parent),
fImage(image), fImage(image),
fMinimum(0.0f), fMinimum(0.0f),
@@ -45,7 +45,7 @@ ImageKnob::ImageKnob(Window* parent, const Image& image, Orientation orientation
} }


ImageKnob::ImageKnob(Widget* widget, const Image& image, Orientation orientation) ImageKnob::ImageKnob(Widget* widget, const Image& image, Orientation orientation)
: Widget(widget->getParent()),
: Widget(widget->getParentWindow()),
fImage(image), fImage(image),
fMinimum(0.0f), fMinimum(0.0f),
fMaximum(1.0f), fMaximum(1.0f),
@@ -66,7 +66,7 @@ ImageKnob::ImageKnob(Widget* widget, const Image& image, Orientation orientation
} }


ImageKnob::ImageKnob(const ImageKnob& imageKnob) ImageKnob::ImageKnob(const ImageKnob& imageKnob)
: Widget(imageKnob.getParent()),
: Widget(imageKnob.getParentWindow()),
fImage(imageKnob.fImage), fImage(imageKnob.fImage),
fMinimum(imageKnob.fMinimum), fMinimum(imageKnob.fMinimum),
fMaximum(imageKnob.fMaximum), fMaximum(imageKnob.fMaximum),
@@ -286,7 +286,7 @@ bool ImageKnob::onMotion(int x, int y)


if (movX != 0) if (movX != 0)
{ {
float d = (getModifiers() & DGL_MODIFIER_SHIFT) ? 2000.0f : 200.0f;
float d = (getModifiers() & MODIFIER_SHIFT) ? 2000.0f : 200.0f;
float value = fValue + (float(fMaximum - fMinimum) / d * float(movX)); float value = fValue + (float(fMaximum - fMinimum) / d * float(movX));


if (value < fMinimum) if (value < fMinimum)
@@ -303,7 +303,7 @@ bool ImageKnob::onMotion(int x, int y)


if (movY != 0) if (movY != 0)
{ {
float d = (getModifiers() & DGL_MODIFIER_SHIFT) ? 2000.0f : 200.0f;
float d = (getModifiers() & MODIFIER_SHIFT) ? 2000.0f : 200.0f;
float value = fValue + (float(fMaximum - fMinimum) / d * float(movY)); float value = fValue + (float(fMaximum - fMinimum) / d * float(movY));


if (value < fMinimum) if (value < fMinimum)


+ 3
- 3
source/modules/distrho/dgl/src/ImageSlider.cpp View File

@@ -20,7 +20,7 @@ START_NAMESPACE_DGL


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


ImageSlider::ImageSlider(Window* parent, const Image& image)
ImageSlider::ImageSlider(Window& parent, const Image& image)
: Widget(parent), : Widget(parent),
fImage(image), fImage(image),
fMinimum(0.0f), fMinimum(0.0f),
@@ -36,7 +36,7 @@ ImageSlider::ImageSlider(Window* parent, const Image& image)
} }


ImageSlider::ImageSlider(Widget* widget, const Image& image) ImageSlider::ImageSlider(Widget* widget, const Image& image)
: Widget(widget->getParent()),
: Widget(widget->getParentWindow()),
fImage(image), fImage(image),
fMinimum(0.0f), fMinimum(0.0f),
fMaximum(1.0f), fMaximum(1.0f),
@@ -51,7 +51,7 @@ ImageSlider::ImageSlider(Widget* widget, const Image& image)
} }


ImageSlider::ImageSlider(const ImageSlider& imageSlider) ImageSlider::ImageSlider(const ImageSlider& imageSlider)
: Widget(imageSlider.getParent()),
: Widget(imageSlider.getParentWindow()),
fImage(imageSlider.fImage), fImage(imageSlider.fImage),
fMinimum(imageSlider.fMinimum), fMinimum(imageSlider.fMinimum),
fMaximum(imageSlider.fMaximum), fMaximum(imageSlider.fMaximum),


+ 32
- 23
source/modules/distrho/dgl/src/Widget.cpp View File

@@ -20,12 +20,6 @@


#include <cassert> #include <cassert>


#ifdef PROPER_CPP11_SUPPORT
# include <cstdint>
#else
# include <stdint.h>
#endif

START_NAMESPACE_DGL START_NAMESPACE_DGL


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -35,7 +29,7 @@ Widget::Widget(Window& parent)
: fParent(parent), : fParent(parent),
fVisible(true) fVisible(true)
{ {
parent.addWidget(this);
fParent.addWidget(this);
} }


Widget::~Widget() Widget::~Widget()
@@ -43,7 +37,7 @@ Widget::~Widget()
fParent.removeWidget(this); fParent.removeWidget(this);
} }


bool Widget::isVisible() const
bool Widget::isVisible() const noexcept
{ {
return fVisible; return fVisible;
} }
@@ -57,17 +51,27 @@ void Widget::setVisible(bool yesNo)
fParent.repaint(); fParent.repaint();
} }


int Widget::getX() const
void Widget::show()
{
setVisible(true);
}

void Widget::hide()
{
setVisible(false);
}

int Widget::getX() const noexcept
{ {
return fArea.getX(); return fArea.getX();
} }


int Widget::getY() const
int Widget::getY() const noexcept
{ {
return fArea.getY(); return fArea.getY();
} }


const Point<int>& Widget::getPos() const
const Point<int>& Widget::getPos() const noexcept
{ {
return fArea.getPos(); return fArea.getPos();
} }
@@ -78,7 +82,7 @@ void Widget::setX(int x)
return; return;


fArea.setX(x); fArea.setX(x);
repaint();
fParent.repaint();
} }


void Widget::setY(int y) void Widget::setY(int y)
@@ -87,7 +91,7 @@ void Widget::setY(int y)
return; return;


fArea.setY(y); fArea.setY(y);
repaint();
fParent.repaint();
} }


void Widget::setPos(int x, int y) void Widget::setPos(int x, int y)
@@ -101,32 +105,32 @@ void Widget::setPos(const Point<int>& pos)
return; return;


fArea.setPos(pos); fArea.setPos(pos);
repaint();
fParent.repaint();
} }


void Widget::move(int x, int y) void Widget::move(int x, int y)
{ {
fArea.move(x, y); fArea.move(x, y);
repaint();
fParent.repaint();
} }


void Widget::move(const Point<int>& pos) void Widget::move(const Point<int>& pos)
{ {
fArea.move(pos); fArea.move(pos);
repaint();
fParent.repaint();
} }


int Widget::getWidth() const
int Widget::getWidth() const noexcept
{ {
return fArea.getWidth(); return fArea.getWidth();
} }


int Widget::getHeight() const
int Widget::getHeight() const noexcept
{ {
return fArea.getHeight(); return fArea.getHeight();
} }


const Size<int>& Widget::getSize() const
const Size<int>& Widget::getSize() const noexcept
{ {
return fArea.getSize(); return fArea.getSize();
} }
@@ -163,22 +167,27 @@ void Widget::setSize(const Size<int>& size)
fParent.repaint(); fParent.repaint();
} }


const Rectangle<int>& Widget::getArea() const
const Rectangle<int>& Widget::getArea() const noexcept
{ {
return fArea; return fArea;
} }


uint32_t Widget::getEventTimestamp()
{
return fParent.getEventTimestamp();
}

int Widget::getModifiers() int Widget::getModifiers()
{ {
return fParent.getModifiers(); return fParent.getModifiers();
} }


App& Widget::getApp() const
App& Widget::getParentApp() const noexcept
{ {
return fParent.getApp(); return fParent.getApp();
} }


Window& Widget::getParent() const
Window& Widget::getParentWindow() const noexcept
{ {
return fParent; return fParent;
} }
@@ -192,7 +201,7 @@ void Widget::onDisplay()
{ {
} }


bool Widget::onKeyboard(bool, unsigned)
bool Widget::onKeyboard(bool, uint32_t)
{ {
return false; return false;
} }


+ 340
- 228
source/modules/distrho/dgl/src/Window.cpp View File

@@ -14,11 +14,13 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */


#include "AppPrivate.hpp"

#include "../App.hpp"
#include "../Widget.hpp" #include "../Widget.hpp"
#include "../Window.hpp" #include "../Window.hpp"


#include <cassert>
#include <list>

#include "pugl/pugl.h" #include "pugl/pugl.h"


#if DGL_OS_WINDOWS #if DGL_OS_WINDOWS
@@ -32,11 +34,9 @@ extern "C" {
# include "pugl/pugl_x11.c" # include "pugl/pugl_x11.c"
} }
#else #else
# error Unsupported platform!
# error Unsupported platform
#endif #endif


#include <cassert>

#define FOR_EACH_WIDGET(it) \ #define FOR_EACH_WIDGET(it) \
for (std::list<Widget*>::iterator it = fWidgets.begin(); it != fWidgets.end(); ++it) for (std::list<Widget*>::iterator it = fWidgets.begin(); it != fWidgets.end(); ++it)


@@ -53,15 +53,58 @@ Window* dgl_lastUiParent = nullptr;
class Window::PrivateData class Window::PrivateData
{ {
public: public:
Private(Window& self, App& app, App::PrivateData& appPriv, PrivateData& parent, intptr_t parentId = 0)
: kApp(app),
kAppPriv(appPriv),
kSelf(self),
kView(puglCreate(parentId, "Window", 100, 100, false, (parentId != 0))),
fParent(parent),
fChildFocus(nullptr),
fVisible((parentId != 0)),
fOnModal(false),
PrivateData(App& app, Window* const self)
: fApp(app),
fSelf(self),
fView(puglCreate(0, "Window", 100, 100, true, false)),
fFirstInit(true),
fVisible(false),
fResizable(true),
#if DGL_OS_WINDOWS
hwnd(0)
#elif DGL_OS_LINUX
xDisplay(nullptr),
xWindow(0)
#else
_dummy('\0')
#endif
{
init();
}

PrivateData(App& app, Window* const self, Window& parent)
: fApp(app),
fSelf(self),
fView(puglCreate(0, "Window", 100, 100, true, false)),
fFirstInit(true),
fVisible(false),
fResizable(true),
fModal(parent.pData),
#if DGL_OS_WINDOWS
hwnd(0)
#elif DGL_OS_LINUX
xDisplay(nullptr),
xWindow(0)
#else
_dummy('\0')
#endif
{
init();

#if DGL_OS_LINUX
PuglInternals* const parentImpl = parent.pData->fView->impl;

XSetTransientForHint(xDisplay, xWindow, parentImpl->win);
XFlush(xDisplay);
#endif
}

PrivateData(App& app, Window* const self, const intptr_t parentId)
: fApp(app),
fSelf(self),
fView(puglCreate(parentId, "Window", 100, 100, true, true)),
fFirstInit(true),
fVisible(true),
fResizable(false), fResizable(false),
#if DGL_OS_WINDOWS #if DGL_OS_WINDOWS
hwnd(0) hwnd(0)
@@ -69,118 +112,85 @@ public:
xDisplay(nullptr), xDisplay(nullptr),
xWindow(0) xWindow(0)
#else #else
_dummy(0)
_dummy('\0')
#endif #endif
{ {
init();

// starts visible
fApp.oneShown();
fFirstInit = false;
} }


void setup()
void init()
{ {
if (kView == nullptr)
if (fView == nullptr)
return; return;


// we can't have both
if (parent != nullptr)
{
assert(parentId == 0);
}
dgl_lastUiParent = fSelf;


puglSetHandle(kView, this);
puglSetDisplayFunc(kView, onDisplayCallback);
puglSetKeyboardFunc(kView, onKeyboardCallback);
puglSetMotionFunc(kView, onMotionCallback);
puglSetMouseFunc(kView, onMouseCallback);
puglSetScrollFunc(kView, onScrollCallback);
puglSetSpecialFunc(kView, onSpecialCallback);
puglSetReshapeFunc(kView, onReshapeCallback);
puglSetCloseFunc(kView, onCloseCallback);
puglSetHandle(fView, this);
puglSetDisplayFunc(fView, onDisplayCallback);
puglSetKeyboardFunc(fView, onKeyboardCallback);
puglSetMotionFunc(fView, onMotionCallback);
puglSetMouseFunc(fView, onMouseCallback);
puglSetScrollFunc(fView, onScrollCallback);
puglSetSpecialFunc(fView, onSpecialCallback);
puglSetReshapeFunc(fView, onReshapeCallback);
puglSetCloseFunc(fView, onCloseCallback);


#if DGL_OS_WINDOWS #if DGL_OS_WINDOWS
PuglInternals* impl = kView->impl;
PuglInternals* impl = fView->impl;
hwnd = impl->hwnd; hwnd = impl->hwnd;
#elif DGL_OS_LINUX #elif DGL_OS_LINUX
PuglInternals* impl = kView->impl;
PuglInternals* impl = fView->impl;
xDisplay = impl->display; xDisplay = impl->display;
xWindow = impl->win; xWindow = impl->win;

if (parent != nullptr && parentId == 0)
{
PuglInternals* parentImpl = parent->kView->impl;

XSetTransientForHint(xDisplay, xWindow, parentImpl->win);
XFlush(xDisplay);
}
#endif #endif


kAppPriv->addWindow(kSelf);
fApp.addWindow(fSelf);
} }


~Private()
~PrivateData()
{ {
fOnModal = false;
//fOnModal = false;
fWidgets.clear(); fWidgets.clear();


if (kView != nullptr)
if (fView != nullptr)
{ {
kAppPriv->removeWindow(kSelf);
puglDestroy(kView);
fApp.removeWindow(fSelf);
puglDestroy(fView);
} }
} }


void exec_init()
// -------------------------------------------------------------------

void close()
{ {
fOnModal = true;
assert(fParent != nullptr);
setVisible(false);


if (fParent != nullptr)
if (! fFirstInit)
{ {
fParent->fChildFocus = this;

#if DGL_OS_WINDOWS
// Center this window
PuglInternals* parentImpl = fParent->kView->impl;

RECT curRect;
RECT parentRect;
GetWindowRect(hwnd, &curRect);
GetWindowRect(parentImpl->hwnd, &parentRect);

int x = parentRect.left+(parentRect.right-curRect.right)/2;
int y = parentRect.top+(parentRect.bottom-curRect.bottom)/2;

SetWindowPos(hwnd, 0, x, y, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
UpdateWindow(hwnd);
#endif

fParent->show();
fApp.oneHidden();
fFirstInit = true;
} }

show();
}

void exec_fini()
{
fOnModal = false;

if (fParent != nullptr)
fParent->fChildFocus = nullptr;
} }


void exec(bool block)
void exec(const bool lockWait)
{ {
exec_init(); exec_init();


if (block)
if (lockWait)
{ {
while (fVisible && fOnModal)
while (fVisible && fModal.enabled)
{ {
// idle() // idle()
puglProcessEvents(kView);
puglProcessEvents(fView);


if (fParent != nullptr)
fParent->idle();
if (fModal.parent != nullptr)
fModal.parent->idle();


dgl_msleep(10);
msleep(10);
} }


exec_fini(); exec_fini();
@@ -191,6 +201,8 @@ public:
} }
} }


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

void focus() void focus()
{ {
#if DGL_OS_WINDOWS #if DGL_OS_WINDOWS
@@ -198,7 +210,7 @@ public:
SetActiveWindow(hwnd); SetActiveWindow(hwnd);
SetFocus(hwnd); SetFocus(hwnd);
#elif DGL_OS_MAC #elif DGL_OS_MAC
puglImplFocus(kView);
puglImplFocus(fView);
#elif DGL_OS_LINUX #elif DGL_OS_LINUX
XRaiseWindow(xDisplay, xWindow); XRaiseWindow(xDisplay, xWindow);
XSetInputFocus(xDisplay, xWindow, RevertToPointerRoot, CurrentTime); XSetInputFocus(xDisplay, xWindow, RevertToPointerRoot, CurrentTime);
@@ -208,60 +220,41 @@ public:


void idle() void idle()
{ {
puglProcessEvents(kView);
puglProcessEvents(fView);


if (fVisible && fOnModal && fParent != nullptr)
fParent->idle();
if (fVisible && fModal.enabled && fModal.parent != nullptr)
fModal.parent->idle();
} }


void repaint() void repaint()
{ {
puglPostRedisplay(kView);
}

void show()
{
setVisible(true);
puglPostRedisplay(fView);
} }


void hide()
{
setVisible(false);
}

void close()
{
setVisible(false, true);
}
// -------------------------------------------------------------------


bool isVisible()
bool isVisible() const noexcept
{ {
return fVisible; return fVisible;
} }


void setResizable(bool yesNo)
{
if (fResizable == yesNo)
return;

fResizable = yesNo;

//setSize(kView->width, kView->height, true);
}

void setVisible(bool yesNo, bool closed = false)
void setVisible(const bool yesNo)
{ {
if (fVisible == yesNo) if (fVisible == yesNo)
return; return;


fVisible = yesNo; fVisible = yesNo;


if (yesNo && fFirstInit)
setSize(fView->width, fView->height, true);

#if DGL_OS_WINDOWS #if DGL_OS_WINDOWS
if (yesNo) if (yesNo)
{ {
ShowWindow(hwnd, WS_VISIBLE); ShowWindow(hwnd, WS_VISIBLE);
ShowWindow(hwnd, SW_RESTORE);
//SetForegroundWindow(hwnd);

if (! fFirstInit)
ShowWindow(hwnd, SW_RESTORE);
} }
else else
{ {
@@ -270,7 +263,7 @@ public:


UpdateWindow(hwnd); UpdateWindow(hwnd);
#elif DGL_OS_MAC #elif DGL_OS_MAC
puglImplSetVisible(kView, yesNo);
puglImplSetVisible(fView, yesNo);
#elif DGL_OS_LINUX #elif DGL_OS_LINUX
if (yesNo) if (yesNo)
XMapRaised(xDisplay, xWindow); XMapRaised(xDisplay, xWindow);
@@ -282,30 +275,62 @@ public:


if (yesNo) if (yesNo)
{ {
kAppPriv->oneShown();
if (fFirstInit)
{
fApp.oneShown();
fFirstInit = false;
}
} }
else
{
if (fOnModal)
exec_fini();
else if (fModal.enabled)
exec_fini();
}


if (closed)
kAppPriv->oneHidden();
}
// -------------------------------------------------------------------

bool isResizable() const noexcept
{
return fResizable;
}

void setResizable(const bool yesNo)
{
if (fResizable == yesNo)
return;

fResizable = yesNo;

setSize(fView->width, fView->height, true);
}

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

int getWidth() const noexcept
{
return fView->width;
}

int getHeight() const noexcept
{
return fView->height;
}

Size<int> getSize() const noexcept
{
return Size<int>(fView->width, fView->height);
} }


void setSize(unsigned int width, unsigned int height /*, bool forced = false*/)
void setSize(unsigned int width, unsigned int height, const bool forced = false)
{ {
if (width == 0) if (width == 0)
width = 1; width = 1;
if (height == 0) if (height == 0)
height = 1; height = 1;


kView->width = width;
kView->height = height;
fView->width = width;
fView->height = height;


//if (kView->width == width && kView->height == height && ! forced)
// return;
if (fView->width == (int)width && fView->height == (int)height && ! forced)
return;


#if DGL_OS_WINDOWS #if DGL_OS_WINDOWS
int winFlags = WS_POPUPWINDOW | WS_CAPTION; int winFlags = WS_POPUPWINDOW | WS_CAPTION;
@@ -319,7 +344,7 @@ public:
SetWindowPos(hwnd, 0, 0, 0, wr.right-wr.left, wr.bottom-wr.top, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOZORDER); SetWindowPos(hwnd, 0, 0, 0, wr.right-wr.left, wr.bottom-wr.top, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOZORDER);
UpdateWindow(hwnd); UpdateWindow(hwnd);
#elif DGL_OS_MAC #elif DGL_OS_MAC
puglImplSetSize(kView, width, height);
puglImplSetSize(fView, width, height);
#elif DGL_OS_LINUX #elif DGL_OS_LINUX
XResizeWindow(xDisplay, xWindow, width, height); XResizeWindow(xDisplay, xWindow, width, height);


@@ -343,43 +368,94 @@ public:
repaint(); repaint();
} }


void setWindowTitle(const char* title)
// -------------------------------------------------------------------

void setTitle(const char* const title)
{ {
#if DGL_OS_WINDOWS #if DGL_OS_WINDOWS
SetWindowTextA(hwnd, title); SetWindowTextA(hwnd, title);
#elif DGL_OS_MAC #elif DGL_OS_MAC
puglImplSetTitle(kView, title);
puglImplSetTitle(fView, title);
#elif DGL_OS_LINUX #elif DGL_OS_LINUX
XStoreName(xDisplay, xWindow, title); XStoreName(xDisplay, xWindow, title);
XFlush(xDisplay); XFlush(xDisplay);
#endif #endif
} }


App* getApp() const
App& getApp() const noexcept
{ {
return kApp;
return fApp;
} }


int getModifiers() const int getModifiers() const
{ {
return puglGetModifiers(kView);
return puglGetModifiers(fView);
}

uint32_t getEventTimestamp() const
{
return puglGetEventTimestamp(fView);
} }


intptr_t getWindowId() const intptr_t getWindowId() const
{ {
return puglGetNativeWindow(kView);
return puglGetNativeWindow(fView);
} }


void addWidget(Widget* widget)
// -------------------------------------------------------------------

void addWidget(Widget* const widget)
{ {
fWidgets.push_back(widget); fWidgets.push_back(widget);
} }


void removeWidget(Widget* widget)
void removeWidget(Widget* const widget)
{ {
fWidgets.remove(widget); fWidgets.remove(widget);
} }


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

void exec_init()
{
fModal.enabled = true;
assert(fModal.parent != nullptr);

if (fModal.parent == nullptr)
return setVisible(true);

fModal.parent->fModal.childFocus = this;

#if DGL_OS_WINDOWS
// Center this window
PuglInternals* const parentImpl = fParent->fView->impl;

RECT curRect;
RECT parentRect;
GetWindowRect(hwnd, &curRect);
GetWindowRect(parentImpl->hwnd, &parentRect);

int x = parentRect.left+(parentRect.right-curRect.right)/2;
int y = parentRect.top +(parentRect.bottom-curRect.bottom)/2;

SetWindowPos(hwnd, 0, x, y, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
UpdateWindow(hwnd);
#endif

fModal.parent->setVisible(true);
setVisible(true);
}

void exec_fini()
{
fModal.enabled = false;

if (fModal.parent != nullptr)
fModal.parent->fModal.childFocus = nullptr;
}

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

protected: protected:
void onDisplay() void onDisplay()
{ {
@@ -388,93 +464,85 @@ protected:
FOR_EACH_WIDGET(it) FOR_EACH_WIDGET(it)
{ {
Widget* const widget(*it); Widget* const widget(*it);

if (widget->isVisible()) if (widget->isVisible())
widget->onDisplay(); widget->onDisplay();
} }
} }


void onKeyboard(bool press, uint32_t key)
void onKeyboard(const bool press, const uint32_t key)
{ {
if (fChildFocus != nullptr)
return fChildFocus->focus();
if (fModal.childFocus != nullptr)
return fModal.childFocus->focus();


FOR_EACH_WIDGET_INV(rit) FOR_EACH_WIDGET_INV(rit)
{ {
Widget* const widget(*rit); Widget* const widget(*rit);
if (widget->isVisible())
{
if (widget->onKeyboard(press, key))
break;
}

if (widget->isVisible() && widget->onKeyboard(press, key))
break;
} }
} }


void onMouse(int button, bool press, int x, int y)
void onMouse(const int button, const bool press, const int x, const int y)
{ {
if (fChildFocus != nullptr)
return fChildFocus->focus();
if (fModal.childFocus != nullptr)
return fModal.childFocus->focus();


FOR_EACH_WIDGET_INV(rit) FOR_EACH_WIDGET_INV(rit)
{ {
Widget* const widget(*rit); Widget* const widget(*rit);
if (widget->isVisible())
{
if (widget->onMouse(button, press, x, y))
break;
}

if (widget->isVisible() && widget->onMouse(button, press, x, y))
break;
} }
} }


void onMotion(int x, int y)
void onMotion(const int x, const int y)
{ {
if (fChildFocus != nullptr)
if (fModal.childFocus != nullptr)
return; return;


FOR_EACH_WIDGET_INV(rit) FOR_EACH_WIDGET_INV(rit)
{ {
Widget* const widget(*rit); Widget* const widget(*rit);
if (widget->isVisible())
{
if (widget->onMotion(x, y))
break;
}

if (widget->isVisible() && widget->onMotion(x, y))
break;
} }
} }


void onScroll(float dx, float dy)
void onScroll(const float dx, const float dy)
{ {
if (fChildFocus != nullptr)
if (fModal.childFocus != nullptr)
return; return;


FOR_EACH_WIDGET_INV(rit) FOR_EACH_WIDGET_INV(rit)
{ {
Widget* const widget(*rit); Widget* const widget(*rit);
if (widget->isVisible())
{
if (widget->onScroll(dx, dy))
break;
}

if (widget->isVisible() && widget->onScroll(dx, dy))
break;
} }
} }


void onSpecial(bool press, Key key)
void onSpecial(const bool press, const Key key)
{ {
if (fChildFocus != nullptr)
if (fModal.childFocus != nullptr)
return; return;


FOR_EACH_WIDGET_INV(rit) FOR_EACH_WIDGET_INV(rit)
{ {
Widget* const widget(*rit); Widget* const widget(*rit);
if (widget->isVisible())
{
if (widget->onSpecial(press, key))
break;
}

if (widget->isVisible() && widget->onSpecial(press, key))
break;
} }
} }


void onReshape(int width, int height)
void onReshape(const int width, const int height)
{ {
printf("resized: %i:%i\n", width, height);
FOR_EACH_WIDGET(it) FOR_EACH_WIDGET(it)
{ {
Widget* const widget(*it); Widget* const widget(*it);
@@ -484,10 +552,10 @@ protected:


void onClose() void onClose()
{ {
fOnModal = false;
fModal.enabled = false;


if (fChildFocus != nullptr)
fChildFocus->onClose();
if (fModal.childFocus != nullptr)
fModal.childFocus->onClose();


FOR_EACH_WIDGET(it) FOR_EACH_WIDGET(it)
{ {
@@ -498,31 +566,53 @@ protected:
close(); close();
} }


private:
App* const kApp;
App::Private* const kAppPriv;
Window* const kSelf;
PuglView* const kView;
// -------------------------------------------------------------------


Private* fParent;
Private* fChildFocus;
bool fVisible;
bool fOnModal;
bool fResizable;
private:
App& fApp;
Window* const fSelf;
PuglView* const fView;


bool fFirstInit;
bool fVisible;
bool fResizable;
std::list<Widget*> fWidgets; std::list<Widget*> fWidgets;


struct Modal {
bool enabled;
PrivateData* parent;
PrivateData* childFocus;

Modal()
: enabled(false),
parent(nullptr),
childFocus(nullptr) {}

Modal(PrivateData* const p)
: enabled(false),
parent(p),
childFocus(nullptr) {}

~Modal()
{
assert(! enabled);
assert(childFocus == nullptr);
}
} fModal;

#if DGL_OS_WINDOWS #if DGL_OS_WINDOWS
HWND hwnd; HWND hwnd;
#elif DGL_OS_LINUX #elif DGL_OS_LINUX
Display* xDisplay; Display* xDisplay;
::Window xWindow; ::Window xWindow;
#else #else
int _dummy;
char _dummy;
#endif #endif


// -------------------------------------------------------------------
// Callbacks // Callbacks
#define handlePtr ((Private*)puglGetHandle(view))

#define handlePtr ((PrivateData*)puglGetHandle(view))


static void onDisplayCallback(PuglView* view) static void onDisplayCallback(PuglView* view)
{ {
@@ -571,21 +661,18 @@ private:
// Window // Window


Window::Window(App& app) Window::Window(App& app)
: pData(new Private(this, app, app->pData, nullptr))
: pData(new PrivateData(app, this))
{ {
dgl_lastUiParent = this;
} }


Window::Window(App& app, Window& parent) Window::Window(App& app, Window& parent)
: pData(new Private(this, app, app->pData, parent->pData))
: pData(new PrivateData(app, this, parent))
{ {
dgl_lastUiParent = this;
} }


Window::Window(App*&app, intptr_t parentId)
: pData(new Private(this, app, app->pData, nullptr, parentId))
Window::Window(App& app, intptr_t parentId)
: pData(new PrivateData(app, this, parentId))
{ {
dgl_lastUiParent = this;
} }


Window::~Window() Window::~Window()
@@ -593,9 +680,24 @@ Window::~Window()
delete pData; delete pData;
} }


void Window::exec(bool lock)
void Window::show()
{
pData->setVisible(true);
}

void Window::hide()
{
pData->setVisible(false);
}

void Window::close()
{ {
pData->exec(lock);
pData->close();
}

void Window::exec(bool lockWait)
{
pData->exec(lockWait);
} }


void Window::focus() void Window::focus()
@@ -613,69 +715,79 @@ void Window::repaint()
pData->repaint(); pData->repaint();
} }


bool Window::isVisible()
bool Window::isVisible() const noexcept
{ {
return pData->isVisible(); return pData->isVisible();
} }


void Window::setVisible(bool yesNo)
{
pData->setVisible(yesNo);
}

bool Window::isResizable() const noexcept
{
return pData->isResizable();
}

void Window::setResizable(bool yesNo) void Window::setResizable(bool yesNo)
{ {
pData->setResizable(yesNo); pData->setResizable(yesNo);
} }


void Window::setVisible(bool yesNo)
int Window::getWidth() const noexcept
{ {
pData->setVisible(yesNo);
return pData->getWidth();
} }


void Window::setSize(unsigned int width, unsigned int height)
int Window::getHeight() const noexcept
{ {
pData->setSize(width, height);
return pData->getHeight();
} }


void Window::setWindowTitle(const char* title)
Size<int> Window::getSize() const noexcept
{ {
pData->setWindowTitle(title);
return pData->getSize();
} }


App* Window::getApp() const
void Window::setSize(unsigned int width, unsigned int height)
{ {
return pData->getApp();
pData->setSize(width, height);
} }


int Window::getModifiers() const
void Window::setTitle(const char* title)
{ {
return pData->getModifiers();
pData->setTitle(title);
} }


intptr_t Window::getWindowId() const
App& Window::getApp() const noexcept
{ {
return pData->getWindowId();
return pData->getApp();
} }


void Window::addWidget(Widget* widget)
int Window::getModifiers() const
{ {
pData->addWidget(widget);
return pData->getModifiers();
} }


void Window::removeWidget(Widget* widget)
uint32_t Window::getEventTimestamp() const
{ {
pData->removeWidget(widget);
return pData->getEventTimestamp();
} }


void Window::show()
intptr_t Window::getWindowId() const
{ {
setVisible(true);
return pData->getWindowId();
} }


void Window::hide()
void Window::addWidget(Widget* const widget)
{ {
setVisible(false);
pData->addWidget(widget);
} }


void Window::close()
void Window::removeWidget(Widget* const widget)
{ {
pData->close();
pData->removeWidget(widget);
} }


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


+ 3
- 3
source/modules/distrho/src/DistrhoUIDSSI.cpp View File

@@ -17,7 +17,7 @@
#include "DistrhoUIInternal.hpp" #include "DistrhoUIInternal.hpp"


#ifdef DISTRHO_UI_EXTERNAL #ifdef DISTRHO_UI_EXTERNAL
# error DSSI always uses external UI, no wrapper neeed!
# error DSSI always uses external UI, no wrapper needed!
#endif #endif


#include <lo/lo.h> #include <lo/lo.h>
@@ -134,7 +134,7 @@ public:
# endif # endif
} }
#else #else
glWindow.setWindowTitle(uiTitle);
glWindow.setTitle(uiTitle);
#endif #endif
} }


@@ -164,7 +164,7 @@ public:
{ {
fOscData.idle(); fOscData.idle();
fUI.idle(); fUI.idle();
dgl_msleep(50);
msleep(50);
} }
#endif #endif
} }


+ 2
- 1
source/modules/distrho/src/DistrhoUIInternal.hpp View File

@@ -119,7 +119,7 @@ public:
UIInternal(void* ptr, intptr_t winId, editParamFunc editParamCall, setParamFunc setParamCall, setStateFunc setStateCall, sendNoteFunc sendNoteCall, uiResizeFunc uiResizeCall) UIInternal(void* ptr, intptr_t winId, editParamFunc editParamCall, setParamFunc setParamCall, setStateFunc setStateCall, sendNoteFunc sendNoteCall, uiResizeFunc uiResizeCall)
#ifdef DISTRHO_UI_OPENGL #ifdef DISTRHO_UI_OPENGL
: glApp(), : glApp(),
glWindow(&glApp, winId),
glWindow(glApp, winId),
fUi(createUI()), fUi(createUI()),
#else #else
: fUi(createUI()), : fUi(createUI()),
@@ -140,6 +140,7 @@ public:


#ifdef DISTRHO_UI_OPENGL #ifdef DISTRHO_UI_OPENGL
glWindow.setSize(fUi->d_getWidth(), fUi->d_getHeight()); glWindow.setSize(fUi->d_getWidth(), fUi->d_getHeight());
glWindow.setResizable(false);
#else #else
assert(winId == 0); assert(winId == 0);
return; return;


+ 1
- 1
source/modules/distrho/src/DistrhoUIOpenGL.cpp View File

@@ -27,7 +27,7 @@ START_NAMESPACE_DISTRHO


OpenGLUI::OpenGLUI() OpenGLUI::OpenGLUI()
: UI(), : UI(),
Widget(DGL::dgl_lastUiParent)
Widget(*DGL::dgl_lastUiParent)
{ {
assert(DGL::dgl_lastUiParent != nullptr); assert(DGL::dgl_lastUiParent != nullptr);




+ 88
- 0
source/tests/DGL.cpp View File

@@ -0,0 +1,88 @@
/*
* Carla Tests
* Copyright (C) 2013 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/

#include "dgl/App.hpp"
#include "dgl/Geometry.hpp"
#include "dgl/Image.hpp"
#include "dgl/ImageAboutWindow.hpp"
#include "dgl/ImageButton.hpp"
#include "dgl/ImageKnob.hpp"
#include "dgl/ImageSlider.hpp"
#include "dgl/Widget.hpp"
#include "dgl/Window.hpp"

#include <cstdio>

int main()
{
USE_NAMESPACE_DGL;

msleep(1);

Point<int> pi;
Point<long> pl;
Point<float> pf;
Point<double> pd;
Point<unsigned> pu;

Size<int> si;
Size<long> sl;
Size<float> sf;
Size<double> sd;
Size<unsigned> su;

Rectangle<int> ri;
Rectangle<long> rl;
Rectangle<float> rf;
Rectangle<double> rd;
Rectangle<unsigned> ru;

Image i;

App app;
Window win(app);
win.setSize(500, 500);
win.show();

// for (int i=0; i < 1000; ++i)
// {
// app.idle();
//
// if (app.isQuiting())
// break;

// if (i % 30 == 0)
// printf("SIZE: %i:%i\n", win.getWidth(), win.getHeight());

// msleep(10);
// }

app.exec();

return 0;
}

#include "dgl/src/ImageAboutWindow.cpp"
#include "dgl/src/App.cpp"
#include "dgl/src/Base.cpp"
#include "dgl/src/Geometry.cpp"
#include "dgl/src/Image.cpp"
#include "dgl/src/ImageButton.cpp"
#include "dgl/src/ImageKnob.cpp"
#include "dgl/src/ImageSlider.cpp"
#include "dgl/src/Widget.cpp"
#include "dgl/src/Window.cpp"

+ 5
- 3
source/tests/Makefile View File

@@ -27,7 +27,7 @@ else
ifeq ($(WIN32),true) ifeq ($(WIN32),true)
DGL_LIBS = -lopengl32 -lgdi32 DGL_LIBS = -lopengl32 -lgdi32
else else
DGL_LIBS = -lX11
DGL_LIBS = -lGL -lX11
endif endif
endif endif


@@ -44,8 +44,10 @@ CarlaString: CarlaString.cpp ../utils/CarlaString.hpp
$(CXX) $< $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@ $(CXX) $< $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@
# valgrind ./CarlaString # valgrind ./CarlaString


DGL: DGL.cpp
$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) -o $@
DGL: DGL.cpp ../modules/distrho/dgl/src/Window.cpp
$(CXX) $< $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) -o $@
# ./DGL
# valgrind ./DGL


Print: Print.cpp Print: Print.cpp
$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@ $(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@


Loading…
Cancel
Save