@@ -192,6 +192,7 @@ public: | |||
void setEndPos(const Point<int>& endPos) noexcept; | |||
void setEndPos(int x, int y) noexcept; | |||
void setCheckable(bool checkable) noexcept; | |||
void setInverted(bool inverted) noexcept; | |||
void setRange(float min, float max) noexcept; | |||
void setStep(float step) noexcept; | |||
@@ -202,8 +202,9 @@ public: | |||
GLenum getType() const noexcept { return GL_UNSIGNED_BYTE; } | |||
private: | |||
GLuint textureId; | |||
bool setupCalled; | |||
bool textureInit; | |||
GLuint textureId; | |||
}; | |||
// ----------------------------------------------------------------------- | |||
@@ -1,6 +1,6 @@ | |||
/* | |||
* DISTRHO Plugin Framework (DPF) | |||
* Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com> | |||
* Copyright (C) 2012-2022 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 | |||
@@ -53,6 +53,15 @@ public: | |||
sgc.done(); | |||
} | |||
/** | |||
Get a graphics context back again. | |||
Called when a valid graphics context is needed outside the constructor. | |||
*/ | |||
void reinit() | |||
{ | |||
sgc.reinit(); | |||
} | |||
/** | |||
Overloaded functions to ensure they apply to the Window class. | |||
*/ | |||
@@ -105,13 +105,17 @@ public: | |||
/** Early context clearing, useful for standalone windows not created by you. */ | |||
void done(); | |||
/** Get a valid context back again. */ | |||
void reinit(); | |||
DISTRHO_DECLARE_NON_COPYABLE(ScopedGraphicsContext) | |||
DISTRHO_PREVENT_HEAP_ALLOCATION | |||
private: | |||
Window& window; | |||
Window::PrivateData* ppData; | |||
Window::PrivateData* const ppData; | |||
bool active; | |||
bool reenter; | |||
}; | |||
/** | |||
@@ -1,6 +1,6 @@ | |||
/* | |||
* DISTRHO Plugin Framework (DPF) | |||
* Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com> | |||
* Copyright (C) 2012-2022 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 | |||
@@ -61,13 +61,20 @@ void ImageBaseAboutWindow<ImageType>::setImage(const ImageType& image) | |||
if (img == image) | |||
return; | |||
img = image; | |||
if (image.isInvalid()) | |||
{ | |||
img = image; | |||
return; | |||
} | |||
reinit(); | |||
img = image; | |||
setSize(image.getSize()); | |||
setGeometryConstraints(image.getWidth(), image.getHeight(), true, true); | |||
done(); | |||
} | |||
template <class ImageType> | |||
@@ -428,6 +435,7 @@ struct ImageBaseSlider<ImageType>::PrivateData { | |||
bool usingDefault; | |||
bool dragging; | |||
bool checkable; | |||
bool inverted; | |||
bool valueIsSet; | |||
double startedX; | |||
@@ -449,6 +457,7 @@ struct ImageBaseSlider<ImageType>::PrivateData { | |||
valueTmp(value), | |||
usingDefault(false), | |||
dragging(false), | |||
checkable(false), | |||
inverted(false), | |||
valueIsSet(false), | |||
startedX(0.0), | |||
@@ -553,6 +562,16 @@ void ImageBaseSlider<ImageType>::setEndPos(int x, int y) noexcept | |||
setEndPos(Point<int>(x, y)); | |||
} | |||
template <class ImageType> | |||
void ImageBaseSlider<ImageType>::setCheckable(bool checkable) noexcept | |||
{ | |||
if (pData->checkable == checkable) | |||
return; | |||
pData->checkable = checkable; | |||
repaint(); | |||
} | |||
template <class ImageType> | |||
void ImageBaseSlider<ImageType>::setInverted(bool inverted) noexcept | |||
{ | |||
@@ -674,6 +693,14 @@ bool ImageBaseSlider<ImageType>::onMouse(const MouseEvent& ev) | |||
return true; | |||
} | |||
if (pData->checkable) | |||
{ | |||
const float value = d_isEqual(pData->valueTmp, pData->minimum) ? pData->maximum : pData->minimum; | |||
setValue(value, true); | |||
pData->valueTmp = pData->value; | |||
return true; | |||
} | |||
float vper; | |||
const double x = ev.pos.getX(); | |||
const double y = ev.pos.getY(); | |||
@@ -445,17 +445,17 @@ static void drawOpenGLImage(const OpenGLImage& image, const Point<int>& pos, con | |||
OpenGLImage::OpenGLImage() | |||
: ImageBase(), | |||
textureId(0), | |||
setupCalled(false) | |||
setupCalled(false), | |||
textureInit(false), | |||
textureId(0) | |||
{ | |||
glGenTextures(1, &textureId); | |||
DISTRHO_SAFE_ASSERT(textureId != 0); | |||
} | |||
OpenGLImage::OpenGLImage(const char* const rdata, const uint w, const uint h, const ImageFormat fmt) | |||
: ImageBase(rdata, w, h, fmt), | |||
textureId(0), | |||
setupCalled(false) | |||
setupCalled(false), | |||
textureInit(true), | |||
textureId(0) | |||
{ | |||
glGenTextures(1, &textureId); | |||
DISTRHO_SAFE_ASSERT(textureId != 0); | |||
@@ -463,8 +463,9 @@ OpenGLImage::OpenGLImage(const char* const rdata, const uint w, const uint h, co | |||
OpenGLImage::OpenGLImage(const char* const rdata, const Size<uint>& s, const ImageFormat fmt) | |||
: ImageBase(rdata, s, fmt), | |||
textureId(0), | |||
setupCalled(false) | |||
setupCalled(false), | |||
textureInit(true), | |||
textureId(0) | |||
{ | |||
glGenTextures(1, &textureId); | |||
DISTRHO_SAFE_ASSERT(textureId != 0); | |||
@@ -472,8 +473,9 @@ OpenGLImage::OpenGLImage(const char* const rdata, const Size<uint>& s, const Ima | |||
OpenGLImage::OpenGLImage(const OpenGLImage& image) | |||
: ImageBase(image), | |||
textureId(0), | |||
setupCalled(false) | |||
setupCalled(false), | |||
textureInit(true), | |||
textureId(0) | |||
{ | |||
glGenTextures(1, &textureId); | |||
DISTRHO_SAFE_ASSERT(textureId != 0); | |||
@@ -487,6 +489,12 @@ OpenGLImage::~OpenGLImage() | |||
void OpenGLImage::loadFromMemory(const char* const rdata, const Size<uint>& s, const ImageFormat fmt) noexcept | |||
{ | |||
if (!textureInit) | |||
{ | |||
textureInit = true; | |||
glGenTextures(1, &textureId); | |||
DISTRHO_SAFE_ASSERT(textureId != 0); | |||
} | |||
setupCalled = false; | |||
ImageBase::loadFromMemory(rdata, s, fmt); | |||
} | |||
@@ -502,14 +510,23 @@ OpenGLImage& OpenGLImage::operator=(const OpenGLImage& image) noexcept | |||
size = image.size; | |||
format = image.format; | |||
setupCalled = false; | |||
if (image.isValid() && !textureInit) | |||
{ | |||
textureInit = true; | |||
glGenTextures(1, &textureId); | |||
DISTRHO_SAFE_ASSERT(textureId != 0); | |||
} | |||
return *this; | |||
} | |||
// deprecated calls | |||
OpenGLImage::OpenGLImage(const char* const rdata, const uint w, const uint h, const GLenum fmt) | |||
: ImageBase(rdata, w, h, asDISTRHOImageFormat(fmt)), | |||
textureId(0), | |||
setupCalled(false) | |||
setupCalled(false), | |||
textureInit(true), | |||
textureId(0) | |||
{ | |||
glGenTextures(1, &textureId); | |||
DISTRHO_SAFE_ASSERT(textureId != 0); | |||
@@ -517,8 +534,9 @@ OpenGLImage::OpenGLImage(const char* const rdata, const uint w, const uint h, co | |||
OpenGLImage::OpenGLImage(const char* const rdata, const Size<uint>& s, const GLenum fmt) | |||
: ImageBase(rdata, s, asDISTRHOImageFormat(fmt)), | |||
textureId(0), | |||
setupCalled(false) | |||
setupCalled(false), | |||
textureInit(true), | |||
textureId(0) | |||
{ | |||
glGenTextures(1, &textureId); | |||
DISTRHO_SAFE_ASSERT(textureId != 0); | |||
@@ -27,12 +27,14 @@ START_NAMESPACE_DGL | |||
Window::ScopedGraphicsContext::ScopedGraphicsContext(Window& win) | |||
: window(win), | |||
ppData(nullptr), | |||
active(puglBackendEnter(window.pData->view)) {} | |||
active(puglBackendEnter(window.pData->view)), | |||
reenter(false) {} | |||
Window::ScopedGraphicsContext::ScopedGraphicsContext(Window& win, Window& transientWin) | |||
: window(win), | |||
ppData(transientWin.pData), | |||
active(false) | |||
active(false), | |||
reenter(true) | |||
{ | |||
puglBackendLeave(ppData->view); | |||
active = puglBackendEnter(window.pData->view); | |||
@@ -51,13 +53,26 @@ void Window::ScopedGraphicsContext::done() | |||
active = false; | |||
} | |||
if (ppData != nullptr) | |||
if (reenter) | |||
{ | |||
reenter = false; | |||
DISTRHO_SAFE_ASSERT_RETURN(ppData != nullptr,); | |||
puglBackendEnter(ppData->view); | |||
ppData = nullptr; | |||
} | |||
} | |||
void Window::ScopedGraphicsContext::reinit() | |||
{ | |||
DISTRHO_SAFE_ASSERT_RETURN(!active,); | |||
DISTRHO_SAFE_ASSERT_RETURN(!reenter,); | |||
DISTRHO_SAFE_ASSERT_RETURN(ppData != nullptr,); | |||
reenter = true; | |||
puglBackendLeave(ppData->view); | |||
active = puglBackendEnter(window.pData->view); | |||
} | |||
// ----------------------------------------------------------------------- | |||
// Window | |||
@@ -540,9 +540,9 @@ void puglWin32ShowCentered(PuglView* const view) | |||
GetWindowRect(impl->hwnd, &rectChild) && | |||
GetWindowRect((HWND)view->transientParent, &rectParent)) | |||
{ | |||
SetWindowPos(impl->hwnd, (HWND)view->transientParent, | |||
rectParent.left + (rectChild.right-rectChild.left)/2, | |||
rectParent.top + (rectChild.bottom-rectChild.top)/2, | |||
SetWindowPos(impl->hwnd, HWND_TOP, | |||
rectParent.left + (rectParent.right-rectParent.left)/2 - (rectChild.right-rectChild.left)/2, | |||
rectParent.top + (rectParent.bottom-rectParent.top)/2 - (rectChild.bottom-rectChild.top)/2, | |||
0, 0, SWP_SHOWWINDOW|SWP_NOSIZE); | |||
} | |||
else | |||
@@ -564,8 +564,7 @@ void puglWin32ShowCentered(PuglView* const view) | |||
mInfo.cbSize = sizeof(mInfo); | |||
if (GetMonitorInfo(MonitorFromWindow(impl->hwnd, MONITOR_DEFAULTTOPRIMARY), &mInfo)) | |||
SetWindowPos(impl->hwnd, | |||
HWND_TOP, | |||
SetWindowPos(impl->hwnd, HWND_TOP, | |||
mInfo.rcWork.left + (mInfo.rcWork.right - mInfo.rcWork.left - view->frame.width) / 2, | |||
mInfo.rcWork.top + (mInfo.rcWork.bottom - mInfo.rcWork.top - view->frame.height) / 2, | |||
0, 0, SWP_SHOWWINDOW|SWP_NOSIZE); | |||
@@ -18,6 +18,8 @@ | |||
#ifndef DISTRHO_PLUGIN_INFO_H_INCLUDED | |||
#define DISTRHO_PLUGIN_INFO_H_INCLUDED | |||
#include "DistrhoArtworkNekobi.hpp" | |||
#define DISTRHO_PLUGIN_BRAND "DISTRHO" | |||
#define DISTRHO_PLUGIN_NAME "Nekobi" | |||
#define DISTRHO_PLUGIN_URI "http://distrho.sf.net/plugins/Nekobi" | |||
@@ -29,4 +31,7 @@ | |||
#define DISTRHO_PLUGIN_NUM_INPUTS 0 | |||
#define DISTRHO_PLUGIN_NUM_OUTPUTS 1 | |||
#define DISTRHO_UI_DEFAULT_WIDTH DistrhoArtworkNekobi::backgroundWidth | |||
#define DISTRHO_UI_DEFAULT_HEIGHT DistrhoArtworkNekobi::backgroundHeight | |||
#endif // DISTRHO_PLUGIN_INFO_H_INCLUDED |
@@ -1,6 +1,6 @@ | |||
/* | |||
* DISTRHO Nekobi Plugin, based on Nekobee by Sean Bolton and others. | |||
* Copyright (C) 2013-2021 Filipe Coelho <falktx@falktx.com> | |||
* Copyright (C) 2013-2022 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU General Public License as | |||
@@ -40,6 +40,7 @@ DistrhoUINekobi::DistrhoUINekobi() | |||
fSliderWaveform->setId(DistrhoPluginNekobi::paramWaveform); | |||
fSliderWaveform->setStartPos(133, 40); | |||
fSliderWaveform->setEndPos(133, 60); | |||
fSliderWaveform->setCheckable(true); | |||
fSliderWaveform->setRange(0.0f, 1.0f); | |||
fSliderWaveform->setStep(1.0f); | |||
fSliderWaveform->setValue(0.0f); | |||
@@ -1,6 +1,6 @@ | |||
/* | |||
* DISTRHO Nekobi Plugin, based on Nekobee by Sean Bolton and others. | |||
* Copyright (C) 2013-2021 Filipe Coelho <falktx@falktx.com> | |||
* Copyright (C) 2013-2022 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU General Public License as | |||
@@ -22,7 +22,6 @@ | |||
#include "ImageWidgets.hpp" | |||
#include "DistrhoArtworkNekobi.hpp" | |||
#include "NekoWidget.hpp" | |||
using DGL_NAMESPACE::ImageAboutWindow; | |||