Signed-off-by: falkTX <falktx@falktx.com>pull/272/head
@@ -55,16 +55,13 @@ public: | |||||
Constructor using raw image data. | Constructor using raw image data. | ||||
@note @a rawData must remain valid for the lifetime of this Image. | @note @a rawData must remain valid for the lifetime of this Image. | ||||
*/ | */ | ||||
CairoImage(const char* const rawData, | |||||
const uint width, | |||||
const uint height); | |||||
CairoImage(const char* rawData, uint width, uint height, ImageFormat format); | |||||
/** | /** | ||||
Constructor using raw image data. | Constructor using raw image data. | ||||
@note @a rawData must remain valid for the lifetime of this Image. | @note @a rawData must remain valid for the lifetime of this Image. | ||||
*/ | */ | ||||
CairoImage(const char* const rawData, | |||||
const Size<uint>& size); | |||||
CairoImage(const char* rawData, const Size<uint>& size, ImageFormat format); | |||||
/** | /** | ||||
Constructor using another image data. | Constructor using another image data. | ||||
@@ -80,6 +77,10 @@ public: | |||||
Draw this image at position @a pos using the graphics context @a context. | Draw this image at position @a pos using the graphics context @a context. | ||||
*/ | */ | ||||
void drawAt(const GraphicsContext& context, const Point<int>& pos) override; | void drawAt(const GraphicsContext& context, const Point<int>& pos) override; | ||||
// FIXME this should not be needed | |||||
inline void drawAt(const GraphicsContext& context, int x, int y) | |||||
{ drawAt(context, Point<int>(x, y)); }; | |||||
}; | }; | ||||
// -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
@@ -23,6 +23,13 @@ START_NAMESPACE_DGL | |||||
// -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
enum ImageFormat { | |||||
kImageFormatBGR, | |||||
kImageFormatBGRA, | |||||
kImageFormatRGB, | |||||
kImageFormatRGBA, | |||||
}; | |||||
/** | /** | ||||
Base DGL Image class. | Base DGL Image class. | ||||
@@ -44,13 +51,13 @@ protected: | |||||
Constructor using raw image data. | Constructor using raw image data. | ||||
@note @a rawData must remain valid for the lifetime of this Image. | @note @a rawData must remain valid for the lifetime of this Image. | ||||
*/ | */ | ||||
ImageBase(const char* const rawData, const uint width, const uint height); | |||||
ImageBase(const char* rawData, uint width, uint height, ImageFormat format); | |||||
/** | /** | ||||
Constructor using raw image data. | Constructor using raw image data. | ||||
@note @a rawData must remain valid for the lifetime of this Image. | @note @a rawData must remain valid for the lifetime of this Image. | ||||
*/ | */ | ||||
ImageBase(const char* const rawData, const Size<uint>& size); | |||||
ImageBase(const char* rawData, const Size<uint>& size, ImageFormat format); | |||||
/** | /** | ||||
Constructor using another image data. | Constructor using another image data. | ||||
@@ -93,6 +100,25 @@ public: | |||||
*/ | */ | ||||
const char* getRawData() const noexcept; | const char* getRawData() const noexcept; | ||||
/** | |||||
Get the image format. | |||||
*/ | |||||
ImageFormat getFormat() const noexcept; | |||||
/** | |||||
Load image data from memory. | |||||
@note @a rawData must remain valid for the lifetime of this Image. | |||||
*/ | |||||
void loadFromMemory(const char* rawData, uint width, uint height, ImageFormat format = kImageFormatBGRA) noexcept; | |||||
/** | |||||
Load image data from memory. | |||||
@note @a rawData must remain valid for the lifetime of this Image. | |||||
*/ | |||||
virtual void loadFromMemory(const char* rawData, | |||||
const Size<uint>& size, | |||||
ImageFormat format = kImageFormatBGRA) noexcept; | |||||
/** | /** | ||||
Draw this image at (0, 0) point using the current OpenGL context. | Draw this image at (0, 0) point using the current OpenGL context. | ||||
*/ | */ | ||||
@@ -101,7 +127,7 @@ public: | |||||
/** | /** | ||||
Draw this image at (x, y) point using the current OpenGL context. | Draw this image at (x, y) point using the current OpenGL context. | ||||
*/ | */ | ||||
void drawAt(const GraphicsContext& context, const int x, const int y); | |||||
void drawAt(const GraphicsContext& context, int x, int y); | |||||
/** | /** | ||||
Draw this image at position @a pos using the current OpenGL context. | Draw this image at position @a pos using the current OpenGL context. | ||||
@@ -118,6 +144,7 @@ public: | |||||
protected: | protected: | ||||
const char* rawData; | const char* rawData; | ||||
Size<uint> size; | Size<uint> size; | ||||
ImageFormat format; | |||||
}; | }; | ||||
// -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
@@ -141,20 +141,13 @@ public: | |||||
Constructor using raw image data. | Constructor using raw image data. | ||||
@note @a rawData must remain valid for the lifetime of this Image. | @note @a rawData must remain valid for the lifetime of this Image. | ||||
*/ | */ | ||||
OpenGLImage(const char* const rawData, | |||||
const uint width, | |||||
const uint height, | |||||
const GLenum format = GL_BGRA, | |||||
const GLenum type = GL_UNSIGNED_BYTE); | |||||
OpenGLImage(const char* rawData, uint width, uint height, ImageFormat format = kImageFormatBGRA); | |||||
/** | /** | ||||
Constructor using raw image data. | Constructor using raw image data. | ||||
@note @a rawData must remain valid for the lifetime of this Image. | @note @a rawData must remain valid for the lifetime of this Image. | ||||
*/ | */ | ||||
OpenGLImage(const char* const rawData, | |||||
const Size<uint>& size, | |||||
const GLenum format = GL_BGRA, | |||||
const GLenum type = GL_UNSIGNED_BYTE); | |||||
OpenGLImage(const char* rawData, const Size<uint>& size, ImageFormat format = kImageFormatBGRA); | |||||
/** | /** | ||||
Constructor using another image data. | Constructor using another image data. | ||||
@@ -170,30 +163,9 @@ public: | |||||
Load image data from memory. | Load image data from memory. | ||||
@note @a rawData must remain valid for the lifetime of this Image. | @note @a rawData must remain valid for the lifetime of this Image. | ||||
*/ | */ | ||||
void loadFromMemory(const char* const rawData, | |||||
const uint width, | |||||
const uint height, | |||||
const GLenum format = GL_BGRA, | |||||
const GLenum type = GL_UNSIGNED_BYTE) noexcept; | |||||
/** | |||||
Load image data from memory. | |||||
@note @a rawData must remain valid for the lifetime of this Image. | |||||
*/ | |||||
void loadFromMemory(const char* const rawData, | |||||
void loadFromMemory(const char* rawData, | |||||
const Size<uint>& size, | const Size<uint>& size, | ||||
const GLenum format = GL_BGRA, | |||||
const GLenum type = GL_UNSIGNED_BYTE) noexcept; | |||||
/** | |||||
Get the image format. | |||||
*/ | |||||
GLenum getFormat() const noexcept; | |||||
/** | |||||
Get the image type. | |||||
*/ | |||||
GLenum getType() const noexcept; | |||||
ImageFormat format = kImageFormatBGRA) noexcept override; | |||||
/** | /** | ||||
Draw this image at position @a pos using the graphics context @a context. | Draw this image at position @a pos using the graphics context @a context. | ||||
@@ -223,10 +195,20 @@ public: | |||||
// TODO mark as deprecated | // TODO mark as deprecated | ||||
void drawAt(const Point<int>& pos); | void drawAt(const Point<int>& pos); | ||||
// FIXME this should not be needed | |||||
inline void loadFromMemory(const char* rawData, uint w, uint h, ImageFormat format) | |||||
{ loadFromMemory(rawData, Size<uint>(w, h), format); }; | |||||
inline void drawAt(const GraphicsContext& context, int x, int y) | |||||
{ drawAt(context, Point<int>(x, y)); }; | |||||
/** | |||||
Get the image type. | |||||
*/ | |||||
// TODO mark as deprecated | |||||
GLenum getType() const noexcept { return GL_UNSIGNED_BYTE; } | |||||
private: | private: | ||||
GLenum fFormat; | |||||
GLenum fType; | |||||
GLuint fTextureId; | |||||
GLuint textureId; | |||||
bool setupCalled; | bool setupCalled; | ||||
}; | }; | ||||
@@ -15,7 +15,10 @@ | |||||
*/ | */ | ||||
#include "../Cairo.hpp" | #include "../Cairo.hpp" | ||||
#include "SubWidgetPrivateData.hpp" | #include "SubWidgetPrivateData.hpp" | ||||
#include "TopLevelWidgetPrivateData.hpp" | |||||
#include "WidgetPrivateData.hpp" | |||||
#include "WindowPrivateData.hpp" | #include "WindowPrivateData.hpp" | ||||
START_NAMESPACE_DGL | START_NAMESPACE_DGL | ||||
@@ -124,14 +127,14 @@ template class Rectangle<ushort>; | |||||
CairoImage::CairoImage() | CairoImage::CairoImage() | ||||
: ImageBase() {} | : ImageBase() {} | ||||
CairoImage::CairoImage(const char* const rawData, const uint width, const uint height) | |||||
: ImageBase(rawData, width, height) {} | |||||
CairoImage::CairoImage(const char* const rawData, const uint width, const uint height, const ImageFormat format) | |||||
: ImageBase(rawData, width, height, format) {} | |||||
CairoImage::CairoImage(const char* const rawData, const Size<uint>& size) | |||||
: ImageBase(rawData, size) {} | |||||
CairoImage::CairoImage(const char* const rawData, const Size<uint>& size, const ImageFormat format) | |||||
: ImageBase(rawData, size, format) {} | |||||
CairoImage::CairoImage(const CairoImage& image) | CairoImage::CairoImage(const CairoImage& image) | ||||
: ImageBase(image.rawData, image.size) {} | |||||
: ImageBase(image.rawData, image.size, image.format) {} | |||||
CairoImage::~CairoImage() | CairoImage::~CairoImage() | ||||
{ | { | ||||
@@ -171,7 +174,32 @@ void SubWidget::PrivateData::display(const uint width, const uint height, const | |||||
cairo_set_matrix(cr, &matrix); | cairo_set_matrix(cr, &matrix); | ||||
// displaySubWidgets(width, height, autoScaleFactor); | |||||
selfw->pData->displaySubWidgets(width, height, autoScaleFactor); | |||||
} | |||||
// ----------------------------------------------------------------------- | |||||
void TopLevelWidget::PrivateData::display() | |||||
{ | |||||
const Size<uint> size(window.getSize()); | |||||
const uint width = size.getWidth(); | |||||
const uint height = size.getHeight(); | |||||
const double autoScaleFactor = window.pData->autoScaleFactor; | |||||
#if 0 | |||||
// full viewport size | |||||
if (window.pData->autoScaling) | |||||
glViewport(0, -(height * autoScaleFactor - height), width * autoScaleFactor, height * autoScaleFactor); | |||||
else | |||||
glViewport(0, 0, width, height); | |||||
#endif | |||||
// main widget drawing | |||||
self->onDisplay(); | |||||
// now draw subwidgets if there are any | |||||
selfw->pData->displaySubWidgets(width, height, autoScaleFactor); | |||||
} | } | ||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
@@ -186,3 +214,10 @@ const GraphicsContext& Window::PrivateData::getGraphicsContext() const noexcept | |||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
END_NAMESPACE_DGL | END_NAMESPACE_DGL | ||||
// ----------------------------------------------------------------------- | |||||
// templated classes | |||||
#include "ImageBaseWidgets.cpp" | |||||
// ----------------------------------------------------------------------- |
@@ -23,19 +23,23 @@ START_NAMESPACE_DGL | |||||
ImageBase::ImageBase() | ImageBase::ImageBase() | ||||
: rawData(nullptr), | : rawData(nullptr), | ||||
size(0, 0) {} | |||||
size(0, 0), | |||||
format(kImageFormatBGRA) {} | |||||
ImageBase::ImageBase(const char* const rdata, const uint width, const uint height) | |||||
ImageBase::ImageBase(const char* const rdata, const uint width, const uint height, const ImageFormat fmt) | |||||
: rawData(rdata), | : rawData(rdata), | ||||
size(width, height) {} | |||||
size(width, height), | |||||
format(fmt) {} | |||||
ImageBase::ImageBase(const char* const rdata, const Size<uint>& s) | |||||
ImageBase::ImageBase(const char* const rdata, const Size<uint>& s, const ImageFormat fmt) | |||||
: rawData(rdata), | : rawData(rdata), | ||||
size(s) {} | |||||
size(s), | |||||
format(fmt) {} | |||||
ImageBase::ImageBase(const ImageBase& image) | ImageBase::ImageBase(const ImageBase& image) | ||||
: rawData(image.rawData), | : rawData(image.rawData), | ||||
size(image.size) {} | |||||
size(image.size), | |||||
format(image.format) {} | |||||
// -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
// public methods | // public methods | ||||
@@ -72,6 +76,26 @@ const char* ImageBase::getRawData() const noexcept | |||||
return rawData; | return rawData; | ||||
} | } | ||||
ImageFormat ImageBase::getFormat() const noexcept | |||||
{ | |||||
return format; | |||||
} | |||||
void ImageBase::loadFromMemory(const char* const rawData, | |||||
const uint width, | |||||
const uint height, | |||||
const ImageFormat format) noexcept | |||||
{ | |||||
loadFromMemory(rawData, Size<uint>(width, height), format); | |||||
} | |||||
void ImageBase::loadFromMemory(const char* const rdata, const Size<uint>& s, const ImageFormat fmt) noexcept | |||||
{ | |||||
rawData = rdata; | |||||
size = s; | |||||
format = fmt; | |||||
} | |||||
void ImageBase::draw(const GraphicsContext& context) | void ImageBase::draw(const GraphicsContext& context) | ||||
{ | { | ||||
drawAt(context, Point<int>(0, 0)); | drawAt(context, Point<int>(0, 0)); | ||||
@@ -171,6 +171,23 @@ template class Rectangle<ushort>; | |||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
static GLenum asOpenGLImageFormat(const ImageFormat format) | |||||
{ | |||||
switch (format) | |||||
{ | |||||
case kImageFormatBGR: | |||||
return GL_BGR; | |||||
case kImageFormatBGRA: | |||||
return GL_BGRA; | |||||
case kImageFormatRGB: | |||||
return GL_RGB; | |||||
case kImageFormatRGBA: | |||||
return GL_RGBA; | |||||
} | |||||
return GL_BGRA; | |||||
} | |||||
static void setupOpenGLImage(const OpenGLImage& image, GLuint textureId) | static void setupOpenGLImage(const OpenGLImage& image, GLuint textureId) | ||||
{ | { | ||||
DISTRHO_SAFE_ASSERT_RETURN(image.isValid(),); | DISTRHO_SAFE_ASSERT_RETURN(image.isValid(),); | ||||
@@ -192,7 +209,7 @@ static void setupOpenGLImage(const OpenGLImage& image, GLuint textureId) | |||||
static_cast<GLsizei>(image.getWidth()), | static_cast<GLsizei>(image.getWidth()), | ||||
static_cast<GLsizei>(image.getHeight()), | static_cast<GLsizei>(image.getHeight()), | ||||
0, | 0, | ||||
image.getFormat(), image.getType(), image.getRawData()); | |||||
asOpenGLImageFormat(image.getFormat()), GL_UNSIGNED_BYTE, image.getRawData()); | |||||
glBindTexture(GL_TEXTURE_2D, 0); | glBindTexture(GL_TEXTURE_2D, 0); | ||||
glDisable(GL_TEXTURE_2D); | glDisable(GL_TEXTURE_2D); | ||||
@@ -200,85 +217,52 @@ static void setupOpenGLImage(const OpenGLImage& image, GLuint textureId) | |||||
OpenGLImage::OpenGLImage() | OpenGLImage::OpenGLImage() | ||||
: ImageBase(), | : ImageBase(), | ||||
fFormat(0), | |||||
fType(0), | |||||
fTextureId(0), | |||||
textureId(0), | |||||
setupCalled(false) | setupCalled(false) | ||||
{ | { | ||||
glGenTextures(1, &fTextureId); | |||||
DISTRHO_SAFE_ASSERT(fTextureId != 0); | |||||
glGenTextures(1, &textureId); | |||||
DISTRHO_SAFE_ASSERT(textureId != 0); | |||||
} | } | ||||
OpenGLImage::OpenGLImage(const char* const rawData, const uint width, const uint height, const GLenum format, const GLenum type) | |||||
: ImageBase(rawData, width, height), | |||||
fFormat(format), | |||||
fType(type), | |||||
fTextureId(0), | |||||
OpenGLImage::OpenGLImage(const char* const rawData, const uint width, const uint height, const ImageFormat format) | |||||
: ImageBase(rawData, width, height, format), | |||||
textureId(0), | |||||
setupCalled(false) | setupCalled(false) | ||||
{ | { | ||||
glGenTextures(1, &fTextureId); | |||||
DISTRHO_SAFE_ASSERT(fTextureId != 0); | |||||
glGenTextures(1, &textureId); | |||||
DISTRHO_SAFE_ASSERT(textureId != 0); | |||||
} | } | ||||
OpenGLImage::OpenGLImage(const char* const rawData, const Size<uint>& size, const GLenum format, const GLenum type) | |||||
: ImageBase(rawData, size), | |||||
fFormat(format), | |||||
fType(type), | |||||
fTextureId(0), | |||||
OpenGLImage::OpenGLImage(const char* const rawData, const Size<uint>& size, const ImageFormat format) | |||||
: ImageBase(rawData, size, format), | |||||
textureId(0), | |||||
setupCalled(false) | setupCalled(false) | ||||
{ | { | ||||
glGenTextures(1, &fTextureId); | |||||
DISTRHO_SAFE_ASSERT(fTextureId != 0); | |||||
glGenTextures(1, &textureId); | |||||
DISTRHO_SAFE_ASSERT(textureId != 0); | |||||
} | } | ||||
OpenGLImage::OpenGLImage(const OpenGLImage& image) | OpenGLImage::OpenGLImage(const OpenGLImage& image) | ||||
: ImageBase(image), | : ImageBase(image), | ||||
fFormat(image.fFormat), | |||||
fType(image.fType), | |||||
fTextureId(0), | |||||
textureId(0), | |||||
setupCalled(false) | setupCalled(false) | ||||
{ | { | ||||
glGenTextures(1, &fTextureId); | |||||
DISTRHO_SAFE_ASSERT(fTextureId != 0); | |||||
glGenTextures(1, &textureId); | |||||
DISTRHO_SAFE_ASSERT(textureId != 0); | |||||
} | } | ||||
OpenGLImage::~OpenGLImage() | OpenGLImage::~OpenGLImage() | ||||
{ | { | ||||
if (fTextureId != 0) | |||||
glDeleteTextures(1, &fTextureId); | |||||
if (textureId != 0) | |||||
glDeleteTextures(1, &textureId); | |||||
} | } | ||||
void OpenGLImage::loadFromMemory(const char* const rawData, | |||||
const uint width, | |||||
const uint height, | |||||
const GLenum format, | |||||
const GLenum type) noexcept | |||||
void OpenGLImage::loadFromMemory(const char* const rdata, const Size<uint>& s, const ImageFormat fmt) noexcept | |||||
{ | { | ||||
loadFromMemory(rawData, Size<uint>(width, height), format, type); | |||||
} | |||||
void OpenGLImage::loadFromMemory(const char* const rdata, | |||||
const Size<uint>& s, | |||||
const GLenum format, | |||||
const GLenum type) noexcept | |||||
{ | |||||
rawData = rdata; | |||||
size = s; | |||||
fFormat = format; | |||||
fType = type; | |||||
ImageBase::loadFromMemory(rdata, s, fmt); | |||||
setupCalled = false; | setupCalled = false; | ||||
} | } | ||||
GLenum OpenGLImage::getFormat() const noexcept | |||||
{ | |||||
return fFormat; | |||||
} | |||||
GLenum OpenGLImage::getType() const noexcept | |||||
{ | |||||
return fType; | |||||
} | |||||
void OpenGLImage::drawAt(const GraphicsContext&, const Point<int>& pos) | void OpenGLImage::drawAt(const GraphicsContext&, const Point<int>& pos) | ||||
{ | { | ||||
drawAt(pos); | drawAt(pos); | ||||
@@ -288,8 +272,7 @@ OpenGLImage& OpenGLImage::operator=(const OpenGLImage& image) noexcept | |||||
{ | { | ||||
rawData = image.rawData; | rawData = image.rawData; | ||||
size = image.size; | size = image.size; | ||||
fFormat = image.fFormat; | |||||
fType = image.fType; | |||||
format = image.format; | |||||
setupCalled = false; | setupCalled = false; | ||||
return *this; | return *this; | ||||
} | } | ||||
@@ -306,17 +289,17 @@ void OpenGLImage::drawAt(const int x, const int y) | |||||
void OpenGLImage::drawAt(const Point<int>& pos) | void OpenGLImage::drawAt(const Point<int>& pos) | ||||
{ | { | ||||
if (fTextureId == 0 || isInvalid()) | |||||
if (textureId == 0 || isInvalid()) | |||||
return; | return; | ||||
if (! setupCalled) | if (! setupCalled) | ||||
{ | { | ||||
setupOpenGLImage(*this, fTextureId); | |||||
setupOpenGLImage(*this, textureId); | |||||
setupCalled = true; | setupCalled = true; | ||||
} | } | ||||
glEnable(GL_TEXTURE_2D); | glEnable(GL_TEXTURE_2D); | ||||
glBindTexture(GL_TEXTURE_2D, fTextureId); | |||||
glBindTexture(GL_TEXTURE_2D, textureId); | |||||
glBegin(GL_QUADS); | glBegin(GL_QUADS); | ||||
@@ -353,6 +336,8 @@ void ImageBaseAboutWindow<OpenGLImage>::onDisplay() | |||||
img.draw(); | img.draw(); | ||||
} | } | ||||
template class ImageBaseAboutWindow<OpenGLImage>; | |||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
void SubWidget::PrivateData::display(const uint width, const uint height, const double autoScaleFactor) | void SubWidget::PrivateData::display(const uint width, const uint height, const double autoScaleFactor) | ||||
@@ -444,10 +429,4 @@ END_NAMESPACE_DGL | |||||
#include "ImageBaseWidgets.cpp" | #include "ImageBaseWidgets.cpp" | ||||
START_NAMESPACE_DGL | |||||
template class ImageBaseAboutWindow<OpenGLImage>; | |||||
END_NAMESPACE_DGL | |||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- |
@@ -72,6 +72,7 @@ START_NAMESPACE_DGL | |||||
#elif defined(DISTRHO_OS_WINDOWS) | #elif defined(DISTRHO_OS_WINDOWS) | ||||
#else | #else | ||||
# include "pugl-upstream/src/x11.c" | # include "pugl-upstream/src/x11.c" | ||||
# include "pugl-upstream/src/x11_stub.c" | |||||
# ifdef DGL_CAIRO | # ifdef DGL_CAIRO | ||||
# include "pugl-upstream/src/x11_cairo.c" | # include "pugl-upstream/src/x11_cairo.c" | ||||
# endif | # endif | ||||
@@ -14,33 +14,49 @@ | |||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||||
*/ | */ | ||||
#ifndef DGL_OPENGL | |||||
#error OpenGL build required for Demo | |||||
#endif | |||||
// #ifndef DGL_OPENGL | |||||
// #error OpenGL build required for Demo | |||||
// #endif | |||||
#include "tests.hpp" | #include "tests.hpp" | ||||
// TODO backend agnostic | |||||
#include "../dgl/OpenGL.hpp" | |||||
#include "widgets/ExampleColorWidget.hpp" | #include "widgets/ExampleColorWidget.hpp" | ||||
#include "widgets/ExampleImagesWidget.hpp" | #include "widgets/ExampleImagesWidget.hpp" | ||||
#include "widgets/ExampleRectanglesWidget.hpp" | #include "widgets/ExampleRectanglesWidget.hpp" | ||||
#include "widgets/ExampleTextWidget.hpp" | |||||
#include "widgets/ExampleShapesWidget.hpp" | #include "widgets/ExampleShapesWidget.hpp" | ||||
#ifdef DGL_OPENGL | |||||
#include "widgets/ExampleTextWidget.hpp" | |||||
#endif | |||||
#include "demo_res/DemoArtwork.cpp" | #include "demo_res/DemoArtwork.cpp" | ||||
#include "images_res/CatPics.cpp" | #include "images_res/CatPics.cpp" | ||||
#ifdef DGL_CAIRO | |||||
#include "../dgl/Cairo.hpp" | |||||
typedef DGL_NAMESPACE::CairoImage DemoImage; | |||||
#endif | |||||
#ifdef DGL_OPENGL | |||||
#include "../dgl/OpenGL.hpp" | |||||
typedef DGL_NAMESPACE::OpenGLImage DemoImage; | |||||
#endif | |||||
START_NAMESPACE_DGL | START_NAMESPACE_DGL | ||||
typedef ExampleImagesWidget<SubWidget, DemoImage> ExampleImagesSubWidget; | |||||
typedef ExampleImagesWidget<TopLevelWidget, DemoImage> ExampleImagesTopLevelWidget; | |||||
typedef ExampleImagesWidget<StandaloneWindow, DemoImage> ExampleImagesStandaloneWindow; | |||||
// -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
// Left side tab-like widget | // Left side tab-like widget | ||||
class LeftSideWidget : public SubWidget | class LeftSideWidget : public SubWidget | ||||
{ | { | ||||
public: | public: | ||||
#ifdef DGL_OPENGL | |||||
static const int kPageCount = 5; | static const int kPageCount = 5; | ||||
#else | |||||
static const int kPageCount = 4; | |||||
#endif | |||||
class Callback | class Callback | ||||
{ | { | ||||
@@ -55,22 +71,26 @@ public: | |||||
curPage(0), | curPage(0), | ||||
curHover(-1) | curHover(-1) | ||||
{ | { | ||||
#ifdef DGL_OPENGL | |||||
// for text | // for text | ||||
nvg.loadSharedResources(); | nvg.loadSharedResources(); | ||||
#endif | |||||
using namespace DemoArtwork; | using namespace DemoArtwork; | ||||
img1.loadFromMemory(ico1Data, ico1Width, ico1Height, GL_BGR); | |||||
img2.loadFromMemory(ico2Data, ico2Width, ico2Height, GL_BGR); | |||||
img3.loadFromMemory(ico3Data, ico3Width, ico2Height, GL_BGR); | |||||
img4.loadFromMemory(ico4Data, ico4Width, ico4Height, GL_BGR); | |||||
img5.loadFromMemory(ico5Data, ico5Width, ico5Height, GL_BGR); | |||||
img1.loadFromMemory(ico1Data, ico1Width, ico1Height, kImageFormatBGR); | |||||
img2.loadFromMemory(ico2Data, ico2Width, ico2Height, kImageFormatBGR); | |||||
img3.loadFromMemory(ico3Data, ico3Width, ico2Height, kImageFormatBGR); | |||||
img4.loadFromMemory(ico4Data, ico4Width, ico4Height, kImageFormatBGR); | |||||
img5.loadFromMemory(ico5Data, ico5Width, ico5Height, kImageFormatBGR); | |||||
} | } | ||||
protected: | protected: | ||||
void onDisplay() override | void onDisplay() override | ||||
{ | { | ||||
const GraphicsContext& context(getGraphicsContext()); | |||||
const int iconSize = bgIcon.getWidth(); | const int iconSize = bgIcon.getWidth(); | ||||
#if 0 /* TODO make generic */ | |||||
glColor3f(0.027f, 0.027f, 0.027f); | glColor3f(0.027f, 0.027f, 0.027f); | ||||
Rectangle<uint>(0, 0, getSize()).draw(); | Rectangle<uint>(0, 0, getSize()).draw(); | ||||
@@ -99,15 +119,17 @@ protected: | |||||
// reset color | // reset color | ||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f); | glColor4f(1.0f, 1.0f, 1.0f, 1.0f); | ||||
#endif | |||||
const int pad = iconSize/2 - DemoArtwork::ico1Width/2; | const int pad = iconSize/2 - DemoArtwork::ico1Width/2; | ||||
img1.drawAt(pad, pad); | |||||
img2.drawAt(pad, pad + 3 + iconSize); | |||||
img3.drawAt(pad, pad + 6 + iconSize*2); | |||||
img4.drawAt(pad, pad + 9 + iconSize*3); | |||||
img5.drawAt(pad, pad + 12 + iconSize*4); | |||||
img1.drawAt(context, pad, pad); | |||||
img2.drawAt(context, pad, pad + 3 + iconSize); | |||||
img3.drawAt(context, pad, pad + 6 + iconSize*2); | |||||
img4.drawAt(context, pad, pad + 9 + iconSize*3); | |||||
img5.drawAt(context, pad, pad + 12 + iconSize*4); | |||||
#ifdef DGL_OPENGL | |||||
// draw some text | // draw some text | ||||
nvg.beginFrame(this); | nvg.beginFrame(this); | ||||
@@ -120,6 +142,7 @@ protected: | |||||
nvg.textBox(15, 440, iconSize, "Look!", nullptr); | nvg.textBox(15, 440, iconSize, "Look!", nullptr); | ||||
nvg.endFrame(); | nvg.endFrame(); | ||||
#endif | |||||
} | } | ||||
bool onMouse(const MouseEvent& ev) override | bool onMouse(const MouseEvent& ev) override | ||||
@@ -203,10 +226,12 @@ private: | |||||
int curPage, curHover; | int curPage, curHover; | ||||
Rectangle<double> bgIcon; | Rectangle<double> bgIcon; | ||||
Line<int> lineSep; | Line<int> lineSep; | ||||
OpenGLImage img1, img2, img3, img4, img5; | |||||
DemoImage img1, img2, img3, img4, img5; | |||||
#ifdef DGL_OPENGL | |||||
// for text | // for text | ||||
NanoVG nvg; | NanoVG nvg; | ||||
#endif | |||||
}; | }; | ||||
// -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
@@ -226,7 +251,9 @@ public: | |||||
wImages(this), | wImages(this), | ||||
wRects(this), | wRects(this), | ||||
wShapes(this), | wShapes(this), | ||||
#ifdef DGL_OPENGL | |||||
wText(this), | wText(this), | ||||
#endif | |||||
wLeft(this, this), | wLeft(this, this), | ||||
curWidget(nullptr) | curWidget(nullptr) | ||||
{ | { | ||||
@@ -234,16 +261,18 @@ public: | |||||
wImages.hide(); | wImages.hide(); | ||||
wRects.hide(); | wRects.hide(); | ||||
wShapes.hide(); | wShapes.hide(); | ||||
#ifdef DGL_OPENGL | |||||
wText.hide(); | wText.hide(); | ||||
// //wPerf.hide(); | |||||
#endif | |||||
wColor.setAbsoluteX(kSidebarWidth); | wColor.setAbsoluteX(kSidebarWidth); | ||||
wImages.setAbsoluteX(kSidebarWidth); | wImages.setAbsoluteX(kSidebarWidth); | ||||
wRects.setAbsoluteX(kSidebarWidth); | wRects.setAbsoluteX(kSidebarWidth); | ||||
wShapes.setAbsoluteX(kSidebarWidth); | wShapes.setAbsoluteX(kSidebarWidth); | ||||
#ifdef DGL_OPENGL | |||||
wText.setAbsoluteX(kSidebarWidth); | wText.setAbsoluteX(kSidebarWidth); | ||||
#endif | |||||
wLeft.setAbsolutePos(2, 2); | wLeft.setAbsolutePos(2, 2); | ||||
// wPerf.setAbsoluteY(5); | |||||
setSize(600, 500); | setSize(600, 500); | ||||
setTitle("DGL Demo"); | setTitle("DGL Demo"); | ||||
@@ -271,9 +300,11 @@ protected: | |||||
case 3: | case 3: | ||||
curWidget = &wShapes; | curWidget = &wShapes; | ||||
break; | break; | ||||
#ifdef DGL_OPENGL | |||||
case 4: | case 4: | ||||
curWidget = &wText; | curWidget = &wText; | ||||
break; | break; | ||||
#endif | |||||
default: | default: | ||||
curWidget = nullptr; | curWidget = nullptr; | ||||
break; | break; | ||||
@@ -299,13 +330,10 @@ protected: | |||||
wImages.setSize(size); | wImages.setSize(size); | ||||
wRects.setSize(size); | wRects.setSize(size); | ||||
wShapes.setSize(size); | wShapes.setSize(size); | ||||
#ifdef DGL_OPENGL | |||||
wText.setSize(size); | wText.setSize(size); | ||||
#endif | |||||
wLeft.setSize(kSidebarWidth-4, height-4); | wLeft.setSize(kSidebarWidth-4, height-4); | ||||
//wRezHandle.setAbsoluteX(width-wRezHandle.getWidth()); | |||||
//wRezHandle.setAbsoluteY(height-wRezHandle.getHeight()); | |||||
// wPerf.setAbsoluteX(width-wPerf.getWidth()-5); | |||||
} | } | ||||
private: | private: | ||||
@@ -313,10 +341,10 @@ private: | |||||
ExampleImagesSubWidget wImages; | ExampleImagesSubWidget wImages; | ||||
ExampleRectanglesSubWidget wRects; | ExampleRectanglesSubWidget wRects; | ||||
ExampleShapesSubWidget wShapes; | ExampleShapesSubWidget wShapes; | ||||
#ifdef DGL_OPENGL | |||||
ExampleTextSubWidget wText; | ExampleTextSubWidget wText; | ||||
#endif | |||||
LeftSideWidget wLeft; | LeftSideWidget wLeft; | ||||
//ResizeHandle wRezHandle; | |||||
// NanoPerfWidget wPerf; | |||||
Widget* curWidget; | Widget* curWidget; | ||||
}; | }; | ||||
@@ -357,8 +385,10 @@ int main(int argc, char* argv[]) | |||||
createAndShowExampleWidgetStandaloneWindow<ExampleRectanglesStandaloneWindow>(app); | createAndShowExampleWidgetStandaloneWindow<ExampleRectanglesStandaloneWindow>(app); | ||||
else if (std::strcmp(argv[1], "shapes") == 0) | else if (std::strcmp(argv[1], "shapes") == 0) | ||||
createAndShowExampleWidgetStandaloneWindow<ExampleShapesStandaloneWindow>(app); | createAndShowExampleWidgetStandaloneWindow<ExampleShapesStandaloneWindow>(app); | ||||
#ifdef DGL_OPENGL | |||||
else if (std::strcmp(argv[1], "text") == 0) | else if (std::strcmp(argv[1], "text") == 0) | ||||
createAndShowExampleWidgetStandaloneWindow<ExampleTextStandaloneWindow>(app); | createAndShowExampleWidgetStandaloneWindow<ExampleTextStandaloneWindow>(app); | ||||
#endif | |||||
else | else | ||||
d_stderr2("Invalid demo mode, must be one of: color, rectangles, shapes"); | d_stderr2("Invalid demo mode, must be one of: color, rectangles, shapes"); | ||||
} | } | ||||
@@ -22,11 +22,12 @@ BUILD_CXX_FLAGS += -Wno-missing-field-initializers -Wno-extra | |||||
TESTS = Application Color Point | TESTS = Application Color Point | ||||
ifeq ($(HAVE_CAIRO),true) | ifeq ($(HAVE_CAIRO),true) | ||||
WTESTS = Window.cairo | |||||
TESTS += Demo.cairo | |||||
WTESTS += Window.cairo | |||||
endif | endif | ||||
ifeq ($(HAVE_OPENGL),true) | ifeq ($(HAVE_OPENGL),true) | ||||
TESTS += Demo | |||||
WTESTS = Window.opengl | |||||
TESTS += Demo.opengl | |||||
WTESTS += Window.opengl | |||||
endif | endif | ||||
ifeq ($(HAVE_VULKAN),true) | ifeq ($(HAVE_VULKAN),true) | ||||
WTESTS = Window.vulkan | WTESTS = Window.vulkan | ||||
@@ -88,16 +89,6 @@ clean: | |||||
@echo "Compiling $< (Cairo)" | @echo "Compiling $< (Cairo)" | ||||
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(CAIRO_FLAGS) -DDGL_CAIRO -c -o $@ | $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(CAIRO_FLAGS) -DDGL_CAIRO -c -o $@ | ||||
../build/tests/Demo.cpp.o: Demo.cpp | |||||
-@mkdir -p ../build/tests | |||||
@echo "Compiling $< (OpenGL)" | |||||
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(OPENGL_FLAGS) -DDGL_OPENGL -c -o $@ | |||||
../build/tests/Testing.cpp.o: Testing.cpp | |||||
-@mkdir -p ../build/tests | |||||
@echo "Compiling $< (OpenGL)" | |||||
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(OPENGL_FLAGS) -DDGL_OPENGL -c -o $@ | |||||
../build/tests/%.cpp.opengl.o: %.cpp | ../build/tests/%.cpp.opengl.o: %.cpp | ||||
-@mkdir -p ../build/tests | -@mkdir -p ../build/tests | ||||
@echo "Compiling $< (OpenGL)" | @echo "Compiling $< (OpenGL)" | ||||
@@ -119,14 +110,6 @@ clean: | |||||
@echo "Linking $*" | @echo "Linking $*" | ||||
$(SILENT)$(CXX) $< $(LINK_FLAGS) $(DGL_SYSTEM_LIBS) $(CAIRO_LIBS) -o $@ | $(SILENT)$(CXX) $< $(LINK_FLAGS) $(DGL_SYSTEM_LIBS) $(CAIRO_LIBS) -o $@ | ||||
../build/tests/Demo: ../build/tests/Demo.cpp.o ../build/libdgl-opengl.a | |||||
@echo "Linking Demo" | |||||
$(SILENT)$(CXX) $^ $(LINK_FLAGS) $(DGL_SYSTEM_LIBS) $(OPENGL_LIBS) -o $@ | |||||
../build/tests/Testing: ../build/tests/Testing.cpp.o | |||||
@echo "Linking Testing" | |||||
$(SILENT)$(CXX) $< $(LINK_FLAGS) $(DGL_SYSTEM_LIBS) $(OPENGL_LIBS) -o $@ | |||||
../build/tests/%.opengl: ../build/tests/%.cpp.opengl.o | ../build/tests/%.opengl: ../build/tests/%.cpp.opengl.o | ||||
@echo "Linking $*" | @echo "Linking $*" | ||||
$(SILENT)$(CXX) $< $(LINK_FLAGS) $(DGL_SYSTEM_LIBS) $(OPENGL_LIBS) -o $@ | $(SILENT)$(CXX) $< $(LINK_FLAGS) $(DGL_SYSTEM_LIBS) $(OPENGL_LIBS) -o $@ | ||||
@@ -135,6 +118,18 @@ clean: | |||||
@echo "Linking $*" | @echo "Linking $*" | ||||
$(SILENT)$(CXX) $< $(LINK_FLAGS) $(DGL_SYSTEM_LIBS) $(VULKAN_LIBS) -o $@ | $(SILENT)$(CXX) $< $(LINK_FLAGS) $(DGL_SYSTEM_LIBS) $(VULKAN_LIBS) -o $@ | ||||
../build/tests/Demo.cairo: ../build/tests/Demo.cpp.cairo.o ../build/libdgl-cairo.a | |||||
@echo "Linking Demo (Cairo)" | |||||
$(SILENT)$(CXX) $^ $(LINK_FLAGS) $(DGL_SYSTEM_LIBS) $(CAIRO_LIBS) -o $@ | |||||
../build/tests/Demo.opengl: ../build/tests/Demo.cpp.opengl.o ../build/libdgl-opengl.a | |||||
@echo "Linking Demo (OpenGL)" | |||||
$(SILENT)$(CXX) $^ $(LINK_FLAGS) $(DGL_SYSTEM_LIBS) $(OPENGL_LIBS) -o $@ | |||||
../build/tests/Demo.vulkan: ../build/tests/Demo.cpp.vulkan.o ../build/libdgl-vulkan.a | |||||
@echo "Linking Demo (OpenGL)" | |||||
$(SILENT)$(CXX) $^ $(LINK_FLAGS) $(DGL_SYSTEM_LIBS) $(VULKAN_LIBS) -o $@ | |||||
# --------------------------------------------------------------------------------------------------------------------- | # --------------------------------------------------------------------------------------------------------------------- | ||||
-include $(OBJS:%.o=%.d) | -include $(OBJS:%.o=%.d) | ||||
@@ -108,6 +108,7 @@ protected: | |||||
{ | { | ||||
const GraphicsContext& context(BaseWidget::getGraphicsContext()); | const GraphicsContext& context(BaseWidget::getGraphicsContext()); | ||||
#if 0 /* TODO make generic */ | |||||
// paint bg color (in full size) | // paint bg color (in full size) | ||||
glColor3b(r, g, b); | glColor3b(r, g, b); | ||||
bgFull.draw(context); | bgFull.draw(context); | ||||
@@ -115,6 +116,7 @@ protected: | |||||
// paint inverted color (in 2/3 size) | // paint inverted color (in 2/3 size) | ||||
glColor3b(100-r, 100-g, 100-b); | glColor3b(100-r, 100-g, 100-b); | ||||
bgSmall.draw(); | bgSmall.draw(); | ||||
#endif | |||||
} | } | ||||
void onResize(const ResizeEvent& ev) override | void onResize(const ResizeEvent& ev) override | ||||
@@ -20,11 +20,10 @@ | |||||
// ------------------------------------------------------ | // ------------------------------------------------------ | ||||
// DGL Stuff | // DGL Stuff | ||||
#include "../../dgl/Image.hpp" | |||||
#include "../../dgl/ImageBase.hpp" | |||||
#include "../../dgl/SubWidget.hpp" | #include "../../dgl/SubWidget.hpp" | ||||
#include "../../dgl/TopLevelWidget.hpp" | #include "../../dgl/TopLevelWidget.hpp" | ||||
// ------------------------------------------------------ | // ------------------------------------------------------ | ||||
// Images | // Images | ||||
@@ -35,7 +34,7 @@ START_NAMESPACE_DGL | |||||
// ------------------------------------------------------ | // ------------------------------------------------------ | ||||
// our widget | // our widget | ||||
template <class BaseWidget> | |||||
template <class BaseWidget, class BaseImage> | |||||
class ExampleImagesWidget : public BaseWidget, | class ExampleImagesWidget : public BaseWidget, | ||||
public IdleCallback | public IdleCallback | ||||
{ | { | ||||
@@ -50,7 +49,7 @@ class ExampleImagesWidget : public BaseWidget, | |||||
int imgTop1st, imgTop2nd, imgTop3rd; | int imgTop1st, imgTop2nd, imgTop3rd; | ||||
int img1x, img2x, img3y; | int img1x, img2x, img3y; | ||||
bool img1rev, img2rev, img3rev; | bool img1rev, img2rev, img3rev; | ||||
Image img1, img2, img3; | |||||
BaseImage img1, img2, img3; | |||||
public: | public: | ||||
static constexpr const char* kExampleWidgetName = "Images"; | static constexpr const char* kExampleWidgetName = "Images"; | ||||
@@ -67,9 +66,9 @@ public: | |||||
img1rev(false), | img1rev(false), | ||||
img2rev(true), | img2rev(true), | ||||
img3rev(true), | img3rev(true), | ||||
img1(CatPics::cat1Data, CatPics::cat1Width, CatPics::cat1Height, GL_BGR), | |||||
img2(CatPics::cat2Data, CatPics::cat2Width, CatPics::cat2Height, GL_BGR), | |||||
img3(CatPics::cat3Data, CatPics::cat3Width, CatPics::cat3Height, GL_BGR) | |||||
img1(CatPics::cat1Data, CatPics::cat1Width, CatPics::cat1Height, kImageFormatBGR), | |||||
img2(CatPics::cat2Data, CatPics::cat2Width, CatPics::cat2Height, kImageFormatBGR), | |||||
img3(CatPics::cat3Data, CatPics::cat3Width, CatPics::cat3Height, kImageFormatBGR) | |||||
{ | { | ||||
BaseWidget::setSize(500, 400); | BaseWidget::setSize(500, 400); | ||||
@@ -88,9 +87,9 @@ public: | |||||
img1rev(false), | img1rev(false), | ||||
img2rev(true), | img2rev(true), | ||||
img3rev(true), | img3rev(true), | ||||
img1(CatPics::cat1Data, CatPics::cat1Width, CatPics::cat1Height, GL_BGR), | |||||
img2(CatPics::cat2Data, CatPics::cat2Width, CatPics::cat2Height, GL_BGR), | |||||
img3(CatPics::cat3Data, CatPics::cat3Width, CatPics::cat3Height, GL_BGR) | |||||
img1(CatPics::cat1Data, CatPics::cat1Width, CatPics::cat1Height, kImageFormatBGR), | |||||
img2(CatPics::cat2Data, CatPics::cat2Width, CatPics::cat2Height, kImageFormatBGR), | |||||
img3(CatPics::cat3Data, CatPics::cat3Width, CatPics::cat3Height, kImageFormatBGR) | |||||
{ | { | ||||
BaseWidget::setSize(500, 400); | BaseWidget::setSize(500, 400); | ||||
@@ -109,9 +108,9 @@ public: | |||||
img1rev(false), | img1rev(false), | ||||
img2rev(true), | img2rev(true), | ||||
img3rev(true), | img3rev(true), | ||||
img1(CatPics::cat1Data, CatPics::cat1Width, CatPics::cat1Height, GL_BGR), | |||||
img2(CatPics::cat2Data, CatPics::cat2Width, CatPics::cat2Height, GL_BGR), | |||||
img3(CatPics::cat3Data, CatPics::cat3Width, CatPics::cat3Height, GL_BGR) | |||||
img1(CatPics::cat1Data, CatPics::cat1Width, CatPics::cat1Height, kImageFormatBGR), | |||||
img2(CatPics::cat2Data, CatPics::cat2Width, CatPics::cat2Height, kImageFormatBGR), | |||||
img3(CatPics::cat3Data, CatPics::cat3Width, CatPics::cat3Height, kImageFormatBGR) | |||||
{ | { | ||||
BaseWidget::setSize(500, 400); | BaseWidget::setSize(500, 400); | ||||
@@ -183,42 +182,44 @@ protected: | |||||
void onDisplay() override | void onDisplay() override | ||||
{ | { | ||||
const GraphicsContext& context(BaseWidget::getGraphicsContext()); | |||||
switch (imgTop3rd) | switch (imgTop3rd) | ||||
{ | { | ||||
case 1: | case 1: | ||||
img1.drawAt(img1x, kImg1y); | |||||
img1.drawAt(context, img1x, kImg1y); | |||||
break; | break; | ||||
case 2: | case 2: | ||||
img2.drawAt(img2x, kImg2y); | |||||
img2.drawAt(context, img2x, kImg2y); | |||||
break; | break; | ||||
case 3: | case 3: | ||||
img3.drawAt(kImg3x, img3y); | |||||
img3.drawAt(context, kImg3x, img3y); | |||||
break; | break; | ||||
}; | }; | ||||
switch (imgTop2nd) | switch (imgTop2nd) | ||||
{ | { | ||||
case 1: | case 1: | ||||
img1.drawAt(img1x, kImg1y); | |||||
img1.drawAt(context, img1x, kImg1y); | |||||
break; | break; | ||||
case 2: | case 2: | ||||
img2.drawAt(img2x, kImg2y); | |||||
img2.drawAt(context, img2x, kImg2y); | |||||
break; | break; | ||||
case 3: | case 3: | ||||
img3.drawAt(kImg3x, img3y); | |||||
img3.drawAt(context, kImg3x, img3y); | |||||
break; | break; | ||||
}; | }; | ||||
switch (imgTop1st) | switch (imgTop1st) | ||||
{ | { | ||||
case 1: | case 1: | ||||
img1.drawAt(img1x, kImg1y); | |||||
img1.drawAt(context, img1x, kImg1y); | |||||
break; | break; | ||||
case 2: | case 2: | ||||
img2.drawAt(img2x, kImg2y); | |||||
img2.drawAt(context, img2x, kImg2y); | |||||
break; | break; | ||||
case 3: | case 3: | ||||
img3.drawAt(kImg3x, img3y); | |||||
img3.drawAt(context, kImg3x, img3y); | |||||
break; | break; | ||||
}; | }; | ||||
} | } | ||||
@@ -242,10 +243,6 @@ private: | |||||
} | } | ||||
}; | }; | ||||
typedef ExampleImagesWidget<SubWidget> ExampleImagesSubWidget; | |||||
typedef ExampleImagesWidget<TopLevelWidget> ExampleImagesTopLevelWidget; | |||||
typedef ExampleImagesWidget<StandaloneWindow> ExampleImagesStandaloneWindow; | |||||
// ------------------------------------------------------ | // ------------------------------------------------------ | ||||
END_NAMESPACE_DGL | END_NAMESPACE_DGL | ||||
@@ -81,30 +81,36 @@ protected: | |||||
// 1st | // 1st | ||||
r.setY(3); | r.setY(3); | ||||
#if 0 /* TODO make generic */ | |||||
if (clicked[0+i]) | if (clicked[0+i]) | ||||
glColor3f(0.8f, 0.5f, 0.3f); | glColor3f(0.8f, 0.5f, 0.3f); | ||||
else | else | ||||
glColor3f(0.3f, 0.5f, 0.8f); | glColor3f(0.3f, 0.5f, 0.8f); | ||||
#endif | |||||
r.draw(); | r.draw(); | ||||
// 2nd | // 2nd | ||||
r.setY(3 + height/3); | r.setY(3 + height/3); | ||||
#if 0 /* TODO make generic */ | |||||
if (clicked[3+i]) | if (clicked[3+i]) | ||||
glColor3f(0.8f, 0.5f, 0.3f); | glColor3f(0.8f, 0.5f, 0.3f); | ||||
else | else | ||||
glColor3f(0.3f, 0.5f, 0.8f); | glColor3f(0.3f, 0.5f, 0.8f); | ||||
#endif | |||||
r.draw(); | r.draw(); | ||||
// 3rd | // 3rd | ||||
r.setY(3 + height*2/3); | r.setY(3 + height*2/3); | ||||
#if 0 /* TODO make generic */ | |||||
if (clicked[6+i]) | if (clicked[6+i]) | ||||
glColor3f(0.8f, 0.5f, 0.3f); | glColor3f(0.8f, 0.5f, 0.3f); | ||||
else | else | ||||
glColor3f(0.3f, 0.5f, 0.8f); | glColor3f(0.3f, 0.5f, 0.8f); | ||||
#endif | |||||
r.draw(); | r.draw(); | ||||
} | } | ||||
@@ -69,6 +69,7 @@ protected: | |||||
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); | glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); | ||||
#endif | #endif | ||||
#if 0 /* TODO make generic */ | |||||
glLineWidth(1.0f); | glLineWidth(1.0f); | ||||
glColor3f(0.302f, 0.337f, 0.361f); | glColor3f(0.302f, 0.337f, 0.361f); | ||||
bg.draw(); | bg.draw(); | ||||
@@ -92,6 +93,7 @@ protected: | |||||
glLineWidth(2.0f); | glLineWidth(2.0f); | ||||
glColor3f(0.176f/4, 0.212f/4, 0.235f/4); | glColor3f(0.176f/4, 0.212f/4, 0.235f/4); | ||||
cir.drawOutline(); | cir.drawOutline(); | ||||
#endif | |||||
} | } | ||||
void onResize(const ResizeEvent& ev) override | void onResize(const ResizeEvent& ev) override | ||||