@@ -206,6 +206,41 @@ public: | |||||
*/ | */ | ||||
void setResizable(bool resizable); | void setResizable(bool resizable); | ||||
/** | |||||
Get X offset, typically 0. | |||||
*/ | |||||
int getOffsetX() const noexcept; | |||||
/** | |||||
Get Y offset, typically 0. | |||||
*/ | |||||
int getOffsetY() const noexcept; | |||||
/** | |||||
Get offset. | |||||
*/ | |||||
Point<int> getOffset() const noexcept; | |||||
/** | |||||
Set X offset. | |||||
*/ | |||||
void setOffsetX(int x); | |||||
/** | |||||
Set Y offset. | |||||
*/ | |||||
void setOffsetY(int y); | |||||
/** | |||||
Set offset using @a x and @a y values. | |||||
*/ | |||||
void setOffset(int x, int y); | |||||
/** | |||||
Set offset. | |||||
*/ | |||||
void setOffset(const Point<int>& offset); | |||||
/** | /** | ||||
Get width. | Get width. | ||||
*/ | */ | ||||
@@ -155,6 +155,48 @@ void Window::setResizable(const bool resizable) | |||||
pData->setResizable(resizable); | pData->setResizable(resizable); | ||||
} | } | ||||
int Window::getOffsetX() const noexcept | |||||
{ | |||||
DISTRHO_SAFE_ASSERT_RETURN(pData->view != nullptr, 0); | |||||
return puglGetFrame(pData->view).x; | |||||
} | |||||
int Window::getOffsetY() const noexcept | |||||
{ | |||||
DISTRHO_SAFE_ASSERT_RETURN(pData->view != nullptr, 0); | |||||
return puglGetFrame(pData->view).y; | |||||
} | |||||
Point<int> Window::getOffset() const noexcept | |||||
{ | |||||
DISTRHO_SAFE_ASSERT_RETURN(pData->view != nullptr, Point<int>()); | |||||
const PuglRect rect = puglGetFrame(pData->view); | |||||
return Point<int>(rect.x, rect.y); | |||||
} | |||||
void Window::setOffsetX(const int x) | |||||
{ | |||||
setOffset(x, getOffsetY()); | |||||
} | |||||
void Window::setOffsetY(const int y) | |||||
{ | |||||
setOffset(getOffsetX(), y); | |||||
} | |||||
void Window::setOffset(const int x, const int y) | |||||
{ | |||||
puglSetWindowOffset(pData->view, x, y); | |||||
} | |||||
void Window::setOffset(const Point<int>& offset) | |||||
{ | |||||
setOffset(offset.getX(), offset.getY()); | |||||
} | |||||
uint Window::getWidth() const noexcept | uint Window::getWidth() const noexcept | ||||
{ | { | ||||
DISTRHO_SAFE_ASSERT_RETURN(pData->view != nullptr, 0); | DISTRHO_SAFE_ASSERT_RETURN(pData->view != nullptr, 0); | ||||
@@ -339,6 +339,18 @@ PuglStatus puglSetGeometryConstraints(PuglView* const view, const uint width, co | |||||
return PUGL_SUCCESS; | return PUGL_SUCCESS; | ||||
} | } | ||||
// -------------------------------------------------------------------------------------------------------------------- | |||||
// set window offset without changing size | |||||
PuglStatus puglSetWindowOffset(PuglView* const view, const int x, const int y) | |||||
{ | |||||
// TODO custom setFrame version | |||||
PuglRect rect = puglGetFrame(view); | |||||
rect.x = x; | |||||
rect.y = y; | |||||
return puglSetFrame(view, rect); | |||||
} | |||||
// -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
// set window size with default size and without changing frame x/y position | // set window size with default size and without changing frame x/y position | ||||
@@ -81,11 +81,15 @@ puglSetMatchingBackendForCurrentBuild(PuglView* view); | |||||
// Combine puglSetMinSize and puglSetAspectRatio | // Combine puglSetMinSize and puglSetAspectRatio | ||||
PUGL_API PuglStatus | PUGL_API PuglStatus | ||||
puglSetGeometryConstraints(PuglView* view, unsigned int width, unsigned int height, bool aspect); | |||||
puglSetGeometryConstraints(PuglView* view, uint width, uint height, bool aspect); | |||||
// set window offset without changing size | |||||
PUGL_API PuglStatus | |||||
puglSetWindowOffset(PuglView* view, int x, int y); | |||||
// set window size with default size and without changing frame x/y position | // set window size with default size and without changing frame x/y position | ||||
PUGL_API PuglStatus | PUGL_API PuglStatus | ||||
puglSetWindowSize(PuglView* view, unsigned int width, unsigned int height); | |||||
puglSetWindowSize(PuglView* view, uint width, uint height); | |||||
// DGL specific, build-specific drawing prepare | // DGL specific, build-specific drawing prepare | ||||
PUGL_API void | PUGL_API void | ||||
@@ -284,6 +284,15 @@ public: | |||||
// ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
void setWindowOffset(const int x, const int y) | |||||
{ | |||||
#if DISTRHO_PLUGIN_HAS_EXTERNAL_UI | |||||
// TODO | |||||
#else | |||||
uiData->window->setOffset(x, y); | |||||
#endif | |||||
} | |||||
#ifdef DISTRHO_PLUGIN_TARGET_VST3 | #ifdef DISTRHO_PLUGIN_TARGET_VST3 | ||||
void setWindowSizeForVST3(const uint width, const uint height) | void setWindowSizeForVST3(const uint width, const uint height) | ||||
{ | { | ||||