@@ -266,17 +266,6 @@ void Window::PrivateData::initPre(const uint width, const uint height, const boo | |||||
#endif | #endif | ||||
puglSetViewHint(view, PUGL_STENCIL_BITS, 8); | puglSetViewHint(view, PUGL_STENCIL_BITS, 8); | ||||
#if defined(DGL_USE_OPENGL3) || defined(DGL_USE_GLES3) | |||||
puglSetViewHint(view, PUGL_USE_COMPAT_PROFILE, PUGL_FALSE); | |||||
puglSetViewHint(view, PUGL_CONTEXT_VERSION_MAJOR, 3); | |||||
#elif defined(DGL_USE_GLES2) | |||||
puglSetViewHint(view, PUGL_USE_COMPAT_PROFILE, PUGL_FALSE); | |||||
puglSetViewHint(view, PUGL_CONTEXT_VERSION_MAJOR, 2); | |||||
#else | |||||
puglSetViewHint(view, PUGL_USE_COMPAT_PROFILE, PUGL_TRUE); | |||||
puglSetViewHint(view, PUGL_CONTEXT_VERSION_MAJOR, 2); | |||||
#endif | |||||
// PUGL_SAMPLES ?? | // PUGL_SAMPLES ?? | ||||
puglSetEventFunc(view, puglEventCallback); | puglSetEventFunc(view, puglEventCallback); | ||||
@@ -32,6 +32,37 @@ | |||||
#ifndef NVG_NO_STB | #ifndef NVG_NO_STB | ||||
#define STB_IMAGE_IMPLEMENTATION | #define STB_IMAGE_IMPLEMENTATION | ||||
#define stbi_convert_iphone_png_to_rgb dpf_stbi_convert_iphone_png_to_rgb | |||||
#define stbi_failure_reason dpf_stbi_failure_reason | |||||
#define stbi_hdr_to_ldr_gamma dpf_stbi_hdr_to_ldr_gamma | |||||
#define stbi_hdr_to_ldr_scale dpf_stbi_hdr_to_ldr_scale | |||||
#define stbi_image_free dpf_stbi_image_free | |||||
#define stbi_info dpf_stbi_info | |||||
#define stbi_info_from_callbacks dpf_stbi_info_from_callbacks | |||||
#define stbi_info_from_file dpf_stbi_info_from_file | |||||
#define stbi_info_from_memory dpf_stbi_info_from_memory | |||||
#define stbi_is_hdr dpf_stbi_is_hdr | |||||
#define stbi_is_hdr_from_callbacks dpf_stbi_is_hdr_from_callbacks | |||||
#define stbi_is_hdr_from_file dpf_stbi_is_hdr_from_file | |||||
#define stbi_is_hdr_from_memory dpf_stbi_is_hdr_from_memory | |||||
#define stbi_ldr_to_hdr_gamma dpf_stbi_ldr_to_hdr_gamma | |||||
#define stbi_ldr_to_hdr_scale dpf_stbi_ldr_to_hdr_scale | |||||
#define stbi_load dpf_stbi_load | |||||
#define stbi_load_from_callbacks dpf_stbi_load_from_callbacks | |||||
#define stbi_load_from_file dpf_stbi_load_from_file | |||||
#define stbi_load_from_memory dpf_stbi_load_from_memory | |||||
#define stbi_loadf dpf_stbi_loadf | |||||
#define stbi_loadf_from_callbacks dpf_stbi_loadf_from_callbacks | |||||
#define stbi_loadf_from_file dpf_stbi_loadf_from_file | |||||
#define stbi_loadf_from_memory dpf_stbi_loadf_from_memory | |||||
#define stbi_set_flip_vertically_on_load dpf_stbi_set_flip_vertically_on_load | |||||
#define stbi_set_unpremultiply_on_load dpf_stbi_set_unpremultiply_on_load | |||||
#define stbi_zlib_decode_buffer dpf_stbi_zlib_decode_buffer | |||||
#define stbi_zlib_decode_malloc dpf_stbi_zlib_decode_malloc | |||||
#define stbi_zlib_decode_malloc_guesssize dpf_stbi_zlib_decode_malloc_guesssize | |||||
#define stbi_zlib_decode_malloc_guesssize_headerflag dpf_stbi_zlib_decode_malloc_guesssize_headerflag | |||||
#define stbi_zlib_decode_noheader_buffer dpf_stbi_zlib_decode_noheader_buffer | |||||
#define stbi_zlib_decode_noheader_malloc dpf_stbi_zlib_decode_noheader_malloc | |||||
#include "stb_image.h" | #include "stb_image.h" | ||||
#endif | #endif | ||||
@@ -44,9 +44,6 @@ | |||||
# ifdef DGL_CAIRO | # ifdef DGL_CAIRO | ||||
# include <cairo-quartz.h> | # include <cairo-quartz.h> | ||||
# endif | # endif | ||||
# ifdef DGL_OPENGL | |||||
# include <OpenGL/gl.h> | |||||
# endif | |||||
# ifdef DGL_VULKAN | # ifdef DGL_VULKAN | ||||
# import <QuartzCore/CAMetalLayer.h> | # import <QuartzCore/CAMetalLayer.h> | ||||
# include <vulkan/vulkan_macos.h> | # include <vulkan/vulkan_macos.h> | ||||
@@ -204,17 +201,35 @@ bool puglBackendLeave(PuglView* const view) | |||||
void puglSetMatchingBackendForCurrentBuild(PuglView* const view) | void puglSetMatchingBackendForCurrentBuild(PuglView* const view) | ||||
{ | { | ||||
#ifdef DGL_CAIRO | |||||
#ifdef DGL_CAIRO | |||||
puglSetBackend(view, puglCairoBackend()); | puglSetBackend(view, puglCairoBackend()); | ||||
#endif | |||||
#ifdef DGL_OPENGL | |||||
#endif | |||||
#ifdef DGL_OPENGL | |||||
puglSetBackend(view, puglGlBackend()); | puglSetBackend(view, puglGlBackend()); | ||||
#endif | |||||
#ifdef DGL_VULKAN | |||||
#endif | |||||
#ifdef DGL_VULKAN | |||||
puglSetBackend(view, puglVulkanBackend()); | puglSetBackend(view, puglVulkanBackend()); | ||||
#endif | |||||
if (view->backend == nullptr) | |||||
#endif | |||||
if (view->backend != nullptr) | |||||
{ | |||||
#ifdef DGL_OPENGL | |||||
#if defined(DGL_USE_OPENGL3) || defined(DGL_USE_GLES3) | |||||
puglSetViewHint(view, PUGL_USE_COMPAT_PROFILE, PUGL_FALSE); | |||||
puglSetViewHint(view, PUGL_CONTEXT_VERSION_MAJOR, 3); | |||||
#elif defined(DGL_USE_GLES2) | |||||
puglSetViewHint(view, PUGL_USE_COMPAT_PROFILE, PUGL_FALSE); | |||||
puglSetViewHint(view, PUGL_CONTEXT_VERSION_MAJOR, 2); | |||||
#else | |||||
puglSetViewHint(view, PUGL_USE_COMPAT_PROFILE, PUGL_TRUE); | |||||
puglSetViewHint(view, PUGL_CONTEXT_VERSION_MAJOR, 2); | |||||
#endif | |||||
#endif | |||||
} | |||||
else | |||||
{ | |||||
puglSetBackend(view, puglStubBackend()); | puglSetBackend(view, puglStubBackend()); | ||||
} | |||||
} | } | ||||
// -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
@@ -406,12 +421,12 @@ PuglStatus puglSetSizeAndDefault(PuglView* view, uint width, uint height) | |||||
void puglOnDisplayPrepare(PuglView*) | void puglOnDisplayPrepare(PuglView*) | ||||
{ | { | ||||
#ifdef DGL_OPENGL | |||||
#ifdef DGL_OPENGL | |||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | ||||
# ifndef DGL_USE_GLES | |||||
#ifndef DGL_USE_OPENGL3 | |||||
glLoadIdentity(); | glLoadIdentity(); | ||||
# endif | |||||
#endif | |||||
#endif | |||||
#endif | |||||
} | } | ||||
// -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
@@ -419,24 +434,24 @@ void puglOnDisplayPrepare(PuglView*) | |||||
void puglFallbackOnResize(PuglView* const view) | void puglFallbackOnResize(PuglView* const view) | ||||
{ | { | ||||
#ifdef DGL_OPENGL | |||||
#ifdef DGL_OPENGL | |||||
glEnable(GL_BLEND); | glEnable(GL_BLEND); | ||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | ||||
# ifndef DGL_USE_GLES | |||||
#ifdef DGL_USE_OPENGL3 | |||||
glViewport(0, 0, static_cast<GLsizei>(view->frame.width), static_cast<GLsizei>(view->frame.height)); | |||||
#else | |||||
glMatrixMode(GL_PROJECTION); | glMatrixMode(GL_PROJECTION); | ||||
glLoadIdentity(); | glLoadIdentity(); | ||||
glOrtho(0.0, static_cast<GLdouble>(view->frame.width), static_cast<GLdouble>(view->frame.height), 0.0, 0.0, 1.0); | glOrtho(0.0, static_cast<GLdouble>(view->frame.width), static_cast<GLdouble>(view->frame.height), 0.0, 0.0, 1.0); | ||||
glViewport(0, 0, static_cast<GLsizei>(view->frame.width), static_cast<GLsizei>(view->frame.height)); | glViewport(0, 0, static_cast<GLsizei>(view->frame.width), static_cast<GLsizei>(view->frame.height)); | ||||
glMatrixMode(GL_MODELVIEW); | glMatrixMode(GL_MODELVIEW); | ||||
glLoadIdentity(); | glLoadIdentity(); | ||||
# else | |||||
glViewport(0, 0, static_cast<GLsizei>(view->frame.width), static_cast<GLsizei>(view->frame.height)); | |||||
# endif | |||||
#else | |||||
#endif | |||||
#else | |||||
return; | return; | ||||
// unused | // unused | ||||
(void)view; | (void)view; | ||||
#endif | |||||
#endif | |||||
} | } | ||||
// -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
@@ -297,6 +297,14 @@ bool DistrhoUIProM::onKeyboard(const KeyboardEvent& ev) | |||||
return true; | return true; | ||||
} | } | ||||
bool DistrhoUIProM::onMouse(const MouseEvent& ev) | |||||
{ | |||||
if (ev.press) | |||||
getWindow().focus(); | |||||
return false; | |||||
} | |||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
UI* createUI() | UI* createUI() | ||||
@@ -49,6 +49,7 @@ protected: | |||||
void onDisplay() override; | void onDisplay() override; | ||||
bool onKeyboard(const KeyboardEvent&) override; | bool onKeyboard(const KeyboardEvent&) override; | ||||
bool onMouse(const MouseEvent& ev) override; | |||||
private: | private: | ||||
ScopedPointer<projectM> fPM; | ScopedPointer<projectM> fPM; | ||||
@@ -16,18 +16,17 @@ | |||||
#pragma once | #pragma once | ||||
#include "TopLevelWidget.hpp" | |||||
#include "Color.hpp" | |||||
#include "NanoVG.hpp" | |||||
START_NAMESPACE_DGL | START_NAMESPACE_DGL | ||||
/** Resize handle for DPF windows, will sit on bottom-right. */ | /** Resize handle for DPF windows, will sit on bottom-right. */ | ||||
class ResizeHandle : public TopLevelWidget | |||||
class ResizeHandle : public NanoTopLevelWidget | |||||
{ | { | ||||
public: | public: | ||||
/** Overloaded constructor, will fetch the window from an existing top-level widget. */ | /** Overloaded constructor, will fetch the window from an existing top-level widget. */ | ||||
explicit ResizeHandle(TopLevelWidget* const tlw) | explicit ResizeHandle(TopLevelWidget* const tlw) | ||||
: TopLevelWidget(tlw->getWindow()), | |||||
: NanoTopLevelWidget(tlw->getWindow()), | |||||
handleSize(16), | handleSize(16), | ||||
hasCursor(false), | hasCursor(false), | ||||
isResizing(false) | isResizing(false) | ||||
@@ -44,22 +43,19 @@ public: | |||||
} | } | ||||
protected: | protected: | ||||
void onDisplay() override | |||||
void onNanoDisplay() override | |||||
{ | { | ||||
const GraphicsContext& context(getGraphicsContext()); | |||||
const double lineWidth = 1.0 * getScaleFactor(); | const double lineWidth = 1.0 * getScaleFactor(); | ||||
glMatrixMode(GL_MODELVIEW); | |||||
glLineWidth(lineWidth); | |||||
strokeWidth(lineWidth); | |||||
// draw white lines, 1px wide | // draw white lines, 1px wide | ||||
glColor3f(1.0f, 1.0f, 1.0f); | |||||
strokeColor(Color(1.0f, 1.0f, 1.0f)); | |||||
drawLine(l1); | drawLine(l1); | ||||
drawLine(l2); | drawLine(l2); | ||||
drawLine(l3); | drawLine(l3); | ||||
// draw black lines, offset by 1px and 1px wide | // draw black lines, offset by 1px and 1px wide | ||||
glColor3f(0.0f, 0.0f, 0.0f); | |||||
strokeColor(Color(0.0f, 0.0f, 0.0f)); | |||||
Line<double> l1b(l1), l2b(l2), l3b(l3); | Line<double> l1b(l1), l2b(l2), l3b(l3); | ||||
l1b.moveBy(lineWidth, lineWidth); | l1b.moveBy(lineWidth, lineWidth); | ||||
l2b.moveBy(lineWidth, lineWidth); | l2b.moveBy(lineWidth, lineWidth); | ||||
@@ -69,6 +65,14 @@ protected: | |||||
drawLine(l3b); | drawLine(l3b); | ||||
} | } | ||||
void drawLine(const Line<double>& line) | |||||
{ | |||||
beginPath(); | |||||
moveTo(line.getStartPos().getX(), line.getStartPos().getY()); | |||||
lineTo(line.getEndPos().getX(), line.getEndPos().getY()); | |||||
stroke(); | |||||
} | |||||
bool onMouse(const MouseEvent& ev) override | bool onMouse(const MouseEvent& ev) override | ||||
{ | { | ||||
if (ev.button != 1) | if (ev.button != 1) | ||||
@@ -155,7 +159,7 @@ private: | |||||
void resetArea() | void resetArea() | ||||
{ | { | ||||
const double scaleFactor = getScaleFactor(); | const double scaleFactor = getScaleFactor(); | ||||
const uint margin = 0.0 * scaleFactor; | |||||
const uint margin = 1.5 * scaleFactor; | |||||
const uint size = handleSize * scaleFactor; | const uint size = handleSize * scaleFactor; | ||||
area = Rectangle<uint>(getWidth() - size - margin, | area = Rectangle<uint>(getWidth() - size - margin, | ||||
@@ -187,25 +191,6 @@ private: | |||||
l3.setEndPos(x + offset, y + linesize + offset); | l3.setEndPos(x + offset, y + linesize + offset); | ||||
} | } | ||||
void drawLine(const Line<double>& line) | |||||
{ | |||||
drawLine(line.getStartPos(), line.getEndPos()); | |||||
} | |||||
void drawLine(const Point<double>& posStart, const Point<double>& posEnd) | |||||
{ | |||||
DISTRHO_SAFE_ASSERT_RETURN(posStart != posEnd,); | |||||
glBegin(GL_LINES); | |||||
{ | |||||
glVertex2d(posStart.getX(), posStart.getY()); | |||||
glVertex2d(posEnd.getX(), posEnd.getY()); | |||||
} | |||||
glEnd(); | |||||
} | |||||
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ResizeHandle) | DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ResizeHandle) | ||||
}; | }; | ||||