llpanelenvsettings.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. /**
  2. * @file llpanelenvsettings.h
  3. * @brief Environment settings panel classes definitions
  4. *
  5. * $LicenseInfo:firstyear=2018&license=viewergpl$
  6. *
  7. * Copyright (c) 2018, Linden Research, Inc, (c) 2019-2023 Henri Beauchamp.
  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. #ifndef LL_LLPANELENVSETTINGS_H
  33. #define LL_LLPANELENVSETTINGS_H
  34. #include "llpanel.h"
  35. #include "llframetimer.h"
  36. #include "llenvironment.h"
  37. class LLButton;
  38. class LLCheckBoxCtrl;
  39. class LLColorSwatchCtrl;
  40. class LLMultiSliderCtrl;
  41. class LLSliderCtrl;
  42. class LLTextBox;
  43. class LLTextureCtrl;
  44. class LLVirtualTrackball;
  45. class LLXYVector;
  46. class LLPanelEnvSettings : public LLPanel
  47. {
  48. public:
  49. virtual void setEnabled(bool enabled) = 0;
  50. virtual void setSettings(const LLSettingsBase::ptr_t& settings,
  51. bool reset_dirty = true) = 0;
  52. virtual LLSettingsBase::ptr_t getSettingsClone() = 0;
  53. virtual bool hasLocalTextures(LLSD& args) = 0;
  54. virtual void updateEditEnvironment() = 0;
  55. virtual void updateLocal() = 0;
  56. virtual void updateParcel(S32 parcel_id) = 0;
  57. virtual void updateRegion() = 0;
  58. virtual std::string getSettingsName() = 0;
  59. virtual void setSettingsName(const std::string& name) = 0;
  60. virtual bool settingsValid() const = 0;
  61. LL_INLINE virtual bool isDirty() const { return mIsDirty; }
  62. LL_INLINE virtual void setDirty(bool b = true) { mIsDirty = b; }
  63. LL_INLINE bool canEdit() const { return mCanEdit; }
  64. LL_INLINE void setCanEdit(bool b = true) { mCanEdit = b; refresh(); }
  65. // Used to refresh the enabled state of any button that needs the file
  66. // selector, depending whether the latter is already in use or not.
  67. // Currently, only the day cycle settings panel got such buttons.
  68. LL_INLINE virtual void setFileLoadingAvailable(bool available)
  69. {
  70. }
  71. enum EEditContext {
  72. CONTEXT_UNKNOWN,
  73. CONTEXT_INVENTORY,
  74. CONTEXT_PARCEL,
  75. CONTEXT_REGION
  76. };
  77. LL_INLINE void setEditContext(EEditContext ctx) { mEditContext = ctx; }
  78. LL_INLINE EEditContext getEditContext() const { return mEditContext; }
  79. protected:
  80. LL_INLINE LLPanelEnvSettings()
  81. : mEditContext(CONTEXT_UNKNOWN),
  82. mIsDirty(false),
  83. mCanEdit(false)
  84. {
  85. }
  86. protected:
  87. EEditContext mEditContext;
  88. bool mIsDirty;
  89. bool mCanEdit;
  90. };
  91. class LLPanelEnvSettingsSky final : public LLPanelEnvSettings
  92. {
  93. protected:
  94. LOG_CLASS(LLPanelEnvSettingsSky);
  95. public:
  96. LLPanelEnvSettingsSky();
  97. ~LLPanelEnvSettingsSky() override;
  98. bool postBuild() override;
  99. void refresh() override;
  100. void setEnabled(bool enabled) override;
  101. void setSettings(const LLSettingsBase::ptr_t& settings,
  102. bool reset_dirty = true) override;
  103. LLSettingsBase::ptr_t getSettingsClone() override;
  104. bool hasLocalTextures(LLSD& args) override;
  105. void updateEditEnvironment() override;
  106. void updateLocal() override;
  107. void updateParcel(S32 parcel_id) override;
  108. void updateRegion() override;
  109. LL_INLINE std::string getSettingsName() override
  110. {
  111. return mSkySettings->getName();
  112. }
  113. LL_INLINE void setSettingsName(const std::string& name) override
  114. {
  115. mSkySettings->setName(name);
  116. }
  117. LL_INLINE bool settingsValid() const override
  118. {
  119. return mSkySettings != NULL;
  120. }
  121. void setSky(const LLSettingsSky::ptr_t& settings, bool reset_dirty = true);
  122. LL_INLINE LLSettingsSky::ptr_t getSky() const
  123. {
  124. return mSkySettings;
  125. }
  126. private:
  127. void updateSettings();
  128. static void onAmbientLightChanged(LLUICtrl*, void* userdata);
  129. static void onBlueHorizonChanged(LLUICtrl*, void* userdata);
  130. static void onBlueDensityChanged(LLUICtrl*, void* userdata);
  131. static void onHazeHorizonChanged(LLUICtrl*, void* userdata);
  132. static void onHazeDensityChanged(LLUICtrl*, void* userdata);
  133. static void onMoistureLevelChanged(LLUICtrl*, void* userdata);
  134. static void onDropletRadiusChanged(LLUICtrl*, void* userdata);
  135. static void onIceLevelChanged(LLUICtrl*, void* userdata);
  136. static void onSceneGammaChanged(LLUICtrl*, void* userdata);
  137. static void onDensityMultipChanged(LLUICtrl*, void* userdata);
  138. static void onDistanceMultipChanged(LLUICtrl*, void* userdata);
  139. static void onMaxAltChanged(LLUICtrl*, void* userdata);
  140. static void onProbeAmbianceChanged(LLUICtrl*, void* userdata);
  141. static void onCloudColorChanged(LLUICtrl*, void* userdata);
  142. static void onCloudMapChanged(LLUICtrl*, void* userdata);
  143. static void onCloudCoverageChanged(LLUICtrl*, void* userdata);
  144. static void onCloudScaleChanged(LLUICtrl*, void* userdata);
  145. static void onCloudVarianceChanged(LLUICtrl*, void* userdata);
  146. static void onCloudScrollChanged(LLUICtrl*, void* userdata);
  147. static void onCloudDensityChanged(LLUICtrl*, void* userdata);
  148. static void onCloudDetailChanged(LLUICtrl*, void* userdata);
  149. static void onSunRotationChanged(LLUICtrl*, void* userdata);
  150. static void onMoonRotationChanged(LLUICtrl*, void* userdata);
  151. static void onSunImageChanged(LLUICtrl*, void* userdata);
  152. static void onMoonImageChanged(LLUICtrl*, void* userdata);
  153. static void onSunlightColorChanged(LLUICtrl*, void* userdata);
  154. static void onSunScaleChanged(LLUICtrl*, void* userdata);
  155. static void onMoonScaleChanged(LLUICtrl*, void* userdata);
  156. static void onGlowChanged(LLUICtrl*, void* userdata);
  157. static void onMoonBrightnessChanged(LLUICtrl*, void* userdata);
  158. static void onStarBrightnessChanged(LLUICtrl*, void* userdata);
  159. protected:
  160. LLSettingsSky::ptr_t mSkySettings;
  161. private:
  162. LLCheckBoxCtrl* mUseProbeAmbianceCtrl;
  163. LLColorSwatchCtrl* mAmbientColorCtrl;
  164. LLColorSwatchCtrl* mBlueHorizonColorCtrl;
  165. LLColorSwatchCtrl* mBlueDensityColorCtrl;
  166. LLColorSwatchCtrl* mCloudColorCtrl;
  167. LLColorSwatchCtrl* mSunLightColorCtrl;
  168. LLSliderCtrl* mHazeHorizonCtrl;
  169. LLSliderCtrl* mHazeDensityCtrl;
  170. LLSliderCtrl* mMoistureLevelCtrl;
  171. LLSliderCtrl* mDropletRadiusCtrl;
  172. LLSliderCtrl* mIceLevelCtrl;
  173. LLSliderCtrl* mSceneGammaCtrl;
  174. LLSliderCtrl* mDensityMultCtrl;
  175. LLSliderCtrl* mDistanceMultCtrl;
  176. LLSliderCtrl* mMaxAltitudeCtrl;
  177. LLSliderCtrl* mProbeAmbianceCtrl;
  178. LLSliderCtrl* mCloudCoverageCtrl;
  179. LLSliderCtrl* mCloudScaleCtrl;
  180. LLSliderCtrl* mCloudVarianceCtrl;
  181. LLSliderCtrl* mCloudDensityXCtrl;
  182. LLSliderCtrl* mCloudDensityYCtrl;
  183. LLSliderCtrl* mCloudDensityDCtrl;
  184. LLSliderCtrl* mCloudDetailXCtrl;
  185. LLSliderCtrl* mCloudDetailYCtrl;
  186. LLSliderCtrl* mCloudDetailDCtrl;
  187. LLSliderCtrl* mSunScaleCtrl;
  188. LLSliderCtrl* mMoonScaleCtrl;
  189. LLSliderCtrl* mGlowFocusCtrl;
  190. LLSliderCtrl* mGlowSizeCtrl;
  191. LLSliderCtrl* mMoonBrightnessCtrl;
  192. LLSliderCtrl* mStarBrightnessCtrl;
  193. LLTextBox* mHdrAutoText;
  194. LLTextBox* mHdrOffText;
  195. LLTextBox* mHdrOnText;
  196. LLTextureCtrl* mCloudMapCtrl;
  197. LLTextureCtrl* mSunImageCtrl;
  198. LLTextureCtrl* mMoonImageCtrl;
  199. LLVirtualTrackball* mSunRotationCtrl;
  200. LLVirtualTrackball* mMoonRotationCtrl;
  201. LLXYVector* mCloudScrollCtrl;
  202. };
  203. class LLPanelEnvSettingsWater final : public LLPanelEnvSettings
  204. {
  205. protected:
  206. LOG_CLASS(LLPanelEnvSettingsWater);
  207. public:
  208. LLPanelEnvSettingsWater();
  209. bool postBuild() override;
  210. void refresh() override;
  211. void setEnabled(bool enabled) override;
  212. void setSettings(const LLSettingsBase::ptr_t& settings,
  213. bool reset_dirty = true) override;
  214. LLSettingsBase::ptr_t getSettingsClone() override;
  215. bool hasLocalTextures(LLSD& args) override;
  216. void updateEditEnvironment() override;
  217. void updateLocal() override;
  218. void updateParcel(S32 parcel_id) override;
  219. void updateRegion() override;
  220. LL_INLINE std::string getSettingsName() override
  221. {
  222. return mWaterSettings->getName();
  223. }
  224. LL_INLINE void setSettingsName(const std::string& name) override
  225. {
  226. mWaterSettings->setName(name);
  227. }
  228. LL_INLINE bool settingsValid() const override
  229. {
  230. return mWaterSettings != NULL;
  231. }
  232. void setWater(const LLSettingsWater::ptr_t& settings,
  233. bool reset_dirty = true);
  234. LL_INLINE LLSettingsWater::ptr_t getWater() const
  235. {
  236. return mWaterSettings;
  237. }
  238. private:
  239. static void onFogColorChanged(LLUICtrl*, void* userdata);
  240. static void onNormalMapChanged(LLUICtrl*, void* userdata);
  241. static void onFogDensityChanged(LLUICtrl*, void* userdata);
  242. static void onFogUnderWaterChanged(LLUICtrl*, void* userdata);
  243. static void onLargeWaveChanged(LLUICtrl*, void* userdata);
  244. static void onSmallWaveChanged(LLUICtrl*, void* userdata);
  245. static void onNormalScaleChanged(LLUICtrl*, void* userdata);
  246. static void onFresnelScaleChanged(LLUICtrl*, void* userdata);
  247. static void onFresnelOffsetChanged(LLUICtrl*, void* userdata);
  248. static void onScaleAboveChanged(LLUICtrl*, void* userdata);
  249. static void onScaleBelowChanged(LLUICtrl*, void* userdata);
  250. static void onBlurMultChanged(LLUICtrl*, void* userdata);
  251. protected:
  252. LLSettingsWater::ptr_t mWaterSettings;
  253. private:
  254. LLColorSwatchCtrl* mFogColorCtrl;
  255. LLSliderCtrl* mFogDensityCtrl;
  256. LLSliderCtrl* mUnderwaterModCtrl;
  257. LLSliderCtrl* mFresnelScaleCtrl;
  258. LLSliderCtrl* mFresnelOffsetCtrl;
  259. LLSliderCtrl* mNormalScaleXCtrl;
  260. LLSliderCtrl* mNormalScaleYCtrl;
  261. LLSliderCtrl* mNormalScaleZCtrl;
  262. LLSliderCtrl* mRefractionAboveCtrl;
  263. LLSliderCtrl* mRefractionBelowCtrl;
  264. LLSliderCtrl* mBlurMultiplierCtrl;
  265. LLTextureCtrl* mNormalMapCtrl;
  266. LLXYVector* mLargeWaveCtrl;
  267. LLXYVector* mSmallWaveCtrl;
  268. };
  269. class LLPanelEnvSettingsDay final : public LLPanelEnvSettings
  270. {
  271. friend class LLFloaterTrackPicker;
  272. protected:
  273. LOG_CLASS(LLPanelEnvSettingsDay);
  274. public:
  275. LLPanelEnvSettingsDay();
  276. ~LLPanelEnvSettingsDay() override;
  277. bool postBuild() override;
  278. void draw() override;
  279. void refresh() override;
  280. void setEnabled(bool enabled) override;
  281. void setSettings(const LLSettingsBase::ptr_t& settings,
  282. bool reset_dirty = true) override;
  283. LLSettingsBase::ptr_t getSettingsClone() override;
  284. bool hasLocalTextures(LLSD& args) override;
  285. void updateEditEnvironment() override;
  286. void updateLocal() override;
  287. void updateParcel(S32 parcel_id) override;
  288. void updateRegion() override;
  289. void setDirty(bool b = true) override;
  290. bool isDirty() const override;
  291. void setFileLoadingAvailable(bool available) override;
  292. LL_INLINE std::string getSettingsName() override
  293. {
  294. return mDaySettings->getName();
  295. }
  296. LL_INLINE void setSettingsName(const std::string& name) override
  297. {
  298. mDaySettings->setName(name);
  299. }
  300. LL_INLINE bool settingsValid() const override
  301. {
  302. return mDaySettings != NULL;
  303. }
  304. void setDay(const LLSettingsDay::ptr_t& settings, bool reset_dirty = true);
  305. LL_INLINE LLSettingsDay::ptr_t getDay() const
  306. {
  307. return mDaySettings;
  308. }
  309. LL_INLINE void setDayLength(S32 seconds) { mDayLength = seconds; }
  310. void loadInventoryItem(LLUUID item_id);
  311. protected:
  312. void onPickerCommitTrackId(S32 track_id);
  313. private:
  314. // For map of sliders to parameters
  315. class FrameData
  316. {
  317. public:
  318. FrameData()
  319. : mFrame(0.f)
  320. {
  321. }
  322. FrameData(F32 frame, LLSettingsBase::ptr_t settings)
  323. : mFrame(frame),
  324. mSettings(settings)
  325. {
  326. }
  327. public:
  328. LLSettingsBase::ptr_t mSettings;
  329. F32 mFrame;
  330. };
  331. void synchronizePanels();
  332. void updatePanels();
  333. void closePickerFloaters();
  334. void addSliderFrame(F32 frame, const LLSettingsBase::ptr_t& setting,
  335. bool update_ui = true);
  336. void removeCurrentSliderFrame();
  337. void removeSliderFrame(F32 frame);
  338. void updateSlider();
  339. void selectFrame(F32 frame, F32 slop_factor);
  340. void selectTrack(S32 track_index, bool force = false);
  341. void cloneTrack(const LLSettingsDay::ptr_t& src_day, S32 src_idx,
  342. S32 dst_idx);
  343. bool isAddingFrameAllowed();
  344. bool isRemovingFrameAllowed();
  345. void updateTimeText();
  346. void reblendSettings();
  347. void onAssetLoaded(const LLUUID& item_id, LLSettingsBase::ptr_t settings,
  348. S32 status);
  349. void startPlay();
  350. void stopPlay();
  351. static void* createSkySettingsPanel(void* userdata);
  352. static void* createWaterSettingsPanel(void* userdata);
  353. static void onIdlePlay(void* userdata);
  354. static void onTrack0Button(void* userdata);
  355. static void onTrack1Button(void* userdata);
  356. static void onTrack2Button(void* userdata);
  357. static void onTrack3Button(void* userdata);
  358. static void onTrack4Button(void* userdata);
  359. static void onCloneTrack(void* userdata);
  360. static void onLoadTrack(void* userdata);
  361. static void onClearTrack(void* userdata);
  362. static void onAddFrame(void* userdata);
  363. static void onLoadFrame(void* userdata);
  364. static void onRemoveFrame(void* userdata);
  365. static void onPlay(void* userdata);
  366. static void onStop(void* userdata);
  367. static void onForward(void* userdata);
  368. static void onBackward(void* userdata);
  369. static void onTimeSliderCallback(LLUICtrl*, void* userdata);
  370. static void onFrameSliderCallback(LLUICtrl*, void* userdata);
  371. static void onFrameSliderMouseDown(S32 x, S32 y, void* userdata);
  372. static void onFrameSliderMouseUp(S32 x, S32 y, void* userdata);
  373. protected:
  374. LLSettingsDay::ptr_t mDaySettings;
  375. private:
  376. LLButton* mWaterTrackBtn;
  377. LLButton* mSky1TrackBtn;
  378. LLButton* mSky2TrackBtn;
  379. LLButton* mSky3TrackBtn;
  380. LLButton* mSky4TrackBtn;
  381. LLButton* mCloneTrackBtn;
  382. LLButton* mLoadTrackBtn;
  383. LLButton* mClearTrackBtn;
  384. LLButton* mAddFrameBtn;
  385. LLButton* mLoadFrameBtn;
  386. LLButton* mDeleteFrameBtn;
  387. LLButton* mPlayBtn;
  388. LLButton* mStopBtn;
  389. LLButton* mForwardBtn;
  390. LLButton* mBackwardBtn;
  391. LLTextBox* mEditLockedText;
  392. LLTextBox* mCurrentTimeText;
  393. LLMultiSliderCtrl* mTimeSlider;
  394. LLMultiSliderCtrl* mFramesSlider;
  395. LLPanelEnvSettingsSky* mSkyPanel;
  396. LLPanelEnvSettingsWater* mWaterPanel;
  397. std::vector<LLButton*> mTrackButtons;
  398. // Source settings copied on callback from to the track selector, used
  399. // by onPickerCommitTrackId().
  400. LLSettingsDay::ptr_t mSourceSettings;
  401. LLSettingsSky::ptr_t mScratchSky;
  402. LLSettingsWater::ptr_t mScratchWater;
  403. LLTrackBlenderLoopingManual::ptr_t mSkyBlender;
  404. LLTrackBlenderLoopingManual::ptr_t mWaterBlender;
  405. std::string mWaterLabel;
  406. std::string mSkyLabel;
  407. typedef std::map<std::string, FrameData> keymap_t;
  408. keymap_t mSliderKeyMap;
  409. LLFrameTimer mPlayTimer;
  410. F32 mPlayStartFrame;
  411. // *HACK: to work around a race condition on asset loading at panel
  412. // creation (and initial refresh) time, in order to get the water and sky
  413. // settings refreshed properly...
  414. F32 mOnOpenRefreshTime;
  415. // Used only for onFrameSliderMouseDown() and onFrameSliderMouseUp()
  416. F32 mCurrentFrame;
  417. S32 mCurrentTrack;
  418. S32 mDayLength;
  419. bool mIsPlaying;
  420. };
  421. #endif // LL_LLPANELENVSETTINGS_H