diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llpreviewtexture.cpp | 63 |
1 files changed, 36 insertions, 27 deletions
diff --git a/linden/indra/newview/llpreviewtexture.cpp b/linden/indra/newview/llpreviewtexture.cpp index 27a9b52..b59846d 100644 --- a/linden/indra/newview/llpreviewtexture.cpp +++ b/linden/indra/newview/llpreviewtexture.cpp | |||
@@ -388,29 +388,23 @@ void LLPreviewTexture::updateAspectRatio() | |||
388 | // If that fails, cut width by half. | 388 | // If that fails, cut width by half. |
389 | S32 client_width = image_width; | 389 | S32 client_width = image_width; |
390 | S32 horiz_pad = 2 * (LLPANEL_BORDER_WIDTH + PREVIEW_PAD) + PREVIEW_RESIZE_HANDLE_SIZE; | 390 | S32 horiz_pad = 2 * (LLPANEL_BORDER_WIDTH + PREVIEW_PAD) + PREVIEW_RESIZE_HANDLE_SIZE; |
391 | S32 vert_pad = PREVIEW_HEADER_SIZE + 2 * CLIENT_RECT_VPAD + LLPANEL_BORDER_WIDTH; | ||
391 | S32 screen_width = gViewerWindow->getWindowWidth(); | 392 | S32 screen_width = gViewerWindow->getWindowWidth(); |
392 | S32 max_client_width = screen_width - horiz_pad; | 393 | S32 max_client_width = screen_width - horiz_pad; |
394 | S32 max_client_height = gViewerWindow->getWindowHeight() - vert_pad; | ||
395 | F32 inv_aspect_ratio = (F32) image_height / (F32) image_width; | ||
393 | 396 | ||
394 | while (client_width > max_client_width) | 397 | while ((client_width > max_client_width) || ( llround(client_width * inv_aspect_ratio) > max_client_height ) ) |
395 | { | 398 | { |
396 | client_width /= 2; | 399 | client_width /= 2; |
397 | } | 400 | } |
398 | 401 | ||
399 | // Demand width at least 128 | ||
400 | if (client_width < 128) | ||
401 | { | ||
402 | client_width = 128; | ||
403 | } | ||
404 | |||
405 | S32 view_width = client_width + horiz_pad; | 402 | S32 view_width = client_width + horiz_pad; |
406 | 403 | ||
407 | // Adjust the height based on the width computed above. | 404 | // Adjust the height based on the width computed above. |
408 | F32 inv_aspect_ratio = (F32) image_height / (F32) image_width; | ||
409 | S32 client_height = llround(client_width * inv_aspect_ratio); | 405 | S32 client_height = llround(client_width * inv_aspect_ratio); |
410 | S32 view_height = | 406 | S32 view_height = client_height + vert_pad; |
411 | PREVIEW_HEADER_SIZE + // header (includes top border) | 407 | |
412 | client_height + 2 * CLIENT_RECT_VPAD + // texture plus uniform spacing (which leaves room for resize handle) | ||
413 | LLPANEL_BORDER_WIDTH; // bottom border | ||
414 | 408 | ||
415 | // set text on dimensions display (should be moved out of here and into a callback of some sort) | 409 | // set text on dimensions display (should be moved out of here and into a callback of some sort) |
416 | childSetTextArg("dimensions", "[WIDTH]", llformat("%d", mImage->mFullWidth)); | 410 | childSetTextArg("dimensions", "[WIDTH]", llformat("%d", mImage->mFullWidth)); |
@@ -453,28 +447,43 @@ void LLPreviewTexture::updateAspectRatio() | |||
453 | } | 447 | } |
454 | } | 448 | } |
455 | 449 | ||
456 | // clamp texture size to fit within actual size of floater after attempting resize | 450 | |
457 | client_width = llmin(client_width, mRect.getWidth() - horiz_pad); | 451 | if (!mUserResized) |
458 | client_height = llmin(client_height, mRect.getHeight() - PREVIEW_HEADER_SIZE - (2 * CLIENT_RECT_VPAD) - LLPANEL_BORDER_WIDTH - info_height); | ||
459 | |||
460 | LLRect window_rect(0, mRect.getHeight(), mRect.getWidth(), 0); | ||
461 | window_rect.mTop -= (PREVIEW_HEADER_SIZE + CLIENT_RECT_VPAD); | ||
462 | window_rect.mBottom += PREVIEW_BORDER + button_height + CLIENT_RECT_VPAD + info_height + CLIENT_RECT_VPAD; | ||
463 | |||
464 | if (getHost()) | ||
465 | { | 452 | { |
466 | // try to keep aspect ratio when hosted, as hosting view can resize without user input | 453 | // clamp texture size to fit within actual size of floater after attempting resize |
467 | mClientRect.setLeftTopAndSize(window_rect.getCenterX() - (client_width / 2), window_rect.mTop, client_width, client_height); | 454 | client_width = llmin(client_width, mRect.getWidth() - horiz_pad); |
455 | client_height = llmin(client_height, mRect.getHeight() - PREVIEW_HEADER_SIZE | ||
456 | - (2 * CLIENT_RECT_VPAD) - LLPANEL_BORDER_WIDTH - info_height); | ||
457 | |||
458 | |||
468 | } | 459 | } |
469 | else | 460 | else |
470 | { | 461 | { |
471 | mClientRect.setLeftTopAndSize(LLPANEL_BORDER_WIDTH + PREVIEW_PAD + 6, | 462 | client_width = mRect.getWidth() - horiz_pad; |
472 | mRect.getHeight() - (PREVIEW_HEADER_SIZE + CLIENT_RECT_VPAD), | 463 | client_height = llround(client_width * inv_aspect_ratio); |
473 | mRect.getWidth() - horiz_pad, | 464 | } |
474 | client_height); | 465 | |
466 | |||
467 | S32 max_height = mRect.getHeight() - PREVIEW_BORDER - button_height | ||
468 | - CLIENT_RECT_VPAD - info_height - CLIENT_RECT_VPAD - PREVIEW_HEADER_SIZE; | ||
469 | max_height = llmax(max_height, 1); | ||
470 | |||
471 | if (client_height > max_height) | ||
472 | { | ||
473 | F32 aspect_ratio = (F32) image_width / (F32) image_height; | ||
474 | client_height = max_height; | ||
475 | client_width = llround(client_height * aspect_ratio); | ||
475 | } | 476 | } |
477 | |||
478 | LLRect window_rect(0, mRect.getHeight(), mRect.getWidth(), 0); | ||
479 | window_rect.mTop -= (PREVIEW_HEADER_SIZE + CLIENT_RECT_VPAD); | ||
480 | window_rect.mBottom += PREVIEW_BORDER + button_height + CLIENT_RECT_VPAD + info_height + CLIENT_RECT_VPAD; | ||
481 | |||
482 | // try to keep aspect ratio when hosted, as hosting view can resize without user input | ||
483 | mClientRect.setLeftTopAndSize(window_rect.getCenterX() - (client_width / 2), window_rect.mTop, client_width, client_height); | ||
476 | } | 484 | } |
477 | 485 | ||
486 | |||
478 | void LLPreviewTexture::loadAsset() | 487 | void LLPreviewTexture::loadAsset() |
479 | { | 488 | { |
480 | mImage = gImageList.getImage(mImageID, MIPMAP_TRUE, FALSE); | 489 | mImage = gImageList.getImage(mImageID, MIPMAP_TRUE, FALSE); |