CHUI-101 WIP Make LLFolderview general purpose

move llfolderview* into LLUI!
master
Richard Linden 2012-07-03 23:55:39 -07:00
parent a8defa513c
commit 1494a1058f
15 changed files with 102 additions and 119 deletions

View File

@ -54,6 +54,9 @@ set(llui_SOURCE_FILES
llfloaterreglistener.cpp
llflyoutbutton.cpp
llfocusmgr.cpp
llfolderview.cpp
llfolderviewitem.cpp
llfolderviewmodel.cpp
llfunctorregistry.cpp
lliconctrl.cpp
llkeywords.cpp
@ -154,6 +157,9 @@ set(llui_HEADER_FILES
llfloaterreglistener.h
llflyoutbutton.h
llfocusmgr.h
llfolderview.h
llfolderviewitem.h
llfolderviewmodel.h
llfunctorregistry.h
llhandle.h
llhelp.h

View File

@ -24,7 +24,7 @@
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "linden_common.h"
#include "llfolderview.h"
#include "llfolderviewmodel.h"
@ -138,8 +138,7 @@ LLFolderViewScrollContainer::LLFolderViewScrollContainer(const LLScrollContainer
/// Class LLFolderView
///----------------------------------------------------------------------------
LLFolderView::Params::Params()
: task_id("task_id"),
title("title"),
: title("title"),
use_label_suffix("use_label_suffix"),
allow_multiselect("allow_multiselect", true),
show_empty_message("show_empty_message", true),
@ -157,7 +156,6 @@ LLFolderView::LLFolderView(const Params& p)
mAllowMultiSelect(p.allow_multiselect),
mShowEmptyMessage(p.show_empty_message),
mShowFolderHierarchy(FALSE),
mSourceID(p.task_id),
mRenameItem( NULL ),
mNeedsScroll( FALSE ),
mUseLabelSuffix(p.use_label_suffix),
@ -618,27 +616,21 @@ std::set<LLFolderViewItem*> LLFolderView::getSelectionList() const
return selection;
}
BOOL LLFolderView::startDrag(LLToolDragAndDrop::ESource source)
bool LLFolderView::startDrag()
{
std::vector<EDragAndDropType> types;
uuid_vec_t cargo_ids;
std::vector<LLFolderViewModelItem*> selected_items;
selected_items_t::iterator item_it;
BOOL can_drag = TRUE;
if (!mSelectedItems.empty())
{
for (item_it = mSelectedItems.begin(); item_it != mSelectedItems.end(); ++item_it)
{
EDragAndDropType type = DAD_NONE;
LLUUID id = LLUUID::null;
can_drag = can_drag && (*item_it)->getViewModelItem()->startDrag(&type, &id);
types.push_back(type);
cargo_ids.push_back(id);
selected_items.push_back((*item_it)->getViewModelItem());
}
LLToolDragAndDrop::getInstance()->beginMultiDrag(types, cargo_ids, source, mSourceID);
return getFolderViewModel()->startDrag(selected_items);
}
return can_drag;
return false;
}
void LLFolderView::commitRename( const LLSD& data )
@ -657,25 +649,6 @@ void LLFolderView::draw()
closeAutoOpenedFolders();
}
// while dragging, update selection rendering to reflect single/multi drag status
if (LLToolDragAndDrop::getInstance()->hasMouseCapture())
{
EAcceptance last_accept = LLToolDragAndDrop::getInstance()->getLastAccept();
if (last_accept == ACCEPT_YES_SINGLE || last_accept == ACCEPT_YES_COPY_SINGLE)
{
setShowSingleSelection(TRUE);
}
else
{
setShowSingleSelection(FALSE);
}
}
else
{
setShowSingleSelection(FALSE);
}
if (mSearchTimer.getElapsedTimeF32() > LLUI::sSettingGroups["config"]->getF32("TypeAheadTimeout") || !mSearchString.size())
{
mSearchString.clear();

View File

@ -44,7 +44,6 @@
#include "lleditmenuhandler.h"
#include "llfontgl.h"
#include "llscrollcontainer.h"
#include "lltooldraganddrop.h"
class LLFolderViewModelInterface;
class LLFolderViewFolder;
@ -88,7 +87,6 @@ public:
struct Params : public LLInitParam::Block<Params, LLFolderViewFolder::Params>
{
Mandatory<LLPanel*> parent_panel;
Optional<LLUUID> task_id;
Optional<std::string> title;
Optional<bool> use_label_suffix,
allow_multiselect,
@ -113,8 +111,6 @@ public:
LLFolderViewModelInterface* getFolderViewModel() { return mViewModel; }
const LLFolderViewModelInterface* getFolderViewModel() const { return mViewModel; }
void setFilterPermMask(PermissionMask filter_perm_mask);
typedef boost::signals2::signal<void (const std::deque<LLFolderViewItem*>& items, BOOL user_action)> signal_t;
void setSelectCallback(const signal_t::slot_type& cb) { mSelectSignal.connect(cb); }
void setReshapeCallback(const signal_t::slot_type& cb) { mReshapeSignal.connect(cb); }
@ -158,7 +154,7 @@ public:
void addToSelectionList(LLFolderViewItem* item);
void removeFromSelectionList(LLFolderViewItem* item);
BOOL startDrag(LLToolDragAndDrop::ESource source);
bool startDrag();
void setDragAndDropThisFrame() { mDragAndDropThisFrame = TRUE; }
void setDraggingOverItem(LLFolderViewItem* item) { mDraggingOverItem = item; }
LLFolderViewItem* getDraggingOverItem() { return mDraggingOverItem; }
@ -271,7 +267,6 @@ protected:
BOOL mAllowMultiSelect;
BOOL mShowEmptyMessage;
BOOL mShowFolderHierarchy;
LLUUID mSourceID;
// Renaming variables and methods
LLFolderViewItem* mRenameItem; // The item currently being renamed

View File

@ -23,19 +23,17 @@
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "linden_common.h"
#include "llfolderviewitem.h"
// viewer includes
#include "llfolderview.h"
#include "llfolderviewmodel.h"
#include "llpanel.h"
// linden library includes
#include "llcriticaldamp.h"
#include "llclipboard.h"
#include "llfocusmgr.h" // gFocusMgr
#include "lltrans.h"
#include "llwindow.h"
///----------------------------------------------------------------------------
/// Class LLFolderViewItem
@ -470,72 +468,46 @@ BOOL LLFolderViewItem::handleMouseDown( S32 x, S32 y, MASK mask )
mSelectPending = TRUE;
}
if( isMovable() )
{
S32 screen_x;
S32 screen_y;
localPointToScreen(x, y, &screen_x, &screen_y );
LLToolDragAndDrop::getInstance()->setDragStart( screen_x, screen_y );
}
mDragStartX = x;
mDragStartY = y;
return TRUE;
}
BOOL LLFolderViewItem::handleHover( S32 x, S32 y, MASK mask )
{
static LLCachedControl<S32> drag_and_drop_threshold(*LLUI::sSettingGroups["config"],"DragAndDropDistanceThreshold");
mIsMouseOverTitle = (y > (getRect().getHeight() - mItemHeight));
if( hasMouseCapture() && isMovable() )
{
S32 screen_x;
S32 screen_y;
localPointToScreen(x, y, &screen_x, &screen_y );
BOOL can_drag = TRUE;
if( LLToolDragAndDrop::getInstance()->isOverThreshold( screen_x, screen_y ) )
LLFolderView* root = getRoot();
if( (x - mDragStartX) * (x - mDragStartX) + (y - mDragStartY) * (y - mDragStartY) > drag_and_drop_threshold() * drag_and_drop_threshold()
&& root->getCurSelectedItem()
&& root->startDrag())
{
LLFolderView* root = getRoot();
// RN: when starting drag and drop, clear out last auto-open
root->autoOpenTest(NULL);
root->setShowSelectionContext(TRUE);
if(root->getCurSelectedItem())
{
LLToolDragAndDrop::ESource src = LLToolDragAndDrop::SOURCE_WORLD;
// Release keyboard focus, so that if stuff is dropped into the
// world, pressing the delete key won't blow away the inventory
// item.
gFocusMgr.setKeyboardFocus(NULL);
// *TODO: push this into listener and remove
// dependency on llagent
src = getViewModelItem()->getDragSource();
can_drag = root->startDrag(src);
if (can_drag)
{
// if (getViewModelItem()) getViewModelItem()->startDrag();
// RN: when starting drag and drop, clear out last auto-open
root->autoOpenTest(NULL);
root->setShowSelectionContext(TRUE);
// Release keyboard focus, so that if stuff is dropped into the
// world, pressing the delete key won't blow away the inventory
// item.
gFocusMgr.setKeyboardFocus(NULL);
return LLToolDragAndDrop::getInstance()->handleHover( x, y, mask );
}
}
}
if (can_drag)
{
getWindow()->setCursor(UI_CURSOR_ARROW);
return TRUE;
}
else
{
getWindow()->setCursor(UI_CURSOR_NOLOCKED);
return TRUE;
}
return TRUE;
}
else
{
if (getRoot())
{
getRoot()->setShowSelectionContext(FALSE);
}
getRoot()->setShowSelectionContext(FALSE);
getWindow()->setCursor(UI_CURSOR_ARROW);
// let parent handle this then...
return FALSE;

View File

@ -102,6 +102,8 @@ protected:
BOOL mHasVisibleChildren;
S32 mIndentation;
S32 mItemHeight;
S32 mDragStartX,
mDragStartY;
//TODO RN: create interface for string highlighting
//std::string::size_type mStringMatchOffset;

View File

@ -24,7 +24,7 @@
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "linden_common.h"
#include "llfolderviewmodel.h"
#include "lltrans.h"

View File

@ -66,9 +66,7 @@ public:
// + Execution And Results
// +-------------------------------------------------------------------+
virtual bool check(const LLFolderViewModelItem* item) = 0;
virtual bool check(const LLInventoryItem* item) = 0;
virtual bool checkFolder(const LLFolderViewModelItem* folder) const = 0;
virtual bool checkFolder(const LLUUID& folder_id) const = 0;
virtual void setEmptyLookupMessage(const std::string& message) = 0;
virtual std::string getEmptyLookupMessage() const = 0;
@ -112,6 +110,7 @@ public:
class LLFolderViewModelInterface
{
public:
virtual ~LLFolderViewModelInterface() {}
virtual void requestSortAll() = 0;
virtual void sort(class LLFolderViewFolder*) = 0;
@ -122,6 +121,8 @@ public:
virtual LLFolderViewFilter* getFilter() = 0;
virtual const LLFolderViewFilter* getFilter() const = 0;
virtual std::string getStatusText() = 0;
virtual bool startDrag(std::vector<LLFolderViewModelItem*>& items) = 0;
};
class LLFolderViewModelCommon : public LLFolderViewModelInterface
@ -263,11 +264,6 @@ public:
virtual S32 getLastFilterGeneration() const = 0;
// This method should be called when a drag begins. returns TRUE
// if the drag can begin, otherwise FALSE.
virtual LLToolDragAndDrop::ESource getDragSource() const = 0;
virtual BOOL startDrag(EDragAndDropType* type, LLUUID* id) const = 0;
virtual bool hasChildren() const = 0;
virtual void addChild(LLFolderViewModelItem* child) = 0;
virtual void removeChild(LLFolderViewModelItem* child) = 0;

View File

@ -253,9 +253,6 @@ set(viewer_SOURCE_FILES
llfloaterwhitelistentry.cpp
llfloaterwindowsize.cpp
llfloaterworldmap.cpp
llfolderview.cpp
llfolderviewitem.cpp
llfolderviewmodel.cpp
llfolderviewmodelinventory.cpp
llfollowcam.cpp
llfriendcard.cpp
@ -813,10 +810,7 @@ set(viewer_HEADER_FILES
llfloaterwhitelistentry.h
llfloaterwindowsize.h
llfloaterworldmap.h
llfolderview.h
llfolderviewmodel.h
llfolderviewmodelinventory.h
llfolderviewitem.h
llfollowcam.h
llfriendcard.h
llgesturelistener.h

View File

@ -28,12 +28,38 @@
#include "llfolderviewmodelinventory.h"
#include "llinventorymodelbackgroundfetch.h"
#include "llinventorypanel.h"
#include "lltooldraganddrop.h"
//
// class LLFolderViewModelInventory
//
static LLFastTimer::DeclareTimer FTM_INVENTORY_SORT("Sort");
bool LLFolderViewModelInventory::startDrag(std::vector<LLFolderViewModelItem*>& items)
{
std::vector<EDragAndDropType> types;
uuid_vec_t cargo_ids;
std::vector<LLFolderViewModelItem*>::iterator item_it;
bool can_drag = true;
if (!items.empty())
{
for (item_it = items.begin(); item_it != items.end(); ++item_it)
{
EDragAndDropType type = DAD_NONE;
LLUUID id = LLUUID::null;
can_drag = can_drag && static_cast<LLFolderViewModelItemInventory*>(*item_it)->startDrag(&type, &id);
types.push_back(type);
cargo_ids.push_back(id);
}
LLToolDragAndDrop::getInstance()->beginMultiDrag(types, cargo_ids,
static_cast<LLFolderViewModelItemInventory*>(items.front())->getDragSource(), mTaskID);
}
return can_drag;
}
void LLFolderViewModelInventory::sort( LLFolderViewFolder* folder )
{
LLFastTimer _(FTM_INVENTORY_SORT);

View File

@ -29,6 +29,9 @@
#define LL_LLFOLDERVIEWMODELINVENTORY_H
#include "llinventoryfilter.h"
#include "llinventory.h"
#include "llwearabletype.h"
#include "lltooldraganddrop.h"
class LLFolderViewModelItemInventory
: public LLFolderViewModelItemCommon
@ -62,6 +65,10 @@ public:
virtual void setPassedFilter(bool filtered, bool filtered_folder, S32 filter_generation);
virtual bool filter( LLFolderViewFilter& filter);
virtual bool filterChildItem( LLFolderViewModelItem* item, LLFolderViewFilter& filter);
virtual BOOL startDrag(EDragAndDropType* type, LLUUID* id) const = 0;
virtual LLToolDragAndDrop::ESource getDragSource() const = 0;
protected:
class LLFolderViewModelInventory* mRootViewModel;
};
@ -97,11 +104,13 @@ class LLFolderViewModelInventory
public:
typedef LLFolderViewModel<LLInventorySort, LLFolderViewModelItemInventory, LLFolderViewModelItemInventory, LLInventoryFilter> base_t;
virtual ~LLFolderViewModelInventory() {}
void setTaskID(const LLUUID& id) {mTaskID = id;}
void sort(LLFolderViewFolder* folder);
bool contentsReady();
bool startDrag(std::vector<LLFolderViewModelItem*>& items);
private:
LLUUID mTaskID;
};
#endif // LL_LLFOLDERVIEWMODELINVENTORY_H

View File

@ -65,8 +65,6 @@ public:
virtual const std::string& getSearchableName() const { return mName; }
virtual const LLUUID& getUUID() const { return mUUID; }
virtual time_t getCreationDate() const { return 0; }
virtual PermissionMask getPermissionMask() const { return PERM_ALL; }
virtual LLFolderType::EType getPreferredType() const { return LLFolderType::FT_NONE; }
virtual LLPointer<LLUIImage> getIcon() const { return NULL; }
virtual LLPointer<LLUIImage> getOpenIcon() const { return getIcon(); }
virtual LLFontGL::StyleFlags getLabelStyle() const { return LLFontGL::NORMAL; }
@ -88,8 +86,6 @@ public:
virtual void buildContextMenu(LLMenuGL& menu, U32 flags) { }
virtual BOOL isUpToDate() const { return TRUE; }
virtual bool hasChildren() const { return FALSE; }
virtual LLInventoryType::EType getInventoryType() const { return LLInventoryType::IT_NONE; }
virtual LLWearableType::EType getWearableType() const { return LLWearableType::WT_NONE; }
virtual bool potentiallyVisible() { return true; }
virtual bool filter( LLFolderViewFilter& filter) { return true; }
@ -107,11 +103,6 @@ public:
void setVisibleIfDetached(BOOL visible);
// This method should be called when a drag begins.
// Returns TRUE if the drag can begin, FALSE otherwise.
virtual LLToolDragAndDrop::ESource getDragSource() const { return LLToolDragAndDrop::SOURCE_PEOPLE; }
virtual BOOL startDrag(EDragAndDropType* type, LLUUID* id) const { return FALSE; }
// This method will be called to determine if a drop can be
// performed, and will set drop to TRUE if a drop is
// requested.

View File

@ -35,6 +35,7 @@
#include "llinventorypanel.h"
#include "llviewercontrol.h"
#include "llwearable.h"
#include "lltooldraganddrop.h"
class LLInventoryFilter;
class LLInventoryPanel;
@ -119,7 +120,7 @@ public:
void getClipboardEntries(bool show_asset_id, menuentry_vec_t &items,
menuentry_vec_t &disabled_items, U32 flags);
virtual void buildContextMenu(LLMenuGL& menu, U32 flags);
virtual LLToolDragAndDrop::ESource getDragSource() const;
virtual LLToolDragAndDrop::ESource getDragSource() const;
virtual BOOL startDrag(EDragAndDropType* type, LLUUID* id) const;
virtual BOOL dragOrDrop(MASK mask, BOOL drop,
EDragAndDropType cargo_type,

View File

@ -571,7 +571,24 @@ void LLInventoryPanel::onIdle(void *userdata)
void LLInventoryPanel::idle(void* user_data)
{
LLInventoryPanel* panel = (LLInventoryPanel*)user_data;
panel->mFolderRoot->doIdle();
panel->mFolderRoot->update();
// while dragging, update selection rendering to reflect single/multi drag status
if (LLToolDragAndDrop::getInstance()->hasMouseCapture())
{
EAcceptance last_accept = LLToolDragAndDrop::getInstance()->getLastAccept();
if (last_accept == ACCEPT_YES_SINGLE || last_accept == ACCEPT_YES_COPY_SINGLE)
{
panel->mFolderRoot->setShowSingleSelection(TRUE);
}
else
{
panel->mFolderRoot->setShowSingleSelection(FALSE);
}
}
else
{
panel->mFolderRoot->setShowSingleSelection(FALSE);
}
}

View File

@ -1557,7 +1557,6 @@ void LLPanelObjectInventory::reset()
LLFolderView::Params p;
p.name = "task inventory";
p.title = "task inventory";
p.task_id = getTaskUUID();
p.parent_panel = this;
p.tool_tip= LLTrans::getString("PanelContentsTooltip");
p.listener = LLTaskInvFVBridge::createObjectBridge(this, NULL);
@ -1823,6 +1822,7 @@ void LLPanelObjectInventory::refresh()
removeVOInventoryListener();
clearContents();
}
mInventoryViewModel.setTaskID(mTaskUUID);
//llinfos << "LLPanelObjectInventory::refresh() " << mTaskUUID << llendl;
}

View File

@ -58,6 +58,7 @@
#include "lltoolmgr.h"
#include "lltoolpipette.h"
#include "llfiltereditor.h"
#include "llwindow.h"
#include "lltool.h"
#include "llviewerwindow.h"