From e625fa3b33bbe4dbe10373c9040549e62b674374 Mon Sep 17 00:00:00 2001 From: Inusaito Sayori Date: Wed, 4 Feb 2015 23:47:37 -0500 Subject: [PATCH] Cleanup duplicate show_picture codestuffs. --- indra/newview/llpanelavatar.cpp | 60 ++++++--------------------------- indra/newview/llpanelavatar.h | 3 -- indra/newview/llpanelpick.cpp | 6 ++-- 3 files changed, 14 insertions(+), 55 deletions(-) diff --git a/indra/newview/llpanelavatar.cpp b/indra/newview/llpanelavatar.cpp index c8483f591..d8377ffb2 100644 --- a/indra/newview/llpanelavatar.cpp +++ b/indra/newview/llpanelavatar.cpp @@ -277,27 +277,6 @@ void LLPanelAvatarSecondLife::enableControls(BOOL self) childSetEnabled("?", self); } -void LLPanelAvatarFirstLife::onClickImage() -{ - const LLUUID& id(getChild("img")->getImageAssetID()); - llinfos << "LLPanelAvatarFirstLife::onClickImage" << llendl; - if (!LLPreview::show(id)) - { - // There isn't one, so make a new preview - S32 left, top; - gFloaterView->getNewFloaterPosition(&left, &top); - LLRect rect = gSavedSettings.getRect("PreviewTextureRect"); - rect.translate( left - rect.mLeft, rect.mTop - top ); // Changed to avoid textures being sunken below the window border. - LLPreviewTexture* preview = new LLPreviewTexture("preview task texture", - rect, - std::string("Profile First Life Picture"), - id); - preview->setFocus(TRUE); - //preview->mIsCopyable=FALSE; - //preview->canSaveAs - } -} - // virtual void LLPanelAvatarFirstLife::processProperties(void* data, EAvatarProcessorType type) { @@ -313,29 +292,6 @@ void LLPanelAvatarFirstLife::processProperties(void* data, EAvatarProcessorType } } -void LLPanelAvatarSecondLife::onClickImage() -{ - const LLUUID& id = getChild("img")->getImageAssetID(); - llinfos << "LLPanelAvatarSecondLife::onClickImage" << llendl; - if (!LLPreview::show(id)) - { - // There isn't one, so make a new preview - S32 left, top; - gFloaterView->getNewFloaterPosition(&left, &top); - LLRect rect = gSavedSettings.getRect("PreviewTextureRect"); - rect.translate(left - rect.mLeft, rect.mTop - top); // Changed to avoid textures being sunken below the window border. - LLPreviewTexture* preview = new LLPreviewTexture("preview task texture", - rect, - std::string("Profile Picture: ") + getChild("dnname")->getText(), - id); - preview->setFocus(TRUE); - //preview->mIsCopyable=FALSE; - /*open_texture(LLUUID::null,//id, - std::string("Profile Picture: ") + getChild("dnname")->getText() + "and image id is " + id.asString() - , FALSE, id, TRUE);*/ - } -} - void LLPanelAvatarSecondLife::onDoubleClickGroup() { if (LLScrollListItem* item = getChild("groups")->getFirstSelected()) @@ -370,6 +326,8 @@ void LLPanelAvatarFirstLife::enableControls(BOOL self) // postBuild //----------------------------------------------------------------------------- +void show_picture(const LLUUID& id, const std::string& name); +static std::string profile_picture_title(const std::string& str) { return "Profile Picture: " + str; } static void show_partner_help() { LLNotificationsUtil::add("ClickPartnerHelpAvatar", LLSD(), LLSD(), boost::bind(LLPanelAvatarSecondLife::onClickPartnerHelpLoadURL, _1, _2)); } BOOL LLPanelAvatarSecondLife::postBuild() { @@ -410,10 +368,11 @@ BOOL LLPanelAvatarSecondLife::postBuild() getChild("Offer Teleport...")->setCommitCallback(boost::bind(static_cast(LLAvatarActions::offerTeleport), boost::bind(&LLPanelAvatar::getAvatarID, pa))); getChild("groups")->setDoubleClickCallback(boost::bind(&LLPanelAvatarSecondLife::onDoubleClickGroup,this)); - - getChild("bigimg")->setCommitCallback(boost::bind(&LLPanelAvatarSecondLife::onClickImage, this)); - - getChild("img")->setFallbackImageName("default_profile_picture.j2c"); + + LLTextureCtrl* ctrl = getChild("img"); + ctrl->setFallbackImageName("default_profile_picture.j2c"); + + getChild("bigimg")->setCommitCallback(boost::bind(boost::bind(show_picture, boost::bind(&LLTextureCtrl::getImageAssetID, ctrl), boost::bind(profile_picture_title, boost::bind(&LLView::getValue, getChild("dnname")))))); return TRUE; } @@ -423,9 +382,10 @@ BOOL LLPanelAvatarFirstLife::postBuild() BOOL own_avatar = (getPanelAvatar()->getAvatarID() == gAgent.getID() ); enableControls(own_avatar); - getChild("img")->setFallbackImageName("default_profile_picture.j2c"); + LLTextureCtrl* ctrl = getChild("img"); + ctrl->setFallbackImageName("default_profile_picture.j2c"); - getChild("flbigimg")->setCommitCallback(boost::bind(&LLPanelAvatarFirstLife::onClickImage, this)); + getChild("flbigimg")->setCommitCallback(boost::bind(boost::bind(boost::bind(show_picture, boost::bind(&LLTextureCtrl::getImageAssetID, ctrl), "First Life Picture")))); return TRUE; } diff --git a/indra/newview/llpanelavatar.h b/indra/newview/llpanelavatar.h index 89cf3b5dc..cc6e10b51 100644 --- a/indra/newview/llpanelavatar.h +++ b/indra/newview/llpanelavatar.h @@ -92,8 +92,6 @@ public: /*virtual*/ BOOL postBuild(); /*virtual*/ void processProperties(void* data, EAvatarProcessorType type); - void onClickImage(); - void enableControls(BOOL own_avatar); }; @@ -113,7 +111,6 @@ public: /*virtual*/ void onChange() {} /*virtual*/ void onChangeDetailed(const LLMute& mute); - void onClickImage(); void onClickFriends(); void onDoubleClickGroup(); static bool onClickPartnerHelpLoadURL(const LLSD& notification, const LLSD& response); diff --git a/indra/newview/llpanelpick.cpp b/indra/newview/llpanelpick.cpp index c2e2a2cb1..f949d482d 100644 --- a/indra/newview/llpanelpick.cpp +++ b/indra/newview/llpanelpick.cpp @@ -63,8 +63,10 @@ void show_picture(const LLUUID& id, const std::string& name) // Try to show and focus existing preview if (LLPreview::show(id)) return; // If there isn't one, make a new preview - LLPreview* preview = new LLPreviewTexture("preview texture", gSavedSettings.getRect("PreviewTextureRect"), name, id); - preview->setFocus(true); + S32 left, top; + gFloaterView->getNewFloaterPosition(&left, &top); + LLRect rect = gSavedSettings.getRect("PreviewTextureRect"); + (new LLPreviewTexture("preview texture", rect.translate(left - rect.mLeft, rect.mTop - top), name, id))->setFocus(true); } //static