llfloatertools.cpp 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071
  1. /**
  2. * @file llfloatertools.cpp
  3. * @brief The edit tools, including move, position, land, etc.
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewergpl$
  6. *
  7. * Copyright (c) 2002-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #include "llviewerprecompiledheaders.h"
  33. #include "llfloatertools.h"
  34. #include "llapp.h"
  35. #include "llbutton.h"
  36. #include "lldraghandle.h"
  37. #include "llgl.h"
  38. #include "llmenugl.h"
  39. #include "llmediaentry.h"
  40. #include "llsliderctrl.h"
  41. #include "llspinctrl.h"
  42. #include "lltabcontainer.h"
  43. #include "lltextbox.h"
  44. #include "lltextureentry.h"
  45. #include "lluictrlfactory.h"
  46. #include "llagent.h"
  47. #include "llfloatermediasettings.h"
  48. #include "llfloaterobjectweights.h"
  49. #include "llfloateropenobject.h"
  50. #include "llmeshrepository.h"
  51. #include "llpanelcontents.h"
  52. #include "llpanelface.h"
  53. #include "llpanelinventory.h"
  54. #include "llpanelland.h"
  55. #include "llpanelobject.h"
  56. #include "llpanelpermissions.h"
  57. #include "llpanelvolume.h"
  58. #include "llpreviewmaterial.h"
  59. //MK
  60. #include "mkrlinterface.h"
  61. //mk
  62. #include "llselectmgr.h"
  63. #include "llstatusbar.h"
  64. #include "qltoolalign.h"
  65. #include "lltoolbrushland.h"
  66. #include "lltoolcomp.h"
  67. #include "lltooldraganddrop.h"
  68. #include "lltoolface.h"
  69. #include "lltoolfocus.h"
  70. #include "lltoolgrab.h"
  71. #include "lltoolmgr.h"
  72. #include "lltoolpie.h"
  73. #include "lltoolpipette.h"
  74. #include "lltoolplacer.h"
  75. #include "lltoolselectland.h"
  76. #include "llviewercontrol.h"
  77. #include "llviewerjoystick.h"
  78. #include "llviewermenu.h"
  79. #include "llviewerparcelmgr.h"
  80. #include "llviewerregion.h"
  81. #include "llviewerwindow.h"
  82. #include "llvograss.h"
  83. #include "llvotree.h"
  84. #include "llvovolume.h"
  85. // Globals
  86. // Instance created in LLViewerWindow::initWorldUI()
  87. LLFloaterTools* gFloaterToolsp = NULL;
  88. static const std::string PANEL_NAMES[LLFloaterTools::PANEL_COUNT] =
  89. {
  90. std::string("General"), // PANEL_GENERAL,
  91. std::string("Object"), // PANEL_OBJECT,
  92. std::string("Features"), // PANEL_FEATURES,
  93. std::string("Texture"), // PANEL_FACE,
  94. std::string("Contents"), // PANEL_CONTENTS,
  95. };
  96. // Local prototypes
  97. void commit_select_tool(LLUICtrl* ctrl, void* data);
  98. void select_next_part(void* data);
  99. void select_previous_part(void* data);
  100. void click_popup_grab_drag(LLUICtrl*, void*);
  101. void click_popup_grab_lift(LLUICtrl*, void*);
  102. void click_popup_grab_spin(LLUICtrl*, void*);
  103. void click_popup_dozer_mode(LLUICtrl*, void* data);
  104. void commit_slider_dozer_size(LLUICtrl*, void*);
  105. void commit_slider_dozer_force(LLUICtrl*, void*);
  106. void click_apply_to_selection(void*);
  107. void commit_radio_zoom(LLUICtrl*, void*);
  108. void commit_radio_orbit(LLUICtrl*, void*);
  109. void commit_radio_pan(LLUICtrl*, void*);
  110. void commit_slider_zoom(LLUICtrl*, void*);
  111. void click_count(void*);
  112. // Floater for setting global object-editing options, such as grid size and
  113. // spacing.
  114. LLFloaterBuildOptions::LLFloaterBuildOptions(const LLSD&)
  115. {
  116. LLUICtrlFactory::getInstance()->buildFloater(this,
  117. "floater_build_options.xml");
  118. }
  119. ///////////////////////////////////////////////////////////////////////////////
  120. // LLFloaterTools class
  121. ///////////////////////////////////////////////////////////////////////////////
  122. //static
  123. bool LLFloaterTools::isVisible()
  124. {
  125. return gFloaterToolsp && gFloaterToolsp->getVisible();
  126. }
  127. //static
  128. void* LLFloaterTools::createPanelPermissions(void* data)
  129. {
  130. LLFloaterTools* floater = (LLFloaterTools*)data;
  131. floater->mPanelPermissions = new LLPanelPermissions("General");
  132. return floater->mPanelPermissions;
  133. }
  134. //static
  135. void* LLFloaterTools::createPanelObject(void* data)
  136. {
  137. LLFloaterTools* floater = (LLFloaterTools*)data;
  138. floater->mPanelObject = new LLPanelObject("Object");
  139. return floater->mPanelObject;
  140. }
  141. //static
  142. void* LLFloaterTools::createPanelVolume(void* data)
  143. {
  144. LLFloaterTools* floater = (LLFloaterTools*)data;
  145. floater->mPanelVolume = new LLPanelVolume("Features");
  146. return floater->mPanelVolume;
  147. }
  148. //static
  149. void* LLFloaterTools::createPanelFace(void* data)
  150. {
  151. LLFloaterTools* floater = (LLFloaterTools*)data;
  152. floater->mPanelFace = new LLPanelFace("Texture");
  153. return floater->mPanelFace;
  154. }
  155. //static
  156. void* LLFloaterTools::createPanelContents(void* data)
  157. {
  158. LLFloaterTools* floater = (LLFloaterTools*)data;
  159. floater->mPanelContents = new LLPanelContents("Contents");
  160. return floater->mPanelContents;
  161. }
  162. //static
  163. void* LLFloaterTools::createPanelContentsInventory(void* data)
  164. {
  165. LLFloaterTools* floater = (LLFloaterTools*)data;
  166. floater->mPanelContents->mPanelInventory =
  167. new LLPanelInventory(std::string("ContentsInventory"), LLRect());
  168. return floater->mPanelContents->mPanelInventory;
  169. }
  170. //static
  171. void* LLFloaterTools::createPanelLandInfo(void* data)
  172. {
  173. LLFloaterTools* floater = (LLFloaterTools*)data;
  174. floater->mPanelLandInfo =
  175. new LLPanelLandInfo(std::string("land info panel"));
  176. return floater->mPanelLandInfo;
  177. }
  178. void LLFloaterTools::toolsPrecision()
  179. {
  180. static LLCachedControl<U32> decimals(gSavedSettings, "DecimalsForTools");
  181. if (mPrecision != decimals)
  182. {
  183. mPrecision = decimals;
  184. if (mPrecision > 5)
  185. {
  186. mPrecision = 5;
  187. }
  188. getChild<LLSpinCtrl>("Pos X")->setPrecision(mPrecision);
  189. getChild<LLSpinCtrl>("Pos Y")->setPrecision(mPrecision);
  190. getChild<LLSpinCtrl>("Pos Z")->setPrecision(mPrecision);
  191. getChild<LLSpinCtrl>("Scale X")->setPrecision(mPrecision);
  192. getChild<LLSpinCtrl>("Scale Y")->setPrecision(mPrecision);
  193. getChild<LLSpinCtrl>("Scale Z")->setPrecision(mPrecision);
  194. getChild<LLSpinCtrl>("Rot X")->setPrecision(mPrecision);
  195. getChild<LLSpinCtrl>("Rot Y")->setPrecision(mPrecision);
  196. getChild<LLSpinCtrl>("Rot Z")->setPrecision(mPrecision);
  197. }
  198. }
  199. //virtual
  200. bool LLFloaterTools::postBuild()
  201. {
  202. // Hide until tool selected
  203. setVisible(false);
  204. // Since we constantly show and hide this during drags, do not make sounds
  205. // on visibility changes.
  206. setSoundFlags(LLView::SILENT);
  207. getDragHandle()->setEnabled(true);
  208. LLRect rect;
  209. mBtnFocus = getChild<LLButton>("button focus");
  210. mBtnFocus->setClickedCallback(setEditTool, (void*)&gToolFocus);
  211. mBtnMove = getChild<LLButton>("button move");
  212. mBtnMove->setClickedCallback(setEditTool, (void*)&gToolGrab);
  213. mBtnEdit = getChild<LLButton>("button edit");
  214. mBtnEdit->setClickedCallback(setEditTool, (void*)&gToolCompTranslate);
  215. mBtnCreate = getChild<LLButton>("button create");
  216. mBtnCreate->setClickedCallback(setEditTool, (void*)&gToolCompCreate);
  217. mBtnLand = getChild<LLButton>("button land");
  218. mBtnLand->setClickedCallback(setEditTool, (void*)&gToolSelectLand);
  219. mTextStatus = getChild<LLTextBox>("text status");
  220. mRadioZoom = getChild<LLCheckBoxCtrl>("radio zoom");
  221. mRadioZoom->setCommitCallback(commit_radio_zoom);
  222. mRadioZoom->setCallbackUserData(this);
  223. mRadioOrbit = getChild<LLCheckBoxCtrl>("radio orbit");
  224. mRadioOrbit->setCommitCallback(commit_radio_orbit);
  225. mRadioOrbit->setCallbackUserData(this);
  226. mRadioPan = getChild<LLCheckBoxCtrl>("radio pan");
  227. mRadioPan->setCommitCallback(commit_radio_pan);
  228. mRadioPan->setCallbackUserData(this);
  229. mSliderZoom = getChild<LLSliderCtrl>("slider zoom");
  230. mSliderZoom->setCommitCallback(commit_slider_zoom);
  231. mSliderZoom->setCallbackUserData(this);
  232. mRadioMove = getChild<LLCheckBoxCtrl>("radio move");
  233. mRadioMove->setCommitCallback(click_popup_grab_drag);
  234. mRadioMove->setCallbackUserData(this);
  235. mRadioLift = getChild<LLCheckBoxCtrl>("radio lift");
  236. mRadioLift->setCommitCallback(click_popup_grab_lift);
  237. mRadioLift->setCallbackUserData(this);
  238. mRadioSpin = getChild<LLCheckBoxCtrl>("radio spin");
  239. mRadioSpin->setCommitCallback(click_popup_grab_spin);
  240. mRadioSpin->setCallbackUserData(this);
  241. mRadioPosition = getChild<LLCheckBoxCtrl>("radio position");
  242. mRadioPosition->setCommitCallback(commit_select_tool);
  243. mRadioPosition->setCallbackUserData((void*)&gToolCompTranslate);
  244. mRadioAlign = getChild<LLCheckBoxCtrl>("radio align");
  245. mRadioAlign->setCommitCallback(commit_select_tool);
  246. mRadioAlign->setCallbackUserData((void*)&gToolAlign);
  247. mRadioRotate = getChild<LLCheckBoxCtrl>("radio rotate");
  248. mRadioRotate->setCommitCallback(commit_select_tool);
  249. mRadioRotate->setCallbackUserData((void*)&gToolCompRotate);
  250. mRadioStretch = getChild<LLCheckBoxCtrl>("radio stretch");
  251. mRadioStretch->setCommitCallback(commit_select_tool);
  252. mRadioStretch->setCallbackUserData((void*)&gToolCompScale);
  253. mRadioSelectFace = getChild<LLCheckBoxCtrl>("radio select face");
  254. mRadioSelectFace->setCommitCallback(commit_select_tool);
  255. mRadioSelectFace->setCallbackUserData((void*)&gToolFace);
  256. mCheckSelectIndividual = getChild<LLCheckBoxCtrl>("checkbox edit linked parts");
  257. mCheckSelectIndividual->setCommitCallback(commitSelectComponent);
  258. mCheckSelectIndividual->setCallbackUserData(this);
  259. mBtnGridOptions = getChild<LLButton>("Grid Options");
  260. mBtnGridOptions->setClickedCallback(onClickGridOptions, this);
  261. mBtnGridOptions->setControlName("GridOptionState", NULL);
  262. mCheckStretchUniform = getChild<LLCheckBoxCtrl>("checkbox uniform");
  263. mCheckStretchTexture = getChild<LLCheckBoxCtrl>("checkbox stretch textures");
  264. mCheckUseRootForPivot = getChild<LLCheckBoxCtrl>("checkbox use root for pivot");
  265. mTextGridMode = getChild<LLTextBox>("text ruler mode");
  266. mComboGridMode = getChild<LLComboBox>("combobox grid mode");
  267. mComboGridMode->setCommitCallback(onCommitGridMode);
  268. mComboGridMode->setCallbackUserData(this);
  269. mBtnPrevChild = getChild<LLButton>("prev_child");
  270. mBtnPrevChild->setClickedCallback(select_previous_part, this);
  271. mBtnNextChild = getChild<LLButton>("next_child");
  272. mBtnNextChild->setClickedCallback(select_next_part, this);
  273. updatePrevNextBtns();
  274. mBtnLink = getChild<LLButton>("Link");
  275. mBtnLink->setClickedCallback(onClickLink, this);
  276. mBtnUnlink = getChild<LLButton>("Unlink");
  277. mBtnUnlink->setClickedCallback(onClickUnlink, this);
  278. mTextObjectCount = getChild<LLTextBox>("obj_count");
  279. mTextObjectCount->setClickedCallback(click_count, this);
  280. mTextPrimCount = getChild<LLTextBox>("prim_count");
  281. mTextPrimCount->setClickedCallback(click_count, this);
  282. toolsPrecision();
  283. //
  284. // Create Buttons
  285. //
  286. static const char* tool_names[] =
  287. {
  288. "ToolCube",
  289. "ToolPrism",
  290. "ToolPyramid",
  291. "ToolTetrahedron",
  292. "ToolCylinder",
  293. "ToolHemiCylinder",
  294. "ToolCone",
  295. "ToolHemiCone",
  296. "ToolSphere",
  297. "ToolHemiSphere",
  298. "ToolTorus",
  299. "ToolTube",
  300. "ToolRing",
  301. "ToolTree",
  302. "ToolGrass"
  303. };
  304. constexpr size_t tool_names_count = LL_ARRAY_SIZE(tool_names);
  305. void* tool_data[] =
  306. {
  307. &LLToolPlacerPanel::sCube,
  308. &LLToolPlacerPanel::sPrism,
  309. &LLToolPlacerPanel::sPyramid,
  310. &LLToolPlacerPanel::sTetrahedron,
  311. &LLToolPlacerPanel::sCylinder,
  312. &LLToolPlacerPanel::sCylinderHemi,
  313. &LLToolPlacerPanel::sCone,
  314. &LLToolPlacerPanel::sConeHemi,
  315. &LLToolPlacerPanel::sSphere,
  316. &LLToolPlacerPanel::sSphereHemi,
  317. &LLToolPlacerPanel::sTorus,
  318. &LLToolPlacerPanel::sSquareTorus,
  319. &LLToolPlacerPanel::sTriangleTorus,
  320. &LLToolPlacerPanel::sTree,
  321. &LLToolPlacerPanel::sGrass
  322. };
  323. for (size_t t = 0; t < tool_names_count; ++t)
  324. {
  325. LLButton* found = getChild<LLButton>(tool_names[t]);
  326. if (found)
  327. {
  328. found->setClickedCallback(setObjectType, tool_data[t]);
  329. mButtons.push_back(found);
  330. }
  331. else
  332. {
  333. llerrs << "Tool button '" << tool_names[t] << "' not found !"
  334. << llendl;
  335. }
  336. }
  337. mCheckCopySelection = getChild<LLCheckBoxCtrl>("checkbox copy selection");
  338. mCheckCopySelection->setValue(gSavedSettings.getBool("CreateToolCopySelection"));
  339. mCheckSticky = getChild<LLCheckBoxCtrl>("checkbox sticky");
  340. mCheckSticky->setValue(gSavedSettings.getBool("CreateToolKeepSelected"));
  341. mCheckCopyCenters = getChild<LLCheckBoxCtrl>("checkbox copy centers");
  342. mCheckCopyCenters->setValue(gSavedSettings.getBool("CreateToolCopyCenters"));
  343. mCheckCopyRotates = getChild<LLCheckBoxCtrl>("checkbox copy rotates");
  344. mCheckCopyRotates->setValue(gSavedSettings.getBool("CreateToolCopyRotates"));
  345. mRadioSelectLand = getChild<LLCheckBoxCtrl>("radio select land");
  346. mRadioSelectLand->setCommitCallback(commit_select_tool);
  347. mRadioSelectLand->setCallbackUserData((void*)&gToolSelectLand);
  348. mRadioDozerFlatten = getChild<LLCheckBoxCtrl>("radio flatten");
  349. mRadioDozerFlatten->setCommitCallback(click_popup_dozer_mode);
  350. mRadioDozerFlatten->setCallbackUserData((void*)0);
  351. mRadioDozerRaise = getChild<LLCheckBoxCtrl>("radio raise");
  352. mRadioDozerRaise->setCommitCallback(click_popup_dozer_mode);
  353. mRadioDozerRaise->setCallbackUserData((void*)1);
  354. mRadioDozerLower = getChild<LLCheckBoxCtrl>("radio lower");
  355. mRadioDozerLower->setCommitCallback(click_popup_dozer_mode);
  356. mRadioDozerLower->setCallbackUserData((void*)2);
  357. mRadioDozerSmooth = getChild<LLCheckBoxCtrl>("radio smooth");
  358. mRadioDozerSmooth->setCommitCallback(click_popup_dozer_mode);
  359. mRadioDozerSmooth->setCallbackUserData((void*)3);
  360. mRadioDozerNoise = getChild<LLCheckBoxCtrl>("radio noise");
  361. mRadioDozerNoise->setCommitCallback(click_popup_dozer_mode);
  362. mRadioDozerNoise->setCallbackUserData((void*)4);
  363. mRadioDozerRevert = getChild<LLCheckBoxCtrl>("radio revert");
  364. mRadioDozerRevert->setCommitCallback(click_popup_dozer_mode);
  365. mRadioDozerRevert->setCallbackUserData((void*)5);
  366. mBtnApplyToSelection = getChild<LLButton>("button apply to selection");
  367. mBtnApplyToSelection->setClickedCallback(click_apply_to_selection, NULL);
  368. mSliderDozerSize = getChild<LLSliderCtrl>("slider brush size");
  369. mSliderDozerSize->setCommitCallback(commit_slider_dozer_size);
  370. mSliderDozerSize->setValue(gSavedSettings.getF32("LandBrushSize"));
  371. mSliderDozerForce = getChild<LLSliderCtrl>("slider force");
  372. mSliderDozerForce->setCommitCallback(commit_slider_dozer_force);
  373. // The setting stores the actual force multiplier, but the slider is
  374. // logarithmic, so we convert here
  375. mSliderDozerForce->setValue(log10f(gSavedSettings.getF32("LandBrushForce")));
  376. mTextBulldozer = getChild<LLTextBox>("Bulldozer:");
  377. mTextDozerSize = getChild<LLTextBox>("Dozer Size:");
  378. mTextStrength = getChild<LLTextBox>("Strength:");
  379. mComboTreesGrass = getChild<LLComboBox>("tree_grass");
  380. mComboTreesGrass->setCommitCallback(onSelectTreesGrass);
  381. mComboTreesGrass->setCallbackUserData(this);
  382. mTextTreeGrass = getChild<LLTextBox>("tree_grass_label");
  383. mBtnToolTree = getChild<LLButton>("ToolTree");
  384. mBtnToolGrass = getChild<LLButton>("ToolGrass");
  385. mTab = getChild<LLTabContainer>("Object Info Tabs");
  386. mTab->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT);
  387. mTab->setBorderVisible(false);
  388. mTab->selectFirstTab();
  389. mStatusText["rotate"] = getString("status_rotate");
  390. mStatusText["scale"] = getString("status_scale");
  391. mStatusText["move"] = getString("status_move");
  392. mStatusText["align"] = getString("status_align");
  393. mStatusText["modifyland"] = getString("status_modifyland");
  394. mStatusText["camera"] = getString("status_camera");
  395. mStatusText["grab"] = getString("status_grab");
  396. mStatusText["place"] = getString("status_place");
  397. mStatusText["selectland"] = getString("status_selectland");
  398. mGridScreenText = getString("grid_screen_text");
  399. mGridLocalText = getString("grid_local_text");
  400. mGridWorldText = getString("grid_world_text");
  401. mGridReferenceText = getString("grid_reference_text");
  402. mGridAttachmentText = getString("grid_attachment_text");
  403. mBtnEditMedia = getChild<LLButton>("edit_media");
  404. mBtnEditMedia->setClickedCallback(onClickBtnEditMedia, this);
  405. mBtnAddMedia = getChild<LLButton>("add_media");
  406. mBtnAddMedia->setClickedCallback(onClickBtnAddMedia, this);
  407. mBtnDeleteMedia = getChild<LLButton>("delete_media");
  408. mBtnDeleteMedia->setClickedCallback(onClickBtnDeleteMedia, this);
  409. mTextMediaInfo = getChild<LLTextBox>("media_info");
  410. return true;
  411. }
  412. // Create the popupview with a dummy center. It will be moved into place during
  413. // LLViewerWindow's per-frame hover processing.
  414. LLFloaterTools::LLFloaterTools()
  415. : LLFloater("build"),
  416. mDirty(true),
  417. mPrecision(3),
  418. mLastObjectCount(-1),
  419. mLastPrimCount(-1),
  420. mLastLandImpact(-1)
  421. {
  422. setAutoFocus(false);
  423. LLCallbackMap::map_t factory_map;
  424. // LLPanelPermissions
  425. factory_map["General"] = LLCallbackMap(createPanelPermissions, this);
  426. // LLPanelObject
  427. factory_map["Object"] = LLCallbackMap(createPanelObject, this);
  428. // LLPanelVolume
  429. factory_map["Features"] = LLCallbackMap(createPanelVolume, this);
  430. // LLPanelFace
  431. factory_map["Texture"] = LLCallbackMap(createPanelFace, this);
  432. // LLPanelContents
  433. factory_map["Contents"] = LLCallbackMap(createPanelContents, this);
  434. // LLPanelContents
  435. factory_map["ContentsInventory"] =
  436. LLCallbackMap(createPanelContentsInventory, this);
  437. // LLPanelLandInfo
  438. factory_map["land info panel"] = LLCallbackMap(createPanelLandInfo, this);
  439. LLUICtrlFactory::getInstance()->buildFloater(this, "floater_tools.xml",
  440. &factory_map, false);
  441. }
  442. //virtual
  443. LLFloaterTools::~LLFloaterTools()
  444. {
  445. llinfos << "Floater Tools destroyed" << llendl;
  446. gFloaterToolsp = NULL;
  447. }
  448. void LLFloaterTools::setStatusText(const std::string& text)
  449. {
  450. std::map<std::string, std::string>::iterator iter = mStatusText.find(text);
  451. if (iter != mStatusText.end())
  452. {
  453. mTextStatus->setText(iter->second);
  454. }
  455. else
  456. {
  457. mTextStatus->setText(text);
  458. }
  459. }
  460. //virtual
  461. void LLFloaterTools::refresh()
  462. {
  463. constexpr S32 INFO_HEIGHT = 384;
  464. LLRect object_info_rect(0, 0, getRect().getWidth(), -INFO_HEIGHT);
  465. bool all_volume = gSelectMgr.selectionAllPCode(LL_PCODE_VOLUME);
  466. S32 idx_features = mTab->getPanelIndexByTitle(PANEL_NAMES[PANEL_FEATURES]);
  467. S32 idx_face = mTab->getPanelIndexByTitle(PANEL_NAMES[PANEL_FACE]);
  468. S32 idx_contents = mTab->getPanelIndexByTitle(PANEL_NAMES[PANEL_CONTENTS]);
  469. S32 selected_index = mTab->getCurrentPanelIndex();
  470. if (!all_volume &&
  471. (selected_index == idx_features || selected_index == idx_face ||
  472. selected_index == idx_contents))
  473. {
  474. mTab->selectFirstTab();
  475. }
  476. mTab->enableTabButton(idx_features, all_volume);
  477. mTab->enableTabButton(idx_face, all_volume);
  478. mTab->enableTabButton(idx_contents, all_volume);
  479. // Refresh object and prim count labels
  480. LLObjectSelectionHandle selection = gSelectMgr.getSelection();
  481. S32 objects = selection->getRootObjectCount();
  482. S32 prims = selection->getObjectCount();
  483. S32 cost = prims;
  484. if (gMeshRepo.meshRezEnabled())
  485. {
  486. cost = (S32)(selection->getSelectedObjectCost() + 0.5f);
  487. }
  488. if (mLastObjectCount != objects || mLastPrimCount != prims ||
  489. mLastLandImpact != cost)
  490. {
  491. mLastObjectCount = objects;
  492. mLastPrimCount = prims;
  493. mLastLandImpact = cost;
  494. std::string count = llformat("%d", objects);
  495. mTextObjectCount->setTextArg("[COUNT]", count);
  496. count = llformat("%d", prims);
  497. if (cost != prims)
  498. {
  499. count += llformat(" (%d)", cost);
  500. }
  501. mTextPrimCount->setTextArg("[COUNT]", count);
  502. }
  503. updatePrevNextBtns();
  504. toolsPrecision();
  505. // Refresh child tabs
  506. mPanelPermissions->refresh();
  507. mPanelObject->refresh();
  508. mPanelVolume->refresh();
  509. mPanelFace->refresh();
  510. mPanelContents->refresh();
  511. mPanelLandInfo->refresh();
  512. getMediaState();
  513. }
  514. //virtual
  515. void LLFloaterTools::draw()
  516. {
  517. //MK
  518. // Fast enough that it can be kept here
  519. if (gRLenabled && gRLInterface.mContainsEdit)
  520. {
  521. LLViewerObject* objp = gSelectMgr.getSelection()->getPrimaryObject();
  522. if (!objp || !gRLInterface.canEdit(objp))
  523. {
  524. close();
  525. return;
  526. }
  527. }
  528. //mk
  529. if (mDirty)
  530. {
  531. refresh();
  532. mDirty = false;
  533. }
  534. LLFloater::draw();
  535. }
  536. void LLFloaterTools::dirty()
  537. {
  538. mDirty = true;
  539. LLFloaterOpenObject::dirty();
  540. }
  541. // Clean up any tool state that should not persist when the floater is closed.
  542. void LLFloaterTools::resetToolState()
  543. {
  544. gCameraBtnZoom = true;
  545. gCameraBtnOrbit = false;
  546. gCameraBtnPan = false;
  547. gGrabBtnSpin = false;
  548. gGrabBtnVertical = false;
  549. }
  550. void LLFloaterTools::updatePrevNextBtns()
  551. {
  552. bool can_do_prev_next = (mCheckSelectIndividual->get() &&
  553. !gSelectMgr.getSelection()->isEmpty()) ||
  554. gToolMgr.isCurrentTool(&gToolFace);
  555. mBtnPrevChild->setEnabled(can_do_prev_next);
  556. mBtnNextChild->setEnabled(can_do_prev_next);
  557. }
  558. void LLFloaterTools::updatePopup(LLCoordGL center, MASK mask)
  559. {
  560. LLTool* tool = gToolMgr.getCurrentTool();
  561. // *HACK to allow seeing the buttons when you have the app in a window.
  562. // Keep the visibility the same as it
  563. if (tool == gToolNull)
  564. {
  565. return;
  566. }
  567. if (isMinimized())
  568. {
  569. // SL looks odd if we draw the tools while the window is minimized
  570. return;
  571. }
  572. // Focus buttons
  573. bool focus_visible = tool == &gToolFocus;
  574. mBtnFocus->setToggleState(focus_visible);
  575. mRadioZoom->setVisible(focus_visible);
  576. mRadioOrbit->setVisible(focus_visible);
  577. mRadioPan->setVisible(focus_visible);
  578. mSliderZoom->setVisible(focus_visible);
  579. mSliderZoom->setEnabled(gCameraBtnZoom);
  580. mRadioZoom->set(!gCameraBtnOrbit && !gCameraBtnPan &&
  581. mask != MASK_ORBIT && mask != (MASK_ORBIT | MASK_ALT) &&
  582. mask != MASK_PAN && mask != (MASK_PAN | MASK_ALT));
  583. mRadioOrbit->set(gCameraBtnOrbit || mask == MASK_ORBIT ||
  584. mask == (MASK_ORBIT | MASK_ALT));
  585. mRadioPan->set(gCameraBtnPan || mask == MASK_PAN ||
  586. mask == (MASK_PAN | MASK_ALT));
  587. // Multiply by correction factor because volume sliders go [0, 0.5]
  588. mSliderZoom->setValue(gAgent.getCameraZoomFraction() * 0.5f);
  589. // Move buttons
  590. bool move_visible = tool == &gToolGrab;
  591. mBtnMove->setToggleState(move_visible);
  592. // HACK - highlight buttons for next click
  593. mRadioMove->setVisible(move_visible);
  594. mRadioMove->set(!gGrabBtnSpin && !gGrabBtnVertical &&
  595. mask != MASK_VERTICAL && mask != MASK_SPIN);
  596. mRadioLift->setVisible(move_visible);
  597. mRadioLift->set(gGrabBtnVertical || mask == MASK_VERTICAL);
  598. mRadioSpin->setVisible(move_visible);
  599. mRadioSpin->set(gGrabBtnSpin || mask == MASK_SPIN);
  600. // Edit buttons
  601. bool edit_visible = tool->isObjectEditTool();
  602. mBtnEdit->setToggleState(edit_visible);
  603. mRadioPosition->setVisible(edit_visible);
  604. mRadioAlign->setVisible(edit_visible);
  605. mRadioRotate->setVisible(edit_visible);
  606. mRadioStretch->setVisible(edit_visible);
  607. mRadioSelectFace->setVisible(edit_visible);
  608. mRadioSelectFace->set(tool == &gToolFace);
  609. mBtnPrevChild->setVisible(edit_visible);
  610. mBtnNextChild->setVisible(edit_visible);
  611. mBtnLink->setVisible(edit_visible);
  612. mBtnUnlink->setVisible(edit_visible);
  613. mBtnLink->setEnabled(gSelectMgr.enableLinkObjects());
  614. mBtnUnlink->setEnabled(gSelectMgr.enableUnlinkObjects());
  615. updatePrevNextBtns();
  616. mCheckSelectIndividual->setVisible(edit_visible);
  617. mRadioPosition->set(tool == &gToolCompTranslate);
  618. mRadioAlign ->set(tool == &gToolAlign);
  619. mRadioRotate->set(tool == &gToolCompRotate);
  620. mRadioStretch->set(tool == &gToolCompScale);
  621. mComboGridMode->setVisible(edit_visible);
  622. S32 index = mComboGridMode->getCurrentIndex();
  623. mComboGridMode->removeall();
  624. switch (mObjectSelection->getSelectType())
  625. {
  626. case SELECT_TYPE_HUD:
  627. mComboGridMode->add(mGridScreenText);
  628. mComboGridMode->add(mGridLocalText);
  629. //mComboGridMode->add(mGridReferenceText);
  630. break;
  631. case SELECT_TYPE_WORLD:
  632. mComboGridMode->add(mGridWorldText);
  633. mComboGridMode->add(mGridLocalText);
  634. mComboGridMode->add(mGridReferenceText);
  635. break;
  636. case SELECT_TYPE_ATTACHMENT:
  637. mComboGridMode->add(mGridAttachmentText);
  638. mComboGridMode->add(mGridLocalText);
  639. mComboGridMode->add(mGridReferenceText);
  640. }
  641. mComboGridMode->setCurrentByIndex(index);
  642. mTextGridMode->setVisible(edit_visible);
  643. mBtnGridOptions->setVisible(edit_visible);
  644. //mCheckSelectLinked->setVisible(edit_visible);
  645. mCheckStretchUniform->setVisible(edit_visible);
  646. mCheckStretchTexture->setVisible(edit_visible);
  647. mCheckUseRootForPivot->setVisible(edit_visible);
  648. // Create buttons
  649. bool create_visible = tool == &gToolCompCreate;
  650. mBtnCreate->setToggleState(tool == &gToolCompCreate);
  651. updateTreeGrassCombo(create_visible);
  652. if (mCheckCopySelection->get())
  653. {
  654. // don't highlight any placer button
  655. for (std::vector<LLButton*>::size_type i = 0; i < mButtons.size(); i++)
  656. {
  657. mButtons[i]->setToggleState(false);
  658. mButtons[i]->setVisible(create_visible);
  659. }
  660. }
  661. else
  662. {
  663. // Highlight the correct placer button
  664. for (std::vector<LLButton*>::size_type i = 0, count = mButtons.size();
  665. i < count; ++i)
  666. {
  667. LLPCode pcode = LLToolPlacer::getObjectType();
  668. void* userdata = mButtons[i]->getCallbackUserData();
  669. LLPCode* cur = (LLPCode*)userdata;
  670. bool state = (pcode == *cur);
  671. mButtons[i]->setToggleState(state);
  672. mButtons[i]->setVisible(create_visible);
  673. }
  674. }
  675. mCheckSticky->setVisible(create_visible);
  676. mCheckCopySelection->setVisible(create_visible);
  677. mCheckCopyCenters->setVisible(create_visible);
  678. mCheckCopyRotates->setVisible(create_visible);
  679. mCheckCopyCenters->setEnabled(mCheckCopySelection->get());
  680. mCheckCopyRotates->setEnabled(mCheckCopySelection->get());
  681. bool is_tool_brush = tool == &gToolBrushLand;
  682. // Land buttons
  683. bool land_visible = is_tool_brush || tool == &gToolSelectLand;
  684. mBtnLand->setToggleState(land_visible);
  685. mRadioSelectLand->set(tool == &gToolSelectLand);
  686. mRadioSelectLand->setVisible(land_visible);
  687. static LLCachedControl<S32> dozer_mode(gSavedSettings,
  688. "RadioLandBrushAction");
  689. mRadioDozerFlatten->set(is_tool_brush && dozer_mode == 0);
  690. mRadioDozerFlatten->setVisible(land_visible);
  691. mRadioDozerRaise->set(is_tool_brush && dozer_mode == 1);
  692. mRadioDozerRaise->setVisible(land_visible);
  693. mRadioDozerLower->set(is_tool_brush && dozer_mode == 2);
  694. mRadioDozerLower->setVisible(land_visible);
  695. mRadioDozerSmooth->set(is_tool_brush && dozer_mode == 3);
  696. mRadioDozerSmooth->setVisible(land_visible);
  697. mRadioDozerNoise->set(is_tool_brush && dozer_mode == 4);
  698. mRadioDozerNoise->setVisible(land_visible);
  699. mRadioDozerRevert->set(is_tool_brush && dozer_mode == 5);
  700. mRadioDozerRevert->setVisible(land_visible);
  701. mBtnApplyToSelection->setVisible(land_visible);
  702. mBtnApplyToSelection->setEnabled(land_visible &&
  703. !gViewerParcelMgr.selectionEmpty() &&
  704. tool != &gToolSelectLand);
  705. mSliderDozerSize->setVisible(land_visible);
  706. mTextBulldozer->setVisible(land_visible);
  707. mTextDozerSize->setVisible(land_visible);
  708. mSliderDozerForce->setVisible(land_visible);
  709. mTextStrength->setVisible(land_visible);
  710. mTextObjectCount->setVisible(!land_visible);
  711. mTextPrimCount->setVisible(!land_visible);
  712. mTab->setVisible(!land_visible);
  713. mPanelLandInfo->setVisible(land_visible);
  714. }
  715. //virtual
  716. bool LLFloaterTools::canClose()
  717. {
  718. // Do not close when quitting, so camera will stay put
  719. return !LLApp::isExiting();
  720. }
  721. //virtual
  722. void LLFloaterTools::onOpen()
  723. {
  724. mParcelSelection = gViewerParcelMgr.getFloatingParcelSelection();
  725. mObjectSelection = gSelectMgr.getEditSelection();
  726. gSavedSettings.setBool("BuildBtnState", true);
  727. }
  728. //virtual
  729. void LLFloaterTools::onClose(bool app_quitting)
  730. {
  731. LLPreviewMaterial::closeLiveEditorInstance();
  732. setMinimized(false);
  733. setVisible(false);
  734. mTab->setVisible(false);
  735. // Must be called, even though this is a dependent floater; this call
  736. // actually closes the floater (instead of hiding it) and unloads the
  737. // media preview as a result (ending a SLPlugin).
  738. LLFloaterMediaSettings::hideInstance();
  739. LLViewerJoystick::getInstance()->moveAvatar(false);
  740. // Different from handle_reset_view() in that it does not actually move the
  741. // camera if EditCameraMovement is not set.
  742. gAgent.resetView(gSavedSettings.getBool("EditCameraMovement"));
  743. // Exit component selection mode
  744. gSelectMgr.promoteSelectionToRoot();
  745. gSavedSettings.setBool("EditLinkedParts", false);
  746. gViewerWindowp->showCursor();
  747. resetToolState();
  748. mParcelSelection = NULL;
  749. mObjectSelection = NULL;
  750. if (!gAgent.cameraMouselook())
  751. {
  752. // Switch back to basic toolset
  753. gToolMgr.setCurrentToolset(gBasicToolset);
  754. // we were already in basic toolset, using build tools
  755. // so manually reset tool to default (pie menu tool)
  756. gToolMgr.getCurrentToolset()->selectFirstTool();
  757. }
  758. else
  759. {
  760. // Switch back to mouselook toolset
  761. gToolMgr.setCurrentToolset(gMouselookToolset);
  762. gViewerWindowp->hideCursor();
  763. gViewerWindowp->moveCursorToCenter();
  764. }
  765. gSavedSettings.setBool("BuildBtnState", false);
  766. }
  767. void LLFloaterTools::showPanel(EInfoPanel panel)
  768. {
  769. llassert(panel >= 0 && panel < PANEL_COUNT);
  770. mTab->selectTabByName(PANEL_NAMES[panel]);
  771. }
  772. void click_popup_grab_drag(LLUICtrl*, void*)
  773. {
  774. gGrabBtnVertical = false;
  775. gGrabBtnSpin = false;
  776. }
  777. void click_popup_grab_lift(LLUICtrl*, void*)
  778. {
  779. gGrabBtnVertical = true;
  780. gGrabBtnSpin = false;
  781. }
  782. void click_popup_grab_spin(LLUICtrl*, void*)
  783. {
  784. gGrabBtnVertical = false;
  785. gGrabBtnSpin = true;
  786. }
  787. void commit_radio_zoom(LLUICtrl*, void*)
  788. {
  789. gCameraBtnZoom = true;
  790. gCameraBtnOrbit = false;
  791. gCameraBtnPan = false;
  792. }
  793. void commit_radio_orbit(LLUICtrl*, void*)
  794. {
  795. gCameraBtnZoom = false;
  796. gCameraBtnOrbit = true;
  797. gCameraBtnPan = false;
  798. }
  799. void commit_radio_pan(LLUICtrl*, void*)
  800. {
  801. gCameraBtnZoom = gCameraBtnOrbit = false;
  802. gCameraBtnPan = true;
  803. }
  804. void commit_slider_zoom(LLUICtrl* ctrl, void*)
  805. {
  806. // renormalize value, since max "volume" level is 0.5 for some reason
  807. F32 zoom_level = (F32)ctrl->getValue().asReal() * 2.f; // / 0.5f;
  808. gAgent.setCameraZoomFraction(zoom_level);
  809. }
  810. void click_popup_dozer_mode(LLUICtrl*, void* data)
  811. {
  812. S32 mode = (S32)(intptr_t)data;
  813. gFloaterToolsp->setEditTool(&gToolBrushLand);
  814. gSavedSettings.setS32("RadioLandBrushAction", mode);
  815. }
  816. void commit_slider_dozer_size(LLUICtrl* ctrl, void*)
  817. {
  818. F32 size = (F32)ctrl->getValue().asReal();
  819. gSavedSettings.setF32("LandBrushSize", size);
  820. }
  821. void commit_slider_dozer_force(LLUICtrl* ctrl, void*)
  822. {
  823. // The slider is logarithmic, so we exponentiate to get the actual force
  824. // multiplier
  825. F32 dozer_force = powf(10.f, ctrl->getValue().asReal());
  826. gSavedSettings.setF32("LandBrushForce", dozer_force);
  827. }
  828. void click_apply_to_selection(void*)
  829. {
  830. gToolBrushLand.modifyLandInSelectionGlobal();
  831. }
  832. void commit_select_tool(LLUICtrl* ctrl, void* data)
  833. {
  834. S32 show_owners = gSavedSettings.getBool("ShowParcelOwners");
  835. gFloaterToolsp->setEditTool(data);
  836. gSavedSettings.setBool("ShowParcelOwners", show_owners);
  837. }
  838. void select_next_part(void* data)
  839. {
  840. select_face_or_linked_prim("next");
  841. }
  842. void select_previous_part(void* data)
  843. {
  844. select_face_or_linked_prim("previous");
  845. }
  846. void click_count(void* data)
  847. {
  848. LLFloaterObjectWeights::show(gFloaterToolsp);
  849. }
  850. void LLFloaterTools::onCommitGridMode(LLUICtrl* ctrl, void* data)
  851. {
  852. LLFloaterTools* self = (LLFloaterTools*)data;
  853. LLComboBox* combo = (LLComboBox*)ctrl;
  854. if (combo && self)
  855. {
  856. gSelectMgr.setGridMode((EGridMode)combo->getCurrentIndex());
  857. self->mPanelObject->refresh();
  858. }
  859. }
  860. //static
  861. void LLFloaterTools::commitSelectComponent(LLUICtrl* ctrl, void* data)
  862. {
  863. LLFloaterTools* self = (LLFloaterTools*)data;
  864. if (!self) return;
  865. // forfeit focus
  866. if (gFocusMgr.childHasKeyboardFocus(self))
  867. {
  868. gFocusMgr.setKeyboardFocus(NULL);
  869. }
  870. if (self->mCheckSelectIndividual->get())
  871. {
  872. gSelectMgr.demoteSelectionToIndividuals();
  873. }
  874. else
  875. {
  876. gSelectMgr.promoteSelectionToRoot();
  877. }
  878. self->dirty();
  879. }
  880. //static
  881. void LLFloaterTools::setObjectType(void* data)
  882. {
  883. LLPCode pcode = *(LLPCode*)data;
  884. LLToolPlacer::setObjectType(pcode);
  885. gSavedSettings.setBool("CreateToolCopySelection", false);
  886. gFloaterToolsp->updateTreeGrassCombo(true);
  887. gFocusMgr.setMouseCapture(NULL);
  888. }
  889. //static
  890. void LLFloaterTools::onClickGridOptions(void* data)
  891. {
  892. LLFloaterBuildOptions::toggleInstance();
  893. // Makes grid options dependent on build tools window
  894. LLFloaterTools* self = (LLFloaterTools*)data;
  895. LLFloaterBuildOptions* floater = LLFloaterBuildOptions::findInstance();
  896. if (self && floater)
  897. {
  898. self->addDependentFloater(floater);
  899. }
  900. }
  901. //static
  902. void LLFloaterTools::onClickLink(void* data)
  903. {
  904. gSelectMgr.linkObjects();
  905. }
  906. //static
  907. void LLFloaterTools::onClickUnlink(void* data)
  908. {
  909. gSelectMgr.unlinkObjects();
  910. }
  911. void LLFloaterTools::setEditTool(void* tool)
  912. {
  913. gToolMgr.getCurrentToolset()->selectTool((LLTool*)tool);
  914. }
  915. void LLFloaterTools::onFocusReceived()
  916. {
  917. gToolMgr.setCurrentToolset(gBasicToolset);
  918. LLFloater::onFocusReceived();
  919. }
  920. //static
  921. void LLFloaterTools::onSelectTreesGrass(LLUICtrl*, void*)
  922. {
  923. const std::string& selected = gFloaterToolsp->mComboTreesGrass->getValue();
  924. LLPCode pcode = LLToolPlacer::getObjectType();
  925. if (pcode == LLToolPlacerPanel::sTree)
  926. {
  927. gSavedSettings.setString("LastTree", selected);
  928. }
  929. else if (pcode == LLToolPlacerPanel::sGrass)
  930. {
  931. gSavedSettings.setString("LastGrass", selected);
  932. }
  933. }
  934. void LLFloaterTools::updateTreeGrassCombo(bool visible)
  935. {
  936. if (visible)
  937. {
  938. LLPCode pcode = LLToolPlacer::getObjectType();
  939. std::map<std::string, S32>::iterator it, end;
  940. std::string selected;
  941. if (pcode == LLToolPlacerPanel::sTree)
  942. {
  943. mTextTreeGrass->setVisible(visible);
  944. mTextTreeGrass->setText(mBtnToolTree->getToolTip());
  945. static LLCachedControl<std::string> last_tree(gSavedSettings,
  946. "LastTree");
  947. selected = last_tree;
  948. it = LLVOTree::sSpeciesNames.begin();
  949. end = LLVOTree::sSpeciesNames.end();
  950. }
  951. else if (pcode == LLToolPlacerPanel::sGrass)
  952. {
  953. mTextTreeGrass->setVisible(visible);
  954. mTextTreeGrass->setText(mBtnToolGrass->getToolTip());
  955. static LLCachedControl<std::string> last_grass(gSavedSettings,
  956. "LastGrass");
  957. selected = last_grass;
  958. it = LLVOGrass::sSpeciesNames.begin();
  959. end = LLVOGrass::sSpeciesNames.end();
  960. }
  961. else
  962. {
  963. mComboTreesGrass->removeall();
  964. // LLComboBox::removeall() does not clear the label
  965. mComboTreesGrass->setLabel("");
  966. mComboTreesGrass->setEnabled(false);
  967. mComboTreesGrass->setVisible(false);
  968. mTextTreeGrass->setVisible(false);
  969. return;
  970. }
  971. mComboTreesGrass->removeall();
  972. mComboTreesGrass->add("Random");
  973. S32 select = 0, i = 0;
  974. while (it != end)
  975. {
  976. const std::string& species = it->first;
  977. mComboTreesGrass->add(species);
  978. ++i;
  979. if (species == selected)
  980. {
  981. select = i;
  982. }
  983. ++it;
  984. }
  985. // if saved species not found, default to "Random"
  986. mComboTreesGrass->selectNthItem(select);
  987. mComboTreesGrass->setEnabled(true);
  988. }
  989. mComboTreesGrass->setVisible(visible);
  990. mTextTreeGrass->setVisible(visible);
  991. }
  992. // Media stuff
  993. // *TODO: move this to llpanelface.cpp, where it belongs...
  994. bool LLFloaterTools::selectedMediaEditable()
  995. {
  996. U32 owner_mask_on, owner_mask_off;
  997. bool valid_owner_perms = gSelectMgr.selectGetPerm(PERM_OWNER,
  998. &owner_mask_on,
  999. &owner_mask_off);
  1000. U32 group_mask_on, group_mask_off;
  1001. bool valid_group_perms = gSelectMgr.selectGetPerm(PERM_GROUP,
  1002. &group_mask_on,
  1003. &group_mask_off);
  1004. U32 everyone_mask_on, everyone_mask_off;
  1005. bool valid_everyone_perms = gSelectMgr.selectGetPerm(PERM_EVERYONE,
  1006. &everyone_mask_on,
  1007. &everyone_mask_off);
  1008. bool selected_media_editable = false;
  1009. // if perms we got back are valid
  1010. if (valid_owner_perms && valid_group_perms && valid_everyone_perms)
  1011. {
  1012. if ((owner_mask_on & PERM_MODIFY) || (group_mask_on & PERM_MODIFY) ||
  1013. (group_mask_on & PERM_MODIFY))
  1014. {
  1015. selected_media_editable = true;
  1016. }
  1017. else
  1018. {
  1019. // user is NOT allowed to press the RESET button
  1020. selected_media_editable = false;
  1021. }
  1022. }
  1023. return selected_media_editable;
  1024. }
  1025. void LLFloaterTools::getMediaState()
  1026. {
  1027. static LLCachedControl<bool> streaming_media(gSavedSettings,
  1028. "EnableStreamingMedia");
  1029. static LLCachedControl<bool> prim_media_master(gSavedSettings,
  1030. "PrimMediaMasterEnabled");
  1031. bool media_enabled = streaming_media && prim_media_master;
  1032. mBtnEditMedia->setVisible(media_enabled);
  1033. mBtnDeleteMedia->setVisible(media_enabled);
  1034. mBtnAddMedia->setVisible(media_enabled);
  1035. mTextMediaInfo->setVisible(media_enabled);
  1036. if (!media_enabled)
  1037. {
  1038. return;
  1039. }
  1040. LLObjectSelectionHandle selected_objects = gSelectMgr.getSelection();
  1041. LLViewerObject* first_object = selected_objects->getFirstObject();
  1042. if (!first_object || first_object->getPCode() != LL_PCODE_VOLUME ||
  1043. !first_object->permModify())
  1044. {
  1045. mBtnEditMedia->setEnabled(false);
  1046. mBtnDeleteMedia->setEnabled(false);
  1047. mBtnAddMedia->setEnabled(false);
  1048. mTextMediaInfo->clear();
  1049. mTextMediaInfo->setToolTip(LLStringUtil::null);
  1050. LLFloaterMediaSettings::clearValues(false);
  1051. return;
  1052. }
  1053. if (first_object->getRegion()->getCapability("ObjectMedia").empty())
  1054. {
  1055. llwarns << "Media not enabled (no capability) in this region"
  1056. << llendl;
  1057. mBtnEditMedia->setEnabled(false);
  1058. mBtnDeleteMedia->setEnabled(false);
  1059. mBtnAddMedia->setEnabled(false);
  1060. mTextMediaInfo->clear();
  1061. mTextMediaInfo->setToolTip(LLStringUtil::null);
  1062. LLFloaterMediaSettings::clearValues(false);
  1063. return;
  1064. }
  1065. bool is_nonpermanent_enforced = (selected_objects->getFirstRootNode() &&
  1066. gSelectMgr.selectGetRootsNonPermanentEnforced()) ||
  1067. gSelectMgr.selectGetNonPermanentEnforced();
  1068. bool editable = is_nonpermanent_enforced &&
  1069. (first_object->permModify() || selectedMediaEditable());
  1070. // Check modify permissions and whether any selected objects are in
  1071. // the process of being fetched. If they are, then we're not editable
  1072. if (editable)
  1073. {
  1074. for (LLObjectSelection::iterator iter = selected_objects->begin(),
  1075. end = selected_objects->end();
  1076. iter != end; ++iter)
  1077. {
  1078. LLSelectNode* node = *iter;
  1079. LLViewerObject* objectp = node->getObject();
  1080. if (!objectp) continue; // Paranoia
  1081. LLVOVolume* vobjp = objectp->asVolume();
  1082. if (vobjp && !vobjp->permModify())
  1083. {
  1084. llinfos << "Selection not editable due to lack of modify permissions on object id "
  1085. << vobjp->getID() << llendl;
  1086. editable = false;
  1087. break;
  1088. }
  1089. }
  1090. }
  1091. // Media settings
  1092. bool bool_has_media = false;
  1093. struct media_functor : public LLSelectedTEGetFunctor<bool>
  1094. {
  1095. bool get(LLViewerObject* object, S32 face)
  1096. {
  1097. LLTextureEntry* te = object->getTE(face);
  1098. if (te)
  1099. {
  1100. return te->hasMedia();
  1101. }
  1102. return false;
  1103. }
  1104. } func;
  1105. // check if all faces have media(or, all dont have media)
  1106. LLFloaterMediaSettings::setHasMediaInfo(selected_objects->getSelectedTEValue(&func,
  1107. bool_has_media));
  1108. const LLMediaEntry default_media_data;
  1109. struct functor_getter_media_data : public LLSelectedTEGetFunctor<LLMediaEntry>
  1110. {
  1111. functor_getter_media_data(const LLMediaEntry& entry)
  1112. : mMediaEntry(entry)
  1113. {
  1114. }
  1115. LLMediaEntry get(LLViewerObject* object, S32 face)
  1116. {
  1117. LLTextureEntry* te = object ? object->getTE(face) : NULL;
  1118. if (te && te->getMediaData())
  1119. {
  1120. return *(te->getMediaData());
  1121. }
  1122. return mMediaEntry;
  1123. }
  1124. const LLMediaEntry& mMediaEntry;
  1125. } func_media_data(default_media_data);
  1126. LLMediaEntry media_data_get;
  1127. LLFloaterMediaSettings::setMultipleMedia(!selected_objects->getSelectedTEValue(&func_media_data,
  1128. media_data_get));
  1129. static const std::string multi_media_info_str = "Multiple Media";
  1130. std::string media_title;
  1131. // update UI depending on whether "object" (prim or face) has media and
  1132. // whether or not you are allowed to edit it.
  1133. if (LLFloaterMediaSettings::getHasMediaInfo())
  1134. {
  1135. // If all the faces have media (or all don't have media)
  1136. mTextMediaInfo->clear();
  1137. // if identical is set, all faces are same (whether all empty or has
  1138. // the same media)
  1139. if (!LLFloaterMediaSettings::getMultipleMedia())
  1140. {
  1141. // Media data is valid
  1142. if (media_data_get != default_media_data)
  1143. {
  1144. // media title is the media URL
  1145. media_title = media_data_get.getHomeURL();
  1146. }
  1147. // else all faces might be empty.
  1148. }
  1149. else // there are different medias on the faces.
  1150. {
  1151. media_title = multi_media_info_str;
  1152. }
  1153. mBtnEditMedia->setEnabled(bool_has_media && editable &&
  1154. LLFloaterMediaSettings::getHasMediaInfo());
  1155. mBtnDeleteMedia->setEnabled(bool_has_media && editable);
  1156. mBtnAddMedia->setEnabled(!bool_has_media && editable);
  1157. }
  1158. else
  1159. {
  1160. // Not all faces have media but at least one does.
  1161. LLFloaterMediaSettings::setMultipleValidMedia(selected_objects->isMultipleTEValue(&func_media_data,
  1162. default_media_data));
  1163. if (LLFloaterMediaSettings::getMultipleValidMedia())
  1164. {
  1165. // Selected faces don't have identical values
  1166. media_title = multi_media_info_str;
  1167. }
  1168. else
  1169. {
  1170. // Media data is valid
  1171. if (media_data_get != default_media_data)
  1172. {
  1173. // media title is the media URL
  1174. media_title = media_data_get.getHomeURL();
  1175. }
  1176. }
  1177. mBtnEditMedia->setEnabled(LLFloaterMediaSettings::getHasMediaInfo());
  1178. mBtnDeleteMedia->setEnabled(true);
  1179. mBtnAddMedia->setEnabled(false);
  1180. }
  1181. mTextMediaInfo->setText(media_title);
  1182. mTextMediaInfo->setToolTip(media_title);
  1183. mTextMediaInfo->setEnabled(true);
  1184. // load values for media settings
  1185. updateMediaSettings();
  1186. LLFloaterMediaSettings::initValues(mMediaSettings, editable);
  1187. }
  1188. //static
  1189. bool LLFloaterTools::multipleFacesSelectedConfirm(const LLSD& notification,
  1190. const LLSD& response)
  1191. {
  1192. S32 option = LLNotification::getSelectedOption(notification, response);
  1193. if (gFloaterToolsp && option == 0) // "Yes"
  1194. {
  1195. gFloaterToolsp->onClickBtnEditMedia(gFloaterToolsp);
  1196. }
  1197. return false;
  1198. }
  1199. //static
  1200. void LLFloaterTools::onClickBtnAddMedia(void* data)
  1201. {
  1202. LLFloaterTools* self = (LLFloaterTools*)data;
  1203. if (self)
  1204. {
  1205. if (gSelectMgr.getSelection()->isMultipleTESelected())
  1206. {
  1207. gNotifications.add("MultipleFacesSelected", LLSD(), LLSD(),
  1208. multipleFacesSelectedConfirm);
  1209. }
  1210. else
  1211. {
  1212. onClickBtnEditMedia(data);
  1213. }
  1214. }
  1215. }
  1216. //////////////////////////////////////////////////////////////////////////////
  1217. // called when a user wants to edit existing media settings on a prim or prim
  1218. // face.
  1219. void LLFloaterTools::onClickBtnEditMedia(void* data)
  1220. {
  1221. LLFloaterTools* self = (LLFloaterTools*)data;
  1222. if (self)
  1223. {
  1224. self->getMediaState();
  1225. // Makes the media settings dependent on build tools window
  1226. self->addDependentFloater(LLFloaterMediaSettings::showInstance(),
  1227. false);
  1228. }
  1229. }
  1230. //////////////////////////////////////////////////////////////////////////////
  1231. // called when a user wants to delete media from a prim or prim face
  1232. //static
  1233. bool LLFloaterTools::deleteMediaConfirm(const LLSD& notification,
  1234. const LLSD& response)
  1235. {
  1236. S32 option = LLNotification::getSelectedOption(notification, response);
  1237. if (option == 0) // "Yes"
  1238. {
  1239. gSelectMgr.selectionSetMedia(0, LLSD());
  1240. LLFloaterMediaSettings::hideInstance();
  1241. }
  1242. return false;
  1243. }
  1244. //static
  1245. void LLFloaterTools::onClickBtnDeleteMedia(void* data)
  1246. {
  1247. gNotifications.add("DeleteMedia", LLSD(), LLSD(), deleteMediaConfirm);
  1248. }
  1249. void LLFloaterTools::updateMediaSettings()
  1250. {
  1251. static const std::string tentative_suffix(LLMediaEntry::TENTATIVE_SUFFIX);
  1252. bool identical = false;
  1253. std::string base_key, value_str;
  1254. int value_int = 0;
  1255. bool value_bool = false;
  1256. LLObjectSelectionHandle selected_objects = gSelectMgr.getSelection();
  1257. const LLMediaEntry default_media_data;
  1258. // controls
  1259. U8 value_u8 = default_media_data.getControls();
  1260. struct functor_getter_controls : public LLSelectedTEGetFunctor<U8>
  1261. {
  1262. functor_getter_controls(const LLMediaEntry& entry)
  1263. : mMediaEntry(entry)
  1264. {
  1265. }
  1266. U8 get(LLViewerObject* object, S32 face)
  1267. {
  1268. LLTextureEntry* tep = object ? object->getTE(face) : NULL;
  1269. if (tep && tep->getMediaData())
  1270. {
  1271. return tep->getMediaData()->getControls();
  1272. }
  1273. return mMediaEntry.getControls();
  1274. }
  1275. const LLMediaEntry& mMediaEntry;
  1276. } func_controls(default_media_data);
  1277. identical = selected_objects->getSelectedTEValue(&func_controls, value_u8);
  1278. base_key = std::string(LLMediaEntry::CONTROLS_KEY);
  1279. mMediaSettings[base_key] = value_u8;
  1280. mMediaSettings[base_key + tentative_suffix] = !identical;
  1281. // First click (formerly left click)
  1282. value_bool = default_media_data.getFirstClickInteract();
  1283. struct functor_getter_first_click : public LLSelectedTEGetFunctor<bool>
  1284. {
  1285. functor_getter_first_click(const LLMediaEntry& entry)
  1286. : mMediaEntry(entry)
  1287. {
  1288. }
  1289. bool get(LLViewerObject* object, S32 face)
  1290. {
  1291. LLTextureEntry* tep = object ? object->getTE(face) : NULL;
  1292. if (tep && tep->getMediaData())
  1293. {
  1294. return tep->getMediaData()->getFirstClickInteract();
  1295. }
  1296. return mMediaEntry.getFirstClickInteract();
  1297. }
  1298. const LLMediaEntry& mMediaEntry;
  1299. } func_first_click(default_media_data);
  1300. identical = selected_objects->getSelectedTEValue(&func_first_click,
  1301. value_bool);
  1302. base_key = std::string(LLMediaEntry::FIRST_CLICK_INTERACT_KEY);
  1303. mMediaSettings[base_key] = value_bool;
  1304. mMediaSettings[base_key + tentative_suffix] = !identical;
  1305. // Home URL
  1306. value_str = default_media_data.getHomeURL();
  1307. struct functor_getter_home_url : public LLSelectedTEGetFunctor<std::string>
  1308. {
  1309. functor_getter_home_url(const LLMediaEntry& entry)
  1310. : mMediaEntry(entry)
  1311. {
  1312. }
  1313. std::string get(LLViewerObject* object, S32 face)
  1314. {
  1315. LLTextureEntry* tep = object ? object->getTE(face) : NULL;
  1316. if (tep && tep->getMediaData())
  1317. {
  1318. return tep->getMediaData()->getHomeURL();
  1319. }
  1320. return mMediaEntry.getHomeURL();
  1321. }
  1322. const LLMediaEntry& mMediaEntry;
  1323. } func_home_url(default_media_data);
  1324. identical = selected_objects->getSelectedTEValue(&func_home_url,
  1325. value_str);
  1326. base_key = std::string(LLMediaEntry::HOME_URL_KEY);
  1327. mMediaSettings[base_key] = value_str;
  1328. mMediaSettings[base_key + tentative_suffix] = !identical;
  1329. // Current URL
  1330. value_str = default_media_data.getCurrentURL();
  1331. struct functor_getter_current_url : public LLSelectedTEGetFunctor<std::string>
  1332. {
  1333. functor_getter_current_url(const LLMediaEntry& entry)
  1334. : mMediaEntry(entry)
  1335. {
  1336. }
  1337. std::string get(LLViewerObject* object, S32 face)
  1338. {
  1339. LLTextureEntry* tep = object ? object->getTE(face) : NULL;
  1340. if (tep && tep->getMediaData())
  1341. {
  1342. return tep->getMediaData()->getCurrentURL();
  1343. }
  1344. return mMediaEntry.getCurrentURL();
  1345. }
  1346. const LLMediaEntry& mMediaEntry;
  1347. } func_current_url(default_media_data);
  1348. identical = selected_objects->getSelectedTEValue(&func_current_url,
  1349. value_str);
  1350. base_key = std::string(LLMediaEntry::CURRENT_URL_KEY);
  1351. mMediaSettings[base_key] = value_str;
  1352. mMediaSettings[base_key + tentative_suffix] = !identical;
  1353. // Auto zoom
  1354. value_bool = default_media_data.getAutoZoom();
  1355. struct functor_getter_auto_zoom : public LLSelectedTEGetFunctor<bool>
  1356. {
  1357. functor_getter_auto_zoom(const LLMediaEntry& entry)
  1358. : mMediaEntry(entry)
  1359. {
  1360. }
  1361. bool get(LLViewerObject* object, S32 face)
  1362. {
  1363. LLTextureEntry* tep = object ? object->getTE(face) : NULL;
  1364. if (tep && tep->getMediaData())
  1365. {
  1366. return tep->getMediaData()->getAutoZoom();
  1367. }
  1368. return mMediaEntry.getAutoZoom();
  1369. }
  1370. const LLMediaEntry& mMediaEntry;
  1371. } func_auto_zoom(default_media_data);
  1372. identical = selected_objects->getSelectedTEValue(&func_auto_zoom,
  1373. value_bool);
  1374. base_key = std::string(LLMediaEntry::AUTO_ZOOM_KEY);
  1375. mMediaSettings[base_key] = value_bool;
  1376. mMediaSettings[base_key + tentative_suffix] = !identical;
  1377. // Auto play
  1378. #if 0 // set default to auto play true -- angela EXT-5172
  1379. value_bool = default_media_data.getAutoPlay();
  1380. #else
  1381. value_bool = true;
  1382. #endif
  1383. struct functor_getter_auto_play : public LLSelectedTEGetFunctor<bool>
  1384. {
  1385. functor_getter_auto_play(const LLMediaEntry& entry)
  1386. : mMediaEntry(entry)
  1387. {
  1388. }
  1389. bool get(LLViewerObject* object, S32 face)
  1390. {
  1391. LLTextureEntry* tep = object ? object->getTE(face) : NULL;
  1392. if (tep && tep->getMediaData())
  1393. {
  1394. return object->getTE(face)->getMediaData()->getAutoPlay();
  1395. }
  1396. #if 0 // set default to auto play true -- angela EXT-5172
  1397. return mMediaEntry.getAutoPlay();
  1398. #else
  1399. return true;
  1400. #endif
  1401. }
  1402. const LLMediaEntry& mMediaEntry;
  1403. } func_auto_play(default_media_data);
  1404. identical = selected_objects->getSelectedTEValue(&func_auto_play,
  1405. value_bool);
  1406. base_key = std::string(LLMediaEntry::AUTO_PLAY_KEY);
  1407. mMediaSettings[base_key] = value_bool;
  1408. mMediaSettings[base_key + tentative_suffix] = !identical;
  1409. // Auto scale
  1410. #if 0 // set default to auto scale true -- angela EXT-5172
  1411. value_bool = default_media_data.getAutoScale();
  1412. #else
  1413. value_bool = true;
  1414. #endif
  1415. struct functor_getter_auto_scale : public LLSelectedTEGetFunctor<bool>
  1416. {
  1417. functor_getter_auto_scale(const LLMediaEntry& entry)
  1418. : mMediaEntry(entry)
  1419. {
  1420. }
  1421. bool get(LLViewerObject* object, S32 face)
  1422. {
  1423. LLTextureEntry* tep = object ? object->getTE(face) : NULL;
  1424. if (tep && tep->getMediaData())
  1425. {
  1426. return tep->getMediaData()->getAutoScale();
  1427. }
  1428. #if 0 // set default to auto scale true -- angela EXT-5172
  1429. return mMediaEntry.getAutoScale();
  1430. #else
  1431. return true;
  1432. #endif
  1433. }
  1434. const LLMediaEntry& mMediaEntry;
  1435. } func_auto_scale(default_media_data);
  1436. identical = selected_objects->getSelectedTEValue(&func_auto_scale,
  1437. value_bool);
  1438. base_key = std::string(LLMediaEntry::AUTO_SCALE_KEY);
  1439. mMediaSettings[base_key] = value_bool;
  1440. mMediaSettings[base_key + tentative_suffix] = !identical;
  1441. // Auto loop
  1442. value_bool = default_media_data.getAutoLoop();
  1443. struct functor_getter_auto_loop : public LLSelectedTEGetFunctor<bool>
  1444. {
  1445. functor_getter_auto_loop(const LLMediaEntry& entry)
  1446. : mMediaEntry(entry)
  1447. {
  1448. }
  1449. bool get(LLViewerObject* object, S32 face)
  1450. {
  1451. LLTextureEntry* tep = object ? object->getTE(face) : NULL;
  1452. if (tep && tep->getMediaData())
  1453. {
  1454. return tep->getMediaData()->getAutoLoop();
  1455. }
  1456. return mMediaEntry.getAutoLoop();
  1457. }
  1458. const LLMediaEntry& mMediaEntry;
  1459. } func_auto_loop(default_media_data);
  1460. identical = selected_objects->getSelectedTEValue(&func_auto_loop,
  1461. value_bool);
  1462. base_key = std::string(LLMediaEntry::AUTO_LOOP_KEY);
  1463. mMediaSettings[base_key] = value_bool;
  1464. mMediaSettings[base_key + tentative_suffix] = !identical;
  1465. // width pixels (if not auto scaled)
  1466. value_int = default_media_data.getWidthPixels();
  1467. struct functor_getter_width_pixels : public LLSelectedTEGetFunctor<int>
  1468. {
  1469. functor_getter_width_pixels(const LLMediaEntry& entry)
  1470. : mMediaEntry(entry)
  1471. {
  1472. }
  1473. int get(LLViewerObject* object, S32 face)
  1474. {
  1475. LLTextureEntry* tep = object ? object->getTE(face) : NULL;
  1476. if (tep && tep->getMediaData())
  1477. {
  1478. return tep->getMediaData()->getWidthPixels();
  1479. }
  1480. return mMediaEntry.getWidthPixels();
  1481. }
  1482. const LLMediaEntry& mMediaEntry;
  1483. } func_width_pixels(default_media_data);
  1484. identical = selected_objects->getSelectedTEValue(&func_width_pixels,
  1485. value_int);
  1486. base_key = std::string(LLMediaEntry::WIDTH_PIXELS_KEY);
  1487. mMediaSettings[base_key] = value_int;
  1488. mMediaSettings[base_key + tentative_suffix] = !identical;
  1489. // height pixels (if not auto scaled)
  1490. value_int = default_media_data.getHeightPixels();
  1491. struct functor_getter_height_pixels : public LLSelectedTEGetFunctor<int>
  1492. {
  1493. functor_getter_height_pixels(const LLMediaEntry& entry)
  1494. : mMediaEntry(entry)
  1495. {
  1496. }
  1497. int get(LLViewerObject* object, S32 face)
  1498. {
  1499. LLTextureEntry* tep = object ? object->getTE(face) : NULL;
  1500. if (tep && tep->getMediaData())
  1501. {
  1502. return tep->getMediaData()->getHeightPixels();
  1503. }
  1504. return mMediaEntry.getHeightPixels();
  1505. }
  1506. const LLMediaEntry& mMediaEntry;
  1507. } func_height_pixels(default_media_data);
  1508. identical = selected_objects->getSelectedTEValue(&func_height_pixels,
  1509. value_int);
  1510. base_key = std::string(LLMediaEntry::HEIGHT_PIXELS_KEY);
  1511. mMediaSettings[base_key] = value_int;
  1512. mMediaSettings[base_key + tentative_suffix] = !identical;
  1513. // Enable Alt image
  1514. value_bool = default_media_data.getAltImageEnable();
  1515. struct functor_getter_enable_alt_image : public LLSelectedTEGetFunctor<bool>
  1516. {
  1517. functor_getter_enable_alt_image(const LLMediaEntry& entry)
  1518. : mMediaEntry(entry)
  1519. {
  1520. }
  1521. bool get(LLViewerObject* object, S32 face)
  1522. {
  1523. LLTextureEntry* tep = object ? object->getTE(face) : NULL;
  1524. if (tep && tep->getMediaData())
  1525. {
  1526. return tep->getMediaData()->getAltImageEnable();
  1527. }
  1528. return mMediaEntry.getAltImageEnable();
  1529. }
  1530. const LLMediaEntry& mMediaEntry;
  1531. } func_enable_alt_image(default_media_data);
  1532. identical = selected_objects->getSelectedTEValue(&func_enable_alt_image,
  1533. value_bool);
  1534. base_key = std::string(LLMediaEntry::ALT_IMAGE_ENABLE_KEY);
  1535. mMediaSettings[base_key] = value_bool;
  1536. mMediaSettings[base_key + tentative_suffix] = !identical;
  1537. // Perms - owner interact
  1538. value_bool = (default_media_data.getPermsInteract() &
  1539. LLMediaEntry::PERM_OWNER) != 0;
  1540. struct functor_getter_perms_owner_interact : public LLSelectedTEGetFunctor<bool>
  1541. {
  1542. functor_getter_perms_owner_interact(const LLMediaEntry& entry)
  1543. : mMediaEntry(entry)
  1544. {
  1545. }
  1546. bool get(LLViewerObject* object, S32 face)
  1547. {
  1548. LLTextureEntry* tep = object ? object->getTE(face) : NULL;
  1549. if (tep && tep->getMediaData())
  1550. {
  1551. return (tep->getMediaData()->getPermsInteract() &
  1552. LLMediaEntry::PERM_OWNER) != 0;
  1553. }
  1554. return (mMediaEntry.getPermsInteract() &
  1555. LLMediaEntry::PERM_OWNER) != 0;
  1556. }
  1557. const LLMediaEntry& mMediaEntry;
  1558. } func_perms_owner_interact(default_media_data);
  1559. identical = selected_objects->getSelectedTEValue(&func_perms_owner_interact,
  1560. value_bool);
  1561. base_key = std::string(LLMediaEntry::PERMS_OWNER_INTERACT_KEY);
  1562. mMediaSettings[base_key] = value_bool;
  1563. mMediaSettings[base_key + tentative_suffix] = !identical;
  1564. // Perms - owner control
  1565. value_bool = (default_media_data.getPermsControl() &
  1566. LLMediaEntry::PERM_OWNER) != 0;
  1567. struct functor_getter_perms_owner_control : public LLSelectedTEGetFunctor<bool>
  1568. {
  1569. functor_getter_perms_owner_control(const LLMediaEntry& entry)
  1570. : mMediaEntry(entry)
  1571. {
  1572. }
  1573. bool get(LLViewerObject* object, S32 face)
  1574. {
  1575. LLTextureEntry* tep = object ? object->getTE(face) : NULL;
  1576. if (tep && tep->getMediaData())
  1577. {
  1578. return (tep->getMediaData()->getPermsControl() &
  1579. LLMediaEntry::PERM_OWNER) != 0;
  1580. }
  1581. return (mMediaEntry.getPermsControl() &
  1582. LLMediaEntry::PERM_OWNER) != 0;
  1583. }
  1584. const LLMediaEntry& mMediaEntry;
  1585. } func_perms_owner_control(default_media_data);
  1586. identical = selected_objects->getSelectedTEValue(&func_perms_owner_control,
  1587. value_bool);
  1588. base_key = std::string(LLMediaEntry::PERMS_OWNER_CONTROL_KEY);
  1589. mMediaSettings[base_key] = value_bool;
  1590. mMediaSettings[base_key + tentative_suffix] = !identical;
  1591. // Perms - group interact
  1592. value_bool = (default_media_data.getPermsInteract() &
  1593. LLMediaEntry::PERM_GROUP) != 0;
  1594. struct functor_getter_perms_group_interact : public LLSelectedTEGetFunctor<bool>
  1595. {
  1596. functor_getter_perms_group_interact(const LLMediaEntry& entry)
  1597. : mMediaEntry(entry)
  1598. {
  1599. }
  1600. bool get(LLViewerObject* object, S32 face)
  1601. {
  1602. LLTextureEntry* tep = object ? object->getTE(face) : NULL;
  1603. if (tep && tep->getMediaData())
  1604. {
  1605. return (tep->getMediaData()->getPermsInteract() &
  1606. LLMediaEntry::PERM_GROUP) != 0;
  1607. }
  1608. return (mMediaEntry.getPermsInteract() &
  1609. LLMediaEntry::PERM_GROUP) != 0;
  1610. }
  1611. const LLMediaEntry& mMediaEntry;
  1612. } func_perms_group_interact(default_media_data);
  1613. identical = selected_objects->getSelectedTEValue(&func_perms_group_interact,
  1614. value_bool);
  1615. base_key = std::string(LLMediaEntry::PERMS_GROUP_INTERACT_KEY);
  1616. mMediaSettings[base_key] = value_bool;
  1617. mMediaSettings[base_key + tentative_suffix] = !identical;
  1618. // Perms - group control
  1619. value_bool = (default_media_data.getPermsControl() &
  1620. LLMediaEntry::PERM_GROUP) != 0;
  1621. struct functor_getter_perms_group_control : public LLSelectedTEGetFunctor<bool>
  1622. {
  1623. functor_getter_perms_group_control(const LLMediaEntry& entry)
  1624. : mMediaEntry(entry)
  1625. {
  1626. }
  1627. bool get(LLViewerObject* object, S32 face)
  1628. {
  1629. LLTextureEntry* tep = object ? object->getTE(face) : NULL;
  1630. if (tep && tep->getMediaData())
  1631. {
  1632. return (tep->getMediaData()->getPermsControl() &
  1633. LLMediaEntry::PERM_GROUP) != 0;
  1634. }
  1635. return (mMediaEntry.getPermsControl() &
  1636. LLMediaEntry::PERM_GROUP) != 0;
  1637. }
  1638. const LLMediaEntry& mMediaEntry;
  1639. } func_perms_group_control(default_media_data);
  1640. identical = selected_objects->getSelectedTEValue(&func_perms_group_control,
  1641. value_bool);
  1642. base_key = std::string(LLMediaEntry::PERMS_GROUP_CONTROL_KEY);
  1643. mMediaSettings[base_key] = value_bool;
  1644. mMediaSettings[base_key + tentative_suffix] = !identical;
  1645. // Perms - anyone interact
  1646. value_bool = (default_media_data.getPermsInteract() &
  1647. LLMediaEntry::PERM_ANYONE) != 0;
  1648. struct functor_getter_perms_anyone_interact : public LLSelectedTEGetFunctor<bool>
  1649. {
  1650. functor_getter_perms_anyone_interact(const LLMediaEntry& entry)
  1651. : mMediaEntry(entry)
  1652. {
  1653. }
  1654. bool get(LLViewerObject* object, S32 face)
  1655. {
  1656. LLTextureEntry* tep = object ? object->getTE(face) : NULL;
  1657. if (tep && tep->getMediaData())
  1658. {
  1659. return (tep->getMediaData()->getPermsInteract() &
  1660. LLMediaEntry::PERM_ANYONE) != 0;
  1661. }
  1662. return (mMediaEntry.getPermsInteract() &
  1663. LLMediaEntry::PERM_ANYONE) != 0;
  1664. }
  1665. const LLMediaEntry& mMediaEntry;
  1666. } func_perms_anyone_interact(default_media_data);
  1667. identical = selected_objects->getSelectedTEValue(&func_perms_anyone_interact,
  1668. value_bool);
  1669. base_key = std::string(LLMediaEntry::PERMS_ANYONE_INTERACT_KEY);
  1670. mMediaSettings[base_key] = value_bool;
  1671. mMediaSettings[base_key + tentative_suffix] = !identical;
  1672. // Perms - anyone control
  1673. value_bool = (default_media_data.getPermsControl() &
  1674. LLMediaEntry::PERM_ANYONE) != 0;
  1675. struct functor_getter_perms_anyone_control : public LLSelectedTEGetFunctor<bool>
  1676. {
  1677. functor_getter_perms_anyone_control(const LLMediaEntry& entry)
  1678. : mMediaEntry(entry)
  1679. {
  1680. }
  1681. bool get(LLViewerObject* object, S32 face)
  1682. {
  1683. LLTextureEntry* tep = object ? object->getTE(face) : NULL;
  1684. if (tep && tep->getMediaData())
  1685. {
  1686. return (tep->getMediaData()->getPermsControl() &
  1687. LLMediaEntry::PERM_ANYONE) != 0;
  1688. }
  1689. return (mMediaEntry.getPermsControl() &
  1690. LLMediaEntry::PERM_ANYONE) != 0;
  1691. }
  1692. const LLMediaEntry& mMediaEntry;
  1693. } func_perms_anyone_control(default_media_data);
  1694. identical = selected_objects->getSelectedTEValue(&func_perms_anyone_control,
  1695. value_bool);
  1696. base_key = std::string(LLMediaEntry::PERMS_ANYONE_CONTROL_KEY);
  1697. mMediaSettings[base_key] = value_bool;
  1698. mMediaSettings[base_key + tentative_suffix] = !identical;
  1699. // Security - whitelist enable
  1700. value_bool = default_media_data.getWhiteListEnable();
  1701. struct functor_getter_whitelist_enable : public LLSelectedTEGetFunctor<bool>
  1702. {
  1703. functor_getter_whitelist_enable(const LLMediaEntry& entry)
  1704. : mMediaEntry(entry)
  1705. {
  1706. }
  1707. bool get(LLViewerObject* object, S32 face)
  1708. {
  1709. LLTextureEntry* tep = object ? object->getTE(face) : NULL;
  1710. if (tep && tep->getMediaData())
  1711. {
  1712. return tep->getMediaData()->getWhiteListEnable();
  1713. }
  1714. return mMediaEntry.getWhiteListEnable();
  1715. }
  1716. const LLMediaEntry& mMediaEntry;
  1717. } func_whitelist_enable(default_media_data);
  1718. identical = selected_objects->getSelectedTEValue(&func_whitelist_enable,
  1719. value_bool);
  1720. base_key = std::string(LLMediaEntry::WHITELIST_ENABLE_KEY);
  1721. mMediaSettings[base_key] = value_bool;
  1722. mMediaSettings[base_key + tentative_suffix] = !identical;
  1723. // Security - whitelist URLs
  1724. std::vector<std::string> value_vector_str = default_media_data.getWhiteList();
  1725. struct functor_getter_whitelist_urls : public LLSelectedTEGetFunctor<std::vector<std::string> >
  1726. {
  1727. functor_getter_whitelist_urls(const LLMediaEntry& entry)
  1728. : mMediaEntry(entry)
  1729. {
  1730. }
  1731. std::vector<std::string> get(LLViewerObject* object, S32 face)
  1732. {
  1733. LLTextureEntry* tep = object ? object->getTE(face) : NULL;
  1734. if (tep && tep->getMediaData())
  1735. {
  1736. return tep->getMediaData()->getWhiteList();
  1737. }
  1738. return mMediaEntry.getWhiteList();
  1739. }
  1740. const LLMediaEntry& mMediaEntry;
  1741. } func_whitelist_urls(default_media_data);
  1742. identical = selected_objects->getSelectedTEValue(&func_whitelist_urls,
  1743. value_vector_str);
  1744. base_key = std::string(LLMediaEntry::WHITELIST_KEY);
  1745. mMediaSettings[base_key].clear();
  1746. std::vector<std::string>::iterator iter = value_vector_str.begin();
  1747. std::vector<std::string>::iterator end = value_vector_str.end();
  1748. while (iter != end)
  1749. {
  1750. std::string white_list_url = *iter++;
  1751. mMediaSettings[base_key].append(white_list_url);
  1752. }
  1753. mMediaSettings[base_key + tentative_suffix] = !identical;
  1754. }