llplacesinventorypanel.cpp
上传用户:king477883
上传日期:2021-03-01
资源大小:9553k
文件大小:6k
源码类别:

游戏引擎

开发平台:

C++ Builder

  1. /** 
  2.  * @file llplacesinventorypanel.cpp
  3.  * @brief LLPlacesInventoryPanel  class definition
  4.  *
  5.  * $LicenseInfo:firstyear=2009&license=viewergpl$
  6.  * 
  7.  * Copyright (c) 2009-2010, Linden Research, Inc.
  8.  * 
  9.  * Second Life Viewer Source Code
  10.  * The source code in this file ("Source Code") is provided by Linden Lab
  11.  * to you under the terms of the GNU General Public License, version 2.0
  12.  * ("GPL"), unless you have obtained a separate licensing agreement
  13.  * ("Other License"), formally executed by you and Linden Lab.  Terms of
  14.  * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15.  * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16.  * 
  17.  * There are special exceptions to the terms and conditions of the GPL as
  18.  * it is applied to this Source Code. View the full text of the exception
  19.  * in the file doc/FLOSS-exception.txt in this software distribution, or
  20.  * online at
  21.  * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22.  * 
  23.  * By copying, modifying or distributing this software, you acknowledge
  24.  * that you have read and understood your obligations described above,
  25.  * and agree to abide by those obligations.
  26.  * 
  27.  * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28.  * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29.  * COMPLETENESS OR PERFORMANCE.
  30.  * $/LicenseInfo$
  31.  */
  32. #include "llviewerprecompiledheaders.h"
  33. #include "llscrollcontainer.h"
  34. #include "llplacesinventorypanel.h"
  35. #include "llfoldervieweventlistener.h"
  36. #include "llinventorybridge.h"
  37. #include "llinventoryfunctions.h"
  38. #include "llpanellandmarks.h"
  39. #include "llplacesinventorybridge.h"
  40. static LLDefaultChildRegistry::Register<LLPlacesInventoryPanel> r("places_inventory_panel");
  41. static const LLPlacesInventoryBridgeBuilder PLACES_INVENTORY_BUILDER;
  42. LLPlacesInventoryPanel::LLPlacesInventoryPanel(const Params& p) : 
  43. LLInventoryPanel(p),
  44. mSavedFolderState(NULL)
  45. {
  46. mInvFVBridgeBuilder = &PLACES_INVENTORY_BUILDER;
  47. mSavedFolderState = new LLSaveFolderState();
  48. mSavedFolderState->setApply(FALSE);
  49. }
  50. LLPlacesInventoryPanel::~LLPlacesInventoryPanel()
  51. {
  52. delete mSavedFolderState;
  53. }
  54. BOOL LLPlacesInventoryPanel::postBuild()
  55. {
  56. LLInventoryPanel::postBuild();
  57. // clear Contents();
  58. {
  59. mFolders->destroyView();
  60. mFolders->getParent()->removeChild(mFolders);
  61. mFolders->die();
  62. if( mScroller )
  63. {
  64. removeChild( mScroller );
  65. mScroller->die();
  66. mScroller = NULL;
  67. }
  68. mFolders = NULL;
  69. }
  70. mCommitCallbackRegistrar.pushScope(); // registered as a widget; need to push callback scope ourselves
  71. // create root folder
  72. {
  73. LLRect folder_rect(0,
  74. 0,
  75. getRect().getWidth(),
  76. 0);
  77. LLPlacesFolderView::Params p;
  78. p.name = getName();
  79. p.rect = folder_rect;
  80. p.parent_panel = this;
  81. mFolders = (LLFolderView*)LLUICtrlFactory::create<LLPlacesFolderView>(p);
  82. mFolders->setAllowMultiSelect(mAllowMultiSelect);
  83. }
  84. mCommitCallbackRegistrar.popScope();
  85. mFolders->setCallbackRegistrar(&mCommitCallbackRegistrar);
  86. // scroller
  87. {
  88. LLRect scroller_view_rect = getRect();
  89. scroller_view_rect.translate(-scroller_view_rect.mLeft, -scroller_view_rect.mBottom);
  90. LLScrollContainer::Params p;
  91. p.name("Inventory Scroller");
  92. p.rect(scroller_view_rect);
  93. p.follows.flags(FOLLOWS_ALL);
  94. p.reserve_scroll_corner(true);
  95. p.tab_stop(true);
  96. mScroller = LLUICtrlFactory::create<LLScrollContainer>(p);
  97. }
  98. addChild(mScroller);
  99. mScroller->addChild(mFolders);
  100. mFolders->setScrollContainer(mScroller);
  101. mFolders->addChild(mFolders->mStatusTextBox);
  102. // cut subitems
  103. mFolders->setUseEllipses(true);
  104. return TRUE;
  105. }
  106. // save current folder open state
  107. void LLPlacesInventoryPanel::saveFolderState()
  108. {
  109. mSavedFolderState->setApply(FALSE);
  110. getRootFolder()->applyFunctorRecursively(*mSavedFolderState);
  111. }
  112. // re-open folders which state was saved
  113. void LLPlacesInventoryPanel::restoreFolderState()
  114. {
  115. mSavedFolderState->setApply(TRUE);
  116. getRootFolder()->applyFunctorRecursively(*mSavedFolderState);
  117. LLOpenFoldersWithSelection opener;
  118. getRootFolder()->applyFunctorRecursively(opener);
  119. getRootFolder()->scrollToShowSelection();
  120. }
  121. S32 LLPlacesInventoryPanel::notify(const LLSD& info) 
  122. {
  123. if(info.has("action"))
  124. {
  125. std::string str_action = info["action"];
  126. if(str_action == "select_first")
  127. {
  128. return getRootFolder()->notify(info);
  129. }
  130. else if(str_action == "select_last")
  131. {
  132. return getRootFolder()->notify(info);
  133. }
  134. }
  135. return 0;
  136. }
  137. /************************************************************************/
  138. /* PROTECTED METHODS                                                    */
  139. /************************************************************************/
  140. /************************************************************************/
  141. /*              LLPlacesFolderView implementation                       */
  142. /************************************************************************/
  143. //////////////////////////////////////////////////////////////////////////
  144. //  PUBLIC METHODS
  145. //////////////////////////////////////////////////////////////////////////
  146. LLPlacesFolderView::LLPlacesFolderView(const LLFolderView::Params& p)
  147. : LLFolderView(p)
  148. {
  149. // we do not need auto select functionality in places landmarks, so override default behavior.
  150. // this disables applying of the LLSelectFirstFilteredItem in LLFolderView::doIdle.
  151. // Fixed issues: EXT-1631, EXT-4994.
  152. mAutoSelectOverride = TRUE;
  153. }
  154. BOOL LLPlacesFolderView::handleRightMouseDown(S32 x, S32 y, MASK mask)
  155. {
  156. // let children to change selection first
  157. childrenHandleRightMouseDown(x, y, mask);
  158. mParentLandmarksPanel->setCurrentSelectedList((LLPlacesInventoryPanel*)getParentPanel());
  159. // then determine its type and set necessary menu handle
  160. if (getCurSelectedItem())
  161. {
  162. LLInventoryType::EType inventory_type = getCurSelectedItem()->getListener()->getInventoryType();
  163. inventory_type_menu_handle_t::iterator it_handle = mMenuHandlesByInventoryType.find(inventory_type);
  164. if (it_handle != mMenuHandlesByInventoryType.end())
  165. {
  166. mPopupMenuHandle = (*it_handle).second;
  167. }
  168. else
  169. {
  170. llwarns << "Requested menu handle for non-setup inventory type: " << inventory_type << llendl;
  171. }
  172. }
  173. return LLFolderView::handleRightMouseDown(x, y, mask);
  174. }
  175. void LLPlacesFolderView::setupMenuHandle(LLInventoryType::EType asset_type, LLHandle<LLView> menu_handle)
  176. {
  177. mMenuHandlesByInventoryType[asset_type] = menu_handle;
  178. }
  179. // EOF