| 345 | } |
| 346 | |
| 347 | bool adjustSize(uint32_t* const width, uint32_t* const height) const |
| 348 | { |
| 349 | if (fUI != nullptr && fUI->isResizable()) |
| 350 | { |
| 351 | uint minimumWidth, minimumHeight; |
| 352 | bool keepAspectRatio; |
| 353 | fUI->getGeometryConstraints(minimumWidth, minimumHeight, keepAspectRatio); |
| 354 | |
| 355 | #ifdef DISTRHO_OS_MAC |
| 356 | const double scaleFactor = fUI->getScaleFactor(); |
| 357 | minimumWidth /= scaleFactor; |
| 358 | minimumHeight /= scaleFactor; |
| 359 | #endif |
| 360 | |
| 361 | if (keepAspectRatio) |
| 362 | { |
| 363 | if (*width < 1) |
| 364 | *width = 1; |
| 365 | if (*height < 1) |
| 366 | *height = 1; |
| 367 | |
| 368 | const double ratio = static_cast<double>(minimumWidth) / static_cast<double>(minimumHeight); |
| 369 | const double reqRatio = static_cast<double>(*width) / static_cast<double>(*height); |
| 370 | |
| 371 | if (d_isNotEqual(ratio, reqRatio)) |
| 372 | { |
| 373 | // fix width |
| 374 | if (reqRatio > ratio) |
| 375 | *width = d_roundToIntPositive(*height * ratio); |
| 376 | // fix height |
| 377 | else |
| 378 | *height = d_roundToIntPositive(static_cast<double>(*width) / ratio); |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | if (minimumWidth > *width) |
| 383 | *width = minimumWidth; |
| 384 | if (minimumHeight > *height) |
| 385 | *height = minimumHeight; |
| 386 | |
| 387 | return true; |
| 388 | } |
| 389 | |
| 390 | return false; |
| 391 | } |
| 392 | |
| 393 | bool setSizeFromHost(uint32_t width, uint32_t height) |
| 394 | { |
no test coverage detected