JIT inventory folder creation, by Nicky Dasmijn

meow-7.2.2
Arrehn 2011-10-15 11:12:08 -04:00
parent 9ebc2078b6
commit c0927681c5
4 changed files with 67 additions and 7 deletions

View File

@ -45,6 +45,8 @@
#include "llfocusmgr.h" // gFocusMgr
#include "lltrans.h"
#include "llinventorypanel.h"
///----------------------------------------------------------------------------
/// Class LLFolderViewItem
///----------------------------------------------------------------------------
@ -897,7 +899,7 @@ void LLFolderViewItem::draw()
const bool up_to_date = mListener && mListener->isUpToDate();
const bool possibly_has_children = ((up_to_date && hasVisibleChildren()) // we fetched our children and some of them have passed the filter...
|| (!up_to_date && mListener && mListener->hasChildren())); // ...or we know we have children but haven't fetched them (doesn't obey filter)
if (possibly_has_children)
if (possibly_has_children || isPreCreatedFolder() ) // <ND> JIT folders / support for isPreCreatedFolder
{
LLUIImage* arrow_image = default_params.folder_arrow_image;
gl_draw_scaled_rotated_image(
@ -1144,7 +1146,9 @@ LLFolderViewFolder::LLFolderViewFolder( const LLFolderViewItem::Params& p ):
mCompletedFilterGeneration(-1),
mMostFilteredDescendantGeneration(-1),
mNeedsSort(false),
mPassedFolderFilter(FALSE)
mPassedFolderFilter(FALSE),
mIsPopulated( false ),
mParentPanel(0)
{
}
@ -2139,6 +2143,15 @@ void LLFolderViewFolder::setOpen(BOOL openitem)
void LLFolderViewFolder::setOpenArrangeRecursively(BOOL openitem, ERecurseType recurse)
{
// <ND> JIT Folders
if( !mIsPopulated && mParentPanel )
{
llinfos << "Lazy populating " << getName() << llendl;
mParentPanel->addSubItems( mFolderId );
mIsPopulated = true;
}
// </ND>
BOOL was_open = mIsOpen;
mIsOpen = openitem;
if (mListener)

View File

@ -338,6 +338,10 @@ public:
EAcceptance* accept,
std::string& tooltip_msg);
// <ND> JIT folders
virtual bool isPreCreatedFolder()
{ return false; }
private:
static std::map<U8, LLFontGL*> sFonts; // map of styles to fonts
};
@ -357,6 +361,12 @@ typedef bool (*sort_order_f)(LLFolderViewItem* a, LLFolderViewItem* b);
class LLFolderViewFolder : public LLFolderViewItem
{
// <ND> JIT folders
LLUUID mFolderId;
class LLInventoryPanel *mParentPanel;
bool mIsPopulated;
// </ND>
protected:
LLFolderViewFolder( const LLFolderViewItem::Params& );
friend class LLUICtrlFactory;
@ -377,6 +387,17 @@ public: // Accessed needed by LLFolderViewItem
void recursiveIncrementNumDescendantsSelected(S32 increment);
S32 numSelected(void) const { return mNumDescendantsSelected + (isSelected() ? 1 : 0); }
// <ND> JIT Folders
void setPanel( LLInventoryPanel* aPanel )
{ mParentPanel = aPanel; }
void setFolderId( LLUUID const &aFolderId )
{ mFolderId = aFolderId; }
virtual bool isPreCreatedFolder()
{ return !mIsPopulated; }
// </ND>
protected:
items_t mItems;
folders_t mFolders;

View File

@ -740,6 +740,10 @@ LLFolderViewItem* LLInventoryPanel::buildNewViews(const LLUUID& id)
if (new_listener)
{
LLFolderViewFolder* folderp = createFolderViewFolder(new_listener);
// <ND> Subfolder JIT
folderp->setPanel(this);
folderp->setFolderId( id );
// </ND>
folderp->setItemSortOrder(mFolderRoot->getSortOrder());
itemp = folderp;
}
@ -769,6 +773,19 @@ LLFolderViewItem* LLInventoryPanel::buildNewViews(const LLUUID& id)
}
}
// <ND> Subfolder JIT
if( id == getRootFolderID() )
addSubItems( id );
// </ND>
return itemp;
}
// <ND> JIT subfolder processing
void LLInventoryPanel::addSubItems(const LLUUID& id)
{
LLInventoryObject const* objectp = gInventory.getObject(id);
// If this is a folder, add the children of the folder and recursively add any
// child folders.
if (id.isNull()
@ -778,7 +795,11 @@ LLFolderViewItem* LLInventoryPanel::buildNewViews(const LLUUID& id)
LLViewerInventoryCategory::cat_array_t* categories;
LLViewerInventoryItem::item_array_t* items;
mInventory->lockDirectDescendentArrays(id, categories, items);
LLFolderViewFolder *parent_folder(0);
if( items && objectp )
parent_folder = (LLFolderViewFolder*)mFolderRoot->getItemByID(objectp->getParentUUID());
if(categories)
{
for (LLViewerInventoryCategory::cat_array_t::const_iterator cat_iter = categories->begin();
@ -786,7 +807,9 @@ LLFolderViewItem* LLInventoryPanel::buildNewViews(const LLUUID& id)
++cat_iter)
{
const LLViewerInventoryCategory* cat = (*cat_iter);
buildNewViews(cat->getUUID());
//buildNewViews(cat->getUUID());
if( !mFolderRoot->getItemByID( cat->getUUID() ) ) //ND
buildNewViews(cat->getUUID());
}
}
@ -797,13 +820,13 @@ LLFolderViewItem* LLInventoryPanel::buildNewViews(const LLUUID& id)
++item_iter)
{
const LLViewerInventoryItem* item = (*item_iter);
buildNewViews(item->getUUID());
//buildNewViews(cat->getUUID());
if( !mFolderRoot->getItemByID( item->getUUID() ) ) //ND
buildNewViews(item->getUUID());
}
}
mInventory->unlockDirectDescendentArrays(id);
}
return itemp;
}
// bit of a hack to make sure the inventory is open.

View File

@ -226,6 +226,9 @@ public:
public:
BOOL getIsViewsInitialized() const { return mViewsInitialized; }
const LLUUID& getRootFolderID() const;
void addSubItems(const LLUUID& id); //ND Just-In-Time subfolder load
protected:
// Builds the UI. Call this once the inventory is usable.
void initializeViews();