summaryrefslogtreecommitdiff
path: root/indra/newview/llfolderview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfolderview.cpp')
-rw-r--r--indra/newview/llfolderview.cpp187
1 files changed, 110 insertions, 77 deletions
diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp
index 6ec2598e44..1fa194ab19 100644
--- a/indra/newview/llfolderview.cpp
+++ b/indra/newview/llfolderview.cpp
@@ -30,7 +30,7 @@
#include "llcallbacklist.h"
#include "llinventorybridge.h"
-#include "llinventoryclipboard.h" // *TODO: remove this once hack below gone.
+#include "llclipboard.h" // *TODO: remove this once hack below gone.
#include "llinventoryfilter.h"
#include "llinventoryfunctions.h"
#include "llinventorymodelbackgroundfetch.h"
@@ -165,6 +165,33 @@ void LLCloseAllFoldersFunctor::doItem(LLFolderViewItem* item)
{ }
///----------------------------------------------------------------------------
+/// Class LLFolderViewScrollContainer
+///----------------------------------------------------------------------------
+
+// virtual
+const LLRect LLFolderViewScrollContainer::getScrolledViewRect() const
+{
+ LLRect rect = LLRect::null;
+ if (mScrolledView)
+ {
+ LLFolderView* folder_view = dynamic_cast<LLFolderView*>(mScrolledView);
+ if (folder_view)
+ {
+ S32 height = folder_view->mRunningHeight;
+
+ rect = mScrolledView->getRect();
+ rect.setLeftTopAndSize(rect.mLeft, rect.mTop, rect.getWidth(), height);
+ }
+ }
+
+ return rect;
+}
+
+LLFolderViewScrollContainer::LLFolderViewScrollContainer(const LLScrollContainer::Params& p)
+: LLScrollContainer(p)
+{}
+
+///----------------------------------------------------------------------------
/// Class LLFolderView
///----------------------------------------------------------------------------
LLFolderView::Params::Params()
@@ -172,6 +199,7 @@ LLFolderView::Params::Params()
title("title"),
use_label_suffix("use_label_suffix"),
allow_multiselect("allow_multiselect", true),
+ show_empty_message("show_empty_message", true),
show_load_status("show_load_status", true),
use_ellipses("use_ellipses", false)
{
@@ -185,6 +213,7 @@ LLFolderView::LLFolderView(const Params& p)
mScrollContainer( NULL ),
mPopupMenuHandle(),
mAllowMultiSelect(p.allow_multiselect),
+ mShowEmptyMessage(p.show_empty_message),
mShowFolderHierarchy(FALSE),
mSourceID(p.task_id),
mRenameItem( NULL ),
@@ -253,7 +282,7 @@ LLFolderView::LLFolderView(const Params& p)
LLRect new_r = LLRect(rect.mLeft + ICON_PAD,
rect.mTop - TEXT_PAD,
rect.mRight,
- rect.mTop - TEXT_PAD - llfloor(font->getLineHeight()));
+ rect.mTop - TEXT_PAD - font->getLineHeight());
text_p.rect(new_r);
text_p.name(std::string(p.name));
text_p.font(font);
@@ -299,7 +328,7 @@ LLFolderView::~LLFolderView( void )
mAutoOpenItems.removeAllNodes();
gIdleCallbacks.deleteFunction(idle, this);
- delete mPopupMenuHandle.get();
+ if (mPopupMenuHandle.get()) mPopupMenuHandle.get()->die();
mAutoOpenItems.removeAllNodes();
clearSelection();
@@ -349,10 +378,6 @@ BOOL LLFolderView::addFolder( LLFolderViewFolder* folder)
{
mFolders.insert(mFolders.begin(), folder);
}
- if (folder->numSelected())
- {
- recursiveIncrementNumDescendantsSelected(folder->numSelected());
- }
folder->setShowLoadStatus(mShowLoadStatus);
folder->setOrigin(0, 0);
folder->reshape(getRect().getWidth(), 0);
@@ -390,7 +415,7 @@ void LLFolderView::setOpenArrangeRecursively(BOOL openitem, ERecurseType recurse
static LLFastTimer::DeclareTimer FTM_ARRANGE("Arrange");
-// This view grows and shinks to enclose all of its children items and folders.
+// This view grows and shrinks to enclose all of its children items and folders.
S32 LLFolderView::arrange( S32* unused_width, S32* unused_height, S32 filter_generation )
{
if (getListener()->getUUID().notNull())
@@ -416,7 +441,7 @@ S32 LLFolderView::arrange( S32* unused_width, S32* unused_height, S32 filter_gen
getRoot()->getFilter()->getShowFolderState();
S32 total_width = LEFT_PAD;
- S32 running_height = mDebugFilters ? llceil(LLFontGL::getFontMonospace()->getLineHeight()) : 0;
+ S32 running_height = mDebugFilters ? LLFontGL::getFontMonospace()->getLineHeight() : 0;
S32 target_height = running_height;
S32 parent_item_height = getRect().getHeight();
@@ -431,8 +456,8 @@ S32 LLFolderView::arrange( S32* unused_width, S32* unused_height, S32 filter_gen
}
else
{
- folderp->setVisible(show_folder_state == LLInventoryFilter::SHOW_ALL_FOLDERS || // always show folders?
- (folderp->getFiltered(filter_generation) || folderp->hasFilteredDescendants(filter_generation))); // passed filter or has descendants that passed filter
+ folderp->setVisible((show_folder_state == LLInventoryFilter::SHOW_ALL_FOLDERS || // always show folders?
+ (folderp->getFiltered(filter_generation) || folderp->hasFilteredDescendants(filter_generation))));
}
if (folderp->getVisible())
@@ -529,15 +554,16 @@ void LLFolderView::reshape(S32 width, S32 height, BOOL called_from_parent)
LLView::reshape(width, height, called_from_parent);
scroll_rect = mScrollContainer->getContentWindowRect();
}
- width = llmax(mMinWidth, scroll_rect.getWidth());
+ width = llmax(mMinWidth, scroll_rect.getWidth());
height = llmax(mRunningHeight, scroll_rect.getHeight());
- // restrict width with scroll container's width
- if (mUseEllipses)
+ // Restrict width within scroll container's width
+ if (mUseEllipses && mScrollContainer)
+ {
width = scroll_rect.getWidth();
+ }
LLView::reshape(width, height, called_from_parent);
-
mReshapeSignal(mSelectedItems, FALSE);
}
@@ -694,26 +720,6 @@ BOOL LLFolderView::changeSelection(LLFolderViewItem* selection, BOOL selected)
return rv;
}
-void LLFolderView::extendSelection(LLFolderViewItem* selection, LLFolderViewItem* last_selected, LLDynamicArray<LLFolderViewItem*>& items)
-{
- // now store resulting selection
- if (mAllowMultiSelect)
- {
- LLFolderViewItem *cur_selection = getCurSelectedItem();
- LLFolderViewFolder::extendSelection(selection, cur_selection, items);
- for (S32 i = 0; i < items.count(); i++)
- {
- addToSelectionList(items[i]);
- }
- }
- else
- {
- setSelection(selection, FALSE, FALSE);
- }
-
- mSignalSelectCallback = SIGNAL_KEYBOARD_FOCUS;
-}
-
static LLFastTimer::DeclareTimer FTM_SANITIZE_SELECTION("Sanitize Selection");
void LLFolderView::sanitizeSelection()
{
@@ -791,7 +797,7 @@ void LLFolderView::sanitizeSelection()
// if nothing selected after prior constraints...
if (mSelectedItems.empty())
{
- // ...select first available parent of original selection, or "My Inventory" otherwise
+ // ...select first available parent of original selection
LLFolderViewItem* new_selection = NULL;
if (original_selected_item)
{
@@ -932,9 +938,9 @@ void LLFolderView::draw()
mStatusText.clear();
mStatusTextBox->setVisible( FALSE );
}
- else
+ else if (mShowEmptyMessage)
{
- if (LLInventoryModelBackgroundFetch::instance().backgroundFetchActive() || mCompletedFilterGeneration < mFilter->getMinRequiredGeneration())
+ if (LLInventoryModelBackgroundFetch::instance().folderFetchActive() || mCompletedFilterGeneration < mFilter->getMinRequiredGeneration())
{
mStatusText = LLTrans::getString("Searching");
}
@@ -965,8 +971,10 @@ void LLFolderView::draw()
// We should call this method to also notify parent about required rect.
// See EXT-7564, EXT-7047.
arrangeFromRoot();
+ LLUI::popMatrix();
+ LLUI::pushMatrix();
+ LLUI::translate((F32)getRect().mLeft, (F32)getRect().mBottom);
}
-
}
// skip over LLFolderViewFolder::draw since we don't want the folder icon, label,
@@ -1037,6 +1045,24 @@ bool isDescendantOfASelectedItem(LLFolderViewItem* item, const std::vector<LLFol
return false;
}
+// static
+void LLFolderView::removeCutItems()
+{
+ // There's no item in "cut" mode on the clipboard -> exit
+ if (!LLClipboard::instance().isCutMode())
+ return;
+
+ // Get the list of clipboard item uuids and iterate through them
+ LLDynamicArray<LLUUID> objects;
+ LLClipboard::instance().pasteFromClipboard(objects);
+ for (LLDynamicArray<LLUUID>::const_iterator iter = objects.begin();
+ iter != objects.end();
+ ++iter)
+ {
+ gInventory.removeObject(*iter);
+ }
+}
+
void LLFolderView::onItemsRemovalConfirmation(const LLSD& notification, const LLSD& response)
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
@@ -1058,7 +1084,7 @@ void LLFolderView::onItemsRemovalConfirmation(const LLSD& notification, const LL
for (item_it = mSelectedItems.begin(); item_it != mSelectedItems.end(); ++item_it)
{
item = *item_it;
- if(item->isRemovable())
+ if (item && item->isRemovable())
{
items.push_back(item);
}
@@ -1222,7 +1248,9 @@ void LLFolderView::changeType(LLInventoryModel *model, LLFolderType::EType new_f
void LLFolderView::autoOpenItem( LLFolderViewFolder* item )
{
- if (mAutoOpenItems.check() == item || mAutoOpenItems.getDepth() >= (U32)AUTO_OPEN_STACK_DEPTH)
+ if ((mAutoOpenItems.check() == item) ||
+ (mAutoOpenItems.getDepth() >= (U32)AUTO_OPEN_STACK_DEPTH) ||
+ item->isOpen())
{
return;
}
@@ -1314,7 +1342,7 @@ BOOL LLFolderView::canCopy() const
void LLFolderView::copy()
{
// *NOTE: total hack to clear the inventory clipboard
- LLInventoryClipboard::instance().reset();
+ LLClipboard::instance().reset();
S32 count = mSelectedItems.size();
if(getVisible() && getEnabled() && (count > 0))
{
@@ -1355,7 +1383,7 @@ BOOL LLFolderView::canCut() const
void LLFolderView::cut()
{
// clear the inventory clipboard
- LLInventoryClipboard::instance().reset();
+ LLClipboard::instance().reset();
S32 count = mSelectedItems.size();
if(getVisible() && getEnabled() && (count > 0))
{
@@ -1369,6 +1397,7 @@ void LLFolderView::cut()
listener->cutToClipboard();
}
}
+ LLFolderView::removeCutItems();
}
mSearchString.clear();
}
@@ -1945,9 +1974,9 @@ BOOL LLFolderView::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
if (!handled)
{
if (getListener()->getUUID().notNull())
- {
- handled = LLFolderViewFolder::handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg);
- }
+ {
+ handled = LLFolderViewFolder::handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg);
+ }
else
{
if (!mFolders.empty())
@@ -1969,7 +1998,7 @@ BOOL LLFolderView::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
void LLFolderView::deleteAllChildren()
{
closeRenamer();
- delete mPopupMenuHandle.get();
+ if (mPopupMenuHandle.get()) mPopupMenuHandle.get()->die();
mPopupMenuHandle = LLHandle<LLView>();
mScrollContainer = NULL;
mRenameItem = NULL;
@@ -1982,19 +2011,13 @@ void LLFolderView::deleteAllChildren()
void LLFolderView::scrollToShowSelection()
{
- // If items are filtered while background fetch is in progress
- // scrollbar resets to the first filtered item. See EXT-3981.
- // However we allow scrolling for folder views with mAutoSelectOverride
- // (used in Places SP) as an exception because the selection in them
- // is not reset during items filtering. See STORM-133.
- if ( (!LLInventoryModelBackgroundFetch::instance().backgroundFetchActive() || mAutoSelectOverride)
- && mSelectedItems.size() )
+ if ( mSelectedItems.size() )
{
mNeedsScroll = TRUE;
}
}
-// If the parent is scroll containter, scroll it to make the selection
+// If the parent is scroll container, scroll it to make the selection
// is maximally visible.
void LLFolderView::scrollToShowItem(LLFolderViewItem* item, const LLRect& constraint_rect)
{
@@ -2015,7 +2038,7 @@ void LLFolderView::scrollToShowItem(LLFolderViewItem* item, const LLRect& constr
LLRect visible_doc_rect = mScrollContainer->getVisibleContentRect();
S32 icon_height = mIcon.isNull() ? 0 : mIcon->getHeight();
- S32 label_height = llround(getLabelFontForStyle(mLabelStyle)->getLineHeight());
+ S32 label_height = getLabelFontForStyle(mLabelStyle)->getLineHeight();
// when navigating with keyboard, only move top of opened folder on screen, otherwise show whole folder
S32 max_height_to_show = item->isOpen() && mScrollContainer->hasFocus() ? (llmax( icon_height, label_height ) + ICON_PAD) : local_rect.getHeight();
@@ -2129,10 +2152,10 @@ bool LLFolderView::doToSelected(LLInventoryModel* model, const LLSD& userdata)
removeSelectedItems();
return true;
}
-
- if ("copy" == action)
- {
- LLInventoryClipboard::instance().reset();
+ if (("copy" == action) || ("cut" == action))
+ {
+ // Clear the clipboard before we start adding things on it
+ LLClipboard::instance().reset();
}
static const std::string change_folder_string = "change_folder_type_";
@@ -2213,46 +2236,56 @@ void LLFolderView::doIdle()
arrangeAll();
}
+ if (mFilter->isModified() && mFilter->isNotDefault())
+ {
+ mNeedsAutoSelect = TRUE;
+ }
mFilter->clearModified();
- BOOL filter_modified_and_active = mCompletedFilterGeneration < mFilter->getCurrentGeneration() &&
- mFilter->isNotDefault();
- mNeedsAutoSelect = filter_modified_and_active &&
- !(gFocusMgr.childHasKeyboardFocus(this) || gFocusMgr.getMouseCapture());
- // filter to determine visiblity before arranging
+ // filter to determine visibility before arranging
filterFromRoot();
// automatically show matching items, and select first one if we had a selection
- // do this every frame until user puts keyboard focus into the inventory window
- // signaling the end of the automatic update
- // only do this when mNeedsFilter is set, meaning filtered items have
- // potentially changed
if (mNeedsAutoSelect)
{
LLFastTimer t3(FTM_AUTO_SELECT);
// select new item only if a filtered item not currently selected
LLFolderViewItem* selected_itemp = mSelectedItems.empty() ? NULL : mSelectedItems.back();
- if ((selected_itemp && !selected_itemp->getFiltered()) && !mAutoSelectOverride)
+ if (!mAutoSelectOverride && (!selected_itemp || !selected_itemp->potentiallyFiltered()))
{
- // select first filtered item
- LLSelectFirstFilteredItem filter;
- applyFunctorRecursively(filter);
+ // 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
+ LLSelectFirstFilteredItem functor;
+ applyFunctorRecursively(functor);
}
// Open filtered folders for folder views with mAutoSelectOverride=TRUE.
// Used by LLPlacesFolderView.
if (mAutoSelectOverride && !mFilter->getFilterSubString().empty())
{
- LLOpenFilteredFolders filter;
- applyFunctorRecursively(filter);
+ // 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
+ LLOpenFilteredFolders functor;
+ applyFunctorRecursively(functor);
}
scrollToShowSelection();
}
+ BOOL filter_finished = mCompletedFilterGeneration >= mFilter->getCurrentGeneration()
+ && !LLInventoryModelBackgroundFetch::instance().folderFetchActive();
+ if (filter_finished
+ || gFocusMgr.childHasKeyboardFocus(inventory_panel)
+ || gFocusMgr.childHasMouseCapture(inventory_panel))
+ {
+ // finishing the filter process, giving focus to the folder view, or dragging the scrollbar all stop the auto select process
+ mNeedsAutoSelect = FALSE;
+ }
+
+
// during filtering process, try to pin selected item's location on screen
// this will happen when searching your inventory and when new items arrive
- if (filter_modified_and_active)
+ if (!filter_finished)
{
// calculate rectangle to pin item to at start of animated rearrange
if (!mPinningSelectedItem && !mSelectedItems.empty())
@@ -2318,7 +2351,7 @@ void LLFolderView::doIdle()
{
scrollToShowItem(mSelectedItems.back(), constraint_rect);
// continue scrolling until animated layout change is done
- if (!filter_modified_and_active
+ if (filter_finished
&& (!needsArrange() || !is_visible))
{
mNeedsScroll = FALSE;