diff options
author | Richard Linden <none@none> | 2012-07-03 23:55:39 -0700 |
---|---|---|
committer | Richard Linden <none@none> | 2012-07-03 23:55:39 -0700 |
commit | 1494a1058f41c5aa00a8ed08fe71123f63e92e81 (patch) | |
tree | 7a93b038b09f1c8217766efab83b8a4936199236 | |
parent | a8defa513c3b2b83f476a1de115fd0332566b483 (diff) |
CHUI-101 WIP Make LLFolderview general purpose
move llfolderview* into LLUI!
-rw-r--r-- | indra/llui/CMakeLists.txt | 6 | ||||
-rw-r--r-- | indra/llui/llfolderview.cpp (renamed from indra/newview/llfolderview.cpp) | 43 | ||||
-rw-r--r-- | indra/llui/llfolderview.h (renamed from indra/newview/llfolderview.h) | 7 | ||||
-rw-r--r-- | indra/llui/llfolderviewitem.cpp (renamed from indra/newview/llfolderviewitem.cpp) | 72 | ||||
-rw-r--r-- | indra/llui/llfolderviewitem.h (renamed from indra/newview/llfolderviewitem.h) | 2 | ||||
-rw-r--r-- | indra/llui/llfolderviewmodel.cpp (renamed from indra/newview/llfolderviewmodel.cpp) | 2 | ||||
-rw-r--r-- | indra/llui/llfolderviewmodel.h (renamed from indra/newview/llfolderviewmodel.h) | 10 | ||||
-rw-r--r-- | indra/newview/CMakeLists.txt | 6 | ||||
-rw-r--r-- | indra/newview/llfolderviewmodelinventory.cpp | 26 | ||||
-rw-r--r-- | indra/newview/llfolderviewmodelinventory.h | 13 | ||||
-rw-r--r-- | indra/newview/llimfloatercontainer.h | 9 | ||||
-rw-r--r-- | indra/newview/llinventorybridge.h | 3 | ||||
-rw-r--r-- | indra/newview/llinventorypanel.cpp | 19 | ||||
-rw-r--r-- | indra/newview/llpanelobjectinventory.cpp | 2 | ||||
-rw-r--r-- | indra/newview/lltexturectrl.cpp | 1 |
15 files changed, 102 insertions, 119 deletions
diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt index b50ed2342d..a9ad0a3c0b 100644 --- a/indra/llui/CMakeLists.txt +++ b/indra/llui/CMakeLists.txt @@ -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 diff --git a/indra/newview/llfolderview.cpp b/indra/llui/llfolderview.cpp index 10677db094..0d3bc44ae4 100644 --- a/indra/newview/llfolderview.cpp +++ b/indra/llui/llfolderview.cpp @@ -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(); diff --git a/indra/newview/llfolderview.h b/indra/llui/llfolderview.h index 78f1d8aff2..ba37a11bbe 100644 --- a/indra/newview/llfolderview.h +++ b/indra/llui/llfolderview.h @@ -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 diff --git a/indra/newview/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index dee3fe7218..741fc9c324 100644 --- a/indra/newview/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -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(); + LLFolderView* root = getRoot(); - if(root->getCurSelectedItem()) - { - LLToolDragAndDrop::ESource src = LLToolDragAndDrop::SOURCE_WORLD; - - // *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); + if( (x - mDragStartX) * (x - mDragStartX) + (y - mDragStartY) * (y - mDragStartY) > drag_and_drop_threshold() * drag_and_drop_threshold() + && root->getCurSelectedItem() + && root->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); + // 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; diff --git a/indra/newview/llfolderviewitem.h b/indra/llui/llfolderviewitem.h index 92923e82da..9cb885066a 100644 --- a/indra/newview/llfolderviewitem.h +++ b/indra/llui/llfolderviewitem.h @@ -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; diff --git a/indra/newview/llfolderviewmodel.cpp b/indra/llui/llfolderviewmodel.cpp index ca6225aca7..dc6e4d754b 100644 --- a/indra/newview/llfolderviewmodel.cpp +++ b/indra/llui/llfolderviewmodel.cpp @@ -24,7 +24,7 @@ * $/LicenseInfo$ */ -#include "llviewerprecompiledheaders.h" +#include "linden_common.h" #include "llfolderviewmodel.h" #include "lltrans.h" diff --git a/indra/newview/llfolderviewmodel.h b/indra/llui/llfolderviewmodel.h index 079409c2a4..0f5f9a1f50 100644 --- a/indra/newview/llfolderviewmodel.h +++ b/indra/llui/llfolderviewmodel.h @@ -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; diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 64bc70da58..b31b99f47c 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -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 diff --git a/indra/newview/llfolderviewmodelinventory.cpp b/indra/newview/llfolderviewmodelinventory.cpp index 99831c61bf..d23b4af8cb 100644 --- a/indra/newview/llfolderviewmodelinventory.cpp +++ b/indra/newview/llfolderviewmodelinventory.cpp @@ -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); diff --git a/indra/newview/llfolderviewmodelinventory.h b/indra/newview/llfolderviewmodelinventory.h index a8fe3f57ea..12a977b28b 100644 --- a/indra/newview/llfolderviewmodelinventory.h +++ b/indra/newview/llfolderviewmodelinventory.h @@ -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 diff --git a/indra/newview/llimfloatercontainer.h b/indra/newview/llimfloatercontainer.h index 9615f3f44d..f68cf07d8c 100644 --- a/indra/newview/llimfloatercontainer.h +++ b/indra/newview/llimfloatercontainer.h @@ -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. diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h index e235d9cf5f..b4a91ca0f7 100644 --- a/indra/newview/llinventorybridge.h +++ b/indra/newview/llinventorybridge.h @@ -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, diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index fed9893158..0aa67cddca 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -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); + } } diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp index 002c0c1113..ca20051a51 100644 --- a/indra/newview/llpanelobjectinventory.cpp +++ b/indra/newview/llpanelobjectinventory.cpp @@ -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; } diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index 4a9e106687..cb59f704a5 100644 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -58,6 +58,7 @@ #include "lltoolmgr.h" #include "lltoolpipette.h" #include "llfiltereditor.h" +#include "llwindow.h" #include "lltool.h" #include "llviewerwindow.h" |