@@ -0,0 +1,54 @@ | |||
/* | |||
* DISTRHO Plugin Toolkit (DPT) | |||
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | |||
* or without fee is hereby granted, provided that the above copyright notice and this | |||
* permission notice appear in all copies. | |||
* | |||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
*/ | |||
#ifndef DGL_APP_HPP_INCLUDED | |||
#define DGL_APP_HPP_INCLUDED | |||
#include "Base.hpp" | |||
START_NAMESPACE_DGL | |||
class Window; | |||
// ----------------------------------------------------------------------- | |||
class App | |||
{ | |||
public: | |||
App(); | |||
~App(); | |||
void idle(); | |||
void exec(); | |||
void quit(); | |||
bool isQuiting() const; | |||
private: | |||
struct PrivateData; | |||
PrivateData* const pData; | |||
friend class Window; | |||
void addWindow(Window* const window); | |||
void removeWindow(Window* const window); | |||
void oneShown(); | |||
void oneHidden(); | |||
}; | |||
// ----------------------------------------------------------------------- | |||
END_NAMESPACE_DGL | |||
#endif // DGL_APP_HPP_INCLUDED |
@@ -0,0 +1,143 @@ | |||
/* | |||
* DISTRHO Plugin Toolkit (DPT) | |||
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | |||
* or without fee is hereby granted, provided that the above copyright notice and this | |||
* permission notice appear in all copies. | |||
* | |||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
*/ | |||
#ifndef DGL_BASE_HPP_INCLUDED | |||
#define DGL_BASE_HPP_INCLUDED | |||
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) | |||
# define DGL_OS_WINDOWS 1 | |||
#elif defined(__APPLE__) | |||
# define DGL_OS_MAC 1 | |||
#elif defined(__HAIKU__) | |||
# define DGL_OS_HAIKU 1 | |||
#elif defined(__linux__) | |||
# define DGL_OS_LINUX 1 | |||
#endif | |||
#if defined(HAVE_CPP11_SUPPORT) | |||
# define PROPER_CPP11_SUPPORT | |||
#elif defined(__GNUC__) && (__cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)) | |||
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 | |||
# define PROPER_CPP11_SUPPORT | |||
# if (__GNUC__ * 100 + __GNUC_MINOR__) < 407 | |||
# define override // gcc4.7+ only | |||
# endif | |||
# endif | |||
#endif | |||
#ifndef PROPER_CPP11_SUPPORT | |||
# ifndef __clang__ | |||
# define noexcept throw() | |||
# endif | |||
# define override | |||
# define nullptr (0) | |||
#endif | |||
#ifndef DGL_NAMESPACE | |||
# define DGL_NAMESPACE DGL | |||
#endif | |||
#define START_NAMESPACE_DGL namespace DGL_NAMESPACE { | |||
#define END_NAMESPACE_DGL } | |||
#define USE_NAMESPACE_DGL using namespace DGL_NAMESPACE; | |||
#if DGL_OS_MAC | |||
# include <OpenGL/gl.h> | |||
#else | |||
# include <GL/gl.h> | |||
#endif | |||
#if defined(GL_BGR_EXT) && ! defined(GL_BGR) | |||
# define GL_BGR GL_BGR_EXT | |||
#endif | |||
#if defined(GL_BGRA_EXT) && ! defined(GL_BGRA) | |||
# define GL_BGRA GL_BGRA_EXT | |||
#endif | |||
#ifndef GL_CLAMP_TO_BORDER | |||
# define GL_CLAMP_TO_BORDER 0x812D | |||
#endif | |||
START_NAMESPACE_DGL | |||
// ----------------------------------------------------------------------- | |||
/* | |||
* Convenience symbols for ASCII control characters. | |||
*/ | |||
enum Char { | |||
CHAR_BACKSPACE = 0x08, | |||
CHAR_ESCAPE = 0x1B, | |||
CHAR_DELETE = 0x7F | |||
}; | |||
/* | |||
* Special (non-Unicode) keyboard keys. | |||
*/ | |||
enum Key { | |||
KEY_F1 = 1, | |||
KEY_F2, | |||
KEY_F3, | |||
KEY_F4, | |||
KEY_F5, | |||
KEY_F6, | |||
KEY_F7, | |||
KEY_F8, | |||
KEY_F9, | |||
KEY_F10, | |||
KEY_F11, | |||
KEY_F12, | |||
KEY_LEFT, | |||
KEY_UP, | |||
KEY_RIGHT, | |||
KEY_DOWN, | |||
KEY_PAGE_UP, | |||
KEY_PAGE_DOWN, | |||
KEY_HOME, | |||
KEY_END, | |||
KEY_INSERT, | |||
KEY_SHIFT, | |||
KEY_CTRL, | |||
KEY_ALT, | |||
KEY_SUPER | |||
}; | |||
/* | |||
* Keyboard modifier flags. | |||
*/ | |||
enum Modifier { | |||
MODIFIER_SHIFT = 1 << 0, /**< Shift key */ | |||
MODIFIER_CTRL = 1 << 1, /**< Control key */ | |||
MODIFIER_ALT = 1 << 2, /**< Alt/Option key */ | |||
MODIFIER_SUPER = 1 << 3 /**< Mod4/Command/Windows key */ | |||
}; | |||
/* | |||
* Cross-platform sleep function. | |||
*/ | |||
void sleep(unsigned int secs); | |||
/* | |||
* Cross-platform msleep function. | |||
*/ | |||
void msleep(unsigned int msecs); | |||
// ----------------------------------------------------------------------- | |||
END_NAMESPACE_DGL | |||
#endif // DGL_BASE_HPP_INCLUDED |
@@ -0,0 +1,142 @@ | |||
/* | |||
* DISTRHO Plugin Toolkit (DPT) | |||
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | |||
* or without fee is hereby granted, provided that the above copyright notice and this | |||
* permission notice appear in all copies. | |||
* | |||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
*/ | |||
#ifndef DGL_CAIRO_WIDGET_HPP_INCLUDED | |||
#define DGL_CAIRO_WIDGET_HPP_INCLUDED | |||
#include "Widget.hpp" | |||
#include <cairo.h> | |||
START_NAMESPACE_DGL | |||
// ----------------------------------------------------------------------- | |||
class CairoWidget : public Widget | |||
{ | |||
public: | |||
CairoWidget(Window& parent) | |||
: Widget(parent), | |||
fContext(nullptr), | |||
fSurface(nullptr), | |||
fTextureId(0) | |||
{ | |||
} | |||
protected: | |||
virtual void cairoDisplay(cairo_t* const context) = 0; | |||
private: | |||
void onReshape(int width, int height) override | |||
{ | |||
// handle resize | |||
setSize(width, height); | |||
Widget::onReshape(width, height); | |||
// free previous if needed | |||
onClose(); | |||
// create new | |||
fSurface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, width, height); | |||
fContext = cairo_create(fSurface); | |||
glGenTextures(1, &fTextureId); | |||
} | |||
void onClose() override | |||
{ | |||
if (fContext != nullptr) | |||
{ | |||
cairo_destroy(fContext); | |||
fContext = nullptr; | |||
} | |||
if (fSurface != nullptr) | |||
{ | |||
cairo_surface_destroy(fSurface); | |||
fSurface = nullptr; | |||
} | |||
if (fTextureId != 0) | |||
{ | |||
glDeleteTextures(1, &fTextureId); | |||
fTextureId = 0; | |||
} | |||
} | |||
void onDisplay() override | |||
{ | |||
// wait for first resize | |||
if (fSurface == nullptr || fContext == nullptr) | |||
{ | |||
glClear(GL_COLOR_BUFFER_BIT); | |||
return; | |||
} | |||
const int width = getWidth(); | |||
const int height = getHeight(); | |||
// draw cairo stuff | |||
cairoDisplay(fContext); | |||
// get cairo surface data (RGB24) | |||
unsigned char* const surfaceData = cairo_image_surface_get_data(fSurface); | |||
// enable GL texture | |||
glEnable(GL_TEXTURE_RECTANGLE_ARB); | |||
// set texture params | |||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); | |||
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); | |||
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | |||
// bind texture to surface data | |||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, fTextureId); | |||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, surfaceData); | |||
// draw the texture | |||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | |||
glBegin(GL_QUADS); | |||
glTexCoord2i(0, height); | |||
glVertex2i(0, height); | |||
glTexCoord2i(width, height); | |||
glVertex2i(width, height); | |||
glTexCoord2i(width, 0); | |||
glVertex2i(width, 0); | |||
glTexCoord2i(0, 0); | |||
glVertex2i(0, 0); | |||
glEnd(); | |||
// cleanup | |||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0); | |||
glDisable(GL_TEXTURE_RECTANGLE_ARB); | |||
} | |||
private: | |||
cairo_t* fContext; | |||
cairo_surface_t* fSurface; | |||
GLuint fTextureId; | |||
}; | |||
// ----------------------------------------------------------------------- | |||
END_NAMESPACE_DGL | |||
#endif // DGL_CAIRO_WIDGET_HPP_INCLUDED |
@@ -0,0 +1,133 @@ | |||
/* | |||
* DISTRHO Plugin Toolkit (DPT) | |||
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | |||
* or without fee is hereby granted, provided that the above copyright notice and this | |||
* permission notice appear in all copies. | |||
* | |||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
*/ | |||
#ifndef DGL_GEOMETRY_HPP_INCLUDED | |||
#define DGL_GEOMETRY_HPP_INCLUDED | |||
#include "Base.hpp" | |||
START_NAMESPACE_DGL | |||
// ----------------------------------------------------------------------- | |||
template<typename T> | |||
class Point | |||
{ | |||
public: | |||
Point() noexcept; | |||
Point(T x, T y) noexcept; | |||
Point(const Point<T>& pos) noexcept; | |||
T getX() const noexcept; | |||
T getY() const noexcept; | |||
void setX(T x) noexcept; | |||
void setY(T y) noexcept; | |||
void move(T x, T y) noexcept; | |||
void move(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; | |||
bool operator==(const Point<T>& pos) const noexcept; | |||
bool operator!=(const Point<T>& pos) const noexcept; | |||
private: | |||
T fX, fY; | |||
template<typename> friend class Rectangle; | |||
}; | |||
// ----------------------------------------------------------------------- | |||
template<typename T> | |||
class Size | |||
{ | |||
public: | |||
Size() noexcept; | |||
Size(T width, T height) noexcept; | |||
Size(const Size<T>& size) noexcept; | |||
T getWidth() const noexcept; | |||
T getHeight() const noexcept; | |||
void setWidth(T width) noexcept; | |||
void setHeight(T height) 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*=(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: | |||
T fWidth, fHeight; | |||
template<typename> friend class Rectangle; | |||
}; | |||
// ----------------------------------------------------------------------- | |||
template<typename T> | |||
class Rectangle | |||
{ | |||
public: | |||
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: | |||
Point<T> fPos; | |||
Size<T> fSize; | |||
}; | |||
// ----------------------------------------------------------------------- | |||
END_NAMESPACE_DGL | |||
#endif // DGL_GEOMETRY_HPP_INCLUDED |
@@ -0,0 +1,66 @@ | |||
/* | |||
* DISTRHO Plugin Toolkit (DPT) | |||
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | |||
* or without fee is hereby granted, provided that the above copyright notice and this | |||
* permission notice appear in all copies. | |||
* | |||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
*/ | |||
#ifndef DGL_IMAGE_HPP_INCLUDED | |||
#define DGL_IMAGE_HPP_INCLUDED | |||
#include "Geometry.hpp" | |||
START_NAMESPACE_DGL | |||
// ----------------------------------------------------------------------- | |||
class Image | |||
{ | |||
public: | |||
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) noexcept; | |||
void loadFromMemory(const char* rawData, const Size<int>& size, GLenum format = GL_BGRA, GLenum type = GL_UNSIGNED_BYTE) noexcept; | |||
bool isValid() const noexcept; | |||
int getWidth() const noexcept; | |||
int getHeight() const noexcept; | |||
const Size<int>& getSize() const noexcept; | |||
const char* getRawData() const noexcept; | |||
GLenum getFormat() const noexcept; | |||
GLenum getType() const noexcept; | |||
void draw() const; | |||
void draw(int x, int y) const; | |||
void draw(const Point<int>& pos) const; | |||
Image& operator=(const Image& image) noexcept; | |||
bool operator==(const Image& image) const noexcept; | |||
bool operator!=(const Image& image) const noexcept; | |||
private: | |||
const char* fRawData; | |||
Size<int> fSize; | |||
GLenum fFormat; | |||
GLenum fType; | |||
}; | |||
// ----------------------------------------------------------------------- | |||
END_NAMESPACE_DGL | |||
#endif // DGL_IMAGE_HPP_INCLUDED |
@@ -0,0 +1,56 @@ | |||
/* | |||
* DISTRHO Plugin Toolkit (DPT) | |||
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | |||
* or without fee is hereby granted, provided that the above copyright notice and this | |||
* permission notice appear in all copies. | |||
* | |||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
*/ | |||
#ifndef DGL_IMAGE_ABOUT_WINDOW_HPP_INCLUDED | |||
#define DGL_IMAGE_ABOUT_WINDOW_HPP_INCLUDED | |||
#include "Image.hpp" | |||
#include "Widget.hpp" | |||
#include "Window.hpp" | |||
#ifdef PROPER_CPP11_SUPPORT | |||
# include <cstdint> | |||
#else | |||
# include <stdint.h> | |||
#endif | |||
START_NAMESPACE_DGL | |||
// ----------------------------------------------------------------------- | |||
class ImageAboutWindow : public Window, | |||
public Widget | |||
{ | |||
public: | |||
ImageAboutWindow(App& app, Window& parent, const Image& image = Image()); | |||
ImageAboutWindow(Widget* widget, const Image& image = Image()); | |||
void setImage(const Image& image); | |||
protected: | |||
void onDisplay() override; | |||
bool onMouse(int button, bool press, int x, int y) override; | |||
bool onKeyboard(bool press, uint32_t key) override; | |||
private: | |||
Image fImgBackground; | |||
}; | |||
// ----------------------------------------------------------------------- | |||
END_NAMESPACE_DGL | |||
#endif // DGL_IMAGE_ABOUT_WINDOW_HPP_INCLUDED |
@@ -0,0 +1,64 @@ | |||
/* | |||
* DISTRHO Plugin Toolkit (DPT) | |||
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | |||
* or without fee is hereby granted, provided that the above copyright notice and this | |||
* permission notice appear in all copies. | |||
* | |||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
*/ | |||
#ifndef DGL_IMAGE_BUTTON_HPP_INCLUDED | |||
#define DGL_IMAGE_BUTTON_HPP_INCLUDED | |||
#include "Image.hpp" | |||
#include "Widget.hpp" | |||
START_NAMESPACE_DGL | |||
// ----------------------------------------------------------------------- | |||
class ImageButton : public Widget | |||
{ | |||
public: | |||
class Callback | |||
{ | |||
public: | |||
virtual ~Callback() {} | |||
virtual void imageButtonClicked(ImageButton* imageButton, int button) = 0; | |||
}; | |||
ImageButton(Window& parent, const Image& image); | |||
ImageButton(Widget* widget, const Image& image); | |||
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(const ImageButton& imageButton); | |||
void setCallback(Callback* callback); | |||
protected: | |||
void onDisplay() override; | |||
bool onMouse(int button, bool press, int x, int y) override; | |||
bool onMotion(int x, int y) override; | |||
private: | |||
Image fImageNormal; | |||
Image fImageHover; | |||
Image fImageDown; | |||
Image* fCurImage; | |||
int fCurButton; | |||
Callback* fCallback; | |||
}; | |||
// ----------------------------------------------------------------------- | |||
END_NAMESPACE_DGL | |||
#endif // DGL_IMAGE_BUTTON_HPP_INCLUDED |
@@ -0,0 +1,89 @@ | |||
/* | |||
* DISTRHO Plugin Toolkit (DPT) | |||
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | |||
* or without fee is hereby granted, provided that the above copyright notice and this | |||
* permission notice appear in all copies. | |||
* | |||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
*/ | |||
#ifndef DGL_IMAGE_KNOB_HPP_INCLUDED | |||
#define DGL_IMAGE_KNOB_HPP_INCLUDED | |||
#include "Image.hpp" | |||
#include "Widget.hpp" | |||
START_NAMESPACE_DGL | |||
// ----------------------------------------------------------------------- | |||
class ImageKnob : public Widget | |||
{ | |||
public: | |||
enum Orientation { | |||
Horizontal, | |||
Vertical | |||
}; | |||
class Callback | |||
{ | |||
public: | |||
virtual ~Callback() {} | |||
virtual void imageKnobDragStarted(ImageKnob* imageKnob) = 0; | |||
virtual void imageKnobDragFinished(ImageKnob* imageKnob) = 0; | |||
virtual void imageKnobValueChanged(ImageKnob* imageKnob, float value) = 0; | |||
}; | |||
ImageKnob(Window& parent, const Image& image, Orientation orientation = Vertical); | |||
ImageKnob(Widget* widget, const Image& image, Orientation orientation = Vertical); | |||
ImageKnob(const ImageKnob& imageKnob); | |||
float getValue() const; | |||
void setOrientation(Orientation orientation); | |||
void setRange(float min, float max); | |||
void setValue(float value, bool sendCallback = false); | |||
void setRotationAngle(int angle); | |||
void setCallback(Callback* callback); | |||
protected: | |||
void onDisplay() override; | |||
bool onMouse(int button, bool press, int x, int y) override; | |||
bool onMotion(int x, int y) override; | |||
void onReshape(int width, int height) override; | |||
void onClose() override; | |||
private: | |||
Image fImage; | |||
float fMinimum; | |||
float fMaximum; | |||
float fValue; | |||
Orientation fOrientation; | |||
int fRotationAngle; | |||
bool fDragging; | |||
int fLastX; | |||
int fLastY; | |||
Callback* fCallback; | |||
bool fIsImgVertical; | |||
int fImgLayerSize; | |||
int fImgLayerCount; | |||
Rectangle<int> fKnobArea; | |||
GLuint fTextureId; | |||
}; | |||
// ----------------------------------------------------------------------- | |||
END_NAMESPACE_DGL | |||
#endif // DGL_IMAGE_KNOB_HPP_INCLUDED |
@@ -0,0 +1,85 @@ | |||
/* | |||
* DISTRHO Plugin Toolkit (DPT) | |||
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | |||
* or without fee is hereby granted, provided that the above copyright notice and this | |||
* permission notice appear in all copies. | |||
* | |||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
*/ | |||
#ifndef DGL_IMAGE_SLIDER_HPP_INCLUDED | |||
#define DGL_IMAGE_SLIDER_HPP_INCLUDED | |||
#include "Image.hpp" | |||
#include "Widget.hpp" | |||
START_NAMESPACE_DGL | |||
// ----------------------------------------------------------------------- | |||
class ImageSlider : public Widget | |||
{ | |||
public: | |||
class Callback | |||
{ | |||
public: | |||
virtual ~Callback() {} | |||
virtual void imageSliderDragStarted(ImageSlider* imageSlider) = 0; | |||
virtual void imageSliderDragFinished(ImageSlider* imageSlider) = 0; | |||
virtual void imageSliderValueChanged(ImageSlider* imageSlider, float value) = 0; | |||
}; | |||
ImageSlider(Window& parent, const Image& image); | |||
ImageSlider(Widget* widget, const Image& image); | |||
ImageSlider(const ImageSlider& imageSlider); | |||
float getValue() const; | |||
void setStartPos(const Point<int>& startPos); | |||
void setStartPos(int x, int y); | |||
void setEndPos(const Point<int>& endPos); | |||
void setEndPos(int x, int y); | |||
void setRange(float min, float max); | |||
void setValue(float value, bool sendCallback = false); | |||
void setIsSwitch(bool yesNo); | |||
void setCallback(Callback* callback); | |||
protected: | |||
void onDisplay() override; | |||
bool onMouse(int button, bool press, int x, int y) override; | |||
bool onMotion(int x, int y) override; | |||
private: | |||
Image fImage; | |||
float fMinimum; | |||
float fMaximum; | |||
float fValue; | |||
bool fIsSwitch; | |||
bool fDragging; | |||
int fStartedX; | |||
int fStartedY; | |||
Callback* fCallback; | |||
Point<int> fStartPos; | |||
Point<int> fEndPos; | |||
Rectangle<int> fSliderArea; | |||
void _recheckArea(); | |||
}; | |||
// ----------------------------------------------------------------------- | |||
END_NAMESPACE_DGL | |||
#endif // DGL_IMAGE_SLIDER_HPP_INCLUDED |
@@ -0,0 +1,67 @@ | |||
#!/usr/bin/make -f | |||
# Makefile for dgl # | |||
# ---------------- # | |||
# Created by falkTX | |||
# | |||
include Makefile.mk | |||
# -------------------------------------------------------------- | |||
BUILD_C_FLAGS += $(DGL_FLAGS) -I. | |||
BUILD_CXX_FLAGS += $(DGL_FLAGS) -I. | |||
LINK_FLAGS += $(DGL_LIBS) | |||
# -------------------------------------------------------------- | |||
OBJS = \ | |||
src/App.cpp.o \ | |||
src/Base.cpp.o \ | |||
src/Image.cpp.o \ | |||
src/ImageAboutWindow.cpp.o \ | |||
src/ImageButton.cpp.o \ | |||
src/ImageKnob.cpp.o \ | |||
src/ImageSlider.cpp.o \ | |||
src/Geometry.cpp.o \ | |||
src/Widget.cpp.o \ | |||
src/Window.cpp.o | |||
ifeq ($(MACOS),true) | |||
OBJS += src/pugl/pugl_osx_extended.m.o | |||
endif | |||
TARGET = ../libdgl.a | |||
# -------------------------------------------------------------- | |||
all: $(TARGET) | |||
# -------------------------------------------------------------- | |||
../libdgl.a: $(OBJS) | |||
$(RM) $@ | |||
$(AR) crs $@ $^ | |||
../libdgl.dll: $(OBJS) | |||
$(CXX) $^ -shared $(LINK_FLAGS) -o $@ | |||
../libdgl.dylib: $(OBJS) | |||
$(CXX) $^ -dynamiclib $(LINK_FLAGS) -o $@ | |||
../libdgl.so: $(OBJS) | |||
$(CXX) $^ -shared $(LINK_FLAGS) -o $@ | |||
# -------------------------------------------------------------- | |||
%.cpp.o: %.cpp | |||
$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | |||
# -------------------------------------------------------------- | |||
clean: | |||
$(RM) src/*.o src/pugl/*.o ../libdgl.* | |||
debug: | |||
$(MAKE) DEBUG=true | |||
# -------------------------------------------------------------- |
@@ -0,0 +1,79 @@ | |||
#!/usr/bin/make -f | |||
# Makefile for dgl # | |||
# ---------------- # | |||
# Created by falkTX | |||
# | |||
AR ?= ar | |||
RM ?= rm -f | |||
CC ?= gcc | |||
CXX ?= g++ | |||
# -------------------------------------------------------------- | |||
# Fallback to Linux if no other OS defined | |||
ifneq ($(MACOS),true) | |||
ifneq ($(WIN32),true) | |||
LINUX=true | |||
endif | |||
endif | |||
# -------------------------------------------------------------- | |||
# Common build and link flags | |||
BASE_FLAGS = -Wall -Wextra -fPIC -DPIC -pipe -DREAL_BUILD | |||
BASE_OPTS = -O3 -ffast-math -mtune=generic -msse -msse2 -mfpmath=sse | |||
ifeq ($(RASPPI),true) | |||
# Raspberry-Pi optimization flags | |||
BASE_OPTS = -O3 -ffast-math -march=armv6 -mfpu=vfp -mfloat-abi=hard | |||
endif | |||
ifeq ($(DEBUG),true) | |||
BASE_FLAGS += -DDEBUG -O0 -g | |||
else | |||
BASE_FLAGS += -DNDEBUG $(BASE_OPTS) -fvisibility=hidden | |||
CXXFLAGS += -fvisibility-inlines-hidden | |||
LINK_OPTS += -Wl,--strip-all | |||
endif | |||
BUILD_C_FLAGS = $(BASE_FLAGS) -std=gnu99 $(CFLAGS) | |||
BUILD_CXX_FLAGS = $(BASE_FLAGS) -std=gnu++0x $(CXXFLAGS) | |||
LINK_FLAGS = $(LINK_OPTS) -Wl,--no-undefined $(LDFLAGS) | |||
ifeq ($(MACOS),true) | |||
# Get rid of most options for old gcc4.2 | |||
BUILD_CXX_FLAGS = $(BASE_FLAGS) $(CXXFLAGS) | |||
LINK_FLAGS = $(LDFLAGS) | |||
endif | |||
# -------------------------------------------------------------- | |||
# Check for required libs | |||
ifeq ($(LINUX),true) | |||
ifneq ($(shell pkg-config --exists gl && echo true),true) | |||
$(error OpenGL missing, cannot continue) | |||
endif | |||
ifneq ($(shell pkg-config --exists x11 && echo true),true) | |||
$(error X11 missing, cannot continue) | |||
endif | |||
endif | |||
# -------------------------------------------------------------- | |||
# Set libs stuff | |||
ifeq ($(LINUX),true) | |||
DGL_FLAGS = $(shell pkg-config --cflags gl x11) | |||
DGL_LIBS = $(shell pkg-config --libs gl x11) | |||
endif | |||
ifeq ($(MACOS),true) | |||
DGL_LIBS = -framework OpenGL -framework Cocoa | |||
endif | |||
ifeq ($(WIN32),true) | |||
DGL_LIBS = -lopengl32 -lgdi32 | |||
endif | |||
# -------------------------------------------------------------- |
@@ -0,0 +1,79 @@ | |||
/* | |||
* DISTRHO Plugin Toolkit (DPT) | |||
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | |||
* or without fee is hereby granted, provided that the above copyright notice and this | |||
* permission notice appear in all copies. | |||
* | |||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
*/ | |||
#ifndef DGL_STANDALONE_WINDOW_HPP_INCLUDED | |||
#define DGL_STANDALONE_WINDOW_HPP_INCLUDED | |||
#include "App.hpp" | |||
#include "Window.hpp" | |||
START_NAMESPACE_DGL | |||
// ----------------------------------------------------------------------- | |||
class StandaloneWindow | |||
{ | |||
public: | |||
StandaloneWindow() | |||
: fApp(), | |||
fWindow(fApp) | |||
{ | |||
} | |||
App& getApp() noexcept | |||
{ | |||
return fApp; | |||
} | |||
Window& getWindow() noexcept | |||
{ | |||
return fWindow; | |||
} | |||
void exec() | |||
{ | |||
fWindow.show(); | |||
fApp.exec(); | |||
} | |||
// ------------------------------------------------------------------- | |||
// helpers | |||
void setResizable(bool yesNo) | |||
{ | |||
fWindow.setResizable(yesNo); | |||
} | |||
void setSize(unsigned int width, unsigned int height) | |||
{ | |||
fWindow.setSize(width, height); | |||
} | |||
void setTitle(const char* title) | |||
{ | |||
fWindow.setTitle(title); | |||
} | |||
private: | |||
App fApp; | |||
Window fWindow; | |||
}; | |||
// ----------------------------------------------------------------------- | |||
END_NAMESPACE_DGL | |||
#endif // DGL_STANDALONE_WINDOW_HPP_INCLUDED |
@@ -0,0 +1,100 @@ | |||
/* | |||
* DISTRHO Plugin Toolkit (DPT) | |||
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | |||
* or without fee is hereby granted, provided that the above copyright notice and this | |||
* permission notice appear in all copies. | |||
* | |||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
*/ | |||
#ifndef DGL_WIDGET_HPP_INCLUDED | |||
#define DGL_WIDGET_HPP_INCLUDED | |||
#include "Geometry.hpp" | |||
#ifdef PROPER_CPP11_SUPPORT | |||
# include <cstdint> | |||
#else | |||
# include <stdint.h> | |||
#endif | |||
START_NAMESPACE_DGL | |||
// ----------------------------------------------------------------------- | |||
class App; | |||
class Window; | |||
class Widget | |||
{ | |||
public: | |||
Widget(Window& parent); | |||
virtual ~Widget(); | |||
bool isVisible() const noexcept; | |||
void setVisible(bool yesNo); | |||
void show(); | |||
void hide(); | |||
int getX() const noexcept; | |||
int getY() const noexcept; | |||
const Point<int>& getPos() const noexcept; | |||
void setX(int x); | |||
void setY(int y); | |||
void setPos(int x, int y); | |||
void setPos(const Point<int>& pos); | |||
void move(int x, int y); | |||
void move(const Point<int>& pos); | |||
int getWidth() const noexcept; | |||
int getHeight() const noexcept; | |||
const Size<int>& getSize() const noexcept; | |||
void setWidth(int width); | |||
void setHeight(int height); | |||
void setSize(int width, int height); | |||
void setSize(const Size<int>& size); | |||
const Rectangle<int>& getArea() const noexcept; | |||
uint32_t getEventTimestamp(); | |||
int getModifiers(); | |||
App& getParentApp() const noexcept; | |||
Window& getParentWindow() const noexcept; | |||
void repaint(); | |||
protected: | |||
virtual void onDisplay() = 0; | |||
virtual bool onKeyboard(bool press, uint32_t key); | |||
virtual bool onMouse(int button, bool press, int x, int y); | |||
virtual bool onMotion(int x, int y); | |||
virtual bool onScroll(float dx, float dy); | |||
virtual bool onSpecial(bool press, Key key); | |||
virtual void onReshape(int width, int height); | |||
virtual void onClose(); | |||
private: | |||
Window& fParent; | |||
bool fVisible; | |||
Rectangle<int> fArea; | |||
friend class Window; | |||
}; | |||
// ----------------------------------------------------------------------- | |||
END_NAMESPACE_DGL | |||
#endif // DGL_WIDGET_HPP_INCLUDED |
@@ -0,0 +1,85 @@ | |||
/* | |||
* DISTRHO Plugin Toolkit (DPT) | |||
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | |||
* or without fee is hereby granted, provided that the above copyright notice and this | |||
* permission notice appear in all copies. | |||
* | |||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
*/ | |||
#ifndef DGL_WINDOW_HPP_INCLUDED | |||
#define DGL_WINDOW_HPP_INCLUDED | |||
#include "Geometry.hpp" | |||
#ifdef PROPER_CPP11_SUPPORT | |||
# include <cstdint> | |||
#else | |||
# include <stdint.h> | |||
#endif | |||
START_NAMESPACE_DGL | |||
// ----------------------------------------------------------------------- | |||
class App; | |||
class Widget; | |||
class Window | |||
{ | |||
public: | |||
Window(App& app); | |||
Window(App& app, Window& parent); | |||
Window(App& app, intptr_t parentId); | |||
virtual ~Window(); | |||
void show(); | |||
void hide(); | |||
void close(); | |||
void exec(bool lockWait = false); | |||
void focus(); | |||
void idle(); | |||
void repaint(); | |||
bool isVisible() const noexcept; | |||
void setVisible(bool yesNo); | |||
bool isResizable() const noexcept; | |||
void setResizable(bool yesNo); | |||
#ifndef DGL_OS_MAC | |||
int getWidth() const noexcept; | |||
int getHeight() const noexcept; | |||
Size<int> getSize() const noexcept; | |||
#endif | |||
void setSize(unsigned int width, unsigned int height); | |||
void setTitle(const char* title); | |||
App& getApp() const noexcept; | |||
uint32_t getEventTimestamp() const; | |||
int getModifiers() const; | |||
intptr_t getWindowId() const; | |||
private: | |||
class PrivateData; | |||
PrivateData* const pData; | |||
friend class Widget; | |||
void addWidget(Widget* const widget); | |||
void removeWidget(Widget* const widget); | |||
}; | |||
// ----------------------------------------------------------------------- | |||
END_NAMESPACE_DGL | |||
#endif // DGL_WINDOW_HPP_INCLUDED |
@@ -0,0 +1,111 @@ | |||
/* | |||
* DISTRHO Plugin Toolkit (DPT) | |||
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | |||
* or without fee is hereby granted, provided that the above copyright notice and this | |||
* permission notice appear in all copies. | |||
* | |||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
*/ | |||
#include "../App.hpp" | |||
#include "../Window.hpp" | |||
#include <list> | |||
START_NAMESPACE_DGL | |||
// ----------------------------------------------------------------------- | |||
struct App::PrivateData { | |||
bool doLoop; | |||
unsigned visibleWindows; | |||
std::list<Window*> windows; | |||
PrivateData() | |||
: doLoop(false), | |||
visibleWindows(0) {} | |||
}; | |||
// ----------------------------------------------------------------------- | |||
App::App() | |||
: pData(new PrivateData()) | |||
{ | |||
} | |||
App::~App() | |||
{ | |||
pData->windows.clear(); | |||
delete pData; | |||
} | |||
void App::idle() | |||
{ | |||
for (std::list<Window*>::iterator it = pData->windows.begin(); it != pData->windows.end(); ++it) | |||
{ | |||
Window* const window(*it); | |||
window->idle(); | |||
} | |||
} | |||
void App::exec() | |||
{ | |||
while (pData->doLoop) | |||
{ | |||
idle(); | |||
msleep(10); | |||
} | |||
} | |||
void App::quit() | |||
{ | |||
pData->doLoop = false; | |||
for (std::list<Window*>::reverse_iterator rit = pData->windows.rbegin(); rit != pData->windows.rend(); ++rit) | |||
{ | |||
Window* const window(*rit); | |||
window->close(); | |||
} | |||
} | |||
bool App::isQuiting() const | |||
{ | |||
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; | |||
} | |||
// ----------------------------------------------------------------------- | |||
END_NAMESPACE_DGL |
@@ -0,0 +1,49 @@ | |||
/* | |||
* DISTRHO Plugin Toolkit (DPT) | |||
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | |||
* or without fee is hereby granted, provided that the above copyright notice and this | |||
* permission notice appear in all copies. | |||
* | |||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
*/ | |||
#include "../Base.hpp" | |||
#if DGL_OS_WINDOWS | |||
# include <windows.h> | |||
#else | |||
# include <unistd.h> | |||
#endif | |||
START_NAMESPACE_DGL | |||
// ----------------------------------------------------------------------- | |||
void sleep(unsigned int secs) | |||
{ | |||
#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 |
@@ -0,0 +1,416 @@ | |||
/* | |||
* DISTRHO Plugin Toolkit (DPT) | |||
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | |||
* or without fee is hereby granted, provided that the above copyright notice and this | |||
* permission notice appear in all copies. | |||
* | |||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
*/ | |||
#include "../Geometry.hpp" | |||
START_NAMESPACE_DGL | |||
// ----------------------------------------------------------------------- | |||
// Point | |||
template<typename T> | |||
Point<T>::Point() noexcept | |||
: fX(0), | |||
fY(0) | |||
{ | |||
} | |||
template<typename T> | |||
Point<T>::Point(T x, T y) noexcept | |||
: fX(x), | |||
fY(y) | |||
{ | |||
} | |||
template<typename T> | |||
Point<T>::Point(const Point& pos) noexcept | |||
: fX(pos.fX), | |||
fY(pos.fY) | |||
{ | |||
} | |||
template<typename T> | |||
T Point<T>::getX() const noexcept | |||
{ | |||
return fX; | |||
} | |||
template<typename T> | |||
T Point<T>::getY() const noexcept | |||
{ | |||
return fY; | |||
} | |||
template<typename T> | |||
void Point<T>::setX(T x) noexcept | |||
{ | |||
fX = x; | |||
} | |||
template<typename T> | |||
void Point<T>::setY(T y) noexcept | |||
{ | |||
fY = y; | |||
} | |||
template<typename T> | |||
void Point<T>::move(T x, T y) noexcept | |||
{ | |||
fX += x; | |||
fY += y; | |||
} | |||
template<typename T> | |||
void Point<T>::move(const Point& pos) noexcept | |||
{ | |||
fX += pos.fX; | |||
fY += pos.fY; | |||
} | |||
template<typename T> | |||
Point<T>& Point<T>::operator=(const Point<T>& pos) noexcept | |||
{ | |||
fX = pos.fX; | |||
fY = pos.fY; | |||
return *this; | |||
} | |||
template<typename T> | |||
Point<T>& Point<T>::operator+=(const Point<T>& pos) noexcept | |||
{ | |||
fX += pos.fX; | |||
fY += pos.fY; | |||
return *this; | |||
} | |||
template<typename T> | |||
Point<T>& Point<T>::operator-=(const Point<T>& pos) noexcept | |||
{ | |||
fX -= pos.fX; | |||
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); | |||
} | |||
template<typename T> | |||
bool Point<T>::operator!=(const Point<T>& pos) const noexcept | |||
{ | |||
return !operator==(pos); | |||
} | |||
// ----------------------------------------------------------------------- | |||
// Size | |||
template<typename T> | |||
Size<T>::Size() noexcept | |||
: fWidth(0), | |||
fHeight(0) | |||
{ | |||
} | |||
template<typename T> | |||
Size<T>::Size(T width, T height) noexcept | |||
: fWidth(width), | |||
fHeight(height) | |||
{ | |||
} | |||
template<typename T> | |||
Size<T>::Size(const Size<T>& size) noexcept | |||
: fWidth(size.fWidth), | |||
fHeight(size.fHeight) | |||
{ | |||
} | |||
template<typename T> | |||
T Size<T>::getWidth() const noexcept | |||
{ | |||
return fWidth; | |||
} | |||
template<typename T> | |||
T Size<T>::getHeight() const noexcept | |||
{ | |||
return fHeight; | |||
} | |||
template<typename T> | |||
void Size<T>::setWidth(T width) noexcept | |||
{ | |||
fWidth = width; | |||
} | |||
template<typename T> | |||
void Size<T>::setHeight(T height) noexcept | |||
{ | |||
fHeight = height; | |||
} | |||
template<typename T> | |||
Size<T>& Size<T>::operator=(const Size<T>& size) noexcept | |||
{ | |||
fWidth = size.fWidth; | |||
fHeight = size.fHeight; | |||
return *this; | |||
} | |||
template<typename T> | |||
Size<T>& Size<T>::operator+=(const Size<T>& size) noexcept | |||
{ | |||
fWidth += size.fWidth; | |||
fHeight += size.fHeight; | |||
return *this; | |||
} | |||
template<typename T> | |||
Size<T>& Size<T>::operator-=(const Size<T>& size) noexcept | |||
{ | |||
fWidth -= size.fWidth; | |||
fHeight -= size.fHeight; | |||
return *this; | |||
} | |||
template<typename T> | |||
Size<T>& Size<T>::operator*=(T m) noexcept | |||
{ | |||
fWidth *= m; | |||
fHeight *= m; | |||
return *this; | |||
} | |||
template<typename T> | |||
Size<T>& Size<T>::operator/=(T d) noexcept | |||
{ | |||
fWidth /= d; | |||
fHeight /= d; | |||
return *this; | |||
} | |||
template<typename T> | |||
bool Size<T>::operator==(const Size<T>& size) const noexcept | |||
{ | |||
return (fWidth == size.fWidth && fHeight == size.fHeight); | |||
} | |||
template<typename T> | |||
bool Size<T>::operator!=(const Size<T>& size) const noexcept | |||
{ | |||
return !operator==(size); | |||
} | |||
// ----------------------------------------------------------------------- | |||
// Rectangle | |||
template<typename T> | |||
Rectangle<T>::Rectangle() noexcept | |||
: fPos(0, 0), | |||
fSize(0, 0) | |||
{ | |||
} | |||
template<typename T> | |||
Rectangle<T>::Rectangle(T x, T y, T width, T height) noexcept | |||
: fPos(x, y), | |||
fSize(width, height) | |||
{ | |||
} | |||
template<typename T> | |||
Rectangle<T>::Rectangle(T x, T y, const Size<T>& size) noexcept | |||
: fPos(x, y), | |||
fSize(size) | |||
{ | |||
} | |||
template<typename T> | |||
Rectangle<T>::Rectangle(const Point<T>& pos, T width, T height) noexcept | |||
: fPos(pos), | |||
fSize(width, height) | |||
{ | |||
} | |||
template<typename T> | |||
Rectangle<T>::Rectangle(const Point<T>& pos, const Size<T>& size) noexcept | |||
: fPos(pos), | |||
fSize(size) | |||
{ | |||
} | |||
template<typename T> | |||
Rectangle<T>::Rectangle(const Rectangle<T>& rect) noexcept | |||
: fPos(rect.fPos), | |||
fSize(rect.fSize) | |||
{ | |||
} | |||
template<typename T> | |||
T Rectangle<T>::getX() const noexcept | |||
{ | |||
return fPos.fX; | |||
} | |||
template<typename T> | |||
T Rectangle<T>::getY() const noexcept | |||
{ | |||
return fPos.fY; | |||
} | |||
template<typename T> | |||
T Rectangle<T>::getWidth() const noexcept | |||
{ | |||
return fSize.fWidth; | |||
} | |||
template<typename T> | |||
T Rectangle<T>::getHeight() const noexcept | |||
{ | |||
return fSize.fHeight; | |||
} | |||
template<typename T> | |||
const Point<T>& Rectangle<T>::getPos() const noexcept | |||
{ | |||
return fPos; | |||
} | |||
template<typename T> | |||
const Size<T>& Rectangle<T>::getSize() const noexcept | |||
{ | |||
return fSize; | |||
} | |||
template<typename T> | |||
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); | |||
} | |||
template<typename T> | |||
bool Rectangle<T>::contains(const Point<T>& pos) const noexcept | |||
{ | |||
return contains(pos.fX, pos.fY); | |||
} | |||
template<typename T> | |||
bool Rectangle<T>::containsX(T x) const noexcept | |||
{ | |||
return (x >= fPos.fX && x <= fPos.fX + fSize.fWidth); | |||
} | |||
template<typename T> | |||
bool Rectangle<T>::containsY(T y) const noexcept | |||
{ | |||
return (y >= fPos.fY && y <= fPos.fY + fSize.fHeight); | |||
} | |||
template<typename T> | |||
void Rectangle<T>::setX(T x) noexcept | |||
{ | |||
fPos.fX = x; | |||
} | |||
template<typename T> | |||
void Rectangle<T>::setY(T y) noexcept | |||
{ | |||
fPos.fY = y; | |||
} | |||
template<typename T> | |||
void Rectangle<T>::setPos(T x, T y) noexcept | |||
{ | |||
fPos.fX = x; | |||
fPos.fY = y; | |||
} | |||
template<typename T> | |||
void Rectangle<T>::setPos(const Point<T>& pos) noexcept | |||
{ | |||
fPos = pos; | |||
} | |||
template<typename T> | |||
void Rectangle<T>::move(T x, T y) noexcept | |||
{ | |||
fPos.fX += x; | |||
fPos.fY += y; | |||
} | |||
template<typename T> | |||
void Rectangle<T>::move(const Point<T>& pos) noexcept | |||
{ | |||
fPos += pos; | |||
} | |||
template<typename T> | |||
void Rectangle<T>::setWidth(T width) noexcept | |||
{ | |||
fSize.fWidth = width; | |||
} | |||
template<typename T> | |||
void Rectangle<T>::setHeight(T height) noexcept | |||
{ | |||
fSize.fHeight = height; | |||
} | |||
template<typename T> | |||
void Rectangle<T>::setSize(T width, T height) noexcept | |||
{ | |||
fSize.fWidth = width; | |||
fSize.fHeight = height; | |||
} | |||
template<typename T> | |||
void Rectangle<T>::setSize(const Size<T>& size) noexcept | |||
{ | |||
fSize = size; | |||
} | |||
template<typename T> | |||
Rectangle<T>& Rectangle<T>::operator=(const Rectangle<T>& rect) noexcept | |||
{ | |||
fPos = rect.fPos; | |||
fSize = rect.fSize; | |||
return *this; | |||
} | |||
// ----------------------------------------------------------------------- | |||
// Possible template data types | |||
template class Point<int>; | |||
template class Point<long>; | |||
template class Point<float>; | |||
template class Point<double>; | |||
template class Size<int>; | |||
template class Size<long>; | |||
template class Size<float>; | |||
template class Size<double>; | |||
template class Rectangle<int>; | |||
template class Rectangle<long>; | |||
template class Rectangle<float>; | |||
template class Rectangle<double>; | |||
// ----------------------------------------------------------------------- | |||
END_NAMESPACE_DGL | |||
@@ -0,0 +1,145 @@ | |||
/* | |||
* DISTRHO Plugin Toolkit (DPT) | |||
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | |||
* or without fee is hereby granted, provided that the above copyright notice and this | |||
* permission notice appear in all copies. | |||
* | |||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
*/ | |||
#include "../Image.hpp" | |||
START_NAMESPACE_DGL | |||
// ----------------------------------------------------------------------- | |||
Image::Image() noexcept | |||
: fRawData(nullptr), | |||
fSize(0, 0), | |||
fFormat(0), | |||
fType(0) | |||
{ | |||
} | |||
Image::Image(const char* rawData, int width, int height, GLenum format, GLenum type) noexcept | |||
: fRawData(rawData), | |||
fSize(width, height), | |||
fFormat(format), | |||
fType(type) | |||
{ | |||
} | |||
Image::Image(const char* rawData, const Size<int>& size, GLenum format, GLenum type) noexcept | |||
: fRawData(rawData), | |||
fSize(size), | |||
fFormat(format), | |||
fType(type) | |||
{ | |||
} | |||
Image::Image(const Image& image) noexcept | |||
: fRawData(image.fRawData), | |||
fSize(image.fSize), | |||
fFormat(image.fFormat), | |||
fType(image.fType) | |||
{ | |||
} | |||
void Image::loadFromMemory(const char* rawData, int width, int height, GLenum format, GLenum type) noexcept | |||
{ | |||
loadFromMemory(rawData, Size<int>(width, height), format, type); | |||
} | |||
void Image::loadFromMemory(const char* rawData, const Size<int>& size, GLenum format, GLenum type) noexcept | |||
{ | |||
fRawData = rawData; | |||
fSize = size; | |||
fFormat = format; | |||
fType = type; | |||
} | |||
bool Image::isValid() const noexcept | |||
{ | |||
return (fRawData != nullptr && getWidth() > 0 && getHeight() > 0); | |||
} | |||
int Image::getWidth() const noexcept | |||
{ | |||
return fSize.getWidth(); | |||
} | |||
int Image::getHeight() const noexcept | |||
{ | |||
return fSize.getHeight(); | |||
} | |||
const Size<int>& Image::getSize() const noexcept | |||
{ | |||
return fSize; | |||
} | |||
const char* Image::getRawData() const noexcept | |||
{ | |||
return fRawData; | |||
} | |||
GLenum Image::getFormat() const noexcept | |||
{ | |||
return fFormat; | |||
} | |||
GLenum Image::getType() const noexcept | |||
{ | |||
return fType; | |||
} | |||
void Image::draw() const | |||
{ | |||
draw(0, 0); | |||
} | |||
void Image::draw(int x, int y) const | |||
{ | |||
if (! isValid()) | |||
return; | |||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); | |||
glPixelStorei(GL_PACK_ALIGNMENT, 1); | |||
glRasterPos2i(x, fSize.getHeight()+y); | |||
glDrawPixels(fSize.getWidth(), fSize.getHeight(), fFormat, fType, fRawData); | |||
} | |||
void Image::draw(const Point<int>& pos) const | |||
{ | |||
draw(pos.getX(), pos.getY()); | |||
} | |||
Image& Image::operator=(const Image& image) noexcept | |||
{ | |||
fRawData = image.fRawData; | |||
fSize = image.fSize; | |||
fFormat = image.fFormat; | |||
fType = image.fType; | |||
return *this; | |||
} | |||
bool Image::operator==(const Image& image) const noexcept | |||
{ | |||
return (fRawData == image.fRawData); | |||
} | |||
bool Image::operator!=(const Image& image) const noexcept | |||
{ | |||
return (fRawData != image.fRawData); | |||
} | |||
// ----------------------------------------------------------------------- | |||
END_NAMESPACE_DGL |
@@ -0,0 +1,83 @@ | |||
/* | |||
* DISTRHO Plugin Toolkit (DPT) | |||
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | |||
* or without fee is hereby granted, provided that the above copyright notice and this | |||
* permission notice appear in all copies. | |||
* | |||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
*/ | |||
#include "../ImageAboutWindow.hpp" | |||
// FIXME: 32bit hack | |||
#if ! (defined (__LP64__) || defined (_LP64) || defined(WIN64) || defined(_WIN64) || defined(__WIN64__)) | |||
# define PAD_SIZE +1 | |||
#else | |||
# define PAD_SIZE | |||
#endif | |||
START_NAMESPACE_DGL | |||
// ----------------------------------------------------------------------- | |||
ImageAboutWindow::ImageAboutWindow(App& app, Window& parent, const Image& image) | |||
: Window(app, parent), | |||
Widget((Window&)*this), | |||
fImgBackground(image) | |||
{ | |||
Window::setSize(image.getWidth(), image.getHeight() PAD_SIZE); | |||
Window::setTitle("About"); | |||
} | |||
ImageAboutWindow::ImageAboutWindow(Widget* widget, const Image& image) | |||
: Window(widget->getParentApp(), widget->getParentWindow()), | |||
Widget((Window&)*this), | |||
fImgBackground(image) | |||
{ | |||
Window::setSize(image.getWidth(), image.getHeight() PAD_SIZE); | |||
Window::setTitle("About"); | |||
} | |||
void ImageAboutWindow::setImage(const Image& image) | |||
{ | |||
fImgBackground = image; | |||
Window::setSize(image.getWidth(), image.getHeight() PAD_SIZE); | |||
} | |||
void ImageAboutWindow::onDisplay() | |||
{ | |||
fImgBackground.draw(); | |||
} | |||
bool ImageAboutWindow::onMouse(int, bool press, int, int) | |||
{ | |||
if (press) | |||
{ | |||
Window::close(); | |||
return true; | |||
} | |||
return false; | |||
} | |||
bool ImageAboutWindow::onKeyboard(bool press, uint32_t key) | |||
{ | |||
if (press && key == CHAR_ESCAPE) | |||
{ | |||
Window::close(); | |||
return true; | |||
} | |||
return false; | |||
} | |||
// ----------------------------------------------------------------------- | |||
END_NAMESPACE_DGL |
@@ -0,0 +1,173 @@ | |||
/* | |||
* DISTRHO Plugin Toolkit (DPT) | |||
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | |||
* or without fee is hereby granted, provided that the above copyright notice and this | |||
* permission notice appear in all copies. | |||
* | |||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
*/ | |||
#include "../ImageButton.hpp" | |||
#include <cassert> | |||
START_NAMESPACE_DGL | |||
// ----------------------------------------------------------------------- | |||
ImageButton::ImageButton(Window& parent, const Image& image) | |||
: Widget(parent), | |||
fImageNormal(image), | |||
fImageHover(image), | |||
fImageDown(image), | |||
fCurImage(&fImageNormal), | |||
fCurButton(-1), |