SL-19108 Fallback thumbnail

master
Andrey Kleshchev 2023-02-24 12:51:03 +02:00
parent 49da5288bd
commit 2b56570c68
6 changed files with 32 additions and 1 deletions

View File

@ -43,6 +43,7 @@ static LLDefaultChildRegistry::Register<LLThumbnailCtrl> r("thumbnail");
LLThumbnailCtrl::Params::Params()
: border("border")
, border_color("border_color")
, fallback_image("fallback_image")
, image_name("image_name")
, border_visible("show_visible", false)
, interactable("interactable", false)
@ -53,6 +54,7 @@ LLThumbnailCtrl::LLThumbnailCtrl(const LLThumbnailCtrl::Params& p)
: LLUICtrl(p)
, mBorderColor(p.border_color())
, mBorderVisible(p.border_visible())
, mFallbackImagep(p.fallback_image)
, mInteractable(p.interactable())
, mShowLoadingPlaceholder(p.show_loading())
, mPriority(LLGLTexture::BOOST_PREVIEW)
@ -76,6 +78,7 @@ LLThumbnailCtrl::~LLThumbnailCtrl()
{
mTexturep = nullptr;
mImagep = nullptr;
mFallbackImagep = nullptr;
}
@ -106,7 +109,30 @@ void LLThumbnailCtrl::draw()
}
else if( mImagep.notNull() )
{
mImagep->draw(getLocalRect(), UI_VERTEX_COLOR % alpha );
mImagep->draw(draw_rect, UI_VERTEX_COLOR % alpha );
}
else if (mFallbackImagep.notNull())
{
if (draw_rect.getWidth() > mFallbackImagep->getWidth()
&& draw_rect.getHeight() > mFallbackImagep->getHeight())
{
S32 img_width = mFallbackImagep->getWidth();
S32 img_height = mFallbackImagep->getHeight();
S32 rect_width = draw_rect.getWidth();
S32 rect_height = draw_rect.getHeight();
LLRect fallback_rect;
fallback_rect.mLeft = draw_rect.mLeft + (rect_width - img_width) / 2;
fallback_rect.mRight = fallback_rect.mLeft + img_width;
fallback_rect.mBottom = draw_rect.mBottom + (rect_height - img_height) / 2;
fallback_rect.mTop = fallback_rect.mBottom + img_height;
mFallbackImagep->draw(fallback_rect, UI_VERTEX_COLOR % alpha);
}
else
{
mFallbackImagep->draw(draw_rect, UI_VERTEX_COLOR % alpha);
}
}
else
{

View File

@ -49,6 +49,7 @@ public:
Optional<LLViewBorder::Params> border;
Optional<LLUIColor> border_color;
Optional<std::string> image_name;
Optional<LLUIImage*> fallback_image;
Optional<bool> border_visible;
Optional<bool> interactable;
Optional<bool> show_loading;
@ -80,6 +81,7 @@ private:
LLPointer<LLViewerFetchedTexture> mTexturep;
LLPointer<LLUIImage> mImagep;
LLPointer<LLUIImage> mFallbackImagep;
};
#endif

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

@ -690,6 +690,7 @@ with the same filename but different name
<texture name="TextField_Active" file_name="widgets/TextField_Active.png" preload="true" scale.left="9" scale.top="12" scale.right="248" scale.bottom="12" />
<texture name="TextField_Search_Highlight" file_name="widgets/TextField_Search_Highlight.png" preload="true" scale.left="9" scale.top="12" scale.right="248" scale.bottom="12" />
<texture name="Thumbnail_Fallback" file_name="icons/thumbnail_fallback_icon.png" preload="true" />
<texture name="Toast_CloseBtn" file_name="windows/Toast_CloseBtn.png" preload="true" />
<texture name="Toast_Background" file_name="windows/Toast_Background.png" preload="true"

View File

@ -56,6 +56,7 @@
<thumbnail
name="item_thumbnail"
fallback_image="Thumbnail_Fallback"
follows="top|left"
layout="topleft"
left="32"

View File

@ -93,6 +93,7 @@
<thumbnail
name="item_thumbnail"
fallback_image="Thumbnail_Fallback"
follows="top|left"
layout="topleft"
left="5"