llpanelaudiovolume.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /**
  2. * @file llpanelaudiovolume.cpp
  3. * @brief A remote control for media (video and music)
  4. *
  5. * $LicenseInfo:firstyear=2005&license=viewergpl$
  6. *
  7. * Copyright (c) 2005-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 "llpanelaudiovolume.h"
  34. #include "lloverlaybar.h"
  35. #include "llviewercontrol.h"
  36. #include "lluictrlfactory.h"
  37. ////////////////////////////////////////////////////////////////////////////////
  38. // LLFloaterAudioVolume: floater version of audio panel
  39. ////////////////////////////////////////////////////////////////////////////////
  40. //static
  41. void* LLFloaterAudioVolume::createVolumePanel(void* data)
  42. {
  43. LLPanelAudioVolume* panel = new LLPanelAudioVolume();
  44. return panel;
  45. }
  46. LLFloaterAudioVolume::LLFloaterAudioVolume(const LLSD& seed)
  47. {
  48. mFactoryMap["Volume Panel"] = LLCallbackMap(createVolumePanel, NULL);
  49. LLUICtrlFactory::getInstance()->buildFloater(this,
  50. "floater_audio_volume.xml",
  51. &getFactoryMap());
  52. S32 pos_x = getRect().mLeft;
  53. S32 pos_y = getRect().mBottom;
  54. LLView* volume_panel_view = NULL;
  55. if (gOverlayBarp)
  56. {
  57. volume_panel_view = gOverlayBarp->getChild<LLView>("master_volume");
  58. }
  59. if (volume_panel_view)
  60. {
  61. pos_x = volume_panel_view->getRect().mLeft;
  62. pos_y = volume_panel_view->getRect().mTop;
  63. }
  64. setOrigin(pos_x, pos_y);
  65. if (gFloaterViewp)
  66. {
  67. gFloaterViewp->adjustToFitScreen(this);
  68. }
  69. }
  70. //static
  71. bool LLFloaterAudioVolume::visible(LLFloater* instance, const LLSD& key)
  72. {
  73. return VisibilityPolicy<LLFloater>::visible(instance, key);
  74. }
  75. //static
  76. void LLFloaterAudioVolume::show(LLFloater* instance, const LLSD& key)
  77. {
  78. VisibilityPolicy<LLFloater>::show(instance, key);
  79. gSavedSettings.setBool("ShowAudioVolume", true);
  80. }
  81. //static
  82. void LLFloaterAudioVolume::hide(LLFloater* instance, const LLSD& key)
  83. {
  84. VisibilityPolicy<LLFloater>::hide(instance, key);
  85. gSavedSettings.setBool("ShowAudioVolume", false);
  86. }
  87. ////////////////////////////////////////////////////////////////////////////////
  88. // LLPanelAudioVolume
  89. ////////////////////////////////////////////////////////////////////////////////
  90. LLPanelAudioVolume::LLPanelAudioVolume()
  91. {
  92. }
  93. bool LLPanelAudioVolume::postBuild()
  94. {
  95. return true;
  96. }
  97. LLPanelAudioVolume::~LLPanelAudioVolume()
  98. {
  99. gSavedSettings.setBool("ShowAudioVolume", false);
  100. }
  101. void LLPanelAudioVolume::draw()
  102. {
  103. bool enable = !gSavedSettings.getBool("MuteAudio");
  104. childSetEnabled("System Volume", enable);
  105. childSetEnabled("Music Volume", enable);
  106. childSetEnabled("Media Volume", enable);
  107. childSetEnabled("Voice Volume", enable);
  108. childSetEnabled("SFX Volume", enable);
  109. childSetEnabled("UI Volume", enable);
  110. childSetEnabled("Wind Volume", enable);
  111. LLPanel::draw();
  112. }