@@ -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
186186int 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
193193Point<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
201201void 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
220220void 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
234234uint 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
243243Size<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
254253void 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
449448void 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
475474void 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
0 commit comments