MCPcopy Create free account
hub / github.com/DISTRHO/DPF / onPuglConfigure

Method onPuglConfigure

dgl/src/WindowPrivateData.cpp:643–696  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

641// pugl events
642
643void Window::PrivateData::onPuglConfigure(const uint width, const uint height)
644{
645 DISTRHO_SAFE_ASSERT_INT2_RETURN(width > 1 && height > 1, width, height,);
646
647 DGL_DBGp("PUGL: onReshape : %d %d\n", width, height);
648
649 #ifndef DPF_TEST_WINDOW_CPP
650 createContextIfNeeded();
651 #endif
652
653 if (autoScaling)
654 {
655 const double scaleHorizontal = width / static_cast<double>(minWidth);
656 const double scaleVertical = height / static_cast<double>(minHeight);
657 autoScaleFactor = scaleHorizontal < scaleVertical ? scaleHorizontal : scaleVertical;
658 }
659 else
660 {
661 autoScaleFactor = 1.0;
662 }
663
664 const uint uwidth = d_roundToUnsignedInt(width / autoScaleFactor);
665 const uint uheight = d_roundToUnsignedInt(height / autoScaleFactor);
666
667 #ifdef DGL_USE_WEB_VIEW
668 if (webViewHandle != nullptr)
669 webViewResize(webViewHandle,
670 uwidth - webViewOffset.getX(),
671 uheight - webViewOffset.getY(),
672 autoScaling ? autoScaleFactor : scaleFactor);
673 #endif
674
675 self->onReshape(uwidth, uheight);
676
677#ifndef DPF_TEST_WINDOW_CPP
678 FOR_EACH_TOP_LEVEL_WIDGET(it)
679 {
680 TopLevelWidget* const widget = *it;
681
682 /* Some special care here, we call Widget::setSize instead of the TopLevelWidget one.
683 * This is because we want TopLevelWidget::setSize to handle both window and widget size,
684 * but we dont want to change window size here, because we are the window..
685 * So we just call the Widget specific method manually.
686 *
687 * Alternatively, we could expose a resize function on the pData, like done with the display function.
688 * But there is nothing extra we need to do in there, so this works fine.
689 */
690 ((Widget*)widget)->setSize(uwidth, uheight);
691 }
692#endif
693
694 // always repaint after a resize
695 puglObscureView(view);
696}
697
698void Window::PrivateData::onPuglExpose()
699{

Callers 1

puglEventCallbackMethod · 0.80

Calls 4

d_roundToUnsignedIntFunction · 0.85
webViewResizeFunction · 0.85
puglObscureViewFunction · 0.85
onReshapeMethod · 0.45

Tested by

no test coverage detected