diff options
author | Vadim Savchuk <vsavchuk@productengine.com> | 2009-12-04 18:09:29 +0200 |
---|---|---|
committer | Vadim Savchuk <vsavchuk@productengine.com> | 2009-12-04 18:09:29 +0200 |
commit | 6d8fd3114349b9efa14d39fab5c77b886b6eda1b (patch) | |
tree | 183549b1a97ec96f74eae315e809dfa43b41b8e1 /indra | |
parent | 63096e40de74b6540a87773cc0449a8a12bafb5b (diff) |
Implemented normal priority task EXT-2311 (Filter in side panels should highlight results).
Added missing highlighting to people/group lists and teleport history.
Btw, the "none" group list entry now gets hidden when user types a filter.
--HG--
branch : product-engine
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/CMakeLists.txt | 2 | ||||
-rw-r--r-- | indra/newview/llavatarlist.cpp | 11 | ||||
-rw-r--r-- | indra/newview/llavatarlistitem.cpp | 29 | ||||
-rw-r--r-- | indra/newview/llavatarlistitem.h | 5 | ||||
-rw-r--r-- | indra/newview/llgrouplist.cpp | 26 | ||||
-rw-r--r-- | indra/newview/llgrouplist.h | 6 | ||||
-rw-r--r-- | indra/newview/llpanelteleporthistory.cpp | 18 |
7 files changed, 63 insertions, 34 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index dd3fc10fa2..61aecdbfb6 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -410,6 +410,7 @@ set(viewer_SOURCE_FILES lltexturestats.cpp lltexturestatsuploader.cpp lltextureview.cpp + lltextutil.cpp lltoast.cpp lltoastalertpanel.cpp lltoastgroupnotifypanel.cpp @@ -911,6 +912,7 @@ set(viewer_HEADER_FILES lltexturestats.h lltexturestatsuploader.h lltextureview.h + lltextutil.h lltoast.h lltoastalertpanel.h lltoastgroupnotifypanel.h diff --git a/indra/newview/llavatarlist.cpp b/indra/newview/llavatarlist.cpp index 202fbdebd4..3bd4f898c8 100644 --- a/indra/newview/llavatarlist.cpp +++ b/indra/newview/llavatarlist.cpp @@ -262,9 +262,18 @@ void LLAvatarList::refresh() bool dirty = add_limit_exceeded || (have_filter && !have_names); setDirty(dirty); - // Refreshed all items, lets send refresh_complete signal. + // Refreshed all items. if(!dirty) { + // Highlight items matching the filter. + std::vector<LLPanel*> items; + getItems(items); + for( std::vector<LLPanel*>::const_iterator it = items.begin(); it != items.end(); it++) + { + static_cast<LLAvatarListItem*>(*it)->setHighlight(mNameFilter); + } + + // Send refresh_complete signal. std::vector<LLSD> cur_values; getValues(cur_values); mRefreshCompleteSignal(this, LLSD((S32)cur_values.size())); diff --git a/indra/newview/llavatarlistitem.cpp b/indra/newview/llavatarlistitem.cpp index 59ed391c06..072eebdf2d 100644 --- a/indra/newview/llavatarlistitem.cpp +++ b/indra/newview/llavatarlistitem.cpp @@ -40,6 +40,7 @@ #include "llagent.h" #include "lloutputmonitorctrl.h" #include "llavatariconctrl.h" +#include "lltextutil.h" #include "llbutton.h" LLAvatarListItem::LLAvatarListItem(bool not_from_ui_factory/* = true*/) @@ -155,13 +156,8 @@ void LLAvatarListItem::setOnline(bool online) mOnlineStatus = (EOnlineStatus) online; // Change avatar name font style depending on the new online status. - LLStyle::Params style_params; - style_params.color = online ? LLColor4::white : LLColor4::grey; - - // Rebuild the text to change its style. - std::string text = mAvatarName->getText(); - mAvatarName->setText(LLStringUtil::null); - mAvatarName->appendText(text, false, style_params); + mAvatarNameStyle.color = online ? LLColor4::white : LLColor4::grey; + setNameInternal(mAvatarName->getText(), mHighlihtSubstring); // Make the icon fade if the avatar goes offline. mAvatarIcon->setColor(online ? LLColor4::white : LLColor4::smoke); @@ -169,8 +165,12 @@ void LLAvatarListItem::setOnline(bool online) void LLAvatarListItem::setName(const std::string& name) { - mAvatarName->setValue(name); - mAvatarName->setToolTip(name); + setNameInternal(name, mHighlihtSubstring); +} + +void LLAvatarListItem::setHighlight(const std::string& highlight) +{ + setNameInternal(mAvatarName->getText(), mHighlihtSubstring = highlight); } void LLAvatarListItem::setAvatarId(const LLUUID& id, bool ignore_status_changes) @@ -310,11 +310,18 @@ const std::string LLAvatarListItem::getAvatarName() const return mAvatarName->getValue(); } +//== PRIVATE SECITON ========================================================== + +void LLAvatarListItem::setNameInternal(const std::string& name, const std::string& highlight) +{ + LLTextUtil::textboxSetHighlightedVal(mAvatarName, mAvatarNameStyle, name, highlight); + mAvatarName->setToolTip(name); +} + void LLAvatarListItem::onNameCache(const std::string& first_name, const std::string& last_name) { std::string name = first_name + " " + last_name; - mAvatarName->setValue(name); - mAvatarName->setToolTip(name); + setName(name); } void LLAvatarListItem::reshapeAvatarName() diff --git a/indra/newview/llavatarlistitem.h b/indra/newview/llavatarlistitem.h index a7b080098d..cb015a5461 100644 --- a/indra/newview/llavatarlistitem.h +++ b/indra/newview/llavatarlistitem.h @@ -37,6 +37,7 @@ #include "lloutputmonitorctrl.h" #include "llbutton.h" #include "lltextbox.h" +#include "llstyle.h" #include "llcallingcard.h" // for LLFriendObserver @@ -71,6 +72,7 @@ public: void setOnline(bool online); void setName(const std::string& name); + void setHighlight(const std::string& highlight); // XXX ugly name void setAvatarId(const LLUUID& id, bool ignore_status_changes = false); void setLastInteractionTime(U32 secs_since); //Show/hide profile/info btn, translating speaker indicator and avatar name coordinates accordingly @@ -112,6 +114,7 @@ private: E_UNKNOWN, } EOnlineStatus; + void setNameInternal(const std::string& name, const std::string& highlight); void onNameCache(const std::string& first_name, const std::string& last_name); std::string formatSeconds(U32 secs); @@ -119,12 +122,14 @@ private: LLAvatarIconCtrl* mAvatarIcon; LLTextBox* mAvatarName; LLTextBox* mLastInteractionTime; + LLStyle::Params mAvatarNameStyle; LLButton* mInfoBtn; LLButton* mProfileBtn; ContextMenu* mContextMenu; LLUUID mAvatarId; + std::string mHighlihtSubstring; // substring to highlight EOnlineStatus mOnlineStatus; //Flag indicating that info/profile button shouldn't be shown at all. //Speaker indicator and avatar name coords are translated accordingly diff --git a/indra/newview/llgrouplist.cpp b/indra/newview/llgrouplist.cpp index 97cf139f1d..80b706a215 100644 --- a/indra/newview/llgrouplist.cpp +++ b/indra/newview/llgrouplist.cpp @@ -44,6 +44,7 @@ #include "llagent.h" #include "llgroupactions.h" #include "llfloaterreg.h" +#include "lltextutil.h" #include "llviewercontrol.h" // for gSavedSettings static LLDefaultChildRegistry::Register<LLGroupList> r("group_list"); @@ -133,17 +134,17 @@ void LLGroupList::refresh() const LLGroupData& group_data = gAgent.mGroups.get(i); if (have_filter && !findInsensitive(group_data.mName, mNameFilter)) continue; - addNewItem(id, group_data.mName, group_data.mInsigniaID, highlight_id == id, ADD_BOTTOM); + addNewItem(id, group_data.mName, group_data.mInsigniaID, ADD_BOTTOM); } // Sort the list. sort(); - // add "none" to list at top + // Add "none" to list at top if filter not set (what's the point of filtering "none"?). + if (!have_filter) { std::string loc_none = LLTrans::getString("GroupsNone"); - if (have_filter || findInsensitive(loc_none, mNameFilter)) - addNewItem(LLUUID::null, loc_none, LLUUID::null, highlight_id.isNull(), ADD_TOP); + addNewItem(LLUUID::null, loc_none, LLUUID::null, ADD_TOP); } selectItemByUUID(highlight_id); @@ -171,12 +172,12 @@ void LLGroupList::toggleIcons() // PRIVATE Section ////////////////////////////////////////////////////////////////////////// -void LLGroupList::addNewItem(const LLUUID& id, const std::string& name, const LLUUID& icon_id, BOOL is_bold, EAddPosition pos) +void LLGroupList::addNewItem(const LLUUID& id, const std::string& name, const LLUUID& icon_id, EAddPosition pos) { LLGroupListItem* item = new LLGroupListItem(); - item->setName(name); item->setGroupID(id); + item->setName(name, mNameFilter); item->setGroupIconID(icon_id); // item->setContextMenu(mContextMenu); @@ -267,10 +268,10 @@ void LLGroupListItem::onMouseLeave(S32 x, S32 y, MASK mask) LLPanel::onMouseLeave(x, y, mask); } -void LLGroupListItem::setName(const std::string& name) +void LLGroupListItem::setName(const std::string& name, const std::string& highlight) { mGroupName = name; - mGroupNameBox->setValue(name); + LLTextUtil::textboxSetHighlightedVal(mGroupNameBox, mGroupNameStyle, name, highlight); mGroupNameBox->setToolTip(name); } @@ -308,6 +309,8 @@ void LLGroupListItem::setGroupIconVisible(bool visible) ////////////////////////////////////////////////////////////////////////// void LLGroupListItem::setActive(bool active) { + // *BUG: setName() overrides the style params. + // Active group should be bold. LLFontDescriptor new_desc(mGroupNameBox->getDefaultFont()->getFontDesc()); @@ -316,15 +319,12 @@ void LLGroupListItem::setActive(bool active) // is predefined as bold (SansSerifSmallBold, for example) new_desc.setStyle(active ? LLFontGL::BOLD : LLFontGL::NORMAL); LLFontGL* new_font = LLFontGL::getFont(new_desc); - LLStyle::Params style_params; - style_params.font = new_font; + mGroupNameStyle.font = new_font; // *NOTE: You cannot set the style on a text box anymore, you must // rebuild the text. This will cause problems if the text contains // hyperlinks, as their styles will be wrong. - std::string text = mGroupNameBox->getText(); - mGroupNameBox->setText(LLStringUtil::null); - mGroupNameBox->appendText(text, false, style_params); + mGroupNameBox->setText(mGroupName, mGroupNameStyle); } void LLGroupListItem::onInfoBtnClick() diff --git a/indra/newview/llgrouplist.h b/indra/newview/llgrouplist.h index 8dbc13997c..41b4d01711 100644 --- a/indra/newview/llgrouplist.h +++ b/indra/newview/llgrouplist.h @@ -37,6 +37,7 @@ #include "llflatlistview.h" #include "llpanel.h" #include "llpointer.h" +#include "llstyle.h" /** * Auto-updating list of agent groups. @@ -66,7 +67,7 @@ public: private: void setDirty(bool val = true) { mDirty = val; } void refresh(); - void addNewItem(const LLUUID& id, const std::string& name, const LLUUID& icon_id, BOOL is_bold, EAddPosition pos = ADD_BOTTOM); + void addNewItem(const LLUUID& id, const std::string& name, const LLUUID& icon_id, EAddPosition pos = ADD_BOTTOM); bool handleEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata); // called on agent group list changes bool mShowIcons; @@ -90,7 +91,7 @@ public: const LLUUID& getGroupID() const { return mGroupID; } const std::string& getGroupName() const { return mGroupName; } - void setName(const std::string& name); + void setName(const std::string& name, const std::string& highlight = LLStringUtil::null); void setGroupID(const LLUUID& group_id); void setGroupIconID(const LLUUID& group_icon_id); void setGroupIconVisible(bool visible); @@ -106,6 +107,7 @@ private: LLButton* mInfoBtn; std::string mGroupName; + LLStyle::Params mGroupNameStyle; static S32 sIconWidth; // icon width + padding }; diff --git a/indra/newview/llpanelteleporthistory.cpp b/indra/newview/llpanelteleporthistory.cpp index 523487fa14..b3e8588efc 100644 --- a/indra/newview/llpanelteleporthistory.cpp +++ b/indra/newview/llpanelteleporthistory.cpp @@ -38,6 +38,8 @@ #include "llsidetray.h" #include "llworldmap.h" #include "llteleporthistorystorage.h" +#include "lltextutil.h" + #include "llaccordionctrl.h" #include "llaccordionctrltab.h" #include "llflatlistview.h" @@ -57,7 +59,7 @@ static const std::string COLLAPSED_BY_USER = "collapsed_by_user"; class LLTeleportHistoryFlatItem : public LLPanel { public: - LLTeleportHistoryFlatItem(S32 index, LLTeleportHistoryPanel::ContextMenu *context_menu, const std::string ®ion_name); + LLTeleportHistoryFlatItem(S32 index, LLTeleportHistoryPanel::ContextMenu *context_menu, const std::string ®ion_name, const std::string &hl); virtual ~LLTeleportHistoryFlatItem() {}; virtual BOOL postBuild(); @@ -82,13 +84,15 @@ private: S32 mIndex; std::string mRegionName; + std::string mHighlight; }; -LLTeleportHistoryFlatItem::LLTeleportHistoryFlatItem(S32 index, LLTeleportHistoryPanel::ContextMenu *context_menu, const std::string ®ion_name) +LLTeleportHistoryFlatItem::LLTeleportHistoryFlatItem(S32 index, LLTeleportHistoryPanel::ContextMenu *context_menu, const std::string ®ion_name, const std::string &hl) : LLPanel(), mIndex(index), mContextMenu(context_menu), - mRegionName(region_name) + mRegionName(region_name), + mHighlight(hl) { LLUICtrlFactory::getInstance()->buildPanel(this, "panel_teleport_history_item.xml"); } @@ -96,8 +100,7 @@ LLTeleportHistoryFlatItem::LLTeleportHistoryFlatItem(S32 index, LLTeleportHistor //virtual BOOL LLTeleportHistoryFlatItem::postBuild() { - LLTextBox *region = getChild<LLTextBox>("region"); - region->setValue(mRegionName); + LLTextUtil::textboxSetHighlightedVal(getChild<LLTextBox>("region"), LLStyle::Params(), mRegionName, mHighlight); mProfileBtn = getChild<LLButton>("profile_btn"); @@ -521,7 +524,7 @@ void LLTeleportHistoryPanel::refresh() if (curr_flat_view) { - LLTeleportHistoryFlatItem* item = new LLTeleportHistoryFlatItem(mCurrentItem, &mContextMenu, items[mCurrentItem].mTitle); + LLTeleportHistoryFlatItem* item = new LLTeleportHistoryFlatItem(mCurrentItem, &mContextMenu, items[mCurrentItem].mTitle, mFilterSubString); curr_flat_view->addItem(item); if (mLastSelectedItemIndex == mCurrentItem) @@ -568,7 +571,8 @@ void LLTeleportHistoryPanel::replaceItem(S32 removed_index) const LLTeleportHistoryStorage::slurl_list_t& history_items = mTeleportHistory->getItems(); LLTeleportHistoryFlatItem* item = new LLTeleportHistoryFlatItem(history_items.size(), // index will be decremented inside loop below &mContextMenu, - history_items[history_items.size() - 1].mTitle); // Most recent item, it was + history_items[history_items.size() - 1].mTitle, // Most recent item, it was + mFilterSubString); // added instead of removed fv->addItem(item, LLUUID::null, ADD_TOP); |