diff options
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/llflatlistview.cpp | 29 | ||||
-rw-r--r-- | indra/llui/llflatlistview.h | 22 | ||||
-rw-r--r-- | indra/llui/lltextbase.cpp | 4 | ||||
-rw-r--r-- | indra/llui/lltextbase.h | 6 |
4 files changed, 55 insertions, 6 deletions
diff --git a/indra/llui/llflatlistview.cpp b/indra/llui/llflatlistview.cpp index 2433c14315..f22b49f30f 100644 --- a/indra/llui/llflatlistview.cpp +++ b/indra/llui/llflatlistview.cpp @@ -50,14 +50,21 @@ LLFlatListView::Params::Params() allow_select("allow_select"), multi_select("multi_select"), keep_one_selected("keep_one_selected"), + keep_selection_visible_on_reshape("keep_selection_visible_on_reshape",false), no_items_text("no_items_text") {}; void LLFlatListView::reshape(S32 width, S32 height, BOOL called_from_parent /* = TRUE */) { + S32 delta = height - getRect().getHeight(); LLScrollContainer::reshape(width, height, called_from_parent); setItemsNoScrollWidth(width); rearrangeItems(); + + if(delta!= 0 && mKeepSelectionVisibleOnReshape) + { + ensureSelectedVisible(); + } } const LLRect& LLFlatListView::getItemsRect() const @@ -380,6 +387,7 @@ LLFlatListView::LLFlatListView(const LLFlatListView::Params& p) , mPrevNotifyParentRect(LLRect()) , mNoItemsCommentTextbox(NULL) , mIsConsecutiveSelection(false) + , mKeepSelectionVisibleOnReshape(p.keep_selection_visible_on_reshape) { mBorderThickness = getBorderWidth(); @@ -1218,6 +1226,8 @@ LLFlatListViewEx::LLFlatListViewEx(const Params& p) : LLFlatListView(p) , mNoFilteredItemsMsg(p.no_filtered_items_msg) , mNoItemsMsg(p.no_items_msg) +, mForceShowingUnmatchedItems(false) +, mLastFilterSucceded(false) { } @@ -1242,6 +1252,16 @@ void LLFlatListViewEx::updateNoItemsMessage(const std::string& filter_string) } +bool LLFlatListViewEx::getForceShowingUnmatchedItems() +{ + return mForceShowingUnmatchedItems; +} + +void LLFlatListViewEx::setForceShowingUnmatchedItems(bool show) +{ + mForceShowingUnmatchedItems = show; +} + void LLFlatListViewEx::setFilterSubString(const std::string& filter_str) { if (0 != LLStringUtil::compareInsensitive(filter_str, mFilterSubString)) @@ -1265,6 +1285,7 @@ void LLFlatListViewEx::filterItems() item_panel_list_t items; getItems(items); + mLastFilterSucceded = false; for (item_panel_list_t::iterator iter = items.begin(), iter_end = items.end(); @@ -1275,13 +1296,14 @@ void LLFlatListViewEx::filterItems() // i.e. we don't hide items that don't support 'match_filter' action, separators etc. if (0 == pItem->notify(action)) { + mLastFilterSucceded = true; pItem->setVisible(true); } else { // TODO: implement (re)storing of current selection. selectItem(pItem, false); - pItem->setVisible(false); + pItem->setVisible(mForceShowingUnmatchedItems); } } @@ -1289,4 +1311,9 @@ void LLFlatListViewEx::filterItems() notifyParentItemsRectChanged(); } +bool LLFlatListViewEx::wasLasFilterSuccessfull() +{ + return mLastFilterSucceded; +} + //EOF diff --git a/indra/llui/llflatlistview.h b/indra/llui/llflatlistview.h index f4e0426f15..caeddfc179 100644 --- a/indra/llui/llflatlistview.h +++ b/indra/llui/llflatlistview.h @@ -105,6 +105,9 @@ public: /** don't allow to deselect all selected items (for mouse events on items only) */ Optional<bool> keep_one_selected; + /** try to keep selection visible after reshape */ + Optional<bool> keep_selection_visible_on_reshape; + /** padding between items */ Optional<U32> item_pad; @@ -412,6 +415,8 @@ private: bool mIsConsecutiveSelection; + bool mKeepSelectionVisibleOnReshape; + /** All pairs of the list */ pairs_list_t mItemPairs; @@ -465,6 +470,10 @@ public: void setNoItemsMsg(const std::string& msg) { mNoItemsMsg = msg; } void setNoFilteredItemsMsg(const std::string& msg) { mNoFilteredItemsMsg = msg; } + bool getForceShowingUnmatchedItems(); + + void setForceShowingUnmatchedItems(bool show); + /** * Sets up new filter string and filters the list. */ @@ -476,6 +485,11 @@ public: */ void filterItems(); + /** + * Returns true if last call of filterItems() found at least one matching item + */ + bool wasLasFilterSuccessfull(); + protected: LLFlatListViewEx(const Params& p); @@ -491,6 +505,14 @@ private: std::string mNoFilteredItemsMsg; std::string mNoItemsMsg; std::string mFilterSubString; + /** + * Show list items that don't match current filter + */ + bool mForceShowingUnmatchedItems; + /** + * True if last call of filterItems() found at least one matching item + */ + bool mLastFilterSucceded; }; #endif diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 2d0d5c12cb..17e41d9e24 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -1630,7 +1630,7 @@ void LLTextBase::appendTextImpl(const std::string &new_text, const LLStyle::Para // Text will be replaced during rendering with the icon, // but string cannot be empty or the segment won't be // added (or drawn). - appendImageSegment(part, icon); + appendImageSegment(icon); } } @@ -1702,7 +1702,7 @@ void LLTextBase::appendLineBreakSegment(const LLStyle::Params& style_params) insertStringNoUndo(getLength(), utf8str_to_wstring("\n"), &segments); } -void LLTextBase::appendImageSegment(S32 highlight_part, const LLStyle::Params& style_params) +void LLTextBase::appendImageSegment(const LLStyle::Params& style_params) { if(getPlainText()) { diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h index 92876e20d6..fe8ebb1b80 100644 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -196,6 +196,9 @@ public: const LLFontGL* getDefaultFont() const { return mDefaultFont; } + void appendLineBreakSegment(const LLStyle::Params& style_params); + void appendImageSegment(const LLStyle::Params& style_params); + public: // Fired when a URL link is clicked commit_signal_t mURLClickSignal; @@ -319,9 +322,6 @@ protected: void updateRects(); void needsScroll() { mScrollNeeded = TRUE; } void replaceUrlLabel(const std::string &url, const std::string &label); - - void appendLineBreakSegment(const LLStyle::Params& style_params); - void appendImageSegment(S32 highlight_part, const LLStyle::Params& style_params); void appendTextImpl(const std::string &new_text, const LLStyle::Params& input_params = LLStyle::Params()); void appendAndHighlightTextImpl(const std::string &new_text, S32 highlight_part, const LLStyle::Params& style_params); |