Skip to content

Commit 6ca6b39

Browse files
committed
Update to latest pugl yet again
Signed-off-by: falkTX <[email protected]>
1 parent 4900b15 commit 6ca6b39

File tree

6 files changed

+125
-139
lines changed

6 files changed

+125
-139
lines changed

dgl/src/OpenGL.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,9 +1087,9 @@ const GraphicsContext& Window::PrivateData::getGraphicsContext() const noexcept
10871087
gl3context.pos = glGetAttribLocation(program, "pos");
10881088
}
10891089

1090-
const PuglRect rect = puglGetFrame(view);
1091-
gl3context.w = static_cast<uint>(rect.width + 0.5);
1092-
gl3context.h = static_cast<uint>(rect.height + 0.5);
1090+
const PuglArea size = puglGetSizeHint(view, PUGL_CURRENT_SIZE);
1091+
gl3context.w = size.width;
1092+
gl3context.h = size.height;
10931093

10941094
glUseProgram(gl3context.prog);
10951095
#endif

dgl/src/Window.cpp

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -180,22 +180,22 @@ int Window::getOffsetX() const noexcept
180180
{
181181
DISTRHO_SAFE_ASSERT_RETURN(pData->view != nullptr, 0);
182182

183-
return puglGetFrame(pData->view).x;
183+
return puglGetPositionHint(pData->view, PUGL_CURRENT_POSITION).x;
184184
}
185185

186186
int Window::getOffsetY() const noexcept
187187
{
188188
DISTRHO_SAFE_ASSERT_RETURN(pData->view != nullptr, 0);
189189

190-
return puglGetFrame(pData->view).y;
190+
return puglGetPositionHint(pData->view, PUGL_CURRENT_POSITION).y;
191191
}
192192

193193
Point<int> Window::getOffset() const noexcept
194194
{
195195
DISTRHO_SAFE_ASSERT_RETURN(pData->view != nullptr, Point<int>());
196196

197-
const PuglRect rect = puglGetFrame(pData->view);
198-
return Point<int>(rect.x, rect.y);
197+
const PuglPoint pos = puglGetPositionHint(pData->view, PUGL_CURRENT_POSITION);
198+
return Point<int>(pos.x, pos.y);
199199
}
200200

201201
void Window::setOffsetX(const int x)
@@ -214,7 +214,7 @@ void Window::setOffset(const int x, const int y)
214214
DISTRHO_SAFE_ASSERT_RETURN(!pData->isEmbed,);
215215

216216
if (pData->view != nullptr)
217-
puglSetPosition(pData->view, x, y);
217+
puglSetPositionHint(pData->view, PUGL_CURRENT_POSITION, x, y);
218218
}
219219

220220
void Window::setOffset(const Point<int>& offset)
@@ -226,29 +226,28 @@ uint Window::getWidth() const noexcept
226226
{
227227
DISTRHO_SAFE_ASSERT_RETURN(pData->view != nullptr, 0);
228228

229-
const double width = puglGetFrame(pData->view).width;
230-
DISTRHO_SAFE_ASSERT_RETURN(width > 0.0, 0);
231-
return static_cast<uint>(width + 0.5);
229+
const PuglSpan width = puglGetSizeHint(pData->view, PUGL_CURRENT_SIZE).width;
230+
DISTRHO_SAFE_ASSERT(width > 0);
231+
return width;
232232
}
233233

234234
uint Window::getHeight() const noexcept
235235
{
236236
DISTRHO_SAFE_ASSERT_RETURN(pData->view != nullptr, 0);
237237

238-
const double height = puglGetFrame(pData->view).height;
239-
DISTRHO_SAFE_ASSERT_RETURN(height > 0.0, 0);
240-
return static_cast<uint>(height + 0.5);
238+
const PuglSpan height = puglGetSizeHint(pData->view, PUGL_CURRENT_SIZE).height;
239+
DISTRHO_SAFE_ASSERT(height > 0);
240+
return height;
241241
}
242242

243243
Size<uint> Window::getSize() const noexcept
244244
{
245245
DISTRHO_SAFE_ASSERT_RETURN(pData->view != nullptr, Size<uint>());
246246

247-
const PuglRect rect = puglGetFrame(pData->view);
248-
DISTRHO_SAFE_ASSERT_RETURN(rect.width > 0.0, Size<uint>());
249-
DISTRHO_SAFE_ASSERT_RETURN(rect.height > 0.0, Size<uint>());
250-
return Size<uint>(static_cast<uint>(rect.width + 0.5),
251-
static_cast<uint>(rect.height + 0.5));
247+
const PuglArea size = puglGetSizeHint(pData->view, PUGL_CURRENT_SIZE);
248+
DISTRHO_SAFE_ASSERT(size.width > 0);
249+
DISTRHO_SAFE_ASSERT(size.height > 0);
250+
return Size<uint>(size.width, size.height);
252251
}
253252

254253
void Window::setWidth(const uint width)
@@ -443,7 +442,7 @@ void Window::repaint() noexcept
443442
if (pData->usesScheduledRepaints)
444443
pData->appData->needsRepaint = true;
445444

446-
puglPostRedisplay(pData->view);
445+
puglObscureView(pData->view);
447446
}
448447

449448
void Window::repaint(const Rectangle<uint>& rect) noexcept
@@ -454,22 +453,22 @@ void Window::repaint(const Rectangle<uint>& rect) noexcept
454453
if (pData->usesScheduledRepaints)
455454
pData->appData->needsRepaint = true;
456455

457-
PuglRect prect = {
458-
static_cast<PuglCoord>(rect.getX()),
459-
static_cast<PuglCoord>(rect.getY()),
460-
static_cast<PuglSpan>(rect.getWidth()),
461-
static_cast<PuglSpan>(rect.getHeight()),
462-
};
456+
int x = static_cast<int>(rect.getX());
457+
int y = static_cast<int>(rect.getY());
458+
uint width = rect.getWidth();
459+
uint height = rect.getHeight();
460+
463461
if (pData->autoScaling)
464462
{
465463
const double autoScaleFactor = pData->autoScaleFactor;
466464

467-
prect.x = static_cast<PuglCoord>(prect.x * autoScaleFactor);
468-
prect.y = static_cast<PuglCoord>(prect.y * autoScaleFactor);
469-
prect.width = static_cast<PuglSpan>(prect.width * autoScaleFactor + 0.5);
470-
prect.height = static_cast<PuglSpan>(prect.height * autoScaleFactor + 0.5);
465+
x = d_roundToIntPositive(x * autoScaleFactor);
466+
y = d_roundToIntPositive(y * autoScaleFactor);
467+
width = d_roundToUnsignedInt(width * autoScaleFactor);
468+
height = d_roundToUnsignedInt(height * autoScaleFactor);
471469
}
472-
puglPostRedisplayRect(pData->view, prect);
470+
471+
puglObscureRegion(pData->view, x, y, width, height);
473472
}
474473

475474
void Window::renderToPicture(const char* const filename)
@@ -523,8 +522,8 @@ void Window::setGeometryConstraints(uint minimumWidth,
523522
{
524523
const Size<uint> size(getSize());
525524

526-
setSize(static_cast<uint>(size.getWidth() * scaleFactor + 0.5),
527-
static_cast<uint>(size.getHeight() * scaleFactor + 0.5));
525+
setSize(d_roundToUnsignedInt(size.getWidth() * scaleFactor),
526+
d_roundToUnsignedInt(size.getHeight() * scaleFactor));
528527
}
529528
}
530529

dgl/src/WindowPrivateData.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,13 @@ static PuglView* puglNewViewWithParentWindow(PuglWorld* const world, const uintp
9191

9292
if (PuglView* const view = puglNewView(world))
9393
{
94-
puglSetParentWindow(view, parentWindowHandle);
94+
puglSetParent(view, parentWindowHandle);
9595

9696
if (parentWindowHandle != 0)
97-
puglSetPosition(view, 0, 0);
97+
{
98+
puglSetPositionHint(view, PUGL_CURRENT_POSITION, 0, 0);
99+
puglSetPositionHint(view, PUGL_DEFAULT_POSITION, 0, 0);
100+
}
98101

99102
return view;
100103
}
@@ -538,9 +541,9 @@ bool Window::PrivateData::createWebView(const char* const url, const DGL_NAMESPA
538541
if (webViewHandle != nullptr)
539542
webViewDestroy(webViewHandle);
540543

541-
const PuglRect rect = puglGetFrame(view);
542-
uint initialWidth = static_cast<uint>(rect.width) - options.offset.x;
543-
uint initialHeight = static_cast<uint>(rect.height) - options.offset.y;
544+
const PuglArea size = puglGetSizeHint(view, PUGL_CURRENT_SIZE);
545+
uint initialWidth = size.width - options.offset.x;
546+
uint initialHeight = size.height - options.offset.y;
544547

545548
webViewOffset = Point<int>(options.offset.x, options.offset.y);
546549

@@ -682,7 +685,7 @@ void Window::PrivateData::onPuglConfigure(const uint width, const uint height)
682685
#endif
683686

684687
// always repaint after a resize
685-
puglPostRedisplay(view);
688+
puglObscureView(view);
686689
}
687690

688691
void Window::PrivateData::onPuglExpose()
@@ -702,9 +705,9 @@ void Window::PrivateData::onPuglExpose()
702705

703706
if (char* const filename = filenameToRenderInto)
704707
{
705-
const PuglRect rect = puglGetFrame(view);
708+
const PuglArea size = puglGetSizeHint(view, PUGL_CURRENT_SIZE);
706709
filenameToRenderInto = nullptr;
707-
renderToPicture(filename, getGraphicsContext(), static_cast<uint>(rect.width), static_cast<uint>(rect.height));
710+
renderToPicture(filename, getGraphicsContext(), size.width, size.height);
708711
std::free(filename);
709712
}
710713
#endif
@@ -978,7 +981,7 @@ PuglStatus Window::PrivateData::puglEventCallback(PuglView* const view, const Pu
978981
SetClassLongPtr(view->impl->hwnd, GCLP_HICON, (LONG_PTR) LoadIcon(hInstance, MAKEINTRESOURCE(DGL_WINDOWS_ICON_ID)));
979982
#endif
980983
#ifdef DGL_USING_X11
981-
puglX11SetWindowTypeAndPID(view, pData->appData->isStandalone);
984+
puglX11SetWindowType(view, pData->appData->isStandalone);
982985
#endif
983986
}
984987
break;

dgl/src/pugl-upstream

Submodule pugl-upstream updated 114 files

0 commit comments

Comments
 (0)