From 4285cc271eacaca31a1d5d76c8e88debf00235c2 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 30 Jul 2012 15:15:42 -0700 Subject: CHUI-217 FIX Items are not visible in Merchant Outbox cleaned up a lot custom code for folder view item creation in inbox and outbox proper initialization of views from inventory panel starting folder --- indra/llui/llfolderviewitem.cpp | 13 +++++++++---- indra/llui/llfolderviewitem.h | 10 ++++++---- indra/llui/lluictrlfactory.cpp | 5 ----- indra/llui/lluictrlfactory.h | 5 +---- 4 files changed, 16 insertions(+), 17 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index b9b6ea7444..1d8dfbbafa 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -89,7 +89,8 @@ LLFolderViewItem::Params::Params() selection_image("selection_image"), item_height("item_height"), item_top_pad("item_top_pad"), - creation_date() + creation_date(), + allow_open("allow_open", true) {} // Default constructor @@ -112,7 +113,8 @@ LLFolderViewItem::LLFolderViewItem(const LLFolderViewItem::Params& p) mLabel(p.name), mRoot(p.root), mViewModelItem(p.listener), - mIsMouseOverTitle(false) + mIsMouseOverTitle(false), + mAllowOpen(p.allow_open) { if (mViewModelItem) { @@ -404,7 +406,10 @@ void LLFolderViewItem::buildContextMenu(LLMenuGL& menu, U32 flags) void LLFolderViewItem::openItem( void ) { - getViewModelItem()->openItem(); + if (mAllowOpen) + { + getViewModelItem()->openItem(); + } } void LLFolderViewItem::rename(const std::string& new_name) @@ -517,7 +522,7 @@ BOOL LLFolderViewItem::handleHover( S32 x, S32 y, MASK mask ) BOOL LLFolderViewItem::handleDoubleClick( S32 x, S32 y, MASK mask ) { - getViewModelItem()->openItem(); + openItem(); return TRUE; } diff --git a/indra/llui/llfolderviewitem.h b/indra/llui/llfolderviewitem.h index 50d3e0580e..df007dd15d 100644 --- a/indra/llui/llfolderviewitem.h +++ b/indra/llui/llfolderviewitem.h @@ -61,6 +61,7 @@ public: item_top_pad; Optional creation_date; + Optional allow_open; Params(); }; @@ -92,14 +93,11 @@ protected: bool mLabelWidthDirty; LLFolderViewFolder* mParentFolder; LLFolderViewModelItem* mViewModelItem; - BOOL mIsCurSelection; - BOOL mSelectPending; LLFontGL::StyleFlags mLabelStyle; std::string mLabelSuffix; LLUIImagePtr mIcon; LLUIImagePtr mIconOpen; LLUIImagePtr mIconOverlay; - BOOL mHasVisibleChildren; S32 mIndentation; S32 mItemHeight; S32 mDragStartX, @@ -109,8 +107,12 @@ protected: //std::string::size_type mStringMatchOffset; F32 mControlLabelRotation; LLFolderView* mRoot; - BOOL mDragAndDropTarget; + bool mHasVisibleChildren; + bool mIsCurSelection; + bool mDragAndDropTarget; bool mIsMouseOverTitle; + bool mAllowOpen; + bool mSelectPending; // this is an internal method used for adding items to folders. A // no-op at this level, but reimplemented in derived classes. diff --git a/indra/llui/lluictrlfactory.cpp b/indra/llui/lluictrlfactory.cpp index f64f33bc5e..91a6b3259c 100644 --- a/indra/llui/lluictrlfactory.cpp +++ b/indra/llui/lluictrlfactory.cpp @@ -304,9 +304,4 @@ void LLUICtrlFactory::registerWidget(const std::type_info* widget_type, const st //LLDefaultParamBlockRegistry::instance().defaultRegistrar().add(widget_type, &get_empty_param_block); } -//static -const std::string* LLUICtrlFactory::getWidgetName(const std::type_info* widget_type) -{ - return LLWidgetNameRegistry::instance().getValue(widget_type); -} diff --git a/indra/llui/lluictrlfactory.h b/indra/llui/lluictrlfactory.h index b441cb0c9d..9f18be2371 100644 --- a/indra/llui/lluictrlfactory.h +++ b/indra/llui/lluictrlfactory.h @@ -105,7 +105,7 @@ private: ParamDefaults() { // look up template file for this param block... - const std::string* param_block_tag = getWidgetName(&typeid(PARAM_BLOCK)); + const std::string* param_block_tag = LLWidgetNameRegistry::instance().getValue(&typeid(PARAM_BLOCK)); if (param_block_tag) { // ...and if it exists, back fill values using the most specific template first PARAM_BLOCK params; @@ -139,7 +139,6 @@ public: template static const typename T::Params& getDefaultParams() { - //#pragma message("Generating ParamDefaults") return ParamDefaults::instance().get(); } @@ -303,8 +302,6 @@ private: } - static const std::string* getWidgetName(const std::type_info* widget_type); - // this exists to get around dependency on llview static void setCtrlParent(LLView* view, LLView* parent, S32 tab_group); -- cgit v1.2.3 From f29bdc27b3038a19317095ef914bd560f3199d28 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 30 Jul 2012 15:16:01 -0700 Subject: moved method from places inventory up into common llfolderview --- indra/llui/llfolderview.h | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llui') diff --git a/indra/llui/llfolderview.h b/indra/llui/llfolderview.h index ba37a11bbe..5ebd8f73ac 100644 --- a/indra/llui/llfolderview.h +++ b/indra/llui/llfolderview.h @@ -217,6 +217,7 @@ public: BOOL getShowSingleSelection() { return mShowSingleSelection; } F32 getSelectionFadeElapsedTime() { return mMultiSelectionFadeTimer.getElapsedTimeF32(); } bool getUseEllipses() { return mUseEllipses; } + S32 getSelectedCount() { return (S32)mSelectedItems.size(); } void update(); // needs to be called periodically (e.g. once per frame) -- cgit v1.2.3 From e9a484f98d0376a5651d4f6eb5a692db4f77c800 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 31 Jul 2012 23:46:13 -0700 Subject: CHUI-254 : Fix Inventory filter and item draw() to highlight matching substrings in inventory --- indra/llui/llfolderviewitem.cpp | 47 +++++++++++++++++++---------------------- indra/llui/llfolderviewitem.h | 2 -- indra/llui/llfolderviewmodel.h | 15 ++++++++++++- 3 files changed, 36 insertions(+), 28 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index 0f486d06c9..368e3caea8 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -106,8 +106,6 @@ LLFolderViewItem::LLFolderViewItem(const LLFolderViewItem::Params& p) mHasVisibleChildren(FALSE), mIndentation(0), mItemHeight(p.item_height), - //TODO RN: create interface for string highlighting - //mStringMatchOffset(std::string::npos), mControlLabelRotation(0.f), mDragAndDropTarget(FALSE), mLabel(p.name), @@ -778,29 +776,28 @@ void LLFolderViewItem::draw() //--------------------------------------------------------------------------------// // Highlight string match // - //TODO RN: expose interface for highlighting - //if (mStringMatchOffset != std::string::npos) - //{ - // // don't draw backgrounds for zero-length strings - // S32 filter_string_length = getRoot()->getFilterSubString().size(); - // if (filter_string_length > 0) - // { - // std::string combined_string = mLabel + mLabelSuffix; - // S32 left = llround(text_left) + font->getWidth(combined_string, 0, mStringMatchOffset) - 1; - // S32 right = left + font->getWidth(combined_string, mStringMatchOffset, filter_string_length) + 2; - // S32 bottom = llfloor(getRect().getHeight() - font->getLineHeight() - 3 - TOP_PAD); - // S32 top = getRect().getHeight() - TOP_PAD; - // - // LLUIImage* box_image = default_params.selection_image; - // LLRect box_rect(left, top, right, bottom); - // box_image->draw(box_rect, sFilterBGColor); - // F32 match_string_left = text_left + font->getWidthF32(combined_string, 0, mStringMatchOffset); - // F32 yy = (F32)getRect().getHeight() - font->getLineHeight() - (F32)TEXT_PAD - (F32)TOP_PAD; - // font->renderUTF8( combined_string, mStringMatchOffset, match_string_left, yy, - // sFilterTextColor, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, - // filter_string_length, S32_MAX, &right_x, FALSE ); - // } - //} + if (mViewModelItem->hasFilterStringMatch()) + { + // don't draw backgrounds for zero-length strings + std::string::size_type filter_string_length = mViewModelItem->getFilterStringSize(); + if (filter_string_length > 0) + { + std::string combined_string = mLabel + mLabelSuffix; + S32 left = llround(text_left) + font->getWidth(combined_string, 0, mViewModelItem->getFilterStringOffset()) - 1; + S32 right = left + font->getWidth(combined_string, mViewModelItem->getFilterStringOffset(), filter_string_length) + 2; + S32 bottom = llfloor(getRect().getHeight() - font->getLineHeight() - 3 - TOP_PAD); + S32 top = getRect().getHeight() - TOP_PAD; + + LLUIImage* box_image = default_params.selection_image; + LLRect box_rect(left, top, right, bottom); + box_image->draw(box_rect, sFilterBGColor); + F32 match_string_left = text_left + font->getWidthF32(combined_string, 0, mViewModelItem->getFilterStringOffset()); + F32 yy = (F32)getRect().getHeight() - font->getLineHeight() - (F32)TEXT_PAD - (F32)TOP_PAD; + font->renderUTF8( combined_string, mViewModelItem->getFilterStringOffset(), match_string_left, yy, + sFilterTextColor, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, + filter_string_length, S32_MAX, &right_x, FALSE ); + } + } } const LLFolderViewModelInterface* LLFolderViewItem::getFolderViewModel( void ) const diff --git a/indra/llui/llfolderviewitem.h b/indra/llui/llfolderviewitem.h index df007dd15d..e323237b13 100644 --- a/indra/llui/llfolderviewitem.h +++ b/indra/llui/llfolderviewitem.h @@ -103,8 +103,6 @@ protected: S32 mDragStartX, mDragStartY; - //TODO RN: create interface for string highlighting - //std::string::size_type mStringMatchOffset; F32 mControlLabelRotation; LLFolderView* mRoot; bool mHasVisibleChildren; diff --git a/indra/llui/llfolderviewmodel.h b/indra/llui/llfolderviewmodel.h index acdec53602..f655e6e4d6 100644 --- a/indra/llui/llfolderviewmodel.h +++ b/indra/llui/llfolderviewmodel.h @@ -73,6 +73,8 @@ public: virtual bool showAllResults() const = 0; + virtual std::string::size_type getStringMatchOffset(LLFolderViewModelItem* item) const = 0; + virtual std::string::size_type getFilterStringSize() const = 0; // +-------------------------------------------------------------------+ // + Status // +-------------------------------------------------------------------+ @@ -155,8 +157,11 @@ public: virtual void filter( LLFolderViewFilter& filter) = 0; virtual bool passedFilter(S32 filter_generation = -1) = 0; virtual bool descendantsPassedFilter(S32 filter_generation = -1) = 0; - virtual void setPassedFilter(bool passed, bool passed_folder, S32 filter_generation) = 0; + virtual void setPassedFilter(bool passed, bool passed_folder, S32 filter_generation, std::string::size_type string_offset = std::string::npos, std::string::size_type string_size = 0) = 0; virtual void dirtyFilter() = 0; + virtual bool hasFilterStringMatch() = 0; + virtual std::string::size_type getFilterStringOffset() = 0; + virtual std::string::size_type getFilterStringSize() = 0; virtual S32 getLastFilterGeneration() const = 0; @@ -193,6 +198,8 @@ public: mPassedFilter(true), mPassedFolderFilter(true), mPrevPassedAllFilters(false), + mStringMatchOffsetFilter(std::string::npos), + mStringFilterSize(0), mFolderViewItem(NULL), mLastFilterGeneration(-1), mMostFilteredDescendantGeneration(-1), @@ -216,6 +223,10 @@ public: mParent->dirtyFilter(); } } + bool hasFilterStringMatch() { return mStringMatchOffsetFilter != std::string::npos; } + std::string::size_type getFilterStringOffset() { return mStringMatchOffsetFilter; } + std::string::size_type getFilterStringSize() { return mStringFilterSize; } + virtual void addChild(LLFolderViewModelItem* child) { mChildren.push_back(child); @@ -234,6 +245,8 @@ protected: bool mPassedFilter; bool mPassedFolderFilter; bool mPrevPassedAllFilters; + std::string::size_type mStringMatchOffsetFilter; + std::string::size_type mStringFilterSize; S32 mLastFilterGeneration; S32 mMostFilteredDescendantGeneration; -- cgit v1.2.3 From a204059d2e69fb33cb1a3c8d2fbed35d3967297c Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 1 Aug 2012 01:14:27 -0700 Subject: CHUI-267 FIX Full inventory listing not always shown for test account changed LLFolderViewModelInterface::getFilter() to return a reference, since it is never NULL removed sort order from filter, which was causing unneeded filtering --- indra/llui/llfolderview.cpp | 12 +++--- indra/llui/llfolderview.h | 2 +- indra/llui/llfolderviewitem.cpp | 68 ++++++++++++--------------------- indra/llui/llfolderviewitem.h | 20 ++++++---- indra/llui/llfolderviewmodel.cpp | 8 ++-- indra/llui/llfolderviewmodel.h | 82 +++++++++++++++++++++++++++++----------- 6 files changed, 107 insertions(+), 85 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llfolderview.cpp b/indra/llui/llfolderview.cpp index e09026fc33..d714d4623d 100644 --- a/indra/llui/llfolderview.cpp +++ b/indra/llui/llfolderview.cpp @@ -274,7 +274,7 @@ BOOL LLFolderView::canFocusChildren() const return FALSE; } -BOOL LLFolderView::addFolder( LLFolderViewFolder* folder) +void LLFolderView::addFolder( LLFolderViewFolder* folder) { LLFolderViewFolder::addFolder(folder); @@ -288,8 +288,6 @@ BOOL LLFolderView::addFolder( LLFolderViewFolder* folder) //{ // mFolders.insert(mFolders.begin(), folder); //} - - return TRUE; } void LLFolderView::closeAllFolders() @@ -1769,14 +1767,14 @@ void LLFolderView::update() // until that inventory is loaded up. LLFastTimer t2(FTM_INVENTORY); - if (getFolderViewModel()->getFilter()->isModified() && getFolderViewModel()->getFilter()->isNotDefault()) + if (getFolderViewModel()->getFilter().isModified() && getFolderViewModel()->getFilter().isNotDefault()) { mNeedsAutoSelect = TRUE; } - getFolderViewModel()->getFilter()->clearModified(); + getFolderViewModel()->getFilter().clearModified(); // filter to determine visibility before arranging - filter(*(getFolderViewModel()->getFilter())); + filter(getFolderViewModel()->getFilter()); // automatically show matching items, and select first one if we had a selection if (mNeedsAutoSelect) @@ -1794,7 +1792,7 @@ void LLFolderView::update() // Open filtered folders for folder views with mAutoSelectOverride=TRUE. // Used by LLPlacesFolderView. - if (getFolderViewModel()->getFilter()->showAllResults()) + if (getFolderViewModel()->getFilter().showAllResults()) { // these are named variables to get around gcc not binding non-const references to rvalues // and functor application is inherently non-const to allow for stateful functors diff --git a/indra/llui/llfolderview.h b/indra/llui/llfolderview.h index 5ebd8f73ac..05beff9bd8 100644 --- a/indra/llui/llfolderview.h +++ b/indra/llui/llfolderview.h @@ -121,7 +121,7 @@ public: void closeAllFolders(); void openTopLevelFolders(); - virtual BOOL addFolder( LLFolderViewFolder* folder); + virtual void addFolder( LLFolderViewFolder* folder); // Find width and height of this object and its children. Also // makes sure that this view and its children are the right size. diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index 0f486d06c9..167c8123a1 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -221,11 +221,11 @@ void LLFolderViewItem::refresh() mIconOpen = vmi.getIconOpen(); mIconOverlay = vmi.getIconOverlay(); - if (mRoot->useLabelSuffix()) - { + if (mRoot->useLabelSuffix()) + { mLabelStyle = vmi.getLabelStyle(); mLabelSuffix = vmi.getLabelSuffix(); -} + } //TODO RN: make sure this logic still fires //std::string searchable_label(mLabel); @@ -255,7 +255,7 @@ void LLFolderViewItem::arrangeAndSet(BOOL set_selection, LLFolderView* root = getRoot(); if (getParentFolder()) { - getParentFolder()->requestArrange(); + getParentFolder()->requestArrange(); } if(set_selection) { @@ -275,9 +275,9 @@ std::set LLFolderViewItem::getSelectionList() const } // addToFolder() returns TRUE if it succeeds. FALSE otherwise -BOOL LLFolderViewItem::addToFolder(LLFolderViewFolder* folder) +void LLFolderViewItem::addToFolder(LLFolderViewFolder* folder) { - return folder->addItem(this); + folder->addItem(this); } @@ -418,12 +418,12 @@ void LLFolderViewItem::rename(const std::string& new_name) { getViewModelItem()->renameItem(new_name); - if(mParentFolder) - { - mParentFolder->requestSort(); - } - } + //if(mParentFolder) + //{ + // mParentFolder->requestSort(); + //} } +} const std::string& LLFolderViewItem::getName( void ) const { @@ -839,9 +839,9 @@ LLFolderViewFolder::~LLFolderViewFolder( void ) } // addToFolder() returns TRUE if it succeeds. FALSE otherwise -BOOL LLFolderViewFolder::addToFolder(LLFolderViewFolder* folder) +void LLFolderViewFolder::addToFolder(LLFolderViewFolder* folder) { - return folder->addFolder(this); + folder->addFolder(this); } static LLFastTimer::DeclareTimer FTM_ARRANGE("Arrange"); @@ -1008,11 +1008,6 @@ BOOL LLFolderViewFolder::needsArrange() return mLastArrangeGeneration < getRoot()->getArrangeGeneration(); } -void LLFolderViewFolder::requestSort() -{ - getViewModelItem()->requestSort(); -} - //TODO RN: get height resetting working //void LLFolderViewFolder::setPassedFilter(BOOL passed, BOOL passed_folder, S32 filter_generation) //{ @@ -1417,7 +1412,6 @@ void LLFolderViewFolder::extractItem( LLFolderViewItem* item ) } //item has been removed, need to update filter getViewModelItem()->removeChild(item->getViewModelItem()); - getViewModelItem()->dirtyFilter(); //because an item is going away regardless of filter status, force rearrange requestArrange(); removeChild(item); @@ -1483,7 +1477,7 @@ BOOL LLFolderViewFolder::isRemovable() } // this is an internal method used for adding items to folders. -BOOL LLFolderViewFolder::addItem(LLFolderViewItem* item) +void LLFolderViewFolder::addItem(LLFolderViewItem* item) { if (item->getParentFolder()) { @@ -1496,7 +1490,6 @@ BOOL LLFolderViewFolder::addItem(LLFolderViewItem* item) item->setRect(LLRect(0, 0, getRect().getWidth(), 0)); item->setVisible(FALSE); - addChild(item); // TODO RN - port creation date management to new code location #if 0 @@ -1504,10 +1497,7 @@ BOOL LLFolderViewFolder::addItem(LLFolderViewItem* item) setCreationDate(llmax(mCreationDate, item->getCreationDate())); #endif - // Handle sorting - requestArrange(); - requestSort(); - + addChild(item); getViewModelItem()->addChild(item->getViewModelItem()); // TODO RN - port creation date management to new code location #if 0 @@ -1533,14 +1523,10 @@ BOOL LLFolderViewFolder::addItem(LLFolderViewItem* item) // parentp = parentp->getParentFolder(); //} - - item->getViewModelItem()->dirtyFilter(); - - return TRUE; } // this is an internal method used for adding items to folders. -BOOL LLFolderViewFolder::addFolder(LLFolderViewFolder* folder) +void LLFolderViewFolder::addFolder(LLFolderViewFolder* folder) { if (folder->mParentFolder) { @@ -1551,30 +1537,26 @@ BOOL LLFolderViewFolder::addFolder(LLFolderViewFolder* folder) folder->setOrigin(0, 0); folder->reshape(getRect().getWidth(), 0); folder->setVisible(FALSE); - addChild( folder ); // rearrange all descendants too, as our indentation level might have changed - folder->requestArrange(); - requestSort(); + //folder->requestArrange(); + //requestSort(); + addChild( folder ); getViewModelItem()->addChild(folder->getViewModelItem()); - //After addChild since addChild assigns parent to bubble up to when calling dirtyFilter - folder->getViewModelItem()->dirtyFilter(); - - return TRUE; } void LLFolderViewFolder::requestArrange() { //if ( mLastArrangeGeneration != -1) { - mLastArrangeGeneration = -1; - // flag all items up to root - if (mParentFolder) - { - mParentFolder->requestArrange(); - } + mLastArrangeGeneration = -1; + // flag all items up to root + if (mParentFolder) + { + mParentFolder->requestArrange(); } } +} void LLFolderViewFolder::toggleOpen() { diff --git a/indra/llui/llfolderviewitem.h b/indra/llui/llfolderviewitem.h index df007dd15d..baa12b38f3 100644 --- a/indra/llui/llfolderviewitem.h +++ b/indra/llui/llfolderviewitem.h @@ -116,8 +116,8 @@ protected: // this is an internal method used for adding items to folders. A // no-op at this level, but reimplemented in derived classes. - virtual BOOL addItem(LLFolderViewItem*) { return FALSE; } - virtual BOOL addFolder(LLFolderViewFolder*) { return FALSE; } + virtual void addItem(LLFolderViewItem*) { } + virtual void addFolder(LLFolderViewFolder*) { } static LLFontGL* getLabelFontForStyle(U8 style); @@ -131,7 +131,7 @@ public: virtual ~LLFolderViewItem( void ); // addToFolder() returns TRUE if it succeeds. FALSE otherwise - virtual BOOL addToFolder(LLFolderViewFolder* folder); + virtual void addToFolder(LLFolderViewFolder* folder); // Finds width and height of this object and it's children. Also // makes sure that this view and it's children are the right size. @@ -297,7 +297,7 @@ public: LLFolderViewItem* getPreviousFromChild( LLFolderViewItem*, BOOL include_children = TRUE ); // addToFolder() returns TRUE if it succeeds. FALSE otherwise - virtual BOOL addToFolder(LLFolderViewFolder* folder); + virtual void addToFolder(LLFolderViewFolder* folder); // Finds width and height of this object and it's children. Also // makes sure that this view and it's children are the right size. @@ -356,8 +356,6 @@ public: // Called when a child is refreshed. virtual void requestArrange(); - virtual void requestSort(); - // internal method which doesn't update the entire view. This // method was written because the list iterators destroy the state // of other iterations, thus, we can't arrange while iterating @@ -381,8 +379,6 @@ public: void applyFunctorToChildren(LLFolderViewFunctor& functor); virtual void openItem( void ); - virtual BOOL addItem(LLFolderViewItem* item); - virtual BOOL addFolder( LLFolderViewFolder* folder); // LLView functionality virtual BOOL handleHover(S32 x, S32 y, MASK mask); @@ -412,6 +408,14 @@ public: LLFolderViewFolder* getCommonAncestor(LLFolderViewItem* item_a, LLFolderViewItem* item_b, bool& reverse); void gatherChildRangeExclusive(LLFolderViewItem* start, LLFolderViewItem* end, bool reverse, std::vector& items); +protected: + friend void LLFolderViewItem::addToFolder(LLFolderViewFolder*); + // internal functions for tracking folders and items separately + // use addToFolder() virtual method to ensure folders are always added to mFolders + // and not mItems + void addItem(LLFolderViewItem* item); + void addFolder( LLFolderViewFolder* folder); + public: //WARNING: do not call directly...use the appropriate LLFolderViewModel-derived class instead template void sortFolders(const SORT_FUNC& func) { mFolders.sort(func); } diff --git a/indra/llui/llfolderviewmodel.cpp b/indra/llui/llfolderviewmodel.cpp index dc6e4d754b..6aa4a63edc 100644 --- a/indra/llui/llfolderviewmodel.cpp +++ b/indra/llui/llfolderviewmodel.cpp @@ -36,18 +36,18 @@ bool LLFolderViewModelCommon::needsSort(LLFolderViewModelItem* item) std::string LLFolderViewModelCommon::getStatusText() { - if (!contentsReady() || mFolderView->getViewModelItem()->getLastFilterGeneration() < getFilter()->getCurrentGeneration()) + if (!contentsReady() || mFolderView->getViewModelItem()->getLastFilterGeneration() < getFilter().getCurrentGeneration()) { return LLTrans::getString("Searching"); } else { - return getFilter()->getEmptyLookupMessage(); + return getFilter().getEmptyLookupMessage(); } } void LLFolderViewModelCommon::filter() { - getFilter()->setFilterCount(llclamp(LLUI::sSettingGroups["config"]->getS32("FilterItemsPerFrame"), 1, 5000)); - mFolderView->getViewModelItem()->filter(*getFilter()); + getFilter().setFilterCount(llclamp(LLUI::sSettingGroups["config"]->getS32("FilterItemsPerFrame"), 1, 5000)); + mFolderView->getViewModelItem()->filter(getFilter()); } diff --git a/indra/llui/llfolderviewmodel.h b/indra/llui/llfolderviewmodel.h index acdec53602..81de15923a 100644 --- a/indra/llui/llfolderviewmodel.h +++ b/indra/llui/llfolderviewmodel.h @@ -107,6 +107,24 @@ public: virtual S32 getFirstRequiredGeneration() const = 0; }; +class LLFolderViewModelInterface +{ +public: + virtual ~LLFolderViewModelInterface() {} + virtual void requestSortAll() = 0; + + virtual void sort(class LLFolderViewFolder*) = 0; + virtual void filter() = 0; + + virtual bool contentsReady() = 0; + virtual void setFolderView(LLFolderView* folder_view) = 0; + virtual LLFolderViewFilter& getFilter() = 0; + virtual const LLFolderViewFilter& getFilter() const = 0; + virtual std::string getStatusText() = 0; + + virtual bool startDrag(std::vector& items) = 0; +}; + // This is am abstract base class that users of the folderview classes // would use to bridge the folder view with the underlying data class LLFolderViewModelItem @@ -188,15 +206,15 @@ protected: class LLFolderViewModelItemCommon : public LLFolderViewModelItem { public: - LLFolderViewModelItemCommon() + LLFolderViewModelItemCommon(LLFolderViewModelInterface& root_view_model) : mSortVersion(-1), mPassedFilter(true), mPassedFolderFilter(true), - mPrevPassedAllFilters(false), mFolderViewItem(NULL), mLastFilterGeneration(-1), mMostFilteredDescendantGeneration(-1), - mParent(NULL) + mParent(NULL), + mRootViewModel(root_view_model) { std::for_each(mChildren.begin(), mChildren.end(), DeletePointer()); } @@ -220,20 +238,55 @@ public: { mChildren.push_back(child); child->setParent(this); + dirtyFilter(); + requestSort(); } virtual void removeChild(LLFolderViewModelItem* child) { mChildren.remove(child); child->setParent(NULL); + dirtyFilter(); + } + + void setPassedFilter(bool passed, bool passed_folder, S32 filter_generation) + { + mPassedFilter = passed; + mPassedFolderFilter = passed_folder; + mLastFilterGeneration = filter_generation; + } + + virtual bool potentiallyVisible() + { + return passedFilter() // we've passed the filter + || getLastFilterGeneration() < mRootViewModel.getFilter().getFirstSuccessGeneration() // or we don't know yet + || descendantsPassedFilter(); } + virtual bool passedFilter(S32 filter_generation = -1) + { + if (filter_generation < 0) + filter_generation = mRootViewModel.getFilter().getFirstSuccessGeneration(); + + bool passed_folder_filter = mPassedFolderFilter && mLastFilterGeneration >= filter_generation; + bool passed_filter = mPassedFilter && mLastFilterGeneration >= filter_generation; + return passed_folder_filter + && (descendantsPassedFilter(filter_generation) + || passed_filter); + } + + virtual bool descendantsPassedFilter(S32 filter_generation = -1) + { + if (filter_generation < 0) filter_generation = mRootViewModel.getFilter().getFirstSuccessGeneration(); + return mMostFilteredDescendantGeneration >= filter_generation; + } + + protected: virtual void setParent(LLFolderViewModelItem* parent) { mParent = parent; } S32 mSortVersion; bool mPassedFilter; bool mPassedFolderFilter; - bool mPrevPassedAllFilters; S32 mLastFilterGeneration; S32 mMostFilteredDescendantGeneration; @@ -242,28 +295,13 @@ protected: typedef std::list child_list_t; child_list_t mChildren; LLFolderViewModelItem* mParent; + LLFolderViewModelInterface& mRootViewModel; void setFolderViewItem(LLFolderViewItem* folder_view_item) { mFolderViewItem = folder_view_item;} LLFolderViewItem* mFolderViewItem; }; -class LLFolderViewModelInterface -{ -public: - virtual ~LLFolderViewModelInterface() {} - virtual void requestSortAll() = 0; - - virtual void sort(class LLFolderViewFolder*) = 0; - virtual void filter() = 0; - - virtual bool contentsReady() = 0; - virtual void setFolderView(LLFolderView* folder_view) = 0; - virtual LLFolderViewFilter* getFilter() = 0; - virtual const LLFolderViewFilter* getFilter() const = 0; - virtual std::string getStatusText() = 0; - virtual bool startDrag(std::vector& items) = 0; -}; class LLFolderViewModelCommon : public LLFolderViewModelInterface { @@ -307,8 +345,8 @@ public: virtual const SortType& getSorter() const { return mSorter; } virtual void setSorter(const SortType& sorter) { mSorter = sorter; requestSortAll(); } - virtual FilterType* getFilter() { return &mFilter; } - virtual const FilterType* getFilter() const { return &mFilter; } + virtual FilterType& getFilter() { return mFilter; } + virtual const FilterType& getFilter() const { return mFilter; } virtual void setFilter(const FilterType& filter) { mFilter = filter; } // TODO RN: remove this and put all filtering logic in view model -- cgit v1.2.3 From 8ccaa8b0b8e65d6022c6ad0d449cecdd8a72f81d Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 1 Aug 2012 01:48:39 -0700 Subject: build fix attempt --- indra/llui/llfolderviewmodel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui') diff --git a/indra/llui/llfolderviewmodel.h b/indra/llui/llfolderviewmodel.h index 3f825a8670..c4d98657e2 100644 --- a/indra/llui/llfolderviewmodel.h +++ b/indra/llui/llfolderviewmodel.h @@ -259,7 +259,7 @@ public: dirtyFilter(); } - void setPassedFilter(bool passed, bool passed_folder, S32 filter_generation, std::string::size_type string_offset, std::string::size_type string_size) + void setPassedFilter(bool passed, bool passed_folder, S32 filter_generation, std::string::size_type string_offset = std::string::npos, std::string::size_type string_size = 0) { mPassedFilter = passed; mPassedFolderFilter = passed_folder; -- cgit v1.2.3 From 4256b54ee78a89dc5e790cc13556451e1a7c43fa Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 1 Aug 2012 10:45:11 -0700 Subject: build fix --- indra/llui/llfolderviewitem.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llfolderviewitem.h b/indra/llui/llfolderviewitem.h index 19caa7f020..4eda02f13f 100644 --- a/indra/llui/llfolderviewitem.h +++ b/indra/llui/llfolderviewitem.h @@ -406,15 +406,12 @@ public: LLFolderViewFolder* getCommonAncestor(LLFolderViewItem* item_a, LLFolderViewItem* item_b, bool& reverse); void gatherChildRangeExclusive(LLFolderViewItem* start, LLFolderViewItem* end, bool reverse, std::vector& items); -protected: - friend void LLFolderViewItem::addToFolder(LLFolderViewFolder*); // internal functions for tracking folders and items separately // use addToFolder() virtual method to ensure folders are always added to mFolders // and not mItems void addItem(LLFolderViewItem* item); void addFolder( LLFolderViewFolder* folder); -public: //WARNING: do not call directly...use the appropriate LLFolderViewModel-derived class instead template void sortFolders(const SORT_FUNC& func) { mFolders.sort(func); } template void sortItems(const SORT_FUNC& func) { mItems.sort(func); } -- cgit v1.2.3 From 898ec6cd362cd92ceef8dca8faf3fb8ed119b1be Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 1 Aug 2012 14:44:29 -0700 Subject: CHUI-254 FIX Fix Inventory filter and item draw() to highlight matching substrings in inventory made background highlighting sit behind label, so as not to obscure neighboring characters in label --- indra/llui/llfolderviewitem.cpp | 50 ++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index 9b802157f2..480332ae70 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -747,15 +747,29 @@ void LLFolderViewItem::draw() return; } + std::string::size_type filter_string_length = mViewModelItem->hasFilterStringMatch() ? mViewModelItem->getFilterStringSize() : 0; + F32 right_x = 0; + F32 y = (F32)getRect().getHeight() - font->getLineHeight() - (F32)TEXT_PAD - (F32)TOP_PAD; + F32 text_left = (F32)(ARROW_SIZE + TEXT_PAD + ICON_WIDTH + ICON_PAD + mIndentation); + std::string combined_string = mLabel + mLabelSuffix; + + if (filter_string_length > 0) + { + S32 left = llround(text_left) + font->getWidth(combined_string, 0, mViewModelItem->getFilterStringOffset()) - 2; + S32 right = left + font->getWidth(combined_string, mViewModelItem->getFilterStringOffset(), filter_string_length) + 2; + S32 bottom = llfloor(getRect().getHeight() - font->getLineHeight() - 3 - TOP_PAD); + S32 top = getRect().getHeight() - TOP_PAD; + + LLUIImage* box_image = default_params.selection_image; + LLRect box_rect(left, top, right, bottom); + box_image->draw(box_rect, sFilterBGColor); + } + LLColor4 color = (mIsSelected && filled) ? sHighlightFgColor : sFgColor; //TODO RN: implement this in terms of getColor() //if (highlight_link) color = sLinkColor; //if (gInventory.isObjectDescendentOf(getViewModelItem()->getUUID(), gInventory.getLibraryRootFolderID())) color = sLibraryColor; - F32 right_x = 0; - F32 y = (F32)getRect().getHeight() - font->getLineHeight() - (F32)TEXT_PAD - (F32)TOP_PAD; - F32 text_left = (F32)(ARROW_SIZE + TEXT_PAD + ICON_WIDTH + ICON_PAD + mIndentation); - //--------------------------------------------------------------------------------// // Draw the actual label text // @@ -776,27 +790,13 @@ void LLFolderViewItem::draw() //--------------------------------------------------------------------------------// // Highlight string match // - if (mViewModelItem->hasFilterStringMatch()) - { - // don't draw backgrounds for zero-length strings - std::string::size_type filter_string_length = mViewModelItem->getFilterStringSize(); - if (filter_string_length > 0) - { - std::string combined_string = mLabel + mLabelSuffix; - S32 left = llround(text_left) + font->getWidth(combined_string, 0, mViewModelItem->getFilterStringOffset()) - 1; - S32 right = left + font->getWidth(combined_string, mViewModelItem->getFilterStringOffset(), filter_string_length) + 2; - S32 bottom = llfloor(getRect().getHeight() - font->getLineHeight() - 3 - TOP_PAD); - S32 top = getRect().getHeight() - TOP_PAD; - - LLUIImage* box_image = default_params.selection_image; - LLRect box_rect(left, top, right, bottom); - box_image->draw(box_rect, sFilterBGColor); - F32 match_string_left = text_left + font->getWidthF32(combined_string, 0, mViewModelItem->getFilterStringOffset()); - F32 yy = (F32)getRect().getHeight() - font->getLineHeight() - (F32)TEXT_PAD - (F32)TOP_PAD; - font->renderUTF8( combined_string, mViewModelItem->getFilterStringOffset(), match_string_left, yy, - sFilterTextColor, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, - filter_string_length, S32_MAX, &right_x, FALSE ); - } + if (filter_string_length > 0) + { + F32 match_string_left = text_left + font->getWidthF32(combined_string, 0, mViewModelItem->getFilterStringOffset()); + F32 yy = (F32)getRect().getHeight() - font->getLineHeight() - (F32)TEXT_PAD - (F32)TOP_PAD; + font->renderUTF8( combined_string, mViewModelItem->getFilterStringOffset(), match_string_left, yy, + sFilterTextColor, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, + filter_string_length, S32_MAX, &right_x, FALSE ); } } -- cgit v1.2.3