From 2b56570c6867dc39aa4c8a19d2657ffed6c596b2 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 24 Feb 2023 12:51:03 +0200 Subject: SL-19108 Fallback thumbnail --- indra/newview/llthumbnailctrl.cpp | 28 ++++++++++++++++++++- indra/newview/llthumbnailctrl.h | 2 ++ .../textures/icons/thumbnail_fallback_icon.png | Bin 0 -> 6162 bytes indra/newview/skins/default/textures/textures.xml | 1 + .../xui/en/floater_change_item_thumbnail.xml | 1 + .../skins/default/xui/en/sidepanel_item_info.xml | 1 + 6 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 indra/newview/skins/default/textures/icons/thumbnail_fallback_icon.png (limited to 'indra') diff --git a/indra/newview/llthumbnailctrl.cpp b/indra/newview/llthumbnailctrl.cpp index 4245237529..1b054b4c27 100644 --- a/indra/newview/llthumbnailctrl.cpp +++ b/indra/newview/llthumbnailctrl.cpp @@ -43,6 +43,7 @@ static LLDefaultChildRegistry::Register 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 { diff --git a/indra/newview/llthumbnailctrl.h b/indra/newview/llthumbnailctrl.h index 978da8d71c..dc21046841 100644 --- a/indra/newview/llthumbnailctrl.h +++ b/indra/newview/llthumbnailctrl.h @@ -49,6 +49,7 @@ public: Optional border; Optional border_color; Optional image_name; + Optional fallback_image; Optional border_visible; Optional interactable; Optional show_loading; @@ -80,6 +81,7 @@ private: LLPointer mTexturep; LLPointer mImagep; + LLPointer mFallbackImagep; }; #endif diff --git a/indra/newview/skins/default/textures/icons/thumbnail_fallback_icon.png b/indra/newview/skins/default/textures/icons/thumbnail_fallback_icon.png new file mode 100644 index 0000000000..8d5ca624af Binary files /dev/null and b/indra/newview/skins/default/textures/icons/thumbnail_fallback_icon.png differ diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml index 5d9c362e78..424fc851fd 100644 --- a/indra/newview/skins/default/textures/textures.xml +++ b/indra/newview/skins/default/textures/textures.xml @@ -690,6 +690,7 @@ with the same filename but different name +