From 3ecfeda2fdb83c9d89f4e8743f9c99a8ec7b01f6 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 6 Feb 2023 20:52:56 +0200 Subject: SL-19134 Thumbnail ctrl LLIconCtrl stores icons indefinitely which is undesired for fairly large and expected to be numerous thumbnails, LLTextureCtrl is tied to texture picker and has a number of limitations (already processes clicks, enforces label area). Intent behind LLThumbnailCtrl is to bridge the gap - to not store texture indefinitely and to allow further customisation. --- indra/newview/llthumbnailctrl.h | 85 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 indra/newview/llthumbnailctrl.h (limited to 'indra/newview/llthumbnailctrl.h') diff --git a/indra/newview/llthumbnailctrl.h b/indra/newview/llthumbnailctrl.h new file mode 100644 index 0000000000..978da8d71c --- /dev/null +++ b/indra/newview/llthumbnailctrl.h @@ -0,0 +1,85 @@ +/** + * @file llthumbnailctrl.h + * @brief LLThumbnailCtrl base class + * + * $LicenseInfo:firstyear=2023&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2023 Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLTHUMBNAILCTRL_H +#define LL_LLTHUMBNAILCTRL_H + +#include "llui.h" +#include "lluictrl.h" +#include "llviewborder.h" // for params + +class LLUICtrlFactory; +class LLUUID; +class LLViewerFetchedTexture; + +// +// Classes +// + +// +class LLThumbnailCtrl +: public LLUICtrl +{ +public: + struct Params : public LLInitParam::Block + { + Optional border; + Optional border_color; + Optional image_name; + Optional border_visible; + Optional interactable; + Optional show_loading; + + Params(); + }; +protected: + LLThumbnailCtrl(const Params&); + friend class LLUICtrlFactory; + +public: + virtual ~LLThumbnailCtrl(); + + virtual void draw() override; + + virtual void setValue(const LLSD& value ) override; + + virtual BOOL handleHover(S32 x, S32 y, MASK mask) override; + +private: + S32 mPriority; + bool mBorderVisible; + bool mInteractable; + bool mShowLoadingPlaceholder; + std::string mLoadingPlaceholderString; + LLUUID mImageAssetID; + LLViewBorder* mBorder; + LLUIColor mBorderColor; + + LLPointer mTexturep; + LLPointer mImagep; +}; + +#endif -- cgit v1.3 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/newview/llthumbnailctrl.h') 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 + Date: Fri, 31 Mar 2023 21:18:50 +0300 Subject: SL-19379 WIP show fallback image with original size --- indra/newview/llinventorygallery.cpp | 2 +- indra/newview/llthumbnailctrl.cpp | 7 +++++++ indra/newview/llthumbnailctrl.h | 1 + .../newview/skins/default/xui/en/panel_inventory_gallery_item.xml | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) (limited to 'indra/newview/llthumbnailctrl.h') diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp index 499d51c431..290688f179 100644 --- a/indra/newview/llinventorygallery.cpp +++ b/indra/newview/llinventorygallery.cpp @@ -1081,7 +1081,7 @@ void LLInventoryGalleryItem::setThumbnail(LLUUID id) mDefaultImage = id.isNull(); if(mDefaultImage) { - getChild("preview_thumbnail")->setValue("Thumbnail_Fallback"); + getChild("preview_thumbnail")->clearTexture(); } else { diff --git a/indra/newview/llthumbnailctrl.cpp b/indra/newview/llthumbnailctrl.cpp index 1b054b4c27..340dba3717 100644 --- a/indra/newview/llthumbnailctrl.cpp +++ b/indra/newview/llthumbnailctrl.cpp @@ -170,6 +170,13 @@ void LLThumbnailCtrl::draw() LLUICtrl::draw(); } +void LLThumbnailCtrl::clearTexture() +{ + mImageAssetID = LLUUID::null; + mTexturep = nullptr; + mImagep = nullptr; +} + // virtual // value might be a string or a UUID void LLThumbnailCtrl::setValue(const LLSD& value) diff --git a/indra/newview/llthumbnailctrl.h b/indra/newview/llthumbnailctrl.h index dc21046841..686603b373 100644 --- a/indra/newview/llthumbnailctrl.h +++ b/indra/newview/llthumbnailctrl.h @@ -66,6 +66,7 @@ public: virtual void draw() override; virtual void setValue(const LLSD& value ) override; + void clearTexture(); virtual BOOL handleHover(S32 x, S32 y, MASK mask) override; diff --git a/indra/newview/skins/default/xui/en/panel_inventory_gallery_item.xml b/indra/newview/skins/default/xui/en/panel_inventory_gallery_item.xml index 05a02158c0..b343aafca5 100644 --- a/indra/newview/skins/default/xui/en/panel_inventory_gallery_item.xml +++ b/indra/newview/skins/default/xui/en/panel_inventory_gallery_item.xml @@ -16,7 +16,7 @@ (worn)