From 0cf9168895b1d7b69e4a0307ade6cbc607f799f2 Mon Sep 17 00:00:00 2001 From: Yuri Chebotarev Date: Fri, 2 Jul 2010 15:23:05 +0300 Subject: EXT-5692 FIX Add callback to create widget segment with LLAvatarIconCtrl (or LLGroupIconCtrl) based on url match id. reviewed by Richard Nelson at https://codereview.productengine.com/secondlife/r/610/ --HG-- branch : product-engine --- indra/llui/lltextutil.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'indra/llui/lltextutil.cpp') diff --git a/indra/llui/lltextutil.cpp b/indra/llui/lltextutil.cpp index c5f3929fb1..56664071b7 100644 --- a/indra/llui/lltextutil.cpp +++ b/indra/llui/lltextutil.cpp @@ -34,7 +34,9 @@ #include "lluicolor.h" #include "lltextbox.h" +#include "llurlmatch.h" +boost::function LLTextUtil::TextHelpers::iconCallbackCreationFunction = 0; void LLTextUtil::textboxSetHighlightedVal(LLTextBox *txtbox, const LLStyle::Params& normal_style, const std::string& text, const std::string& hl) { @@ -76,4 +78,36 @@ const std::string& LLTextUtil::formatPhoneNumber(const std::string& phone_str) return formatted_phone_str; } +bool LLTextUtil::processUrlMatch(LLUrlMatch* match,LLTextBase* text_base) +{ + if (match == 0 || text_base == 0) + return false; + + if(match->getID() != LLUUID::null && TextHelpers::iconCallbackCreationFunction) + { + bool segment_created = TextHelpers::iconCallbackCreationFunction(match,text_base); + if(segment_created) + return true; + } + + // output an optional icon before the Url + if (!match->getIcon().empty() ) + { + LLUIImagePtr image = LLUI::getUIImage(match->getIcon()); + if (image) + { + LLStyle::Params icon; + icon.image = image; + // Text will be replaced during rendering with the icon, + // but string cannot be empty or the segment won't be + // added (or drawn). + text_base->appendImageSegment(icon); + + return true; + } + } + + return false; +} + // EOF -- cgit v1.2.3