From 0c6afa58de6b57ad41d31a3dddaac9ef30321960 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 6 Jun 2022 18:55:33 +0300 Subject: SL-15312 Larger image preview At the moment without cursor handling --- indra/newview/llfloaterprofiletexture.cpp | 211 ++++++++++++++++++++++++++++++ 1 file changed, 211 insertions(+) create mode 100644 indra/newview/llfloaterprofiletexture.cpp (limited to 'indra/newview/llfloaterprofiletexture.cpp') diff --git a/indra/newview/llfloaterprofiletexture.cpp b/indra/newview/llfloaterprofiletexture.cpp new file mode 100644 index 0000000000..4ddd7dfc6b --- /dev/null +++ b/indra/newview/llfloaterprofiletexture.cpp @@ -0,0 +1,211 @@ +/** + * @file llfloaterprofiletexture.cpp + * @brief LLFloaterProfileTexture class implementation + * + * $LicenseInfo:firstyear=2022&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2022, 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$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llfloaterprofiletexture.h" + +#include "llbutton.h" +#include "llfloaterreg.h" +#include "llpreview.h" // fors constants +#include "lltrans.h" +#include "llviewercontrol.h" +#include "lltextureview.h" +#include "llviewertexture.h" +#include "llviewertexturelist.h" + + +const S32 CLIENT_RECT_VPAD = 4; +const F32 PREVIEW_TEXTURE_MAX_ASPECT = 20.f; +const F32 PREVIEW_TEXTURE_MIN_ASPECT = 0.5f; + + +LLFloaterProfileTexture::LLFloaterProfileTexture(LLView* owner) + : LLFloater(LLSD()) + , mUpdateDimensions(TRUE) + , mLastHeight(0) + , mLastWidth(0) + , mImage(NULL) + , mImageOldBoostLevel(LLGLTexture::BOOST_NONE) + , mOwnerHandle(owner->getHandle()) +{ + buildFromFile("floater_profile_texture.xml"); +} + +LLFloaterProfileTexture::~LLFloaterProfileTexture() +{ + if (mImage.notNull()) + { + mImage->setBoostLevel(mImageOldBoostLevel); + mImage = NULL; + } +} + +// virtual +BOOL LLFloaterProfileTexture::postBuild() +{ + pProfileIcon = getChild("profile_pic"); + + getChild("close_btn")->setCommitCallback([this](LLUICtrl*, void*) { closeFloater(); }, nullptr); + + return TRUE; +} + +// virtual +void LLFloaterProfileTexture::reshape(S32 width, S32 height, BOOL called_from_parent) +{ + LLFloater::reshape(width, height, called_from_parent); +} + +// It takes a while until we get height and width information. +// When we receive it, reshape the window accordingly. +void LLFloaterProfileTexture::updateDimensions() +{ + if (mImage.isNull()) + { + return; + } + if ((mImage->getFullWidth() * mImage->getFullHeight()) == 0) + { + return; + } + + S32 img_width = mImage->getFullWidth(); + S32 img_height = mImage->getFullHeight(); + + if (mAssetStatus != LLPreview::PREVIEW_ASSET_LOADED + || mLastWidth != img_width + || mLastHeight != img_height) + { + mAssetStatus = LLPreview::PREVIEW_ASSET_LOADED; + // Asset has been fully loaded + mUpdateDimensions = TRUE; + } + + mLastHeight = img_height; + mLastWidth = img_width; + + // Reshape the floater only when required + if (mUpdateDimensions) + { + mUpdateDimensions = FALSE; + + LLRect old_floater_rect = getRect(); + LLRect old_image_rect = pProfileIcon->getRect(); + S32 width = old_floater_rect.getWidth() - old_image_rect.getWidth() + mLastWidth; + S32 height = old_floater_rect.getHeight() - old_image_rect.getHeight() + mLastHeight; + + //reshape floater + reshape(width, height); + + gFloaterView->adjustToFitScreen(this, FALSE); + } +} + +void LLFloaterProfileTexture::draw() +{ + // drawFrustum + LLView *owner = mOwnerHandle.get(); + static LLCachedControl max_opacity(gSavedSettings, "PickerContextOpacity", 0.4f); + drawConeToOwner(mContextConeOpacity, max_opacity, owner); + + LLFloater::draw(); +} + +void LLFloaterProfileTexture::resetAsset() +{ + pProfileIcon->setValue("Generic_Person_Large"); + mImageID = LLUUID::null; + if (mImage.notNull()) + { + mImage->setBoostLevel(mImageOldBoostLevel); + mImage = NULL; + } +} +void LLFloaterProfileTexture::loadAsset(const LLUUID &image_id) +{ + if (mImageID != image_id) + { + if (mImage.notNull()) + { + mImage->setBoostLevel(mImageOldBoostLevel); + mImage = NULL; + } + } + else + { + return; + } + + pProfileIcon->setValue(image_id); + mImageID = image_id; + mImage = LLViewerTextureManager::getFetchedTexture(mImageID, FTT_DEFAULT, MIPMAP_TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); + mImageOldBoostLevel = mImage->getBoostLevel(); + + if ((mImage->getFullWidth() * mImage->getFullHeight()) == 0) + { + mImage->setLoadedCallback(LLFloaterProfileTexture::onTextureLoaded, + 0, TRUE, FALSE, new LLHandle(getHandle()), &mCallbackTextureList); + + mImage->setBoostLevel(LLGLTexture::BOOST_PREVIEW); + mAssetStatus = LLPreview::PREVIEW_ASSET_LOADING; + } + else + { + mAssetStatus = LLPreview::PREVIEW_ASSET_LOADED; + } + + mUpdateDimensions = TRUE; + updateDimensions(); +} + +// static +void LLFloaterProfileTexture::onTextureLoaded( + BOOL success, + LLViewerFetchedTexture *src_vi, + LLImageRaw* src, + LLImageRaw* aux_src, + S32 discard_level, + BOOL final, + void* userdata) +{ + LLHandle* handle = (LLHandle*)userdata; + + if (!handle->isDead()) + { + LLFloaterProfileTexture* floater = static_cast(handle->get()); + if (floater && success) + { + floater->mUpdateDimensions = TRUE; + floater->updateDimensions(); + } + } + + if (final || !success) + { + delete handle; + } +} -- cgit v1.3 From 111d1d7c94887cb91bcb82ec6c86aaed133d8043 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 6 Jun 2022 21:27:13 +0300 Subject: SL-15312 Fixed group names not having padding Plus some focus and interactibility fixes --- indra/llui/lliconctrl.cpp | 13 +++++++++++++ indra/llui/lliconctrl.h | 7 ++++++- indra/newview/llfloaterprofiletexture.cpp | 20 +++++++++++--------- indra/newview/llfloaterprofiletexture.h | 13 ++++++++----- indra/newview/llgrouplist.cpp | 21 +++++++++++---------- indra/newview/llgrouplist.h | 2 +- indra/newview/llpanelprofile.cpp | 22 +++++++++++++++++++--- indra/newview/llpanelprofile.h | 16 ++++++++-------- .../default/xui/en/panel_profile_secondlife.xml | 7 +++++++ 9 files changed, 84 insertions(+), 37 deletions(-) (limited to 'indra/newview/llfloaterprofiletexture.cpp') diff --git a/indra/llui/lliconctrl.cpp b/indra/llui/lliconctrl.cpp index 82b01e705d..e01aba402e 100644 --- a/indra/llui/lliconctrl.cpp +++ b/indra/llui/lliconctrl.cpp @@ -35,6 +35,7 @@ #include "llui.h" #include "lluictrlfactory.h" #include "lluiimage.h" +#include "llwindow.h" static LLDefaultChildRegistry::Register r("icon"); @@ -42,6 +43,7 @@ LLIconCtrl::Params::Params() : image("image_name"), color("color"), use_draw_context_alpha("use_draw_context_alpha", true), + interactable("interactable", false), scale_image("scale_image"), min_width("min_width", 0), min_height("min_height", 0) @@ -52,6 +54,7 @@ LLIconCtrl::LLIconCtrl(const LLIconCtrl::Params& p) mColor(p.color()), mImagep(p.image), mUseDrawContextAlpha(p.use_draw_context_alpha), + mInteractable(p.interactable), mPriority(0), mMinWidth(p.min_width), mMinHeight(p.min_height), @@ -81,6 +84,16 @@ void LLIconCtrl::draw() LLUICtrl::draw(); } +BOOL LLIconCtrl::handleHover(S32 x, S32 y, MASK mask) +{ + if (mInteractable && getEnabled()) + { + getWindow()->setCursor(UI_CURSOR_HAND); + return TRUE; + } + return LLUICtrl::handleHover(x, y, mask); +} + // virtual // value might be a string or a UUID void LLIconCtrl::setValue(const LLSD& value) diff --git a/indra/llui/lliconctrl.h b/indra/llui/lliconctrl.h index dd83e78fd3..9c3b517bca 100644 --- a/indra/llui/lliconctrl.h +++ b/indra/llui/lliconctrl.h @@ -48,7 +48,8 @@ public: { Optional image; Optional color; - Optional use_draw_context_alpha; + Optional use_draw_context_alpha, + interactable; Optional min_width, min_height; Ignored scale_image; @@ -67,6 +68,9 @@ public: // llview overrides virtual void draw(); + // llview overrides + virtual BOOL handleHover(S32 x, S32 y, MASK mask); + // lluictrl overrides virtual void setValue(const LLSD& value ); @@ -88,6 +92,7 @@ protected: // If set to true (default), use the draw context transparency. // If false, will use transparency returned by getCurrentTransparency(). See STORM-698. bool mUseDrawContextAlpha; + bool mInteractable; private: LLUIColor mColor; diff --git a/indra/newview/llfloaterprofiletexture.cpp b/indra/newview/llfloaterprofiletexture.cpp index 4ddd7dfc6b..743685e7d1 100644 --- a/indra/newview/llfloaterprofiletexture.cpp +++ b/indra/newview/llfloaterprofiletexture.cpp @@ -38,10 +38,6 @@ #include "llviewertexturelist.h" -const S32 CLIENT_RECT_VPAD = 4; -const F32 PREVIEW_TEXTURE_MAX_ASPECT = 20.f; -const F32 PREVIEW_TEXTURE_MIN_ASPECT = 0.5f; - LLFloaterProfileTexture::LLFloaterProfileTexture(LLView* owner) : LLFloater(LLSD()) @@ -67,9 +63,10 @@ LLFloaterProfileTexture::~LLFloaterProfileTexture() // virtual BOOL LLFloaterProfileTexture::postBuild() { - pProfileIcon = getChild("profile_pic"); + mProfileIcon = getChild("profile_pic"); - getChild("close_btn")->setCommitCallback([this](LLUICtrl*, void*) { closeFloater(); }, nullptr); + mCloseButton = getChild("close_btn"); + mCloseButton->setCommitCallback([this](LLUICtrl*, void*) { closeFloater(); }, nullptr); return TRUE; } @@ -114,7 +111,7 @@ void LLFloaterProfileTexture::updateDimensions() mUpdateDimensions = FALSE; LLRect old_floater_rect = getRect(); - LLRect old_image_rect = pProfileIcon->getRect(); + LLRect old_image_rect = mProfileIcon->getRect(); S32 width = old_floater_rect.getWidth() - old_image_rect.getWidth() + mLastWidth; S32 height = old_floater_rect.getHeight() - old_image_rect.getHeight() + mLastHeight; @@ -135,9 +132,14 @@ void LLFloaterProfileTexture::draw() LLFloater::draw(); } +void LLFloaterProfileTexture::onOpen(const LLSD& key) +{ + mCloseButton->setFocus(true); +} + void LLFloaterProfileTexture::resetAsset() { - pProfileIcon->setValue("Generic_Person_Large"); + mProfileIcon->setValue("Generic_Person_Large"); mImageID = LLUUID::null; if (mImage.notNull()) { @@ -160,7 +162,7 @@ void LLFloaterProfileTexture::loadAsset(const LLUUID &image_id) return; } - pProfileIcon->setValue(image_id); + mProfileIcon->setValue(image_id); mImageID = image_id; mImage = LLViewerTextureManager::getFetchedTexture(mImageID, FTT_DEFAULT, MIPMAP_TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); mImageOldBoostLevel = mImage->getBoostLevel(); diff --git a/indra/newview/llfloaterprofiletexture.h b/indra/newview/llfloaterprofiletexture.h index 84ff4ecb16..66a61213dd 100644 --- a/indra/newview/llfloaterprofiletexture.h +++ b/indra/newview/llfloaterprofiletexture.h @@ -30,6 +30,7 @@ #include "llfloater.h" #include "llviewertexture.h" +class LLButton; class LLImageRaw; class LLIconCtrl; @@ -39,7 +40,8 @@ public: LLFloaterProfileTexture(LLView* owner); ~LLFloaterProfileTexture(); - virtual void draw(); + void draw() override; + void onOpen(const LLSD& key) override; void resetAsset(); void loadAsset(const LLUUID &image_id); @@ -54,12 +56,12 @@ public: BOOL final, void* userdata); - virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); + void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE) override; protected: - /* virtual */ BOOL postBuild(); + BOOL postBuild() override; private: - void updateDimensions(); + void updateDimensions(); LLUUID mImageID; LLPointer mImage; @@ -71,7 +73,8 @@ private: BOOL mUpdateDimensions; LLHandle mOwnerHandle; - LLIconCtrl* pProfileIcon; + LLIconCtrl* mProfileIcon; + LLButton* mCloseButton; LLLoadedCallbackEntry::source_callback_list_t mCallbackTextureList; }; diff --git a/indra/newview/llgrouplist.cpp b/indra/newview/llgrouplist.cpp index 38c0b64e0a..32af2592d3 100644 --- a/indra/newview/llgrouplist.cpp +++ b/indra/newview/llgrouplist.cpp @@ -45,7 +45,6 @@ #include "llvoiceclient.h" static LLDefaultChildRegistry::Register r("group_list"); -S32 LLGroupListItem::sIconWidth = 0; class LLGroupComparator : public LLFlatListView::ItemComparator { @@ -305,7 +304,10 @@ void LLGroupList::addNewItem(const LLUUID& id, const std::string& name, const LL item->getChildView("info_btn")->setVisible( false); item->getChildView("profile_btn")->setVisible( false); item->setGroupIconVisible(mShowIcons); - item->setVisibleInProfile(visible_in_profile); + if (!mShowIcons) + { + item->setVisibleInProfile(visible_in_profile); + } addItem(item, id, pos); // setCommentVisible(false); @@ -414,13 +416,6 @@ mForAgent(for_agent) { buildFromFile( "panel_group_list_item_short.xml"); } - - // Remember group icon width including its padding from the name text box, - // so that we can hide and show the icon again later. - if (!sIconWidth && mGroupNameBox) - { - sIconWidth = mGroupNameBox->getRect().mLeft - mGroupIcon->getRect().mLeft; - } } LLGroupListItem::~LLGroupListItem() @@ -451,6 +446,12 @@ BOOL LLGroupListItem::postBuild() mVisibilityShowBtn->setClickedCallback([this](LLUICtrl *, const LLSD &) { onVisibilityBtnClick(true); }); } + // Remember group icon width including its padding from the name text box, + // so that we can hide and show the icon again later. + // Also note that panel_group_list_item and panel_group_list_item_short + // have icons of different sizes so we need to figure it per file. + mIconWidth = mGroupNameBox->getRect().mLeft - mGroupIcon->getRect().mLeft; + return TRUE; } @@ -541,7 +542,7 @@ void LLGroupListItem::setGroupIconVisible(bool visible) // Move the group name horizontally by icon size + its distance from the group name. LLRect name_rect = mGroupNameBox->getRect(); - name_rect.mLeft += visible ? sIconWidth : -sIconWidth; + name_rect.mLeft += visible ? mIconWidth : -mIconWidth; mGroupNameBox->setRect(name_rect); } diff --git a/indra/newview/llgrouplist.h b/indra/newview/llgrouplist.h index bab9127e10..5cbabb712f 100644 --- a/indra/newview/llgrouplist.h +++ b/indra/newview/llgrouplist.h @@ -137,6 +137,6 @@ private: bool mForAgent; LLStyle::Params mGroupNameStyle; - static S32 sIconWidth; // icon width + padding + S32 mIconWidth; }; #endif // LL_LLGROUPLIST_H diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp index 441a69bc5d..69e36a2df7 100644 --- a/indra/newview/llpanelprofile.cpp +++ b/indra/newview/llpanelprofile.cpp @@ -669,6 +669,8 @@ void LLFloaterProfilePermissions::onOpen(const LLSD& key) fillRightsData(); } + mCancelBtn->setFocus(true); + mAvatarNameCacheConnection = LLAvatarNameCache::get(mAvatarID, boost::bind(&LLFloaterProfilePermissions::onAvatarNameCache, this, _1, _2)); } @@ -986,6 +988,13 @@ void LLPanelProfileSecondLife::resetData() mCanEditObjectsIcon->setVisible(false); mCantEditObjectsIcon->setVisible(!own_profile); + mCanSeeOnlineIcon->setEnabled(false); + mCantSeeOnlineIcon->setEnabled(false); + mCanSeeOnMapIcon->setEnabled(false); + mCantSeeOnMapIcon->setEnabled(false); + mCanEditObjectsIcon->setEnabled(false); + mCantEditObjectsIcon->setEnabled(false); + childSetVisible("partner_layout", FALSE); childSetVisible("partner_spacer_layout", TRUE); } @@ -1222,15 +1231,22 @@ void LLPanelProfileSecondLife::fillRightsData() mCantSeeOnMapIcon->setVisible(!can_see_on_map); mCanEditObjectsIcon->setVisible(can_edit_objects); mCantEditObjectsIcon->setVisible(!can_edit_objects); + + mCanSeeOnlineIcon->setEnabled(true); + mCantSeeOnlineIcon->setEnabled(true); + mCanSeeOnMapIcon->setEnabled(true); + mCantSeeOnMapIcon->setEnabled(true); + mCanEditObjectsIcon->setEnabled(true); + mCantEditObjectsIcon->setEnabled(true); } else { mCanSeeOnlineIcon->setVisible(false); - mCantSeeOnlineIcon->setVisible(true); + mCantSeeOnlineIcon->setVisible(false); mCanSeeOnMapIcon->setVisible(false); - mCantSeeOnMapIcon->setVisible(true); + mCantSeeOnMapIcon->setVisible(false); mCanEditObjectsIcon->setVisible(false); - mCantEditObjectsIcon->setVisible(true); + mCantEditObjectsIcon->setVisible(false); } } diff --git a/indra/newview/llpanelprofile.h b/indra/newview/llpanelprofile.h index 4de5f274d8..943048843f 100644 --- a/indra/newview/llpanelprofile.h +++ b/indra/newview/llpanelprofile.h @@ -90,7 +90,7 @@ public: BOOL postBuild() override; - void resetData(); + void resetData() override; /** * Sends update data request to server. @@ -228,18 +228,18 @@ public: LLPanelProfileWeb(); /*virtual*/ ~LLPanelProfileWeb(); - /*virtual*/ void onOpen(const LLSD& key); + void onOpen(const LLSD& key) override; - /*virtual*/ BOOL postBuild(); + BOOL postBuild() override; - void resetData(); + void resetData() override; /** * Loads web profile. */ - /*virtual*/ void updateData(); + void updateData() override; - /*virtual*/ void handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event); + void handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event) override; void onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name); @@ -275,7 +275,7 @@ public: void processProperties(const LLAvatarData* avatar_data); - void resetData(); + void resetData() override; void setProfileImageUploading(bool loading); void setProfileImageUploaded(const LLUUID &image_asset_id); @@ -324,7 +324,7 @@ public: void processProperties(LLAvatarNotes* avatar_notes); - void resetData(); + void resetData() override; void updateData() override; diff --git a/indra/newview/skins/default/xui/en/panel_profile_secondlife.xml b/indra/newview/skins/default/xui/en/panel_profile_secondlife.xml index 0a74d934ac..53bd9666c1 100644 --- a/indra/newview/skins/default/xui/en/panel_profile_secondlife.xml +++ b/indra/newview/skins/default/xui/en/panel_profile_secondlife.xml @@ -49,6 +49,7 @@ Account: [ACCTTYPE] image_name="Generic_Person_Large" layout="topleft" follows="all" + interactable="true" top="0" left="2" bottom="-1" @@ -350,6 +351,7 @@ Account: [ACCTTYPE] image_name="Profile_Perm_Online_Enabled" layout="topleft" follows="right|top" + interactable="true" top="0" right="-61" height="24" @@ -363,6 +365,7 @@ Account: [ACCTTYPE] image_name="Profile_Perm_Online_Disabled" layout="topleft" follows="right|top" + interactable="true" top="0" right="-61" height="24" @@ -376,6 +379,7 @@ Account: [ACCTTYPE] image_name="Profile_Perm_Find_Enabled" layout="topleft" follows="right|top" + interactable="true" top="0" right="-30" height="24" @@ -389,6 +393,7 @@ Account: [ACCTTYPE] image_name="Profile_Perm_Find_Disabled" layout="topleft" follows="right|top" + interactable="true" top="0" right="-30" height="24" @@ -402,6 +407,7 @@ Account: [ACCTTYPE] image_name="Profile_Perm_Objects_Enabled" layout="topleft" follows="right|top" + interactable="true" top="0" right="-1" height="24" @@ -415,6 +421,7 @@ Account: [ACCTTYPE] image_name="Profile_Perm_Objects_Disabled" layout="topleft" follows="right|top" + interactable="true" top="0" right="-1" height="24" -- cgit v1.3 From 8ef8497add2007d29de1cb75b55e77349a7c717f Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 8 Jun 2022 19:36:29 +0300 Subject: SL-17532 Cap image size for profile image preview --- indra/newview/llfloaterprofiletexture.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'indra/newview/llfloaterprofiletexture.cpp') diff --git a/indra/newview/llfloaterprofiletexture.cpp b/indra/newview/llfloaterprofiletexture.cpp index 743685e7d1..bf1f56a6d1 100644 --- a/indra/newview/llfloaterprofiletexture.cpp +++ b/indra/newview/llfloaterprofiletexture.cpp @@ -115,6 +115,16 @@ void LLFloaterProfileTexture::updateDimensions() S32 width = old_floater_rect.getWidth() - old_image_rect.getWidth() + mLastWidth; S32 height = old_floater_rect.getHeight() - old_image_rect.getHeight() + mLastHeight; + const F32 MAX_DIMENTIONS = 512; // most profiles are supposed to be 256x256 + + S32 biggest_dim = llmax(width, height); + if (biggest_dim > MAX_DIMENTIONS) + { + F32 scale_down = MAX_DIMENTIONS / (F32)biggest_dim; + width *= scale_down; + height *= scale_down; + } + //reshape floater reshape(width, height); -- cgit v1.3