From 606b381c9fbc43c214afd26fb2e2598eec656b66 Mon Sep 17 00:00:00 2001 From: Steven Bennetts Date: Tue, 29 Sep 2009 19:37:05 +0000 Subject: merge https://svn.aws.productengine.com/secondlife/export-from-ll/viewer-2-0@1830 https://svn.aws.productengine.com/secondlife/pe/stable-2@1839 -> viewer-2.0.0-3 JIRAS: EXT-96 EXT-204 EXT-312 EXT-334 EXT-479 EXT-498 EXT-514 EXT-637 EXT-647 EXT-746 EXT-748 EXT-749 EXT-757 EXT-789 EXT-794 EXT-808 EXT-817 EXT-823 EXT-831 EXT-834 EXT-837 EXT-844 EXT-848 EXT-862 EXT-876 EXT-896 EXT-897 EXT-898 EXT-899 EXT-910 EXT-912 EXT-918 EXT-921 EXT-925 EXT-926 EXT-928 EXT-930 EXT-931 EXT-935 EXT-938 EXT-939 EXT-952 EXT-985 EXT-986 EXT-992 EXT-994 EXT-995 EXT-996 EXT-997 EXT-998 EXT-1001 EXT-1004 EXT-1010 EXT-1012 EXT-1016 EXT-1018 EXT-1020 EXT-1028 EXT-1041 EXT-1044 EXT-1051 EXT-1052 EXT-1061 EXT-1069 EXT-1071 EXT-1074 EXT-1075 EXT-1076 EXT-1078 EXT-1080 EXT-1081 EXT-1082 EXT-1083 EXT-1085 EXT-1092 EXT-1093 EXT-1099 EXT-1100 EXT-1101 EXT-1104 EXT-1106 EXT-1111 EXT-1113 EXT-1114 EXT-1115 EXT-1116 EXT-1118 EXT-1119 EXT-1129 EXT-1132 EXT-1135 EXT-1138 EXT-1142 EXT-1161 EXT-1162 EXT-1178 EXT-1180 * NEW DEVELOPMENT: * EXT-898 - Add dock/undock support for camera and movement controls * Avatar list changes * Bottom bar changes: menu, docking, visibility * Camera changes * Camera & Movement Floaters * Dockable Floaters (LLDockableFloater) * Removed LLListCtrl * Toast / Notification changes: signal / destruction changes, ordering * Nearby chat input should display active voice indicator QA NOTES: * Message Well Window is ready to be tested for regression & matching the spec. * Verify Group List Item L&F * Verify All tabs in People Panel * Verify that Picks behavior is not changed --- indra/llui/llflatlistview.h | 142 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 131 insertions(+), 11 deletions(-) (limited to 'indra/llui/llflatlistview.h') diff --git a/indra/llui/llflatlistview.h b/indra/llui/llflatlistview.h index bd0b419f4f..af5a9cfa9b 100644 --- a/indra/llui/llflatlistview.h +++ b/indra/llui/llflatlistview.h @@ -33,10 +33,10 @@ #ifndef LL_LLFLATLISTVIEW_H #define LL_LLFLATLISTVIEW_H +#include "llpanel.h" #include "llscrollcontainer.h" - -class LLPanel; +class LLTextBox; /** * LLFlatListView represents a flat list ui control that operates on items in a form of LLPanel's. @@ -62,6 +62,38 @@ class LLFlatListView : public LLScrollContainer { public: + /** + * Abstract comparator for comparing flat list items in a form of LLPanel + */ + class ItemComparator + { + public: + ItemComparator() {}; + virtual ~ItemComparator() {}; + + /** Returns true if item1 < item2, false otherwise */ + virtual bool compare(const LLPanel* item1, const LLPanel* item2) const = 0; + }; + + /** + * Represents reverse comparator which acts as a decorator for a comparator that need to be reversed + */ + class ItemReverseComparator : public ItemComparator + { + public: + ItemReverseComparator(const ItemComparator& comparator) : mComparator(comparator) {}; + virtual ~ItemReverseComparator() {}; + + virtual bool compare(const LLPanel* item1, const LLPanel* item2) const + { + return mComparator.compare(item2, item1); + } + + private: + const ItemComparator& mComparator; + }; + + struct Params : public LLInitParam::Block { /** turning on/off selection support */ @@ -85,18 +117,23 @@ public: /** Overridden LLPanel's reshape, height is ignored, the list sets its height to accommodate all items */ virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); + /** Returns full rect of child panel */ + const LLRect& getItemsRect() const; + + /** Returns distance between items */ + const S32 getItemsPad() { return mItemPad; } /** * Adds and item and LLSD value associated with it to the list at specified position * @return true if the item was added, false otherwise */ - virtual bool addItem(LLPanel* item, LLSD value = LLUUID::null, EAddPosition pos = ADD_BOTTOM); + virtual bool addItem(LLPanel * item, const LLSD& value = LLUUID::null, EAddPosition pos = ADD_BOTTOM); /** * Insert item_to_add along with associated value to the list right after the after_item. * @return true if the item was successfully added, false otherwise */ - virtual bool insertItemAfter(LLPanel* after_item, LLPanel* item_to_add, LLSD value = LLUUID::null); + virtual bool insertItemAfter(LLPanel* after_item, LLPanel* item_to_add, const LLSD& value = LLUUID::null); /** * Remove specified item @@ -114,13 +151,19 @@ public: * Remove an item specified by uuid * @return true if the item was removed, false otherwise */ - virtual bool removeItemByUUID(LLUUID& uuid); + virtual bool removeItemByUUID(const LLUUID& uuid); /** * Get an item by value * @return the item as LLPanel if associated with value, NULL otherwise */ - virtual LLPanel* getItemByValue(LLSD& value) const; + virtual LLPanel* getItemByValue(const LLSD& value) const; + + template + T* getTypedItemByValue(const LLSD& value) const + { + return dynamic_cast(getItemByValue(value)); + } /** * Select or deselect specified item based on select @@ -138,9 +181,17 @@ public: * Select or deselect an item by associated uuid based on select * @return true if succeed, false otherwise */ - virtual bool selectItemByUUID(LLUUID& uuid, bool select = true); + virtual bool selectItemByUUID(const LLUUID& uuid, bool select = true); + /** + * Get all panels stored in the list. + */ + virtual void getItems(std::vector& items) const; + /** + * Get all items values. + */ + virtual void getValues(std::vector& values) const; /** * Get LLSD associated with the first selected item @@ -176,9 +227,23 @@ public: virtual void getSelectedItems(std::vector& selected_items) const; - /** Resets selection of items */ - virtual void resetSelection(); + /** + * Resets selection of items. + * + * It calls onCommit callback if setCommitOnSelectionChange(bool b) was called with "true" + * argument for current Flat List. + * @param no_commit_on_deselection - if true onCommit callback will not be called + */ + virtual void resetSelection(bool no_commit_on_deselection = false); + /** + * Sets comment text which will be shown in the list is it is empty. + * + * Textbox to hold passed text is created while this method is called at the first time. + * + * @param comment_text - string to be shown as a comment. + */ + void setNoItemsCommentText( const std::string& comment_text); /** Turn on/off multiple selection support */ void setAllowMultipleSelection(bool allow) { mMultipleSelection = allow; } @@ -186,6 +251,8 @@ public: /** Turn on/off selection support */ void setAllowSelection(bool can_select) { mAllowSelection = can_select; } + /** Sets flag whether onCommit should be fired if selection was changed */ + void setCommitOnSelectionChange(bool b) { mCommitOnSelectionChange = b; } /** Get number of selected items in the list */ U32 numSelected() const {return mSelectedItemPairs.size(); } @@ -197,6 +264,14 @@ public: /** Removes all items from the list */ virtual void clear(); + /** + * Set comparator to use for future sorts. + * + * This class does NOT manage lifetime of the comparator + * but assumes that the comparator is always alive. + */ + void setComparator(const ItemComparator* comp) { mItemComparator = comp; } + void sort(); protected: @@ -207,6 +282,19 @@ protected: typedef pairs_list_t::iterator pairs_iterator_t; typedef pairs_list_t::const_iterator pairs_const_iterator_t; + /** An adapter for a ItemComparator */ + struct ComparatorAdaptor + { + ComparatorAdaptor(const ItemComparator& comparator) : mComparator(comparator) {}; + + bool operator()(const item_pair_t* item_pair1, const item_pair_t* item_pair2) + { + return mComparator.compare(item_pair1->first, item_pair2->first); + } + + const ItemComparator& mComparator; + }; + friend class LLUICtrlFactory; LLFlatListView(const LLFlatListView::Params& p); @@ -214,7 +302,10 @@ protected: /** Manage selection on mouse events */ void onItemMouseClick(item_pair_t* item_pair, MASK mask); - /** Updates position of items */ + /** + * Updates position of items. + * It does not take into account invisible items. + */ virtual void rearrangeItems(); virtual item_pair_t* getItemPair(LLPanel* item) const; @@ -227,14 +318,27 @@ protected: virtual bool removeItemPair(item_pair_t* item_pair); + /** + * Notify parent about changed size of internal controls with "size_changes" action + * + * Size includes Items Rect width and either Items Rect height or comment text height. + * Comment text height is included if comment text is set and visible. + * List border size is also included into notified size. + */ + void notifyParentItemsRectChanged(); + private: void setItemsNoScrollWidth(S32 new_width) {mItemsNoScrollWidth = new_width - 2 * mBorderThickness;} + void setNoItemsCommentVisible(bool visible) const; private: + /** Comparator to use when sorting the list. */ + const ItemComparator* mItemComparator; + LLPanel* mItemsPanel; S32 mItemsNoScrollWidth; @@ -242,7 +346,7 @@ private: S32 mBorderThickness; /** Items padding */ - U32 mItemPad; + S32 mItemPad; /** Selection support flag */ bool mAllowSelection; @@ -250,6 +354,14 @@ private: /** Multiselection support flag, ignored if selection is not supported */ bool mMultipleSelection; + /** + * Flag specified whether onCommit be called if selection is changed in the list. + * + * Can be ignored in the resetSelection() method. + * @see resetSelection() + */ + bool mCommitOnSelectionChange; + bool mKeepOneItemSelected; /** All pairs of the list */ @@ -257,6 +369,14 @@ private: /** Selected pairs for faster access */ pairs_list_t mSelectedItemPairs; + + /** + * Rectangle contained previous size of items parent notified last time. + * Is used to reduce amount of parentNotify() calls if size was not changed. + */ + LLRect mPrevNotifyParentRect; + + LLTextBox* mNoItemsCommentTextbox; }; #endif -- cgit v1.2.3