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

游戏引擎

开发平台:

C++ Builder

  1. /** 
  2.  * @file lltexturectrl.cpp
  3.  * @author Richard Nelson, James Cook
  4.  * @brief LLTextureCtrl class implementation including related functions
  5.  *
  6.  * $LicenseInfo:firstyear=2002&license=viewergpl$
  7.  * 
  8.  * Copyright (c) 2002-2010, Linden Research, Inc.
  9.  * 
  10.  * Second Life Viewer Source Code
  11.  * The source code in this file ("Source Code") is provided by Linden Lab
  12.  * to you under the terms of the GNU General Public License, version 2.0
  13.  * ("GPL"), unless you have obtained a separate licensing agreement
  14.  * ("Other License"), formally executed by you and Linden Lab.  Terms of
  15.  * the GPL can be found in doc/GPL-license.txt in this distribution, or
  16.  * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  17.  * 
  18.  * There are special exceptions to the terms and conditions of the GPL as
  19.  * it is applied to this Source Code. View the full text of the exception
  20.  * in the file doc/FLOSS-exception.txt in this software distribution, or
  21.  * online at
  22.  * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  23.  * 
  24.  * By copying, modifying or distributing this software, you acknowledge
  25.  * that you have read and understood your obligations described above,
  26.  * and agree to abide by those obligations.
  27.  * 
  28.  * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  29.  * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  30.  * COMPLETENESS OR PERFORMANCE.
  31.  * $/LicenseInfo$
  32.  */
  33. #include "llviewerprecompiledheaders.h"
  34. #include "lltexturectrl.h"
  35. #include "llrender.h"
  36. #include "llagent.h"
  37. #include "llviewertexturelist.h"
  38. #include "llcheckboxctrl.h"
  39. #include "llcombobox.h"
  40. #include "llbutton.h"
  41. #include "lldraghandle.h"
  42. #include "llfocusmgr.h"
  43. #include "llviewertexture.h"
  44. #include "llfolderview.h"
  45. #include "llfoldervieweventlistener.h"
  46. #include "llinventory.h"
  47. #include "llinventoryfunctions.h"
  48. #include "llinventoryobserver.h"
  49. #include "llinventorypanel.h"
  50. #include "llfloaterinventory.h"
  51. #include "lllineeditor.h"
  52. #include "llui.h"
  53. #include "llviewerinventory.h"
  54. #include "llpermissions.h"
  55. #include "llsaleinfo.h"
  56. #include "llassetstorage.h"
  57. #include "lltextbox.h"
  58. #include "llresizehandle.h"
  59. #include "llscrollcontainer.h"
  60. #include "lltoolmgr.h"
  61. #include "lltoolpipette.h"
  62. #include "llfiltereditor.h"
  63. #include "lltool.h"
  64. #include "llviewerwindow.h"
  65. #include "llviewerobject.h"
  66. #include "llviewercontrol.h"
  67. #include "llglheaders.h"
  68. #include "lluictrlfactory.h"
  69. #include "lltrans.h"
  70. static const S32 HPAD = 4;
  71. static const S32 VPAD = 4;
  72. static const S32 LINE = 16;
  73. static const S32 FOOTER_HEIGHT = 100;
  74. static const S32 BORDER_PAD = HPAD;
  75. static const S32 TEXTURE_INVENTORY_PADDING = 30;
  76. static const F32 CONTEXT_CONE_IN_ALPHA = 0.0f;
  77. static const F32 CONTEXT_CONE_OUT_ALPHA = 1.f;
  78. static const F32 CONTEXT_FADE_TIME = 0.08f;
  79. //static const char CURRENT_IMAGE_NAME[] = "Current Texture";
  80. //static const char WHITE_IMAGE_NAME[] = "Blank Texture";
  81. //static const char NO_IMAGE_NAME[] = "None";
  82. //////////////////////////////////////////////////////////////////////////////////////////
  83. // LLFloaterTexturePicker
  84. class LLFloaterTexturePicker : public LLFloater
  85. {
  86. public:
  87. LLFloaterTexturePicker(
  88. LLTextureCtrl* owner,
  89. const std::string& label,
  90. PermissionMask immediate_filter_perm_mask,
  91. PermissionMask non_immediate_filter_perm_mask,
  92. BOOL can_apply_immediately,
  93. const std::string& fallback_image_name);
  94. virtual ~LLFloaterTexturePicker();
  95. // LLView overrides
  96. /*virtual*/ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask,
  97. BOOL drop, EDragAndDropType cargo_type, void *cargo_data, 
  98. EAcceptance *accept,
  99. std::string& tooltip_msg);
  100. /*virtual*/ void draw();
  101. /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask);
  102. // LLFloater overrides
  103. /*virtual*/ BOOL    postBuild();
  104. /*virtual*/ void onClose(bool app_settings);
  105. // New functions
  106. void setImageID( const LLUUID& image_asset_id);
  107. void updateImageStats();
  108. const LLUUID& getAssetID() { return mImageAssetID; }
  109. const LLUUID& findItemID(const LLUUID& asset_id, BOOL copyable_only);
  110. void setCanApplyImmediately(BOOL b);
  111. void setActive( BOOL active );
  112. LLTextureCtrl* getOwner() const { return mOwner; }
  113. void setOwner(LLTextureCtrl* owner) { mOwner = owner; }
  114. void stopUsingPipette();
  115. PermissionMask  getFilterPermMask();
  116. void updateFilterPermMask();
  117. void commitIfImmediateSet();
  118. void onFilterEdit(const std::string& search_string );
  119. static void onBtnSetToDefault( void* userdata );
  120. static void onBtnSelect( void* userdata );
  121. static void onBtnCancel( void* userdata );
  122.    void onBtnPipette( );
  123. //static void onBtnRevert( void* userdata );
  124. static void onBtnWhite( void* userdata );
  125. static void onBtnNone( void* userdata );
  126. static void onBtnClear( void* userdata );
  127.    void onSelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action);
  128. static void onShowFolders(LLUICtrl* ctrl, void* userdata);
  129. static void onApplyImmediateCheck(LLUICtrl* ctrl, void* userdata);
  130.    void onTextureSelect( const LLTextureEntry& te );
  131. protected:
  132. LLPointer<LLViewerTexture> mTexturep;
  133. LLTextureCtrl* mOwner;
  134. LLUUID mImageAssetID; // Currently selected texture
  135. std::string mFallbackImageName; // What to show if currently selected texture is null.
  136. LLUUID mWhiteImageAssetID;
  137. LLUUID mSpecialCurrentImageAssetID;  // Used when the asset id has no corresponding texture in the user's inventory.
  138. LLUUID mOriginalImageAssetID;
  139. std::string mLabel;
  140. LLTextBox* mTentativeLabel;
  141. LLTextBox* mResolutionLabel;
  142. std::string mPendingName;
  143. BOOL mActive;
  144. LLFilterEditor* mFilterEdit;
  145. LLInventoryPanel* mInventoryPanel;
  146. PermissionMask mImmediateFilterPermMask;
  147. PermissionMask mNonImmediateFilterPermMask;
  148. BOOL mCanApplyImmediately;
  149. BOOL mNoCopyTextureSelected;
  150. F32 mContextConeOpacity;
  151. LLSaveFolderState mSavedFolderState;
  152. };
  153. LLFloaterTexturePicker::LLFloaterTexturePicker(
  154. LLTextureCtrl* owner,
  155. const std::string& label,
  156. PermissionMask immediate_filter_perm_mask,
  157. PermissionMask non_immediate_filter_perm_mask,
  158. BOOL can_apply_immediately,
  159. const std::string& fallback_image_name)
  160. : LLFloater(LLSD()),
  161. mOwner( owner ),
  162. mImageAssetID( owner->getImageAssetID() ),
  163. mFallbackImageName( fallback_image_name ),
  164. mWhiteImageAssetID( gSavedSettings.getString( "UIImgWhiteUUID" ) ),
  165. mOriginalImageAssetID(owner->getImageAssetID()),
  166. mLabel(label),
  167. mTentativeLabel(NULL),
  168. mResolutionLabel(NULL),
  169. mActive( TRUE ),
  170. mFilterEdit(NULL),
  171. mImmediateFilterPermMask(immediate_filter_perm_mask),
  172. mNonImmediateFilterPermMask(non_immediate_filter_perm_mask),
  173. mContextConeOpacity(0.f)
  174. {
  175. mCanApplyImmediately = can_apply_immediately;
  176. LLUICtrlFactory::getInstance()->buildFloater(this,"floater_texture_ctrl.xml",NULL);
  177. setCanMinimize(FALSE);
  178. }
  179. LLFloaterTexturePicker::~LLFloaterTexturePicker()
  180. {
  181. }
  182. void LLFloaterTexturePicker::setImageID(const LLUUID& image_id)
  183. {
  184. if( mImageAssetID != image_id && mActive)
  185. {
  186. mNoCopyTextureSelected = FALSE;
  187. mViewModel->setDirty(); // *TODO: shouldn't we be using setValue() here?
  188. mImageAssetID = image_id; 
  189. LLUUID item_id = findItemID(mImageAssetID, FALSE);
  190. if (item_id.isNull())
  191. {
  192. mInventoryPanel->clearSelection();
  193. }
  194. else
  195. {
  196. LLInventoryItem* itemp = gInventory.getItem(image_id);
  197. if (itemp && !itemp->getPermissions().allowCopyBy(gAgent.getID()))
  198. {
  199. // no copy texture
  200. childSetValue("apply_immediate_check", FALSE);
  201. mNoCopyTextureSelected = TRUE;
  202. }
  203. mInventoryPanel->setSelection(item_id, TAKE_FOCUS_NO);
  204. }
  205. }
  206. }
  207. void LLFloaterTexturePicker::setActive( BOOL active )
  208. {
  209. if (!active && childGetValue("Pipette").asBoolean())
  210. {
  211. stopUsingPipette();
  212. }
  213. mActive = active; 
  214. }
  215. void LLFloaterTexturePicker::setCanApplyImmediately(BOOL b)
  216. {
  217. mCanApplyImmediately = b;
  218. if (!mCanApplyImmediately)
  219. {
  220. childSetValue("apply_immediate_check", FALSE);
  221. }
  222. updateFilterPermMask();
  223. }
  224. void LLFloaterTexturePicker::stopUsingPipette()
  225. {
  226. if (LLToolMgr::getInstance()->getCurrentTool() == LLToolPipette::getInstance())
  227. {
  228. LLToolMgr::getInstance()->clearTransientTool();
  229. }
  230. }
  231. void LLFloaterTexturePicker::updateImageStats()
  232. {
  233. if (mTexturep.notNull())
  234. {
  235. //RN: have we received header data for this image?
  236. if (mTexturep->getFullWidth() > 0 && mTexturep->getFullHeight() > 0)
  237. {
  238. std::string formatted_dims = llformat("%d x %d", mTexturep->getFullWidth(),mTexturep->getFullHeight());
  239. mResolutionLabel->setTextArg("[DIMENSIONS]", formatted_dims);
  240. }
  241. else
  242. {
  243. mResolutionLabel->setTextArg("[DIMENSIONS]", std::string("[? x ?]"));
  244. }
  245. }
  246. else
  247. {
  248. mResolutionLabel->setTextArg("[DIMENSIONS]", std::string(""));
  249. }
  250. }
  251. // virtual
  252. BOOL LLFloaterTexturePicker::handleDragAndDrop( 
  253. S32 x, S32 y, MASK mask,
  254. BOOL drop,
  255. EDragAndDropType cargo_type, void *cargo_data, 
  256. EAcceptance *accept,
  257. std::string& tooltip_msg)
  258. {
  259. BOOL handled = FALSE;
  260. if (cargo_type == DAD_TEXTURE)
  261. {
  262. LLInventoryItem *item = (LLInventoryItem *)cargo_data;
  263. BOOL copy = item->getPermissions().allowCopyBy(gAgent.getID());
  264. BOOL mod = item->getPermissions().allowModifyBy(gAgent.getID());
  265. BOOL xfer = item->getPermissions().allowOperationBy(PERM_TRANSFER,
  266. gAgent.getID());
  267. PermissionMask item_perm_mask = 0;
  268. if (copy) item_perm_mask |= PERM_COPY;
  269. if (mod)  item_perm_mask |= PERM_MODIFY;
  270. if (xfer) item_perm_mask |= PERM_TRANSFER;
  271. //PermissionMask filter_perm_mask = getFilterPermMask();  Commented out due to no-copy texture loss.
  272. PermissionMask filter_perm_mask = mImmediateFilterPermMask;
  273. if ( (item_perm_mask & filter_perm_mask) == filter_perm_mask )
  274. {
  275. if (drop)
  276. {
  277. setImageID( item->getAssetUUID() );
  278. commitIfImmediateSet();
  279. }
  280. *accept = ACCEPT_YES_SINGLE;
  281. }
  282. else
  283. {
  284. *accept = ACCEPT_NO;
  285. }
  286. }
  287. else
  288. {
  289. *accept = ACCEPT_NO;
  290. }
  291. handled = TRUE;
  292. lldebugst(LLERR_USER_INPUT) << "dragAndDrop handled by LLFloaterTexturePicker " << getName() << llendl;
  293. return handled;
  294. }
  295. BOOL LLFloaterTexturePicker::handleKeyHere(KEY key, MASK mask)
  296. {
  297. LLFolderView* root_folder = mInventoryPanel->getRootFolder();
  298. if (root_folder && mFilterEdit)
  299. {
  300. if (mFilterEdit->hasFocus() 
  301. && (key == KEY_RETURN || key == KEY_DOWN) 
  302. && mask == MASK_NONE)
  303. {
  304. if (!root_folder->getCurSelectedItem())
  305. {
  306. LLFolderViewItem* itemp = root_folder->getItemByID(gInventory.getRootFolderID());
  307. if (itemp)
  308. {
  309. root_folder->setSelection(itemp, FALSE, FALSE);
  310. }
  311. }
  312. root_folder->scrollToShowSelection();
  313. // move focus to inventory proper
  314. mInventoryPanel->setFocus(TRUE);
  315. // treat this as a user selection of the first filtered result
  316. commitIfImmediateSet();
  317. return TRUE;
  318. }
  319. if (mInventoryPanel->hasFocus() && key == KEY_UP)
  320. {
  321. mFilterEdit->focusFirstItem(TRUE);
  322. }
  323. }
  324. return LLFloater::handleKeyHere(key, mask);
  325. }
  326. void LLFloaterTexturePicker::onClose(bool app_quitting)
  327. {
  328. if (mOwner)
  329. {
  330. mOwner->onFloaterClose();
  331. }
  332. stopUsingPipette();
  333. }
  334. // virtual
  335. BOOL LLFloaterTexturePicker::postBuild()
  336. {
  337. LLFloater::postBuild();
  338. if (!mLabel.empty())
  339. {
  340. std::string pick = getString("pick title");
  341. setTitle(pick + mLabel);
  342. }
  343. mTentativeLabel = getChild<LLTextBox>("Multiple");
  344. mResolutionLabel = getChild<LLTextBox>("unknown");
  345. childSetAction("Default",LLFloaterTexturePicker::onBtnSetToDefault,this);
  346. childSetAction("None", LLFloaterTexturePicker::onBtnNone,this);
  347. childSetAction("Blank", LLFloaterTexturePicker::onBtnWhite,this);
  348. childSetCommitCallback("show_folders_check", onShowFolders, this);
  349. childSetVisible("show_folders_check", FALSE);
  350. mFilterEdit = getChild<LLFilterEditor>("inventory search editor");
  351. mFilterEdit->setCommitCallback(boost::bind(&LLFloaterTexturePicker::onFilterEdit, this, _2));
  352. mInventoryPanel = getChild<LLInventoryPanel>("inventory panel");
  353. if(mInventoryPanel)
  354. {
  355. U32 filter_types = 0x0;
  356. filter_types |= 0x1 << LLInventoryType::IT_TEXTURE;
  357. filter_types |= 0x1 << LLInventoryType::IT_SNAPSHOT;
  358. mInventoryPanel->setFilterTypes(filter_types);
  359. //mInventoryPanel->setFilterPermMask(getFilterPermMask());  //Commented out due to no-copy texture loss.
  360. mInventoryPanel->setFilterPermMask(mImmediateFilterPermMask);
  361. mInventoryPanel->setSelectCallback(boost::bind(&LLFloaterTexturePicker::onSelectionChange, this, _1, _2));
  362. mInventoryPanel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS);
  363. mInventoryPanel->setAllowMultiSelect(FALSE);
  364. // store this filter as the default one
  365. mInventoryPanel->getRootFolder()->getFilter()->markDefault();
  366. // Commented out to stop opening all folders with textures
  367. // mInventoryPanel->openDefaultFolderForType(LLFolderType::FT_TEXTURE);
  368. // don't put keyboard focus on selected item, because the selection callback
  369. // will assume that this was user input
  370. mInventoryPanel->setSelection(findItemID(mImageAssetID, FALSE), TAKE_FOCUS_NO);
  371. }
  372. mNoCopyTextureSelected = FALSE;
  373. childSetValue("apply_immediate_check", gSavedSettings.getBOOL("ApplyTextureImmediately"));
  374. childSetCommitCallback("apply_immediate_check", onApplyImmediateCheck, this);
  375. if (!mCanApplyImmediately)
  376. {
  377. childSetEnabled("show_folders_check", FALSE);
  378. }
  379. getChild<LLUICtrl>("Pipette")->setCommitCallback( boost::bind(&LLFloaterTexturePicker::onBtnPipette, this));
  380. childSetAction("Cancel", LLFloaterTexturePicker::onBtnCancel,this);
  381. childSetAction("Select", LLFloaterTexturePicker::onBtnSelect,this);
  382. // update permission filter once UI is fully initialized
  383. updateFilterPermMask();
  384. mSavedFolderState.setApply(FALSE);
  385. LLToolPipette::getInstance()->setToolSelectCallback(boost::bind(&LLFloaterTexturePicker::onTextureSelect, this, _1));
  386. return TRUE;
  387. }
  388. // virtual
  389. void LLFloaterTexturePicker::draw()
  390. {
  391. S32 floater_header_size = getHeaderHeight();
  392. if (mOwner)
  393. {
  394. // draw cone of context pointing back to texture swatch
  395. LLRect owner_rect;
  396. mOwner->localRectToOtherView(mOwner->getLocalRect(), &owner_rect, this);
  397. LLRect local_rect = getLocalRect();
  398. if (gFocusMgr.childHasKeyboardFocus(this) && mOwner->isInVisibleChain() && mContextConeOpacity > 0.001f)
  399. {
  400. gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
  401. LLGLEnable(GL_CULL_FACE);
  402. gGL.begin(LLRender::QUADS);
  403. {
  404. gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_IN_ALPHA * mContextConeOpacity);
  405. gGL.vertex2i(owner_rect.mLeft, owner_rect.mTop);
  406. gGL.vertex2i(owner_rect.mRight, owner_rect.mTop);
  407. gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_OUT_ALPHA * mContextConeOpacity);
  408. gGL.vertex2i(local_rect.mRight, local_rect.mTop);
  409. gGL.vertex2i(local_rect.mLeft, local_rect.mTop);
  410. gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_OUT_ALPHA * mContextConeOpacity);
  411. gGL.vertex2i(local_rect.mLeft, local_rect.mTop);
  412. gGL.vertex2i(local_rect.mLeft, local_rect.mBottom);
  413. gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_IN_ALPHA * mContextConeOpacity);
  414. gGL.vertex2i(owner_rect.mLeft, owner_rect.mBottom);
  415. gGL.vertex2i(owner_rect.mLeft, owner_rect.mTop);
  416. gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_OUT_ALPHA * mContextConeOpacity);
  417. gGL.vertex2i(local_rect.mRight, local_rect.mBottom);
  418. gGL.vertex2i(local_rect.mRight, local_rect.mTop);
  419. gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_IN_ALPHA * mContextConeOpacity);
  420. gGL.vertex2i(owner_rect.mRight, owner_rect.mTop);
  421. gGL.vertex2i(owner_rect.mRight, owner_rect.mBottom);
  422. gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_OUT_ALPHA * mContextConeOpacity);
  423. gGL.vertex2i(local_rect.mLeft, local_rect.mBottom);
  424. gGL.vertex2i(local_rect.mRight, local_rect.mBottom);
  425. gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_IN_ALPHA * mContextConeOpacity);
  426. gGL.vertex2i(owner_rect.mRight, owner_rect.mBottom);
  427. gGL.vertex2i(owner_rect.mLeft, owner_rect.mBottom);
  428. }
  429. gGL.end();
  430. }
  431. }
  432. if (gFocusMgr.childHasMouseCapture(getDragHandle()))
  433. {
  434. mContextConeOpacity = lerp(mContextConeOpacity, gSavedSettings.getF32("PickerContextOpacity"), LLCriticalDamp::getInterpolant(CONTEXT_FADE_TIME));
  435. }
  436. else
  437. {
  438. mContextConeOpacity = lerp(mContextConeOpacity, 0.f, LLCriticalDamp::getInterpolant(CONTEXT_FADE_TIME));
  439. }
  440. updateImageStats();
  441. // if we're inactive, gray out "apply immediate" checkbox
  442. childSetEnabled("show_folders_check", mActive && mCanApplyImmediately && !mNoCopyTextureSelected);
  443. childSetEnabled("Select", mActive);
  444. childSetEnabled("Pipette", mActive);
  445. childSetValue("Pipette", LLToolMgr::getInstance()->getCurrentTool() == LLToolPipette::getInstance());
  446. //BOOL allow_copy = FALSE;
  447. if( mOwner ) 
  448. {
  449. mTexturep = NULL;
  450. if(mImageAssetID.notNull())
  451. {
  452. mTexturep = LLViewerTextureManager::getFetchedTexture(mImageAssetID, MIPMAP_YES);
  453. mTexturep->setBoostLevel(LLViewerTexture::BOOST_PREVIEW);
  454. }
  455. else if (!mFallbackImageName.empty())
  456. {
  457. mTexturep = LLViewerTextureManager::getFetchedTextureFromFile(mFallbackImageName);
  458. mTexturep->setBoostLevel(LLViewerTexture::BOOST_PREVIEW);
  459. }
  460. if (mTentativeLabel)
  461. {
  462. mTentativeLabel->setVisible( FALSE  );
  463. }
  464. childSetEnabled("Default",  mImageAssetID != mOwner->getDefaultImageAssetID());
  465. childSetEnabled("Blank",   mImageAssetID != mWhiteImageAssetID );
  466. childSetEnabled("None", mOwner->getAllowNoTexture() && !mImageAssetID.isNull() );
  467. LLFloater::draw();
  468. if( isMinimized() )
  469. {
  470. return;
  471. }
  472. // Border
  473. LLRect border( BORDER_PAD, 
  474.    getRect().getHeight() - floater_header_size - BORDER_PAD, 
  475.    ((getMinWidth() / 2) - TEXTURE_INVENTORY_PADDING - HPAD) - BORDER_PAD,
  476.    BORDER_PAD + FOOTER_HEIGHT + (getRect().getHeight() - getMinHeight()));
  477. gl_rect_2d( border, LLColor4::black, FALSE );
  478. // Interior
  479. LLRect interior = border;
  480. interior.stretch( -1 ); 
  481. if( mTexturep )
  482. {
  483. if( mTexturep->getComponents() == 4 )
  484. {
  485. gl_rect_2d_checkerboard( interior );
  486. }
  487. gl_draw_scaled_image( interior.mLeft, interior.mBottom, interior.getWidth(), interior.getHeight(), mTexturep );
  488. // Pump the priority
  489. mTexturep->addTextureStats( (F32)(interior.getWidth() * interior.getHeight()) );
  490. // Draw Tentative Label over the image
  491. if( mOwner->getTentative() && !mViewModel->isDirty() )
  492. {
  493. mTentativeLabel->setVisible( TRUE );
  494. drawChild(mTentativeLabel);
  495. }
  496. }
  497. else
  498. {
  499. gl_rect_2d( interior, LLColor4::grey, TRUE );
  500. // Draw X
  501. gl_draw_x(interior, LLColor4::black );
  502. }
  503. }
  504. }
  505. // static
  506. /*
  507. void LLFloaterTexturePicker::onSaveAnotherCopyDialog( S32 option, void* userdata )
  508. {
  509. LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata;
  510. if( 0 == option )
  511. {
  512. self->copyToInventoryFinal();
  513. }
  514. }
  515. */
  516. const LLUUID& LLFloaterTexturePicker::findItemID(const LLUUID& asset_id, BOOL copyable_only)
  517. {
  518. LLViewerInventoryCategory::cat_array_t cats;
  519. LLViewerInventoryItem::item_array_t items;
  520. LLAssetIDMatches asset_id_matches(asset_id);
  521. gInventory.collectDescendentsIf(LLUUID::null,
  522. cats,
  523. items,
  524. LLInventoryModel::INCLUDE_TRASH,
  525. asset_id_matches);
  526. if (items.count())
  527. {
  528. // search for copyable version first
  529. for (S32 i = 0; i < items.count(); i++)
  530. {
  531. LLInventoryItem* itemp = items[i];
  532. LLPermissions item_permissions = itemp->getPermissions();
  533. if (item_permissions.allowCopyBy(gAgent.getID(), gAgent.getGroupID()))
  534. {
  535. return itemp->getUUID();
  536. }
  537. }
  538. // otherwise just return first instance, unless copyable requested
  539. if (copyable_only)
  540. {
  541. return LLUUID::null;
  542. }
  543. else
  544. {
  545. return items[0]->getUUID();
  546. }
  547. }
  548. return LLUUID::null;
  549. }
  550. PermissionMask LLFloaterTexturePicker::getFilterPermMask()
  551. {
  552. bool apply_immediate = childGetValue("apply_immediate_check").asBoolean();
  553. return apply_immediate ? mImmediateFilterPermMask : mNonImmediateFilterPermMask;
  554. }
  555. void LLFloaterTexturePicker::commitIfImmediateSet()
  556. {
  557. bool apply_immediate = childGetValue("apply_immediate_check").asBoolean();
  558. if (!mNoCopyTextureSelected && apply_immediate && mOwner)
  559. {
  560. mOwner->onFloaterCommit(LLTextureCtrl::TEXTURE_CHANGE);
  561. }
  562. }
  563. // static
  564. void LLFloaterTexturePicker::onBtnSetToDefault(void* userdata)
  565. {
  566. LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata;
  567. if (self->mOwner)
  568. {
  569. self->setImageID( self->mOwner->getDefaultImageAssetID() );
  570. }
  571. self->commitIfImmediateSet();
  572. }
  573. // static
  574. void LLFloaterTexturePicker::onBtnWhite(void* userdata)
  575. {
  576. LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata;
  577. self->setImageID( self->mWhiteImageAssetID );
  578. self->commitIfImmediateSet();
  579. }
  580. // static
  581. void LLFloaterTexturePicker::onBtnNone(void* userdata)
  582. {
  583. LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata;
  584. self->setImageID( LLUUID::null );
  585. self->commitIfImmediateSet();
  586. }
  587. /*
  588. // static
  589. void LLFloaterTexturePicker::onBtnRevert(void* userdata)
  590. {
  591. LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata;
  592. self->setImageID( self->mOriginalImageAssetID );
  593. // TODO: Change this to tell the owner to cancel.  It needs to be
  594. // smart enough to restore multi-texture selections.
  595. self->mOwner->onFloaterCommit();
  596. self->mViewModel->resetDirty();
  597. }*/
  598. // static
  599. void LLFloaterTexturePicker::onBtnCancel(void* userdata)
  600. {
  601. LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata;
  602. self->setImageID( self->mOriginalImageAssetID );
  603. if (self->mOwner)
  604. {
  605. self->mOwner->onFloaterCommit(LLTextureCtrl::TEXTURE_CANCEL);
  606. }
  607. self->mViewModel->resetDirty();
  608. self->closeFloater();
  609. }
  610. // static
  611. void LLFloaterTexturePicker::onBtnSelect(void* userdata)
  612. {
  613. LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata;
  614. if (self->mOwner)
  615. {
  616. self->mOwner->onFloaterCommit(LLTextureCtrl::TEXTURE_SELECT);
  617. }
  618. self->closeFloater();
  619. }
  620. void LLFloaterTexturePicker::onBtnPipette()
  621. {
  622. BOOL pipette_active = childGetValue("Pipette").asBoolean();
  623. pipette_active = !pipette_active;
  624. if (pipette_active)
  625. {
  626. LLToolMgr::getInstance()->setTransientTool(LLToolPipette::getInstance());
  627. }
  628. else
  629. {
  630. LLToolMgr::getInstance()->clearTransientTool();
  631. }
  632. }
  633. void LLFloaterTexturePicker::onSelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action)
  634. {
  635. if (items.size())
  636. {
  637. LLFolderViewItem* first_item = items.front();
  638. LLInventoryItem* itemp = gInventory.getItem(first_item->getListener()->getUUID());
  639. mNoCopyTextureSelected = FALSE;
  640. if (itemp)
  641. {
  642. if (!itemp->getPermissions().allowCopyBy(gAgent.getID()))
  643. {
  644. mNoCopyTextureSelected = TRUE;
  645. }
  646. mImageAssetID = itemp->getAssetUUID();
  647. mViewModel->setDirty(); // *TODO: shouldn't we be using setValue() here?
  648. if (user_action)
  649. {
  650. // only commit intentional selections, not implicit ones
  651. commitIfImmediateSet();
  652. }
  653. }
  654. }
  655. }
  656. // static
  657. void LLFloaterTexturePicker::onShowFolders(LLUICtrl* ctrl, void *user_data)
  658. {
  659. LLCheckBoxCtrl* check_box = (LLCheckBoxCtrl*)ctrl;
  660. LLFloaterTexturePicker* picker = (LLFloaterTexturePicker*)user_data;
  661. if (check_box->get())
  662. {
  663. picker->mInventoryPanel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS);
  664. }
  665. else
  666. {
  667. picker->mInventoryPanel->setShowFolderState(LLInventoryFilter::SHOW_NO_FOLDERS);
  668. }
  669. }
  670. // static
  671. void LLFloaterTexturePicker::onApplyImmediateCheck(LLUICtrl* ctrl, void *user_data)
  672. {
  673. LLFloaterTexturePicker* picker = (LLFloaterTexturePicker*)user_data;
  674. LLCheckBoxCtrl* check_box = (LLCheckBoxCtrl*)ctrl;
  675. gSavedSettings.setBOOL("ApplyTextureImmediately", check_box->get());
  676. picker->updateFilterPermMask();
  677. picker->commitIfImmediateSet();
  678. }
  679. void LLFloaterTexturePicker::updateFilterPermMask()
  680. {
  681. //mInventoryPanel->setFilterPermMask( getFilterPermMask() );  Commented out due to no-copy texture loss.
  682. }
  683. void LLFloaterTexturePicker::onFilterEdit(const std::string& search_string )
  684. {
  685. std::string upper_case_search_string = search_string;
  686. LLStringUtil::toUpper(upper_case_search_string);
  687. if (upper_case_search_string.empty())
  688. {
  689. if (mInventoryPanel->getFilterSubString().empty())
  690. {
  691. // current filter and new filter empty, do nothing
  692. return;
  693. }
  694. mSavedFolderState.setApply(TRUE);
  695. mInventoryPanel->getRootFolder()->applyFunctorRecursively(mSavedFolderState);
  696. // add folder with current item to list of previously opened folders
  697. LLOpenFoldersWithSelection opener;
  698. mInventoryPanel->getRootFolder()->applyFunctorRecursively(opener);
  699. mInventoryPanel->getRootFolder()->scrollToShowSelection();
  700. }
  701. else if (mInventoryPanel->getFilterSubString().empty())
  702. {
  703. // first letter in search term, save existing folder open state
  704. if (!mInventoryPanel->getRootFolder()->isFilterModified())
  705. {
  706. mSavedFolderState.setApply(FALSE);
  707. mInventoryPanel->getRootFolder()->applyFunctorRecursively(mSavedFolderState);
  708. }
  709. }
  710. mInventoryPanel->setFilterSubString(upper_case_search_string);
  711. }
  712. void LLFloaterTexturePicker::onTextureSelect( const LLTextureEntry& te )
  713. {
  714. LLUUID inventory_item_id = findItemID(te.getID(), TRUE);
  715. if (inventory_item_id.notNull())
  716. {
  717. LLToolPipette::getInstance()->setResult(TRUE, "");
  718. setImageID(te.getID());
  719. mNoCopyTextureSelected = FALSE;
  720. LLInventoryItem* itemp = gInventory.getItem(inventory_item_id);
  721. if (itemp && !itemp->getPermissions().allowCopyBy(gAgent.getID()))
  722. {
  723. // no copy texture
  724. mNoCopyTextureSelected = TRUE;
  725. }
  726. commitIfImmediateSet();
  727. }
  728. else
  729. {
  730. LLToolPipette::getInstance()->setResult(FALSE, LLTrans::getString("InventoryNoTexture"));
  731. }
  732. }
  733. ///////////////////////////////////////////////////////////////////////
  734. // LLTextureCtrl
  735. static LLDefaultChildRegistry::Register<LLTextureCtrl> r("texture_picker");
  736. LLTextureCtrl::LLTextureCtrl(const LLTextureCtrl::Params& p)
  737. : LLUICtrl(p),
  738. mDragCallback(NULL),
  739. mDropCallback(NULL),
  740. mOnCancelCallback(NULL),
  741. mOnSelectCallback(NULL),
  742. mBorderColor( p.border_color() ),
  743. mAllowNoTexture( FALSE ),
  744. mImmediateFilterPermMask( PERM_NONE ),
  745. mNonImmediateFilterPermMask( PERM_NONE ),
  746. mCanApplyImmediately( FALSE ),
  747. mNeedsRawImageData( FALSE ),
  748. mValid( TRUE ),
  749. mShowLoadingPlaceholder( TRUE ),
  750. mImageAssetID(p.image_id),
  751. mDefaultImageAssetID(p.default_image_id),
  752. mDefaultImageName(p.default_image_name)
  753. {
  754. setAllowNoTexture(p.allow_no_texture);
  755. setCanApplyImmediately(p.can_apply_immediately);
  756. mCommitOnSelection = !p.no_commit_on_selection;
  757. LLTextBox::Params params(p.caption_text);
  758. params.name(p.label);
  759. params.rect(LLRect( 0, BTN_HEIGHT_SMALL, getRect().getWidth(), 0 ));
  760. params.initial_value(p.label());
  761. params.follows.flags(FOLLOWS_LEFT | FOLLOWS_RIGHT | FOLLOWS_BOTTOM);
  762. mCaption = LLUICtrlFactory::create<LLTextBox> (params);
  763. addChild( mCaption );
  764. S32 image_top = getRect().getHeight();
  765. S32 image_bottom = BTN_HEIGHT_SMALL;
  766. S32 image_middle = (image_top + image_bottom) / 2;
  767. S32 line_height = llround(LLFontGL::getFontSansSerifSmall()->getLineHeight());
  768. LLTextBox::Params tentative_label_p(p.multiselect_text);
  769. tentative_label_p.name("Multiple");
  770. tentative_label_p.rect(LLRect (0, image_middle + line_height / 2, getRect().getWidth(), image_middle - line_height / 2 ));
  771. tentative_label_p.follows.flags(FOLLOWS_ALL);
  772. mTentativeLabel = LLUICtrlFactory::create<LLTextBox> (tentative_label_p);
  773. addChild( mTentativeLabel );
  774. LLRect border_rect = getLocalRect();
  775. border_rect.mBottom += BTN_HEIGHT_SMALL;
  776. LLViewBorder::Params vbparams(p.border);
  777. vbparams.name("border");
  778. vbparams.rect(border_rect);
  779. mBorder = LLUICtrlFactory::create<LLViewBorder> (vbparams);
  780. addChild(mBorder);
  781. mLoadingPlaceholderString = LLTrans::getString("texture_loading");
  782. }
  783. LLTextureCtrl::~LLTextureCtrl()
  784. {
  785. closeDependentFloater();
  786. }
  787. void LLTextureCtrl::setShowLoadingPlaceholder(BOOL showLoadingPlaceholder)
  788. {
  789. mShowLoadingPlaceholder = showLoadingPlaceholder;
  790. }
  791. void LLTextureCtrl::setCaption(const std::string& caption)
  792. {
  793. mCaption->setText( caption );
  794. }
  795. void LLTextureCtrl::setCanApplyImmediately(BOOL b)
  796. {
  797. mCanApplyImmediately = b; 
  798. LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterHandle.get();
  799. if( floaterp )
  800. {
  801. floaterp->setCanApplyImmediately(b);
  802. }
  803. }
  804. void LLTextureCtrl::setVisible( BOOL visible ) 
  805. {
  806. if( !visible )
  807. {
  808. closeDependentFloater();
  809. }
  810. LLUICtrl::setVisible( visible );
  811. }
  812. void LLTextureCtrl::setEnabled( BOOL enabled )
  813. {
  814. LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterHandle.get();
  815. if( enabled )
  816. {
  817. std::string tooltip;
  818. if (floaterp) tooltip = floaterp->getString("choose_picture");
  819. setToolTip( tooltip );
  820. }
  821. else
  822. {
  823. setToolTip( std::string() );
  824. // *TODO: would be better to keep floater open and show
  825. // disabled state.
  826. closeDependentFloater();
  827. }
  828. if( floaterp )
  829. {
  830. floaterp->setActive(enabled);
  831. }
  832. mCaption->setEnabled( enabled );
  833. LLView::setEnabled( enabled );
  834. }
  835. void LLTextureCtrl::setValid(BOOL valid )
  836. {
  837. mValid = valid;
  838. if (!valid)
  839. {
  840. LLFloaterTexturePicker* pickerp = (LLFloaterTexturePicker*)mFloaterHandle.get();
  841. if (pickerp)
  842. {
  843. pickerp->setActive(FALSE);
  844. }
  845. }
  846. }
  847. // virtual
  848. void LLTextureCtrl::clear()
  849. {
  850. setImageAssetID(LLUUID::null);
  851. }
  852. void LLTextureCtrl::setLabel(const std::string& label)
  853. {
  854. mLabel = label;
  855. mCaption->setText(label);
  856. }
  857. void LLTextureCtrl::showPicker(BOOL take_focus)
  858. {
  859. // show hourglass cursor when loading inventory window
  860. // because inventory construction is slooow
  861. getWindow()->setCursor(UI_CURSOR_WAIT);
  862. LLFloater* floaterp = mFloaterHandle.get();
  863. // Show the dialog
  864. if( floaterp )
  865. {
  866. floaterp->openFloater();
  867. }
  868. else
  869. {
  870. floaterp = new LLFloaterTexturePicker(
  871. this,
  872. mLabel,
  873. mImmediateFilterPermMask,
  874. mNonImmediateFilterPermMask,
  875. mCanApplyImmediately,
  876. mFallbackImageName);
  877. mFloaterHandle = floaterp->getHandle();
  878. LLFloater* root_floater = gFloaterView->getParentFloater(this);
  879. if (root_floater)
  880. root_floater->addDependentFloater(floaterp);
  881. floaterp->openFloater();
  882. }
  883. if (take_focus)
  884. {
  885. floaterp->setFocus(TRUE);
  886. }
  887. }
  888. void LLTextureCtrl::closeDependentFloater()
  889. {
  890. LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterHandle.get();
  891. if( floaterp )
  892. {
  893. floaterp->setOwner(NULL);
  894. floaterp->closeFloater();
  895. }
  896. }
  897. // Allow us to download textures quickly when floater is shown
  898. class LLTextureFetchDescendentsObserver : public LLInventoryFetchDescendentsObserver
  899. {
  900. public:
  901. virtual void done()
  902. {
  903. // We need to find textures in all folders, so get the main
  904. // background download going.
  905. gInventory.startBackgroundFetch();
  906. gInventory.removeObserver(this);
  907. delete this;
  908. }
  909. };
  910. BOOL LLTextureCtrl::handleHover(S32 x, S32 y, MASK mask)
  911. {
  912. getWindow()->setCursor(UI_CURSOR_HAND);
  913. return TRUE;
  914. }
  915. BOOL LLTextureCtrl::handleMouseDown(S32 x, S32 y, MASK mask)
  916. {
  917. BOOL handled = LLUICtrl::handleMouseDown( x, y , mask );
  918. if( !handled )
  919. {
  920. showPicker(FALSE);
  921. //grab textures first...
  922. gInventory.startBackgroundFetch(gInventory.findCategoryUUIDForType(LLFolderType::FT_TEXTURE));
  923. //...then start full inventory fetch.
  924. gInventory.startBackgroundFetch();
  925. handled = TRUE;
  926. }
  927. return handled;
  928. }
  929. void LLTextureCtrl::onFloaterClose()
  930. {
  931. LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterHandle.get();
  932. if (floaterp)
  933. {
  934. floaterp->setOwner(NULL);
  935. }
  936. mFloaterHandle.markDead();
  937. }
  938. void LLTextureCtrl::onFloaterCommit(ETexturePickOp op)
  939. {
  940. LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterHandle.get();
  941. if( floaterp && getEnabled())
  942. {
  943. if (op == TEXTURE_CANCEL)
  944. mViewModel->resetDirty();
  945. // If the "no_commit_on_selection" parameter is set
  946. // we get dirty only when user presses OK in the picker
  947. // (i.e. op == TEXTURE_SELECT) or texture changes via DnD.
  948. else if (mCommitOnSelection || op == TEXTURE_SELECT)
  949. mViewModel->setDirty(); // *TODO: shouldn't we be using setValue() here?
  950. if( floaterp->isDirty() )
  951. {
  952. setTentative( FALSE );
  953. mImageItemID = floaterp->findItemID(floaterp->getAssetID(), FALSE);
  954. lldebugs << "mImageItemID: " << mImageItemID << llendl;
  955. mImageAssetID = floaterp->getAssetID();
  956. lldebugs << "mImageAssetID: " << mImageAssetID << llendl;
  957. if (op == TEXTURE_SELECT && mOnSelectCallback)
  958. {
  959. mOnSelectCallback( this, LLSD() );
  960. }
  961. else if (op == TEXTURE_CANCEL && mOnCancelCallback)
  962. {
  963. mOnCancelCallback( this, LLSD() );
  964. }
  965. else
  966. {
  967. // If the "no_commit_on_selection" parameter is set
  968. // we commit only when user presses OK in the picker
  969. // (i.e. op == TEXTURE_SELECT) or texture changes via DnD.
  970. if (mCommitOnSelection || op == TEXTURE_SELECT)
  971. onCommit();
  972. }
  973. }
  974. }
  975. }
  976. void LLTextureCtrl::setImageAssetID( const LLUUID& asset_id )
  977. {
  978. if( mImageAssetID != asset_id )
  979. {
  980. mImageItemID.setNull();
  981. mImageAssetID = asset_id;
  982. LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterHandle.get();
  983. if( floaterp && getEnabled() )
  984. {
  985. floaterp->setImageID( asset_id );
  986. floaterp->resetDirty();
  987. }
  988. }
  989. }
  990. BOOL LLTextureCtrl::handleDragAndDrop(S32 x, S32 y, MASK mask,
  991.   BOOL drop, EDragAndDropType cargo_type, void *cargo_data,
  992.   EAcceptance *accept,
  993.   std::string& tooltip_msg)
  994. {
  995. BOOL handled = FALSE;
  996. // this downcast may be invalid - but if the second test below
  997. // returns true, then the cast was valid, and we can perform
  998. // the third test without problems.
  999. LLInventoryItem* item = (LLInventoryItem*)cargo_data; 
  1000. if (getEnabled() && (cargo_type == DAD_TEXTURE) && allowDrop(item))
  1001. {
  1002. if (drop)
  1003. {
  1004. if(doDrop(item))
  1005. {
  1006. if (!mCommitOnSelection)
  1007. mViewModel->setDirty();
  1008. // This removes the 'Multiple' overlay, since
  1009. // there is now only one texture selected.
  1010. setTentative( FALSE ); 
  1011. onCommit();
  1012. }
  1013. }
  1014. *accept = ACCEPT_YES_SINGLE;
  1015. }
  1016. else
  1017. {
  1018. *accept = ACCEPT_NO;
  1019. }
  1020. handled = TRUE;
  1021. lldebugst(LLERR_USER_INPUT) << "dragAndDrop handled by LLTextureCtrl " << getName() << llendl;
  1022. return handled;
  1023. }
  1024. void LLTextureCtrl::draw()
  1025. {
  1026. mBorder->setKeyboardFocusHighlight(hasFocus());
  1027. if (!mValid)
  1028. {
  1029. mTexturep = NULL;
  1030. }
  1031. else if (!mImageAssetID.isNull())
  1032. {
  1033. LLPointer<LLViewerFetchedTexture> texture = LLViewerTextureManager::getFetchedTexture(mImageAssetID, MIPMAP_YES,LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE);
  1034. texture->setBoostLevel(LLViewerTexture::BOOST_PREVIEW);
  1035. texture->forceToSaveRawImage(0) ;
  1036. mTexturep = texture;
  1037. }
  1038. else if (!mFallbackImageName.empty())
  1039. {
  1040. // Show fallback image.
  1041. mTexturep = LLViewerTextureManager::getFetchedTextureFromFile(mFallbackImageName);
  1042. mTexturep->setBoostLevel(LLViewerTexture::BOOST_PREVIEW);
  1043. }
  1044. else//mImageAssetID == LLUUID::null
  1045. {
  1046. mTexturep = NULL;
  1047. }
  1048. // Border
  1049. LLRect border( 0, getRect().getHeight(), getRect().getWidth(), BTN_HEIGHT_SMALL );
  1050. gl_rect_2d( border, mBorderColor.get(), FALSE );
  1051. // Interior
  1052. LLRect interior = border;
  1053. interior.stretch( -1 ); 
  1054. if( mTexturep )
  1055. {
  1056. if( mTexturep->getComponents() == 4 )
  1057. {
  1058. gl_rect_2d_checkerboard( interior );
  1059. }
  1060. gl_draw_scaled_image( interior.mLeft, interior.mBottom, interior.getWidth(), interior.getHeight(), mTexturep);
  1061. mTexturep->addTextureStats( (F32)(interior.getWidth() * interior.getHeight()) );
  1062. }
  1063. else
  1064. {
  1065. gl_rect_2d( interior, LLColor4::grey, TRUE );
  1066. // Draw X
  1067. gl_draw_x( interior, LLColor4::black );
  1068. }
  1069. mTentativeLabel->setVisible( !mTexturep.isNull() && getTentative() );
  1070. // Show "Loading..." string on the top left corner while this texture is loading.
  1071. // Using the discard level, do not show the string if the texture is almost but not 
  1072. // fully loaded.
  1073. if ( mTexturep.notNull() &&
  1074.  (!mTexturep->isFullyLoaded()) &&
  1075.  (mShowLoadingPlaceholder == TRUE) && 
  1076.  (mTexturep->getDiscardLevel() != 1) &&
  1077.  (mTexturep->getDiscardLevel() != 0))
  1078. {
  1079. LLFontGL* font = LLFontGL::getFontSansSerif();
  1080. font->renderUTF8(
  1081. mLoadingPlaceholderString, 0,
  1082. llfloor(interior.mLeft+3), 
  1083. llfloor(interior.mTop-25),
  1084. LLColor4::white,
  1085. LLFontGL::LEFT,
  1086. LLFontGL::BASELINE,
  1087. LLFontGL::DROP_SHADOW);
  1088. }
  1089. LLUICtrl::draw();
  1090. }
  1091. BOOL LLTextureCtrl::allowDrop(LLInventoryItem* item)
  1092. {
  1093. BOOL copy = item->getPermissions().allowCopyBy(gAgent.getID());
  1094. BOOL mod = item->getPermissions().allowModifyBy(gAgent.getID());
  1095. BOOL xfer = item->getPermissions().allowOperationBy(PERM_TRANSFER,
  1096. gAgent.getID());
  1097. PermissionMask item_perm_mask = 0;
  1098. if (copy) item_perm_mask |= PERM_COPY;
  1099. if (mod)  item_perm_mask |= PERM_MODIFY;
  1100. if (xfer) item_perm_mask |= PERM_TRANSFER;
  1101. // PermissionMask filter_perm_mask = mCanApplyImmediately ? commented out due to no-copy texture loss.
  1102. // mImmediateFilterPermMask : mNonImmediateFilterPermMask;
  1103. PermissionMask filter_perm_mask = mImmediateFilterPermMask;
  1104. if ( (item_perm_mask & filter_perm_mask) == filter_perm_mask )
  1105. {
  1106. if(mDragCallback)
  1107. {
  1108. return mDragCallback(this, item);
  1109. }
  1110. else
  1111. {
  1112. return TRUE;
  1113. }
  1114. }
  1115. else
  1116. {
  1117. return FALSE;
  1118. }
  1119. }
  1120. BOOL LLTextureCtrl::doDrop(LLInventoryItem* item)
  1121. {
  1122. // call the callback if it exists.
  1123. if(mDropCallback)
  1124. {
  1125. // if it returns TRUE, we return TRUE, and therefore the
  1126. // commit is called above.
  1127. return mDropCallback(this, item);
  1128. }
  1129. // no callback installed, so just set the image ids and carry on.
  1130. setImageAssetID( item->getAssetUUID() );
  1131. mImageItemID = item->getUUID();
  1132. return TRUE;
  1133. }
  1134. BOOL LLTextureCtrl::handleUnicodeCharHere(llwchar uni_char)
  1135. {
  1136. if( ' ' == uni_char )
  1137. {
  1138. showPicker(TRUE);
  1139. return TRUE;
  1140. }
  1141. return LLUICtrl::handleUnicodeCharHere(uni_char);
  1142. }
  1143. void LLTextureCtrl::setValue( const LLSD& value )
  1144. {
  1145. setImageAssetID(value.asUUID());
  1146. }
  1147. LLSD LLTextureCtrl::getValue() const
  1148. {
  1149. return LLSD(getImageAssetID());
  1150. }