PageRenderTime 144ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 1ms

/indra/newview/llfloatertools.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 1930 lines | 1471 code | 274 blank | 185 comment | 296 complexity | 070352a9ccc929d05d8b6459d20b9a0a MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llfloatertools.cpp
  3. * @brief The edit tools, including move, position, land, etc.
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #include "llviewerprecompiledheaders.h"
  27. #include "llfloatertools.h"
  28. #include "llfontgl.h"
  29. #include "llcoord.h"
  30. //#include "llgl.h"
  31. #include "llagent.h"
  32. #include "llagentcamera.h"
  33. #include "llbutton.h"
  34. #include "llcheckboxctrl.h"
  35. #include "lldraghandle.h"
  36. #include "llerror.h"
  37. #include "llfloaterbuildoptions.h"
  38. #include "llfloatermediasettings.h"
  39. #include "llfloateropenobject.h"
  40. #include "llfloaterobjectweights.h"
  41. #include "llfloaterreg.h"
  42. #include "llfocusmgr.h"
  43. #include "llmediaentry.h"
  44. #include "llmediactrl.h"
  45. #include "llmenugl.h"
  46. #include "llnotificationsutil.h"
  47. #include "llpanelcontents.h"
  48. #include "llpanelface.h"
  49. #include "llpanelland.h"
  50. #include "llpanelobjectinventory.h"
  51. #include "llpanelobject.h"
  52. #include "llpanelvolume.h"
  53. #include "llpanelpermissions.h"
  54. #include "llparcel.h"
  55. #include "llradiogroup.h"
  56. #include "llresmgr.h"
  57. #include "llselectmgr.h"
  58. #include "llslider.h"
  59. #include "llstatusbar.h"
  60. #include "lltabcontainer.h"
  61. #include "lltextbox.h"
  62. #include "lltoolbrush.h"
  63. #include "lltoolcomp.h"
  64. #include "lltooldraganddrop.h"
  65. #include "lltoolface.h"
  66. #include "lltoolfocus.h"
  67. #include "lltoolgrab.h"
  68. #include "lltoolgrab.h"
  69. #include "lltoolindividual.h"
  70. #include "lltoolmgr.h"
  71. #include "lltoolpie.h"
  72. #include "lltoolpipette.h"
  73. #include "lltoolplacer.h"
  74. #include "lltoolselectland.h"
  75. #include "lltrans.h"
  76. #include "llui.h"
  77. #include "llviewercontrol.h"
  78. #include "llviewerjoystick.h"
  79. #include "llviewerregion.h"
  80. #include "llviewermenu.h"
  81. #include "llviewerparcelmgr.h"
  82. #include "llviewerwindow.h"
  83. #include "llvovolume.h"
  84. #include "lluictrlfactory.h"
  85. #include "llmeshrepository.h"
  86. // Globals
  87. LLFloaterTools *gFloaterTools = NULL;
  88. bool LLFloaterTools::sShowObjectCost = true;
  89. const std::string PANEL_NAMES[LLFloaterTools::PANEL_COUNT] =
  90. {
  91. std::string("General"), // PANEL_GENERAL,
  92. std::string("Object"), // PANEL_OBJECT,
  93. std::string("Features"), // PANEL_FEATURES,
  94. std::string("Texture"), // PANEL_FACE,
  95. std::string("Content"), // PANEL_CONTENTS,
  96. };
  97. // Local prototypes
  98. void commit_select_component(void *data);
  99. void click_show_more(void*);
  100. void click_popup_info(void*);
  101. void click_popup_done(void*);
  102. void click_popup_minimize(void*);
  103. void click_popup_rotate_left(void*);
  104. void click_popup_rotate_reset(void*);
  105. void click_popup_rotate_right(void*);
  106. void commit_slider_dozer_force(LLUICtrl *);
  107. void click_apply_to_selection(void*);
  108. void commit_radio_group_focus(LLUICtrl* ctrl);
  109. void commit_radio_group_move(LLUICtrl* ctrl);
  110. void commit_radio_group_edit(LLUICtrl* ctrl);
  111. void commit_radio_group_land(LLUICtrl* ctrl);
  112. void commit_slider_zoom(LLUICtrl *ctrl);
  113. /**
  114. * Class LLLandImpactsObserver
  115. *
  116. * An observer class to monitor parcel selection and update
  117. * the land impacts data from a parcel containing the selected object.
  118. */
  119. class LLLandImpactsObserver : public LLParcelObserver
  120. {
  121. public:
  122. virtual void changed()
  123. {
  124. LLFloaterTools* tools_floater = LLFloaterReg::getTypedInstance<LLFloaterTools>("build");
  125. if(tools_floater)
  126. {
  127. tools_floater->updateLandImpacts();
  128. }
  129. }
  130. };
  131. //static
  132. void* LLFloaterTools::createPanelPermissions(void* data)
  133. {
  134. LLFloaterTools* floater = (LLFloaterTools*)data;
  135. floater->mPanelPermissions = new LLPanelPermissions();
  136. return floater->mPanelPermissions;
  137. }
  138. //static
  139. void* LLFloaterTools::createPanelObject(void* data)
  140. {
  141. LLFloaterTools* floater = (LLFloaterTools*)data;
  142. floater->mPanelObject = new LLPanelObject();
  143. return floater->mPanelObject;
  144. }
  145. //static
  146. void* LLFloaterTools::createPanelVolume(void* data)
  147. {
  148. LLFloaterTools* floater = (LLFloaterTools*)data;
  149. floater->mPanelVolume = new LLPanelVolume();
  150. return floater->mPanelVolume;
  151. }
  152. //static
  153. void* LLFloaterTools::createPanelFace(void* data)
  154. {
  155. LLFloaterTools* floater = (LLFloaterTools*)data;
  156. floater->mPanelFace = new LLPanelFace();
  157. return floater->mPanelFace;
  158. }
  159. //static
  160. void* LLFloaterTools::createPanelContents(void* data)
  161. {
  162. LLFloaterTools* floater = (LLFloaterTools*)data;
  163. floater->mPanelContents = new LLPanelContents();
  164. return floater->mPanelContents;
  165. }
  166. //static
  167. void* LLFloaterTools::createPanelLandInfo(void* data)
  168. {
  169. LLFloaterTools* floater = (LLFloaterTools*)data;
  170. floater->mPanelLandInfo = new LLPanelLandInfo();
  171. return floater->mPanelLandInfo;
  172. }
  173. static const std::string toolNames[]={
  174. "ToolCube",
  175. "ToolPrism",
  176. "ToolPyramid",
  177. "ToolTetrahedron",
  178. "ToolCylinder",
  179. "ToolHemiCylinder",
  180. "ToolCone",
  181. "ToolHemiCone",
  182. "ToolSphere",
  183. "ToolHemiSphere",
  184. "ToolTorus",
  185. "ToolTube",
  186. "ToolRing",
  187. "ToolTree",
  188. "ToolGrass"};
  189. LLPCode toolData[]={
  190. LL_PCODE_CUBE,
  191. LL_PCODE_PRISM,
  192. LL_PCODE_PYRAMID,
  193. LL_PCODE_TETRAHEDRON,
  194. LL_PCODE_CYLINDER,
  195. LL_PCODE_CYLINDER_HEMI,
  196. LL_PCODE_CONE,
  197. LL_PCODE_CONE_HEMI,
  198. LL_PCODE_SPHERE,
  199. LL_PCODE_SPHERE_HEMI,
  200. LL_PCODE_TORUS,
  201. LLViewerObject::LL_VO_SQUARE_TORUS,
  202. LLViewerObject::LL_VO_TRIANGLE_TORUS,
  203. LL_PCODE_LEGACY_TREE,
  204. LL_PCODE_LEGACY_GRASS};
  205. BOOL LLFloaterTools::postBuild()
  206. {
  207. // Hide until tool selected
  208. setVisible(FALSE);
  209. // Since we constantly show and hide this during drags, don't
  210. // make sounds on visibility changes.
  211. setSoundFlags(LLView::SILENT);
  212. getDragHandle()->setEnabled( !gSavedSettings.getBOOL("ToolboxAutoMove") );
  213. LLRect rect;
  214. mBtnFocus = getChild<LLButton>("button focus");//btn;
  215. mBtnMove = getChild<LLButton>("button move");
  216. mBtnEdit = getChild<LLButton>("button edit");
  217. mBtnCreate = getChild<LLButton>("button create");
  218. mBtnLand = getChild<LLButton>("button land" );
  219. mTextStatus = getChild<LLTextBox>("text status");
  220. mRadioGroupFocus = getChild<LLRadioGroup>("focus_radio_group");
  221. mRadioGroupMove = getChild<LLRadioGroup>("move_radio_group");
  222. mRadioGroupEdit = getChild<LLRadioGroup>("edit_radio_group");
  223. mBtnGridOptions = getChild<LLButton>("Options...");
  224. mTitleMedia = getChild<LLMediaCtrl>("title_media");
  225. mBtnLink = getChild<LLButton>("link_btn");
  226. mBtnUnlink = getChild<LLButton>("unlink_btn");
  227. mCheckSelectIndividual = getChild<LLCheckBoxCtrl>("checkbox edit linked parts");
  228. getChild<LLUICtrl>("checkbox edit linked parts")->setValue((BOOL)gSavedSettings.getBOOL("EditLinkedParts"));
  229. mCheckSnapToGrid = getChild<LLCheckBoxCtrl>("checkbox snap to grid");
  230. getChild<LLUICtrl>("checkbox snap to grid")->setValue((BOOL)gSavedSettings.getBOOL("SnapEnabled"));
  231. mCheckStretchUniform = getChild<LLCheckBoxCtrl>("checkbox uniform");
  232. getChild<LLUICtrl>("checkbox uniform")->setValue((BOOL)gSavedSettings.getBOOL("ScaleUniform"));
  233. mCheckStretchTexture = getChild<LLCheckBoxCtrl>("checkbox stretch textures");
  234. getChild<LLUICtrl>("checkbox stretch textures")->setValue((BOOL)gSavedSettings.getBOOL("ScaleStretchTextures"));
  235. mCheckStretchUniformLabel = getChild<LLTextBox>("checkbox uniform label");
  236. //
  237. // Create Buttons
  238. //
  239. for(size_t t=0; t<LL_ARRAY_SIZE(toolNames); ++t)
  240. {
  241. LLButton *found = getChild<LLButton>(toolNames[t]);
  242. if(found)
  243. {
  244. found->setClickedCallback(boost::bind(&LLFloaterTools::setObjectType, toolData[t]));
  245. mButtons.push_back( found );
  246. }else{
  247. llwarns << "Tool button not found! DOA Pending." << llendl;
  248. }
  249. }
  250. mCheckCopySelection = getChild<LLCheckBoxCtrl>("checkbox copy selection");
  251. getChild<LLUICtrl>("checkbox copy selection")->setValue((BOOL)gSavedSettings.getBOOL("CreateToolCopySelection"));
  252. mCheckSticky = getChild<LLCheckBoxCtrl>("checkbox sticky");
  253. getChild<LLUICtrl>("checkbox sticky")->setValue((BOOL)gSavedSettings.getBOOL("CreateToolKeepSelected"));
  254. mCheckCopyCenters = getChild<LLCheckBoxCtrl>("checkbox copy centers");
  255. getChild<LLUICtrl>("checkbox copy centers")->setValue((BOOL)gSavedSettings.getBOOL("CreateToolCopyCenters"));
  256. mCheckCopyRotates = getChild<LLCheckBoxCtrl>("checkbox copy rotates");
  257. getChild<LLUICtrl>("checkbox copy rotates")->setValue((BOOL)gSavedSettings.getBOOL("CreateToolCopyRotates"));
  258. mRadioGroupLand = getChild<LLRadioGroup>("land_radio_group");
  259. mBtnApplyToSelection = getChild<LLButton>("button apply to selection");
  260. mSliderDozerSize = getChild<LLSlider>("slider brush size");
  261. getChild<LLUICtrl>("slider brush size")->setValue(gSavedSettings.getF32("LandBrushSize"));
  262. mSliderDozerForce = getChild<LLSlider>("slider force");
  263. // the setting stores the actual force multiplier, but the slider is logarithmic, so we convert here
  264. getChild<LLUICtrl>("slider force")->setValue(log10(gSavedSettings.getF32("LandBrushForce")));
  265. mCostTextBorder = getChild<LLViewBorder>("cost_text_border");
  266. mTab = getChild<LLTabContainer>("Object Info Tabs");
  267. if(mTab)
  268. {
  269. mTab->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT);
  270. mTab->setBorderVisible(FALSE);
  271. mTab->selectFirstTab();
  272. }
  273. mStatusText["rotate"] = getString("status_rotate");
  274. mStatusText["scale"] = getString("status_scale");
  275. mStatusText["move"] = getString("status_move");
  276. mStatusText["modifyland"] = getString("status_modifyland");
  277. mStatusText["camera"] = getString("status_camera");
  278. mStatusText["grab"] = getString("status_grab");
  279. mStatusText["place"] = getString("status_place");
  280. mStatusText["selectland"] = getString("status_selectland");
  281. sShowObjectCost = gSavedSettings.getBOOL("ShowObjectRenderingCost");
  282. return TRUE;
  283. }
  284. // Create the popupview with a dummy center. It will be moved into place
  285. // during LLViewerWindow's per-frame hover processing.
  286. LLFloaterTools::LLFloaterTools(const LLSD& key)
  287. : LLFloater(key),
  288. mBtnFocus(NULL),
  289. mBtnMove(NULL),
  290. mBtnEdit(NULL),
  291. mBtnCreate(NULL),
  292. mBtnLand(NULL),
  293. mTextStatus(NULL),
  294. mRadioGroupFocus(NULL),
  295. mRadioGroupMove(NULL),
  296. mRadioGroupEdit(NULL),
  297. mCheckSelectIndividual(NULL),
  298. mCheckSnapToGrid(NULL),
  299. mBtnGridOptions(NULL),
  300. mTitleMedia(NULL),
  301. mCheckStretchUniform(NULL),
  302. mCheckStretchTexture(NULL),
  303. mCheckStretchUniformLabel(NULL),
  304. mBtnRotateLeft(NULL),
  305. mBtnRotateReset(NULL),
  306. mBtnRotateRight(NULL),
  307. mBtnLink(NULL),
  308. mBtnUnlink(NULL),
  309. mBtnDelete(NULL),
  310. mBtnDuplicate(NULL),
  311. mBtnDuplicateInPlace(NULL),
  312. mCheckSticky(NULL),
  313. mCheckCopySelection(NULL),
  314. mCheckCopyCenters(NULL),
  315. mCheckCopyRotates(NULL),
  316. mRadioGroupLand(NULL),
  317. mSliderDozerSize(NULL),
  318. mSliderDozerForce(NULL),
  319. mBtnApplyToSelection(NULL),
  320. mTab(NULL),
  321. mPanelPermissions(NULL),
  322. mPanelObject(NULL),
  323. mPanelVolume(NULL),
  324. mPanelContents(NULL),
  325. mPanelFace(NULL),
  326. mPanelLandInfo(NULL),
  327. mCostTextBorder(NULL),
  328. mTabLand(NULL),
  329. mLandImpactsObserver(NULL),
  330. mDirty(TRUE),
  331. mNeedMediaTitle(TRUE)
  332. {
  333. gFloaterTools = this;
  334. setAutoFocus(FALSE);
  335. mFactoryMap["General"] = LLCallbackMap(createPanelPermissions, this);//LLPanelPermissions
  336. mFactoryMap["Object"] = LLCallbackMap(createPanelObject, this);//LLPanelObject
  337. mFactoryMap["Features"] = LLCallbackMap(createPanelVolume, this);//LLPanelVolume
  338. mFactoryMap["Texture"] = LLCallbackMap(createPanelFace, this);//LLPanelFace
  339. mFactoryMap["Contents"] = LLCallbackMap(createPanelContents, this);//LLPanelContents
  340. mFactoryMap["land info panel"] = LLCallbackMap(createPanelLandInfo, this);//LLPanelLandInfo
  341. mCommitCallbackRegistrar.add("BuildTool.setTool", boost::bind(&LLFloaterTools::setTool,this, _2));
  342. mCommitCallbackRegistrar.add("BuildTool.commitZoom", boost::bind(&commit_slider_zoom, _1));
  343. mCommitCallbackRegistrar.add("BuildTool.commitRadioFocus", boost::bind(&commit_radio_group_focus, _1));
  344. mCommitCallbackRegistrar.add("BuildTool.commitRadioMove", boost::bind(&commit_radio_group_move,_1));
  345. mCommitCallbackRegistrar.add("BuildTool.commitRadioEdit", boost::bind(&commit_radio_group_edit,_1));
  346. mCommitCallbackRegistrar.add("BuildTool.selectComponent", boost::bind(&commit_select_component, this));
  347. mCommitCallbackRegistrar.add("BuildTool.gridOptions", boost::bind(&LLFloaterTools::onClickGridOptions,this));
  348. mCommitCallbackRegistrar.add("BuildTool.applyToSelection", boost::bind(&click_apply_to_selection, this));
  349. mCommitCallbackRegistrar.add("BuildTool.commitRadioLand", boost::bind(&commit_radio_group_land,_1));
  350. mCommitCallbackRegistrar.add("BuildTool.LandBrushForce", boost::bind(&commit_slider_dozer_force,_1));
  351. mCommitCallbackRegistrar.add("BuildTool.AddMedia", boost::bind(&LLFloaterTools::onClickBtnAddMedia,this));
  352. mCommitCallbackRegistrar.add("BuildTool.DeleteMedia", boost::bind(&LLFloaterTools::onClickBtnDeleteMedia,this));
  353. mCommitCallbackRegistrar.add("BuildTool.EditMedia", boost::bind(&LLFloaterTools::onClickBtnEditMedia,this));
  354. mCommitCallbackRegistrar.add("BuildTool.LinkObjects", boost::bind(&LLSelectMgr::linkObjects, LLSelectMgr::getInstance()));
  355. mCommitCallbackRegistrar.add("BuildTool.UnlinkObjects", boost::bind(&LLSelectMgr::unlinkObjects, LLSelectMgr::getInstance()));
  356. mLandImpactsObserver = new LLLandImpactsObserver();
  357. LLViewerParcelMgr::getInstance()->addObserver(mLandImpactsObserver);
  358. }
  359. LLFloaterTools::~LLFloaterTools()
  360. {
  361. // children automatically deleted
  362. gFloaterTools = NULL;
  363. LLViewerParcelMgr::getInstance()->removeObserver(mLandImpactsObserver);
  364. delete mLandImpactsObserver;
  365. }
  366. void LLFloaterTools::setStatusText(const std::string& text)
  367. {
  368. std::map<std::string, std::string>::iterator iter = mStatusText.find(text);
  369. if (iter != mStatusText.end())
  370. {
  371. mTextStatus->setText(iter->second);
  372. }
  373. else
  374. {
  375. mTextStatus->setText(text);
  376. }
  377. }
  378. void LLFloaterTools::refresh()
  379. {
  380. const S32 INFO_WIDTH = getRect().getWidth();
  381. const S32 INFO_HEIGHT = 384;
  382. LLRect object_info_rect(0, 0, INFO_WIDTH, -INFO_HEIGHT);
  383. BOOL all_volume = LLSelectMgr::getInstance()->selectionAllPCode( LL_PCODE_VOLUME );
  384. S32 idx_features = mTab->getPanelIndexByTitle(PANEL_NAMES[PANEL_FEATURES]);
  385. S32 idx_face = mTab->getPanelIndexByTitle(PANEL_NAMES[PANEL_FACE]);
  386. S32 idx_contents = mTab->getPanelIndexByTitle(PANEL_NAMES[PANEL_CONTENTS]);
  387. S32 selected_index = mTab->getCurrentPanelIndex();
  388. if (!all_volume && (selected_index == idx_features || selected_index == idx_face ||
  389. selected_index == idx_contents))
  390. {
  391. mTab->selectFirstTab();
  392. }
  393. mTab->enableTabButton(idx_features, all_volume);
  394. mTab->enableTabButton(idx_face, all_volume);
  395. mTab->enableTabButton(idx_contents, all_volume);
  396. // Refresh object and prim count labels
  397. LLLocale locale(LLLocale::USER_LOCALE);
  398. #if 0
  399. if (!gMeshRepo.meshRezEnabled())
  400. {
  401. std::string obj_count_string;
  402. LLResMgr::getInstance()->getIntegerString(obj_count_string, LLSelectMgr::getInstance()->getSelection()->getRootObjectCount());
  403. getChild<LLUICtrl>("selection_count")->setTextArg("[OBJ_COUNT]", obj_count_string);
  404. std::string prim_count_string;
  405. LLResMgr::getInstance()->getIntegerString(prim_count_string, LLSelectMgr::getInstance()->getSelection()->getObjectCount());
  406. getChild<LLUICtrl>("selection_count")->setTextArg("[PRIM_COUNT]", prim_count_string);
  407. // calculate selection rendering cost
  408. if (sShowObjectCost)
  409. {
  410. std::string prim_cost_string;
  411. S32 render_cost = LLSelectMgr::getInstance()->getSelection()->getSelectedObjectRenderCost();
  412. LLResMgr::getInstance()->getIntegerString(prim_cost_string, render_cost);
  413. getChild<LLUICtrl>("RenderingCost")->setTextArg("[COUNT]", prim_cost_string);
  414. }
  415. // disable the object and prim counts if nothing selected
  416. bool have_selection = ! LLSelectMgr::getInstance()->getSelection()->isEmpty();
  417. getChildView("obj_count")->setEnabled(have_selection);
  418. getChildView("prim_count")->setEnabled(have_selection);
  419. getChildView("RenderingCost")->setEnabled(have_selection && sShowObjectCost);
  420. }
  421. else
  422. #endif
  423. {
  424. F32 link_cost = LLSelectMgr::getInstance()->getSelection()->getSelectedLinksetCost();
  425. S32 link_count = LLSelectMgr::getInstance()->getSelection()->getRootObjectCount();
  426. LLCrossParcelFunctor func;
  427. if (LLSelectMgr::getInstance()->getSelection()->applyToRootObjects(&func, true))
  428. {
  429. // Selection crosses parcel bounds.
  430. // We don't display remaining land capacity in this case.
  431. const LLStringExplicit empty_str("");
  432. childSetTextArg("remaining_capacity", "[CAPACITY_STRING]", empty_str);
  433. }
  434. else
  435. {
  436. LLViewerObject* selected_object = mObjectSelection->getFirstObject();
  437. if (selected_object)
  438. {
  439. // Select a parcel at the currently selected object's position.
  440. LLViewerParcelMgr::getInstance()->selectParcelAt(selected_object->getPositionGlobal());
  441. }
  442. else
  443. {
  444. llwarns << "Failed to get selected object" << llendl;
  445. }
  446. }
  447. LLStringUtil::format_map_t selection_args;
  448. selection_args["OBJ_COUNT"] = llformat("%.1d", link_count);
  449. selection_args["LAND_IMPACT"] = llformat("%.1d", (S32)link_cost);
  450. std::ostringstream selection_info;
  451. selection_info << getString("status_selectcount", selection_args);
  452. getChild<LLTextBox>("selection_count")->setText(selection_info.str());
  453. bool have_selection = !LLSelectMgr::getInstance()->getSelection()->isEmpty();
  454. childSetVisible("selection_count", have_selection);
  455. childSetVisible("remaining_capacity", have_selection);
  456. childSetVisible("selection_empty", !have_selection);
  457. }
  458. // Refresh child tabs
  459. mPanelPermissions->refresh();
  460. mPanelObject->refresh();
  461. mPanelVolume->refresh();
  462. mPanelFace->refresh();
  463. refreshMedia();
  464. mPanelContents->refresh();
  465. mPanelLandInfo->refresh();
  466. // Refresh the advanced weights floater
  467. LLFloaterObjectWeights* object_weights_floater = LLFloaterReg::findTypedInstance<LLFloaterObjectWeights>("object_weights");
  468. if(object_weights_floater && object_weights_floater->getVisible())
  469. {
  470. object_weights_floater->refresh();
  471. }
  472. }
  473. void LLFloaterTools::draw()
  474. {
  475. if (mDirty)
  476. {
  477. refresh();
  478. mDirty = FALSE;
  479. }
  480. // grab media name/title and update the UI widget
  481. updateMediaTitle();
  482. // mCheckSelectIndividual->set(gSavedSettings.getBOOL("EditLinkedParts"));
  483. LLFloater::draw();
  484. }
  485. void LLFloaterTools::dirty()
  486. {
  487. mDirty = TRUE;
  488. LLFloaterOpenObject* instance = LLFloaterReg::findTypedInstance<LLFloaterOpenObject>("openobject");
  489. if (instance) instance->dirty();
  490. }
  491. // Clean up any tool state that should not persist when the
  492. // floater is closed.
  493. void LLFloaterTools::resetToolState()
  494. {
  495. gCameraBtnZoom = TRUE;
  496. gCameraBtnOrbit = FALSE;
  497. gCameraBtnPan = FALSE;
  498. gGrabBtnSpin = FALSE;
  499. gGrabBtnVertical = FALSE;
  500. }
  501. void LLFloaterTools::updatePopup(LLCoordGL center, MASK mask)
  502. {
  503. LLTool *tool = LLToolMgr::getInstance()->getCurrentTool();
  504. // HACK to allow seeing the buttons when you have the app in a window.
  505. // Keep the visibility the same as it
  506. if (tool == gToolNull)
  507. {
  508. return;
  509. }
  510. if ( isMinimized() )
  511. { // SL looks odd if we draw the tools while the window is minimized
  512. return;
  513. }
  514. // Focus buttons
  515. BOOL focus_visible = ( tool == LLToolCamera::getInstance() );
  516. mBtnFocus ->setToggleState( focus_visible );
  517. mRadioGroupFocus->setVisible( focus_visible );
  518. getChildView("slider zoom")->setVisible( focus_visible);
  519. getChildView("slider zoom")->setEnabled(gCameraBtnZoom);
  520. if (!gCameraBtnOrbit &&
  521. !gCameraBtnPan &&
  522. !(mask == MASK_ORBIT) &&
  523. !(mask == (MASK_ORBIT | MASK_ALT)) &&
  524. !(mask == MASK_PAN) &&
  525. !(mask == (MASK_PAN | MASK_ALT)) )
  526. {
  527. mRadioGroupFocus->setValue("radio zoom");
  528. }
  529. else if ( gCameraBtnOrbit ||
  530. (mask == MASK_ORBIT) ||
  531. (mask == (MASK_ORBIT | MASK_ALT)) )
  532. {
  533. mRadioGroupFocus->setValue("radio orbit");
  534. }
  535. else if ( gCameraBtnPan ||
  536. (mask == MASK_PAN) ||
  537. (mask == (MASK_PAN | MASK_ALT)) )
  538. {
  539. mRadioGroupFocus->setValue("radio pan");
  540. }
  541. // multiply by correction factor because volume sliders go [0, 0.5]
  542. getChild<LLUICtrl>("slider zoom")->setValue(gAgentCamera.getCameraZoomFraction() * 0.5f);
  543. // Move buttons
  544. BOOL move_visible = (tool == LLToolGrab::getInstance());
  545. if (mBtnMove) mBtnMove ->setToggleState( move_visible );
  546. // HACK - highlight buttons for next click
  547. mRadioGroupMove->setVisible(move_visible);
  548. if (!gGrabBtnSpin &&
  549. !gGrabBtnVertical &&
  550. !(mask == MASK_VERTICAL) &&
  551. !(mask == MASK_SPIN) )
  552. {
  553. mRadioGroupMove->setValue("radio move");
  554. }
  555. else if (gGrabBtnVertical ||
  556. (mask == MASK_VERTICAL) )
  557. {
  558. mRadioGroupMove->setValue("radio lift");
  559. }
  560. else if (gGrabBtnSpin ||
  561. (mask == MASK_SPIN) )
  562. {
  563. mRadioGroupMove->setValue("radio spin");
  564. }
  565. // Edit buttons
  566. BOOL edit_visible = tool == LLToolCompTranslate::getInstance() ||
  567. tool == LLToolCompRotate::getInstance() ||
  568. tool == LLToolCompScale::getInstance() ||
  569. tool == LLToolFace::getInstance() ||
  570. tool == LLToolIndividual::getInstance() ||
  571. tool == LLToolPipette::getInstance();
  572. mBtnEdit ->setToggleState( edit_visible );
  573. mRadioGroupEdit->setVisible( edit_visible );
  574. bool linked_parts = gSavedSettings.getBOOL("EditLinkedParts");
  575. getChildView("RenderingCost")->setVisible( !linked_parts && (edit_visible || focus_visible || move_visible) && sShowObjectCost);
  576. mBtnLink->setVisible(edit_visible);
  577. mBtnUnlink->setVisible(edit_visible);
  578. mBtnLink->setEnabled(LLSelectMgr::instance().enableLinkObjects());
  579. mBtnUnlink->setEnabled(LLSelectMgr::instance().enableUnlinkObjects());
  580. if (mCheckSelectIndividual)
  581. {
  582. mCheckSelectIndividual->setVisible(edit_visible);
  583. //mCheckSelectIndividual->set(gSavedSettings.getBOOL("EditLinkedParts"));
  584. }
  585. if ( tool == LLToolCompTranslate::getInstance() )
  586. {
  587. mRadioGroupEdit->setValue("radio position");
  588. }
  589. else if ( tool == LLToolCompRotate::getInstance() )
  590. {
  591. mRadioGroupEdit->setValue("radio rotate");
  592. }
  593. else if ( tool == LLToolCompScale::getInstance() )
  594. {
  595. mRadioGroupEdit->setValue("radio stretch");
  596. }
  597. else if ( tool == LLToolFace::getInstance() )
  598. {
  599. mRadioGroupEdit->setValue("radio select face");
  600. }
  601. // Snap to grid disabled for grab tool - very confusing
  602. if (mCheckSnapToGrid) mCheckSnapToGrid->setVisible( edit_visible /* || tool == LLToolGrab::getInstance() */ );
  603. if (mBtnGridOptions) mBtnGridOptions->setVisible( edit_visible /* || tool == LLToolGrab::getInstance() */ );
  604. //mCheckSelectLinked ->setVisible( edit_visible );
  605. if (mCheckStretchUniform) mCheckStretchUniform->setVisible( edit_visible );
  606. if (mCheckStretchTexture) mCheckStretchTexture->setVisible( edit_visible );
  607. if (mCheckStretchUniformLabel) mCheckStretchUniformLabel->setVisible( edit_visible );
  608. // Create buttons
  609. BOOL create_visible = (tool == LLToolCompCreate::getInstance());
  610. mBtnCreate ->setToggleState( tool == LLToolCompCreate::getInstance() );
  611. if (mCheckCopySelection
  612. && mCheckCopySelection->get())
  613. {
  614. // don't highlight any placer button
  615. for (std::vector<LLButton*>::size_type i = 0; i < mButtons.size(); i++)
  616. {
  617. mButtons[i]->setToggleState(FALSE);
  618. mButtons[i]->setVisible( create_visible );
  619. }
  620. }
  621. else
  622. {
  623. // Highlight the correct placer button
  624. for( S32 t = 0; t < (S32)mButtons.size(); t++ )
  625. {
  626. LLPCode pcode = LLToolPlacer::getObjectType();
  627. LLPCode button_pcode = toolData[t];
  628. BOOL state = (pcode == button_pcode);
  629. mButtons[t]->setToggleState( state );
  630. mButtons[t]->setVisible( create_visible );
  631. }
  632. }
  633. if (mCheckSticky) mCheckSticky ->setVisible( create_visible );
  634. if (mCheckCopySelection) mCheckCopySelection ->setVisible( create_visible );
  635. if (mCheckCopyCenters) mCheckCopyCenters ->setVisible( create_visible );
  636. if (mCheckCopyRotates) mCheckCopyRotates ->setVisible( create_visible );
  637. if (mCheckCopyCenters && mCheckCopySelection) mCheckCopyCenters->setEnabled( mCheckCopySelection->get() );
  638. if (mCheckCopyRotates && mCheckCopySelection) mCheckCopyRotates->setEnabled( mCheckCopySelection->get() );
  639. // Land buttons
  640. BOOL land_visible = (tool == LLToolBrushLand::getInstance() || tool == LLToolSelectLand::getInstance() );
  641. mCostTextBorder->setVisible(!land_visible);
  642. if (mBtnLand) mBtnLand ->setToggleState( land_visible );
  643. mRadioGroupLand->setVisible( land_visible );
  644. if ( tool == LLToolSelectLand::getInstance() )
  645. {
  646. mRadioGroupLand->setValue("radio select land");
  647. }
  648. else if ( tool == LLToolBrushLand::getInstance() )
  649. {
  650. S32 dozer_mode = gSavedSettings.getS32("RadioLandBrushAction");
  651. switch(dozer_mode)
  652. {
  653. case 0:
  654. mRadioGroupLand->setValue("radio flatten");
  655. break;
  656. case 1:
  657. mRadioGroupLand->setValue("radio raise");
  658. break;
  659. case 2:
  660. mRadioGroupLand->setValue("radio lower");
  661. break;
  662. case 3:
  663. mRadioGroupLand->setValue("radio smooth");
  664. break;
  665. case 4:
  666. mRadioGroupLand->setValue("radio noise");
  667. break;
  668. case 5:
  669. mRadioGroupLand->setValue("radio revert");
  670. break;
  671. default:
  672. break;
  673. }
  674. }
  675. if (mBtnApplyToSelection)
  676. {
  677. mBtnApplyToSelection->setVisible( land_visible );
  678. mBtnApplyToSelection->setEnabled( land_visible && !LLViewerParcelMgr::getInstance()->selectionEmpty() && tool != LLToolSelectLand::getInstance());
  679. }
  680. if (mSliderDozerSize)
  681. {
  682. mSliderDozerSize ->setVisible( land_visible );
  683. getChildView("Bulldozer:")->setVisible( land_visible);
  684. getChildView("Dozer Size:")->setVisible( land_visible);
  685. }
  686. if (mSliderDozerForce)
  687. {
  688. mSliderDozerForce ->setVisible( land_visible );
  689. getChildView("Strength:")->setVisible( land_visible);
  690. }
  691. bool have_selection = !LLSelectMgr::getInstance()->getSelection()->isEmpty();
  692. getChildView("selection_count")->setVisible(!land_visible && have_selection);
  693. getChildView("remaining_capacity")->setVisible(!land_visible && have_selection);
  694. getChildView("selection_empty")->setVisible(!land_visible && !have_selection);
  695. mTab->setVisible(!land_visible);
  696. mPanelLandInfo->setVisible(land_visible);
  697. }
  698. // virtual
  699. BOOL LLFloaterTools::canClose()
  700. {
  701. // don't close when quitting, so camera will stay put
  702. return !LLApp::isExiting();
  703. }
  704. // virtual
  705. void LLFloaterTools::onOpen(const LLSD& key)
  706. {
  707. mParcelSelection = LLViewerParcelMgr::getInstance()->getFloatingParcelSelection();
  708. mObjectSelection = LLSelectMgr::getInstance()->getEditSelection();
  709. std::string panel = key.asString();
  710. if (!panel.empty())
  711. {
  712. mTab->selectTabByName(panel);
  713. }
  714. //gMenuBarView->setItemVisible("BuildTools", TRUE);
  715. }
  716. // virtual
  717. void LLFloaterTools::onClose(bool app_quitting)
  718. {
  719. mTab->setVisible(FALSE);
  720. LLViewerJoystick::getInstance()->moveAvatar(false);
  721. // destroy media source used to grab media title
  722. if( mTitleMedia )
  723. mTitleMedia->unloadMediaSource();
  724. // Different from handle_reset_view in that it doesn't actually
  725. // move the camera if EditCameraMovement is not set.
  726. gAgentCamera.resetView(gSavedSettings.getBOOL("EditCameraMovement"));
  727. // exit component selection mode
  728. LLSelectMgr::getInstance()->promoteSelectionToRoot();
  729. gSavedSettings.setBOOL("EditLinkedParts", FALSE);
  730. gViewerWindow->showCursor();
  731. resetToolState();
  732. mParcelSelection = NULL;
  733. mObjectSelection = NULL;
  734. // Switch back to basic toolset
  735. LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset);
  736. // we were already in basic toolset, using build tools
  737. // so manually reset tool to default (pie menu tool)
  738. LLToolMgr::getInstance()->getCurrentToolset()->selectFirstTool();
  739. //gMenuBarView->setItemVisible("BuildTools", FALSE);
  740. LLFloaterReg::hideInstance("media_settings");
  741. // hide the advanced object weights floater
  742. LLFloaterReg::hideInstance("object_weights");
  743. }
  744. void click_popup_info(void*)
  745. {
  746. }
  747. void click_popup_done(void*)
  748. {
  749. handle_reset_view();
  750. }
  751. void commit_radio_group_move(LLUICtrl* ctrl)
  752. {
  753. LLRadioGroup* group = (LLRadioGroup*)ctrl;
  754. std::string selected = group->getValue().asString();
  755. if (selected == "radio move")
  756. {
  757. gGrabBtnVertical = FALSE;
  758. gGrabBtnSpin = FALSE;
  759. }
  760. else if (selected == "radio lift")
  761. {
  762. gGrabBtnVertical = TRUE;
  763. gGrabBtnSpin = FALSE;
  764. }
  765. else if (selected == "radio spin")
  766. {
  767. gGrabBtnVertical = FALSE;
  768. gGrabBtnSpin = TRUE;
  769. }
  770. }
  771. void commit_radio_group_focus(LLUICtrl* ctrl)
  772. {
  773. LLRadioGroup* group = (LLRadioGroup*)ctrl;
  774. std::string selected = group->getValue().asString();
  775. if (selected == "radio zoom")
  776. {
  777. gCameraBtnZoom = TRUE;
  778. gCameraBtnOrbit = FALSE;
  779. gCameraBtnPan = FALSE;
  780. }
  781. else if (selected == "radio orbit")
  782. {
  783. gCameraBtnZoom = FALSE;
  784. gCameraBtnOrbit = TRUE;
  785. gCameraBtnPan = FALSE;
  786. }
  787. else if (selected == "radio pan")
  788. {
  789. gCameraBtnZoom = FALSE;
  790. gCameraBtnOrbit = FALSE;
  791. gCameraBtnPan = TRUE;
  792. }
  793. }
  794. void commit_slider_zoom(LLUICtrl *ctrl)
  795. {
  796. // renormalize value, since max "volume" level is 0.5 for some reason
  797. F32 zoom_level = (F32)ctrl->getValue().asReal() * 2.f; // / 0.5f;
  798. gAgentCamera.setCameraZoomFraction(zoom_level);
  799. }
  800. void click_popup_rotate_left(void*)
  801. {
  802. LLSelectMgr::getInstance()->selectionRotateAroundZ( 45.f );
  803. dialog_refresh_all();
  804. }
  805. void click_popup_rotate_reset(void*)
  806. {
  807. LLSelectMgr::getInstance()->selectionResetRotation();
  808. dialog_refresh_all();
  809. }
  810. void click_popup_rotate_right(void*)
  811. {
  812. LLSelectMgr::getInstance()->selectionRotateAroundZ( -45.f );
  813. dialog_refresh_all();
  814. }
  815. void commit_slider_dozer_force(LLUICtrl *ctrl)
  816. {
  817. // the slider is logarithmic, so we exponentiate to get the actual force multiplier
  818. F32 dozer_force = pow(10.f, (F32)ctrl->getValue().asReal());
  819. gSavedSettings.setF32("LandBrushForce", dozer_force);
  820. }
  821. void click_apply_to_selection(void*)
  822. {
  823. LLToolBrushLand::getInstance()->modifyLandInSelectionGlobal();
  824. }
  825. void commit_radio_group_edit(LLUICtrl *ctrl)
  826. {
  827. S32 show_owners = gSavedSettings.getBOOL("ShowParcelOwners");
  828. LLRadioGroup* group = (LLRadioGroup*)ctrl;
  829. std::string selected = group->getValue().asString();
  830. if (selected == "radio position")
  831. {
  832. LLFloaterTools::setEditTool( LLToolCompTranslate::getInstance() );
  833. }
  834. else if (selected == "radio rotate")
  835. {
  836. LLFloaterTools::setEditTool( LLToolCompRotate::getInstance() );
  837. }
  838. else if (selected == "radio stretch")
  839. {
  840. LLFloaterTools::setEditTool( LLToolCompScale::getInstance() );
  841. }
  842. else if (selected == "radio select face")
  843. {
  844. LLFloaterTools::setEditTool( LLToolFace::getInstance() );
  845. }
  846. gSavedSettings.setBOOL("ShowParcelOwners", show_owners);
  847. }
  848. void commit_radio_group_land(LLUICtrl* ctrl)
  849. {
  850. LLRadioGroup* group = (LLRadioGroup*)ctrl;
  851. std::string selected = group->getValue().asString();
  852. if (selected == "radio select land")
  853. {
  854. LLFloaterTools::setEditTool( LLToolSelectLand::getInstance() );
  855. }
  856. else
  857. {
  858. LLFloaterTools::setEditTool( LLToolBrushLand::getInstance() );
  859. S32 dozer_mode = gSavedSettings.getS32("RadioLandBrushAction");
  860. if (selected == "radio flatten")
  861. dozer_mode = 0;
  862. else if (selected == "radio raise")
  863. dozer_mode = 1;
  864. else if (selected == "radio lower")
  865. dozer_mode = 2;
  866. else if (selected == "radio smooth")
  867. dozer_mode = 3;
  868. else if (selected == "radio noise")
  869. dozer_mode = 4;
  870. else if (selected == "radio revert")
  871. dozer_mode = 5;
  872. gSavedSettings.setS32("RadioLandBrushAction", dozer_mode);
  873. }
  874. }
  875. void commit_select_component(void *data)
  876. {
  877. LLFloaterTools* floaterp = (LLFloaterTools*)data;
  878. //forfeit focus
  879. if (gFocusMgr.childHasKeyboardFocus(floaterp))
  880. {
  881. gFocusMgr.setKeyboardFocus(NULL);
  882. }
  883. BOOL select_individuals = floaterp->mCheckSelectIndividual->get();
  884. gSavedSettings.setBOOL("EditLinkedParts", select_individuals);
  885. floaterp->dirty();
  886. if (select_individuals)
  887. {
  888. LLSelectMgr::getInstance()->demoteSelectionToIndividuals();
  889. }
  890. else
  891. {
  892. LLSelectMgr::getInstance()->promoteSelectionToRoot();
  893. }
  894. }
  895. // static
  896. void LLFloaterTools::setObjectType( LLPCode pcode )
  897. {
  898. LLToolPlacer::setObjectType( pcode );
  899. gSavedSettings.setBOOL("CreateToolCopySelection", FALSE);
  900. gFocusMgr.setMouseCapture(NULL);
  901. }
  902. void LLFloaterTools::onClickGridOptions()
  903. {
  904. LLFloaterReg::showInstance("build_options");
  905. // RN: this makes grid options dependent on build tools window
  906. //floaterp->addDependentFloater(LLFloaterBuildOptions::getInstance(), FALSE);
  907. }
  908. // static
  909. void LLFloaterTools::setEditTool(void* tool_pointer)
  910. {
  911. LLTool *tool = (LLTool *)tool_pointer;
  912. LLToolMgr::getInstance()->getCurrentToolset()->selectTool( tool );
  913. }
  914. void LLFloaterTools::setTool(const LLSD& user_data)
  915. {
  916. std::string control_name = user_data.asString();
  917. if(control_name == "Focus")
  918. LLToolMgr::getInstance()->getCurrentToolset()->selectTool((LLTool *) LLToolCamera::getInstance() );
  919. else if (control_name == "Move" )
  920. LLToolMgr::getInstance()->getCurrentToolset()->selectTool( (LLTool *)LLToolGrab::getInstance() );
  921. else if (control_name == "Edit" )
  922. LLToolMgr::getInstance()->getCurrentToolset()->selectTool( (LLTool *) LLToolCompTranslate::getInstance());
  923. else if (control_name == "Create" )
  924. LLToolMgr::getInstance()->getCurrentToolset()->selectTool( (LLTool *) LLToolCompCreate::getInstance());
  925. else if (control_name == "Land" )
  926. LLToolMgr::getInstance()->getCurrentToolset()->selectTool( (LLTool *) LLToolSelectLand::getInstance());
  927. else
  928. llwarns<<" no parameter name "<<control_name<<" found!! No Tool selected!!"<< llendl;
  929. }
  930. void LLFloaterTools::onFocusReceived()
  931. {
  932. LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset);
  933. LLFloater::onFocusReceived();
  934. }
  935. // Media stuff
  936. void LLFloaterTools::refreshMedia()
  937. {
  938. getMediaState();
  939. }
  940. bool LLFloaterTools::selectedMediaEditable()
  941. {
  942. U32 owner_mask_on;
  943. U32 owner_mask_off;
  944. U32 valid_owner_perms = LLSelectMgr::getInstance()->selectGetPerm( PERM_OWNER,
  945. &owner_mask_on, &owner_mask_off );
  946. U32 group_mask_on;
  947. U32 group_mask_off;
  948. U32 valid_group_perms = LLSelectMgr::getInstance()->selectGetPerm( PERM_GROUP,
  949. &group_mask_on, &group_mask_off );
  950. U32 everyone_mask_on;
  951. U32 everyone_mask_off;
  952. S32 valid_everyone_perms = LLSelectMgr::getInstance()->selectGetPerm( PERM_EVERYONE,
  953. &everyone_mask_on, &everyone_mask_off );
  954. bool selected_Media_editable = false;
  955. // if perms we got back are valid
  956. if ( valid_owner_perms &&
  957. valid_group_perms &&
  958. valid_everyone_perms )
  959. {
  960. if ( ( owner_mask_on & PERM_MODIFY ) ||
  961. ( group_mask_on & PERM_MODIFY ) ||
  962. ( group_mask_on & PERM_MODIFY ) )
  963. {
  964. selected_Media_editable = true;
  965. }
  966. else
  967. // user is NOT allowed to press the RESET button
  968. {
  969. selected_Media_editable = false;
  970. };
  971. };
  972. return selected_Media_editable;
  973. }
  974. void LLFloaterTools::updateLandImpacts()
  975. {
  976. LLParcel *parcel = mParcelSelection->getParcel();
  977. if (!parcel)
  978. {
  979. return;
  980. }
  981. S32 rezzed_prims = parcel->getSimWidePrimCount();
  982. S32 total_capacity = parcel->getSimWideMaxPrimCapacity();
  983. std::string remaining_capacity_str = "";
  984. bool show_mesh_cost = gMeshRepo.meshRezEnabled();
  985. if (show_mesh_cost)
  986. {
  987. LLStringUtil::format_map_t remaining_capacity_args;
  988. remaining_capacity_args["LAND_CAPACITY"] = llformat("%d", total_capacity - rezzed_prims);
  989. remaining_capacity_str = getString("status_remaining_capacity", remaining_capacity_args);
  990. }
  991. childSetTextArg("remaining_capacity", "[CAPACITY_STRING]", remaining_capacity_str);
  992. // Update land impacts info in the weights floater
  993. LLFloaterObjectWeights* object_weights_floater = LLFloaterReg::getTypedInstance<LLFloaterObjectWeights>("object_weights");
  994. if(object_weights_floater)
  995. {
  996. object_weights_floater->updateLandImpacts(parcel);
  997. }
  998. }
  999. void LLFloaterTools::getMediaState()
  1000. {
  1001. LLObjectSelectionHandle selected_objects =LLSelectMgr::getInstance()->getSelection();
  1002. LLViewerObject* first_object = selected_objects->getFirstObject();
  1003. LLTextBox* media_info = getChild<LLTextBox>("media_info");
  1004. if( !(first_object
  1005. && first_object->getPCode() == LL_PCODE_VOLUME
  1006. &&first_object->permModify()
  1007. ))
  1008. {
  1009. getChildView("Add_Media")->setEnabled(FALSE);
  1010. media_info->clear();
  1011. clearMediaSettings();
  1012. return;
  1013. }
  1014. std::string url = first_object->getRegion()->getCapability("ObjectMedia");
  1015. bool has_media_capability = (!url.empty());
  1016. if(!has_media_capability)
  1017. {
  1018. getChildView("Add_Media")->setEnabled(FALSE);
  1019. LL_WARNS("LLFloaterTools: media") << "Media not enabled (no capability) in this region!" << LL_ENDL;
  1020. clearMediaSettings();
  1021. return;
  1022. }
  1023. bool editable = (first_object->permModify() || selectedMediaEditable());
  1024. // Check modify permissions and whether any selected objects are in
  1025. // the process of being fetched. If they are, then we're not editable
  1026. if (editable)
  1027. {
  1028. LLObjectSelection::iterator iter = selected_objects->begin();
  1029. LLObjectSelection::iterator end = selected_objects->end();
  1030. for ( ; iter != end; ++iter)
  1031. {
  1032. LLSelectNode* node = *iter;
  1033. LLVOVolume* object = dynamic_cast<LLVOVolume*>(node->getObject());
  1034. if (NULL != object)
  1035. {
  1036. if (!object->permModify())
  1037. {
  1038. LL_INFOS("LLFloaterTools: media")
  1039. << "Selection not editable due to lack of modify permissions on object id "
  1040. << object->getID() << LL_ENDL;
  1041. editable = false;
  1042. break;
  1043. }
  1044. // XXX DISABLE this for now, because when the fetch finally
  1045. // does come in, the state of this floater doesn't properly
  1046. // update. Re-selecting fixes the problem, but there is
  1047. // contention as to whether this is a sufficient solution.
  1048. // if (object->isMediaDataBeingFetched())
  1049. // {
  1050. // LL_INFOS("LLFloaterTools: media")
  1051. // << "Selection not editable due to media data being fetched for object id "
  1052. // << object->getID() << LL_ENDL;
  1053. //
  1054. // editable = false;
  1055. // break;
  1056. // }
  1057. }
  1058. }
  1059. }
  1060. // Media settings
  1061. bool bool_has_media = false;
  1062. struct media_functor : public LLSelectedTEGetFunctor<bool>
  1063. {
  1064. bool get(LLViewerObject* object, S32 face)
  1065. {
  1066. LLTextureEntry *te = object->getTE(face);
  1067. if (te)
  1068. {
  1069. return te->hasMedia();
  1070. }
  1071. return false;
  1072. }
  1073. } func;
  1074. // check if all faces have media(or, all dont have media)
  1075. LLFloaterMediaSettings::getInstance()->mIdenticalHasMediaInfo = selected_objects->getSelectedTEValue( &func, bool_has_media );
  1076. const LLMediaEntry default_media_data;
  1077. struct functor_getter_media_data : public LLSelectedTEGetFunctor< LLMediaEntry>
  1078. {
  1079. functor_getter_media_data(const LLMediaEntry& entry): mMediaEntry(entry) {}
  1080. LLMediaEntry get( LLViewerObject* object, S32 face )
  1081. {
  1082. if ( object )
  1083. if ( object->getTE(face) )
  1084. if ( object->getTE(face)->getMediaData() )
  1085. return *(object->getTE(face)->getMediaData());
  1086. return mMediaEntry;
  1087. };
  1088. const LLMediaEntry& mMediaEntry;
  1089. } func_media_data(default_media_data);
  1090. LLMediaEntry media_data_get;
  1091. LLFloaterMediaSettings::getInstance()->mMultipleMedia = !(selected_objects->getSelectedTEValue( &func_media_data, media_data_get ));
  1092. std::string multi_media_info_str = LLTrans::getString("Multiple Media");
  1093. std::string media_title = "";
  1094. mNeedMediaTitle = false;
  1095. // update UI depending on whether "object" (prim or face) has media
  1096. // and whether or not you are allowed to edit it.
  1097. getChildView("Add_Media")->setEnabled(editable);
  1098. // IF all the faces have media (or all dont have media)
  1099. if ( LLFloaterMediaSettings::getInstance()->mIdenticalHasMediaInfo )
  1100. {
  1101. // TODO: get media title and set it.
  1102. media_info->clear();
  1103. // if identical is set, all faces are same (whether all empty or has the same media)
  1104. if(!(LLFloaterMediaSettings::getInstance()->mMultipleMedia) )
  1105. {
  1106. // Media data is valid
  1107. if(media_data_get!=default_media_data)
  1108. {
  1109. // initial media title is the media URL (until we get the name)
  1110. media_title = media_data_get.getHomeURL();
  1111. // kick off a navigate and flag that we need to update the title
  1112. navigateToTitleMedia( media_data_get.getHomeURL() );
  1113. mNeedMediaTitle = true;
  1114. }
  1115. // else all faces might be empty.
  1116. }
  1117. else // there' re Different Medias' been set on on the faces.
  1118. {
  1119. media_title = multi_media_info_str;
  1120. mNeedMediaTitle = false;
  1121. }
  1122. getChildView("media_tex")->setEnabled(bool_has_media && editable);
  1123. getChildView("edit_media")->setEnabled(bool_has_media && LLFloaterMediaSettings::getInstance()->mIdenticalHasMediaInfo && editable );
  1124. getChildView("delete_media")->setEnabled(bool_has_media && editable );
  1125. getChildView("add_media")->setEnabled(( ! bool_has_media ) && editable );
  1126. // TODO: display a list of all media on the face - use 'identical' flag
  1127. }
  1128. else // not all face has media but at least one does.
  1129. {
  1130. // seleted faces have not identical value
  1131. LLFloaterMediaSettings::getInstance()->mMultipleValidMedia = selected_objects->isMultipleTEValue(&func_media_data, default_media_data );
  1132. if(LLFloaterMediaSettings::getInstance()->mMultipleValidMedia)
  1133. {
  1134. media_title = multi_media_info_str;
  1135. mNeedMediaTitle = false;
  1136. }
  1137. else
  1138. {
  1139. // Media data is valid
  1140. if(media_data_get!=default_media_data)
  1141. {
  1142. // initial media title is the media URL (until we get the name)
  1143. media_title = media_data_get.getHomeURL();
  1144. // kick off a navigate and flag that we need to update the title
  1145. navigateToTitleMedia( media_data_get.getHomeURL() );
  1146. mNeedMediaTitle = true;
  1147. }
  1148. }
  1149. getChildView("media_tex")->setEnabled(TRUE);
  1150. getChildView("edit_media")->setEnabled(LLFloaterMediaSettings::getInstance()->mIdenticalHasMediaInfo);
  1151. getChildView("delete_media")->setEnabled(TRUE);
  1152. getChildView("add_media")->setEnabled(FALSE );
  1153. }
  1154. media_info->setText(media_title);
  1155. // load values for media settings
  1156. updateMediaSettings();
  1157. LLFloaterMediaSettings::initValues(mMediaSettings, editable );
  1158. }
  1159. //////////////////////////////////////////////////////////////////////////////
  1160. // called when a user wants to add media to a prim or prim face
  1161. void LLFloaterTools::onClickBtnAddMedia()
  1162. {
  1163. // check if multiple faces are selected
  1164. if(LLSelectMgr::getInstance()->getSelection()->isMultipleTESelected())
  1165. {
  1166. LLNotificationsUtil::add("MultipleFacesSelected", LLSD(), LLSD(), multipleFacesSelectedConfirm);
  1167. }
  1168. else
  1169. {
  1170. onClickBtnEditMedia();
  1171. }
  1172. }
  1173. // static
  1174. bool LLFloaterTools::multipleFacesSelectedConfirm(const LLSD& notification, const LLSD& response)
  1175. {
  1176. S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
  1177. switch( option )
  1178. {
  1179. case 0: // "Yes"
  1180. gFloaterTools->onClickBtnEditMedia();
  1181. break;
  1182. case 1: // "No"
  1183. default:
  1184. break;
  1185. }
  1186. return false;
  1187. }
  1188. //////////////////////////////////////////////////////////////////////////////
  1189. // called when a user wants to edit existing media settings on a prim or prim face
  1190. // TODO: test if there is media on the item and only allow editing if present
  1191. void LLFloaterTools::onClickBtnEditMedia()
  1192. {
  1193. refreshMedia();
  1194. LLFloaterReg::showInstance("media_settings");
  1195. }
  1196. //////////////////////////////////////////////////////////////////////////////
  1197. // called when a user wants to delete media from a prim or prim face
  1198. void LLFloaterTools::onClickBtnDeleteMedia()
  1199. {
  1200. LLNotificationsUtil::add("DeleteMedia", LLSD(), LLSD(), deleteMediaConfirm);
  1201. }
  1202. // static
  1203. bool LLFloaterTools::deleteMediaConfirm(const LLSD& notification, const LLSD& response)
  1204. {
  1205. S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
  1206. switch( option )
  1207. {
  1208. case 0: // "Yes"
  1209. LLSelectMgr::getInstance()->selectionSetMedia( 0, LLSD() );
  1210. if(LLFloaterReg::instanceVisible("media_settings"))
  1211. {
  1212. LLFloaterReg::hideInstance("media_settings");
  1213. }
  1214. break;
  1215. case 1: // "No"
  1216. default:
  1217. break;
  1218. }
  1219. return false;
  1220. }
  1221. //////////////////////////////////////////////////////////////////////////////
  1222. //
  1223. void LLFloaterTools::clearMediaSettings()
  1224. {
  1225. LLFloaterMediaSettings::clearValues(false);
  1226. }
  1227. //////////////////////////////////////////////////////////////////////////////
  1228. //
  1229. void LLFloaterTools::navigateToTitleMedia( const std::string url )
  1230. {
  1231. if ( mTitleMedia )
  1232. {
  1233. LLPluginClassMedia* media_plugin = mTitleMedia->getMediaPlugin();
  1234. if ( media_plugin )
  1235. {
  1236. // if it's a movie, we don't want to hear it
  1237. media_plugin->setVolume( 0 );
  1238. };
  1239. mTitleMedia->navigateTo( url );
  1240. };
  1241. }
  1242. //////////////////////////////////////////////////////////////////////////////
  1243. //
  1244. void LLFloaterTools::updateMediaTitle()
  1245. {
  1246. // only get the media name if we need it
  1247. if ( ! mNeedMediaTitle )
  1248. return;
  1249. // get plugin impl
  1250. LLPluginClassMedia* media_plugin = mTitleMedia->getMediaPlugin();
  1251. if ( media_plugin )
  1252. {
  1253. // get the media name (asynchronous - must call repeatedly)
  1254. std::string media_title = media_plugin->getMediaName();
  1255. // only replace the title if what we get contains something
  1256. if ( ! media_title.empty() )
  1257. {
  1258. // update the UI widget
  1259. LLTextBox* media_title_field = getChild<LLTextBox>("media_info");
  1260. if ( media_title_field )
  1261. {
  1262. media_title_field->setText( media_title );
  1263. // stop looking for a title when we get one
  1264. // FIXME: check this is the right approach
  1265. mNeedMediaTitle = false;
  1266. };
  1267. };
  1268. };
  1269. }
  1270. //////////////////////////////////////////////////////////////////////////////
  1271. //
  1272. void LLFloaterTools::updateMediaSettings()
  1273. {
  1274. bool identical( false );
  1275. std::string base_key( "" );
  1276. std::string value_str( "" );
  1277. int value_int = 0;
  1278. bool value_bool = false;
  1279. LLObjectSelectionHandle selected_objects =LLSelectMgr::getInstance()->getSelection();
  1280. // TODO: (CP) refactor this using something clever or boost or both !!
  1281. const LLMediaEntry default_media_data;
  1282. // controls
  1283. U8 value_u8 = default_media_data.getControls();
  1284. struct functor_getter_controls : public LLSelectedTEGetFunctor< U8 >
  1285. {
  1286. functor_getter_controls(const LLMediaEntry &entry) : mMediaEntry(entry) {}
  1287. U8 get( LLViewerObject* object, S32 face )
  1288. {
  1289. if ( object )
  1290. if ( object->getTE(face) )
  1291. if ( object->getTE(face)->getMediaData() )
  1292. return object->getTE(face)->getMediaData()->getControls();
  1293. return mMediaEntry.getControls();
  1294. };
  1295. const LLMediaEntry &mMediaEntry;
  1296. } func_controls(default_media_data);
  1297. identical = selected_objects->getSelectedTEValue( &func_controls, value_u8 );
  1298. base_key = std::string( LLMediaEntry::CONTROLS_KEY );
  1299. mMediaSettings[ base_key ] = value_u8;
  1300. mMediaSettings[ base_key + std::string( LLPanelContents::TENTATIVE_SUFFIX ) ] = ! identical;
  1301. // First click (formerly left click)
  1302. value_bool = default_media_data.getFirstClickInteract();
  1303. struct functor_getter_first_click : public LLSelectedTEGetFunctor< bool >
  1304. {
  1305. functor_getter_first_click(const LLMediaEntry& entry): mMediaEntry(entry) {}
  1306. bool get( LLViewerObject* object, S32 face )
  1307. {
  1308. if ( object )
  1309. if ( object->getTE(face) )
  1310. if ( object->getTE(face)->getMediaData() )
  1311. return object->getTE(face)->getMediaData()->getFirstClickInteract();
  1312. return mMediaEntry.getFirstClickInteract();
  1313. };
  1314. const LLMediaEntry &mMediaEntry;
  1315. } func_first_click(default_media_data);
  1316. identical = selected_objects->getSelectedTEValue( &func_first_click, value_bool );
  1317. base_key = std::string( LLMediaEntry::FIRST_CLICK_INTERACT_KEY );
  1318. mMediaSettings[ base_key ] = value_bool;
  1319. mMediaSettings[ base_key + std::string( LLPanelContents::TENTATIVE_SUFFIX ) ] = ! identical;
  1320. // Home URL
  1321. value_str = default_media_data.getHomeURL();
  1322. struct functor_getter_home_url : public LLSelectedTEGetFunctor< std::string >
  1323. {
  1324. functor_getter_home_url(const LLMediaEntry& entry): mMediaEntry(entry) {}
  1325. std::string get( LLViewerObject* object, S32 face )
  1326. {
  1327. if ( object )
  1328. if ( object->getTE(face) )
  1329. if ( object->getTE(face)->getMediaData() )
  1330. return object->getTE(face)->getMediaData()->getHomeURL();
  1331. return mMediaEntry.getHomeURL();
  1332. };
  1333. const LLMediaEntry &mMediaEntry;
  1334. } func_home_url(default_media_data);
  1335. identical = selected_objects->getSelectedTEValue( &func_home_url, value_str );
  1336. base_key = std::string( LLMediaEntry::HOME_URL_KEY );
  1337. mMediaSettings[ base_key ] = value_str;
  1338. mMediaSettings[ base_key + std::string( LLPanelContents::TENTATIVE_SUFFIX ) ] = ! identical;
  1339. // Current URL
  1340. value_str = default_media_data.getCurrentURL();
  1341. struct functor_getter_current_url : public LLSelectedTEGetFunctor< std::string >
  1342. {
  1343. functor_getter_current_url(const LLMediaEntry& entry): mMediaEntry(entry) {}
  1344. std::string get( LLViewerObject* object, S32 face )
  1345. {
  1346. if ( object )
  1347. if ( object->getTE(face) )
  1348. if ( object->getTE(face)->getMediaData() )
  1349. return object->getTE(face)->getMediaData()->getCurrentURL();
  1350. return mMediaEntry.getCurrentURL();
  1351. };
  1352. const LLMediaEntry &mMediaEntry;
  1353. } func_current_url(default_media_data);
  1354. identical = selected_objects->getSelectedTEValue( &func_current_url, value_str );
  1355. base_key = std::string( LLMediaEntry::CURRENT_URL_KEY );
  1356. mMediaSettings[ base_key ] = value_str;
  1357. mMediaSettings[ base_key + std::string( LLPanelContents::TENTATIVE_SUFFIX ) ] = ! identical;
  1358. // Auto zoom
  1359. value_bool = default_media_data.getAutoZoom();
  1360. struct functor_getter_auto_zoom : public LLSelectedTEGetFunctor< bool >
  1361. {
  1362. functor_getter_auto_zoom(const LLMediaEntry& entry) : mMediaEntry(entry) {}
  1363. bool get( LLViewerObject* object, S32 face )
  1364. {
  1365. if ( object )
  1366. if ( object->getTE(face) )
  1367. if ( object->getTE(face)->getMediaData() )
  1368. return object->getTE(face)->getMediaData()->getAutoZoom();
  1369. return mMediaEntry.getAutoZoom();
  1370. };
  1371. const LLMediaEntry &mMediaEntry;
  1372. } func_auto_zoom(default_media_data);
  1373. identical = selected_objects->getSelectedTEValue( &func_auto_zoom, value_bool );
  1374. base_key = std::string( LLMediaEntry::AUTO_ZOOM_KEY );
  1375. mMediaSettings[ base_key ] = value_bool;
  1376. mMediaSettings[ base_key + std::string( LLPanelContents::TENTATIVE_SUFFIX ) ] = ! identical;
  1377. // Auto play
  1378. //value_bool = default_media_data.getAutoPlay();
  1379. // set default to auto play TRUE -- angela EXT-5172
  1380. value_bool = true;
  1381. struct functor_getter_auto_play : public LLSelectedTEGetFunctor< bool >
  1382. {
  1383. functor_getter_auto_play(const LLMediaEntry& entry) : mMediaEntry(entry) {}
  1384. bool get( LLViewerObject* object, S32 face )
  1385. {
  1386. if ( object )
  1387. if ( object->getTE(face) )
  1388. if ( object->getTE(face)->getMediaData() )
  1389. return object->getTE(face)->getMediaData()->getAutoPlay();
  1390. //return mMediaEntry.getAutoPlay(); set default to auto play TRUE -- angela EXT-5172
  1391. return true;
  1392. };
  1393. const LLMediaEntry &mMediaEntry;
  1394. } func_auto_play(default_media_data);
  1395. identical = selected_objects->getSelectedTEValue( &func_auto_play, value_bool );
  1396. base_key = std::string( LLMediaEntry::AUTO_PLAY_KEY );
  1397. mMediaSettings[ base_key ] = value_bool;
  1398. mMediaSettings[ base_key + std::string( LLPanelContents::TENTATIVE_SUFFIX ) ] = ! identical;
  1399. // Auto scale
  1400. // set default to auto scale TRUE -- angela EXT-5172
  1401. //value_bool = default_media_data.getAutoScale();
  1402. value_bool = true;
  1403. struct functor_getter_auto_scale : public LLSelectedTEGetFunctor< bool >
  1404. {
  1405. functor_getter_auto_scale(const LLMediaEntry& entry): mMediaEntry(entry) {}
  1406. bool get( LLViewerObject* object, S32 face )
  1407. {
  1408. if ( object )
  1409. if ( object->getTE(face) )
  1410. if ( object->getTE(face)->getMediaData() )
  1411. return object->getTE(face)->getMediaData()->getAutoScale();
  1412. // return mMediaEntry.getAutoScale(); set default to auto scale TRUE -- angela EXT-5172
  1413. return true;
  1414. };
  1415. const LLMediaEntry &mMediaEntry;
  1416. } func_auto_scale(default_media_data);
  1417. identical = selected_objects->getSelectedTEValue( &func_auto_scale, value_bool );
  1418. base_key = std::string( LLMediaEntry::AUTO_SCALE_KEY );
  1419. mMediaSettings[ base_key ] = value_bool;
  1420. mMediaSettings[ base_key + std::string( LLPanelContents::TENTATIVE_SUFFIX ) ] = ! identical;
  1421. // Auto loop
  1422. value_bool = default_media_data.getAutoLoop();
  1423. struct functor_getter_auto_loop : public LLSelectedTEGetFunctor< bool >
  1424. {
  1425. functor_getter_auto_loop(const LLMediaEntry& entry) : mMediaEntry(entry) {}
  1426. bool get( LLViewerObject* object, S32 face )
  1427. {
  1428. if ( object )
  1429. if ( object->getTE(face) )
  1430. if ( object->getTE(face)->getMediaData() )
  1431. return object->getTE(face)->getMediaData()->getAutoLoop();
  1432. return mMediaEntry.getAutoLoop();
  1433. };
  1434. const LLMediaEntry &mMediaEntry;
  1435. } func_auto_loop(default_media_data);
  1436. identical = selected_objects->getSelectedTEValue( &func_auto_loop, value_bool );
  1437. base_key = std::string( LLMediaEntry::AUTO_LOOP_KEY );
  1438. mMediaSettings[ base_key ] = value_bool;
  1439. mMediaSettings[ base_key + std::string( LLPanelContents::TENTATIVE_SUFFIX ) ] = ! identical;
  1440. // width pixels (if not auto scaled)
  1441. value_int = default_media_data.getWidthPixels();
  1442. struct functor_getter_width_pixels : public LLSelectedTEGetFunctor< int >
  1443. {
  1444. functor_getter_width_pixels(const LLMediaEntry& entry): mMediaEntry(entry) {}
  1445. int get( LLViewerObject* object, S32 face )
  1446. {
  1447. if ( object )
  1448. if ( object->getTE(face) )
  1449. if ( object->getTE(face)->getMediaData() )
  1450. return object->getTE(face)->getMediaData()->getWidthPixels();
  1451. return mMediaEntry.getWidthPixels();
  1452. };
  1453. const LLMediaEntry &mMediaEntry;
  1454. } func_width_pixels(default_media_data);
  1455. identical = selected_objects->getSelectedTEValue( &func_width_pixels, value_int );
  1456. base_key = std::string( LLMediaEntry::WIDTH_PIXELS_KEY );
  1457. mMediaSettings[ base_key ] = value_int;
  1458. mMediaSettings[ base_key + std::string( LLPanelContents::TENTATIVE_SUFFIX ) ] = ! identical;
  1459. // height pixels (if not auto scaled)
  1460. value_int = default_media_data.getHeightPixels();
  1461. struct functor_getter_height_pixels : public LLSelectedTEGetFunctor< int >
  1462. {
  1463. functor_getter_height_pixels(const LLMediaEntry& entry) : mMediaEntry(entry) {}
  1464. int get( LLViewerObject* object, S32 face )
  1465. {
  1466. if ( object )
  1467. if ( object->getTE(face) )
  1468. if ( object->getTE(face)->getMediaData() )
  1469. return object->getTE(face)->getMediaData()->getHeightPixels();
  1470. return mMediaEntry.getHeightPixels();
  1471. };
  1472. const LLMediaEntry &mMediaEntry;
  1473. } func_height_pixels(default_media_data);
  1474. identical = selected_objects->getSelectedTEValue( &func_height_pixels, value_int );
  1475. base_key = std::string( LLMediaEntry::HEIGHT_PIXELS_KEY );
  1476. mMediaSettings[ base_key ] = value_int;
  1477. mMediaSettings[ base_key + std::string( LLPanelContents::TENTATIVE_SUFFIX ) ] = ! identical;
  1478. // Enable Alt image
  1479. value_bool = default_media_data.getAltImageEnable();
  1480. struct functor_getter_enable_alt_image : public LLSelectedTEGetFunctor< bool >
  1481. {
  1482. functor_getter_enable_alt_image(const LLMediaEntry& entry): mMediaEntry(entry) {}
  1483. bool get( LLViewerObject* object, S32 face )
  1484. {
  1485. if ( object )
  1486. if ( object->getTE(face) )
  1487. if ( object->getTE(face)->getMediaData() )
  1488. return object->getTE(face)->getMediaData()->getAltImageEnable();
  1489. return mMediaEntry.getAltImageEnable();
  1490. };
  1491. const LLMediaEntry &mMediaEntry;
  1492. } func_enable_alt_image(default_media_data);
  1493. identical = selected_objects->getSelectedTEValue( &func_enable_alt_image, value_bool );
  1494. base_key = std::string( LLMediaEntry::ALT_IMAGE_ENABLE_KEY );
  1495. mMediaSettings[ base_key ] = value_bool;
  1496. mMediaSettings[ base_key + std::string( LLPanelContents::TENTATIVE_SUFFIX ) ] = ! identical;
  1497. // Perms - owner interact
  1498. value_bool = 0 != ( default_media_data.getPermsInteract() & LLMediaEntry::PERM_OWNER );
  1499. struct functor_getter_perms_owner_interact : public LLSelectedTEGetFunctor< bool >
  1500. {
  1501. functor_getter_perms_owner_interact(const LLMediaEntry& entry): mMediaEntry(entry) {}
  1502. bool get( LLViewerObject* object, S32 face )
  1503. {
  1504. if ( object )
  1505. if ( object->getTE(face) )
  1506. if ( object->getTE(face)->getMediaData() )
  1507. return (0 != (object->getTE(face)->getMediaData()->getPermsInteract() & LLMediaEntry::PERM_OWNER));
  1508. return 0 != ( mMediaEntry.getPermsInteract() & LLMediaEntry::PERM_OWNER );
  1509. };
  1510. const LLMediaEntry &mMediaEntry;
  1511. } func_perms_owner_interact(default_media_data);
  1512. identical = selected_objects->getSelectedTEValue( &func_perms_owner_interact, value_bool );
  1513. base_key = std::string( LLPanelContents::PERMS_OWNER_INTERACT_KEY );
  1514. mMediaSettings[ base_key ] = value_bool;
  1515. mMediaSettings[ base_key + std::string( LLPanelContents::TENTATIVE_SUFFIX ) ] = ! identical;
  1516. // Perms - owner control
  1517. value_bool = 0 != ( default_media_data.getPermsControl() & LLMediaEntry::PERM_OWNER );
  1518. struct functor_getter_perms_owner_control : public LLSelectedTEGetFunctor< bool >
  1519. {
  1520. functor_getter_perms_owner_control(const LLMediaEntry& entry) : mMediaEntry(entry) {}
  1521. bool get( LLViewerObject* object, S32 face )
  1522. {
  1523. if ( object )
  1524. if ( object->getTE(face) )
  1525. if ( object->getTE(face)->getMediaData() )
  1526. return (0 != (object->getTE(face)->getMediaData()->getPermsControl() & LLMediaEntry::PERM_OWNER));
  1527. return 0 != ( mMediaEntry.getPermsControl() & LLMediaEntry::PERM_OWNER );
  1528. };
  1529. const LLMediaEntry &mMediaEntry;
  1530. } func_perms_owner_control(default_media_data);
  1531. identical = selected_objects ->getSelectedTEValue( &func_perms_owner_control, value_bool );
  1532. base_key = std::string( LLPanelContents::PERMS_OWNER_CONTROL_KEY );
  1533. mMediaSettings[ base_key ] = value_bool;
  1534. mMediaSettings[ base_key + std::string( LLPanelContents::TENTATIVE_SUFFIX ) ] = ! identical;
  1535. // Perms - group interact
  1536. value_bool = 0 != ( default_media_data.getPermsInteract() & LLMediaEntry::PERM_GROUP );
  1537. struct functor_getter_perms_group_interact : public LLSelectedTEGetFunctor< bool >
  1538. {
  1539. functor_getter_perms_group_interact(const LLMediaEntry& entry): mMediaEntry(entry) {}
  1540. bool get( LLViewerObject* object, S32 face )
  1541. {
  1542. if ( object )
  1543. if ( object->getTE(face) )
  1544. if ( object->getTE(face)->getMediaData() )
  1545. return (0 != (object->getTE(face)->getMediaData()->getPermsInteract() & LLMediaEntry::PERM_GROUP));
  1546. return 0 != ( mMediaEntry.getPermsInteract() & LLMediaEntry::PERM_GROUP );
  1547. };
  1548. const LLMediaEntry &mMediaEntry;
  1549. } func_perms_group_interact(default_media_data);
  1550. identical = selected_objects->getSelectedTEValue( &func_perms_group_interact, value_bool );
  1551. base_key = std::string( LLPanelContents::PERMS_GROUP_INTERACT_KEY );
  1552. mMediaSettings[ base_key ] = value_bool;
  1553. mMediaSettings[ base_key + std::string( LLPanelContents::TENTATIVE_SUFFIX ) ] = ! identical;
  1554. // Perms - group control
  1555. value_bool = 0 != ( default_media_data.getPermsControl() & LLMediaEntry::PERM_GROUP );
  1556. struct functor_getter_perms_group_control : public LLSelectedTEGetFunctor< bool >
  1557. {
  1558. functor_getter_perms_group_control(const LLMediaEntry& entry): mMediaEntry(entry) {}
  1559. bool get( LLViewerObject* object, S32 face )
  1560. {
  1561. if ( object )
  1562. if ( object->getTE(face) )
  1563. if ( object->getTE(face)->getMediaData() )
  1564. return (0 != (object->getTE(face)->getMediaData()->getPermsControl() & LLMediaEntry::PERM_GROUP));
  1565. return 0 != ( mMediaEntry.getPermsControl() & LLMediaEntry::PERM_GROUP );
  1566. };
  1567. const LLMediaEntry &mMediaEntry;
  1568. } func_perms_group_control(default_media_data);
  1569. identical = selected_objects->getSelectedTEValue( &func_perms_group_control, value_bool );
  1570. base_key = std::string( LLPanelContents::PERMS_GROUP_CONTROL_KEY );
  1571. mMediaSettings[ base_key ] = value_bool;
  1572. mMediaSettings[ base_key + std::string( LLPanelContents::TENTATIVE_SUFFIX ) ] = ! identical;
  1573. // Perms - anyone interact
  1574. value_bool = 0 != ( default_media_data.getPermsInteract() & LLMediaEntry::PERM_ANYONE );
  1575. struct functor_getter_perms_anyone_interact : public LLSelectedTEGetFunctor< bool >
  1576. {
  1577. functor_getter_perms_anyone_interact(const LLMediaEntry& entry): mMediaEntry(entry) {}
  1578. bool get( LLViewerObject* object, S32 face )
  1579. {
  1580. if ( object )
  1581. if ( object->getTE(face) )
  1582. if ( object->getTE(face)->getMediaData() )
  1583. return (0 != (object->getTE(face)->getMediaData()->getPermsInteract() & LLMediaEntry::PERM_ANYONE));
  1584. return 0 != ( mMediaEntry.getPermsInteract() & LLMediaEntry::PERM_ANYONE );
  1585. };
  1586. const LLMediaEntry &mMediaEntry;
  1587. } func_perms_anyone_interact(default_media_data);
  1588. identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func_perms_anyone_interact, value_bool );
  1589. base_key = std::string( LLPanelContents::PERMS_ANYONE_INTERACT_KEY );
  1590. mMediaSettings[ base_key ] = value_bool;
  1591. mMediaSettings[ base_key + std::string( LLPanelContents::TENTATIVE_SUFFIX ) ] = ! identical;
  1592. // Perms - anyone control
  1593. value_bool = 0 != ( default_media_data.getPermsControl() & LLMediaEntry::PERM_ANYONE );
  1594. struct functor_getter_perms_anyone_control : public LLSelectedTEGetFunctor< bool >
  1595. {
  1596. functor_getter_perms_anyone_control(const LLMediaEntry& entry) : mMediaEntry(entry) {}
  1597. bool get( LLViewerObject* object, S32 face )
  1598. {
  1599. if ( object )
  1600. if ( object->getTE(face) )
  1601. if ( object->getTE(face)->getMediaData() )
  1602. return (0 != (object->getTE(face)->getMediaData()->getPermsControl() & LLMediaEntry::PERM_ANYONE));
  1603. return 0 != ( mMediaEntry.getPermsControl() & LLMediaEntry::PERM_ANYONE );
  1604. };
  1605. const LLMediaEntry &mMediaEntry;
  1606. } func_perms_anyone_control(default_media_data);
  1607. identical = selected_objects->getSelectedTEValue( &func_perms_anyone_control, value_bool );
  1608. base_key = std::string( LLPanelContents::PERMS_ANYONE_CONTROL_KEY );
  1609. mMediaSettings[ base_key ] = value_bool;
  1610. mMediaSettings[ base_key + std::string( LLPanelContents::TENTATIVE_SUFFIX ) ] = ! identical;
  1611. // security - whitelist enable
  1612. value_bool = default_media_data.getWhiteListEnable();
  1613. struct functor_getter_whitelist_enable : public LLSelectedTEGetFunctor< bool >
  1614. {
  1615. functor_getter_whitelist_enable(const LLMediaEntry& entry) : mMediaEntry(entry) {}
  1616. bool get( LLViewerObject* object, S32 face )
  1617. {
  1618. if ( object )
  1619. if ( object->getTE(face) )
  1620. if ( object->getTE(face)->getMediaData() )
  1621. return object->getTE(face)->getMediaData()->getWhiteListEnable();
  1622. return mMediaEntry.getWhiteListEnable();
  1623. };
  1624. const LLMediaEntry &mMediaEntry;
  1625. } func_whitelist_enable(default_media_data);
  1626. identical = selected_objects->getSelectedTEValue( &func_whitelist_enable, value_bool );
  1627. base_key = std::string( LLMediaEntry::WHITELIST_ENABLE_KEY );
  1628. mMediaSettings[ base_key ] = value_bool;
  1629. mMediaSettings[ base_key + std::string( LLPanelContents::TENTATIVE_SUFFIX ) ] = ! identical;
  1630. // security - whitelist URLs
  1631. std::vector<std::string> value_vector_str = default_media_data.getWhiteList();
  1632. struct functor_getter_whitelist_urls : public LLSelectedTEGetFunctor< std::vector<std::string> >
  1633. {
  1634. functor_getter_whitelist_urls(const LLMediaEntry& entry): mMediaEntry(entry) {}
  1635. std::vector<std::string> get( LLViewerObject* object, S32 face )
  1636. {
  1637. if ( object )
  1638. if ( object->getTE(face) )
  1639. if ( object->getTE(face)->getMediaData() )
  1640. return object->getTE(face)->getMediaData()->getWhiteList();
  1641. return mMediaEntry.getWhiteList();
  1642. };
  1643. const LLMediaEntry &mMediaEntry;
  1644. } func_whitelist_urls(default_media_data);
  1645. identical = selected_objects->getSelectedTEValue( &func_whitelist_urls, value_vector_str );
  1646. base_key = std::string( LLMediaEntry::WHITELIST_KEY );
  1647. mMediaSettings[ base_key ].clear();
  1648. std::vector< std::string >::iterator iter = value_vector_str.begin();
  1649. while( iter != value_vector_str.end() )
  1650. {
  1651. std::string white_list_url = *iter;
  1652. mMediaSettings[ base_key ].append( white_list_url );
  1653. ++iter;
  1654. };
  1655. mMediaSettings[ base_key + std::string( LLPanelContents::TENTATIVE_SUFFIX ) ] = ! identical;
  1656. }