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

Method setSize

dgl/src/Window.cpp:269–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

267}
268
269void Window::setSize(uint width, uint height)
270{
271 DISTRHO_SAFE_ASSERT_UINT2_RETURN(width > 1 && height > 1, width, height,);
272
273 if (pData->isEmbed)
274 {
275 const double scaleFactor = pData->scaleFactor;
276 uint minWidth = pData->minWidth;
277 uint minHeight = pData->minHeight;
278
279 if (pData->autoScaling && d_isNotEqual(scaleFactor, 1.0))
280 {
281 minWidth = d_roundToUnsignedInt(minWidth * scaleFactor);
282 minHeight = d_roundToUnsignedInt(minHeight * scaleFactor);
283 }
284
285 // handle geometry constraints here
286 if (width < minWidth)
287 width = minWidth;
288
289 if (height < minHeight)
290 height = minHeight;
291
292 if (pData->keepAspectRatio)
293 {
294 const double ratio = static_cast<double>(pData->minWidth)
295 / static_cast<double>(pData->minHeight);
296 const double reqRatio = static_cast<double>(width)
297 / static_cast<double>(height);
298
299 if (d_isNotEqual(ratio, reqRatio))
300 {
301 // fix width
302 if (reqRatio > ratio)
303 width = d_roundToUnsignedInt(height * ratio);
304 // fix height
305 else
306 height = d_roundToUnsignedInt(static_cast<double>(width) / ratio);
307 }
308 }
309 }
310
311 if (pData->usesSizeRequest)
312 {
313 DISTRHO_SAFE_ASSERT_RETURN(pData->topLevelWidgets.size() != 0,);
314
315 TopLevelWidget* const topLevelWidget = pData->topLevelWidgets.front();
316 DISTRHO_SAFE_ASSERT_RETURN(topLevelWidget != nullptr,);
317
318 topLevelWidget->requestSizeChange(width, height);
319 }
320 else if (pData->view != nullptr)
321 {
322 puglSetSizeAndDefault(pData->view, width, height);
323
324 // there are no resize events for closed windows, so short-circuit the top-level widgets here
325 if (pData->isClosed)
326 {

Callers 11

_updateSizeMethod · 0.45
onReshapeMethod · 0.45
onDisplayFunction · 0.45
CairoExampleUIMethod · 0.45
onResizeMethod · 0.45
onDisplayFunction · 0.45
setupButtonFunction · 0.45
onResizeFunction · 0.45

Calls 8

d_isNotEqualFunction · 0.85
d_roundToUnsignedIntFunction · 0.85
puglSetSizeAndDefaultFunction · 0.85
sizeMethod · 0.80
setSizeFunction · 0.50
requestSizeChangeMethod · 0.45
getWidthMethod · 0.45
getHeightMethod · 0.45

Tested by

no test coverage detected