PageRenderTime 32ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llpanelsnapshotinventory.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 109 lines | 62 code | 15 blank | 32 comment | 1 complexity | 6b7dfb693644da617e156cab33949786 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llpanelsnapshotinventory.cpp
  3. * @brief The panel provides UI for saving snapshot as an inventory texture.
  4. *
  5. * $LicenseInfo:firstyear=2011&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2011, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #include "llviewerprecompiledheaders.h"
  27. #include "llcombobox.h"
  28. #include "lleconomy.h"
  29. #include "llsidetraypanelcontainer.h"
  30. #include "llspinctrl.h"
  31. #include "llfloatersnapshot.h" // FIXME: replace with a snapshot storage model
  32. #include "llpanelsnapshot.h"
  33. #include "llviewercontrol.h" // gSavedSettings
  34. /**
  35. * The panel provides UI for saving snapshot as an inventory texture.
  36. */
  37. class LLPanelSnapshotInventory
  38. : public LLPanelSnapshot
  39. {
  40. LOG_CLASS(LLPanelSnapshotInventory);
  41. public:
  42. LLPanelSnapshotInventory();
  43. /*virtual*/ BOOL postBuild();
  44. /*virtual*/ void onOpen(const LLSD& key);
  45. private:
  46. /*virtual*/ void updateCustomResControls(); ///< Show/hide custom resolution controls (spinners and checkbox)
  47. /*virtual*/ std::string getWidthSpinnerName() const { return "inventory_snapshot_width"; }
  48. /*virtual*/ std::string getHeightSpinnerName() const { return "inventory_snapshot_height"; }
  49. /*virtual*/ std::string getAspectRatioCBName() const { return "inventory_keep_aspect_check"; }
  50. /*virtual*/ std::string getImageSizeComboName() const { return "texture_size_combo"; }
  51. /*virtual*/ std::string getImageSizePanelName() const { return LLStringUtil::null; }
  52. /*virtual*/ void updateControls(const LLSD& info);
  53. void onSend();
  54. };
  55. static LLRegisterPanelClassWrapper<LLPanelSnapshotInventory> panel_class("llpanelsnapshotinventory");
  56. LLPanelSnapshotInventory::LLPanelSnapshotInventory()
  57. {
  58. mCommitCallbackRegistrar.add("Inventory.Save", boost::bind(&LLPanelSnapshotInventory::onSend, this));
  59. mCommitCallbackRegistrar.add("Inventory.Cancel", boost::bind(&LLPanelSnapshotInventory::cancel, this));
  60. }
  61. // virtual
  62. BOOL LLPanelSnapshotInventory::postBuild()
  63. {
  64. getChild<LLSpinCtrl>(getWidthSpinnerName())->setAllowEdit(FALSE);
  65. getChild<LLSpinCtrl>(getHeightSpinnerName())->setAllowEdit(FALSE);
  66. getChild<LLUICtrl>(getAspectRatioCBName())->setVisible(FALSE); // we don't keep aspect ratio for inventory textures
  67. return LLPanelSnapshot::postBuild();
  68. }
  69. // virtual
  70. void LLPanelSnapshotInventory::onOpen(const LLSD& key)
  71. {
  72. getChild<LLUICtrl>("hint_lbl")->setTextArg("[UPLOAD_COST]", llformat("%d", LLGlobalEconomy::Singleton::getInstance()->getPriceUpload()));
  73. LLPanelSnapshot::onOpen(key);
  74. }
  75. // virtual
  76. void LLPanelSnapshotInventory::updateCustomResControls()
  77. {
  78. LLComboBox* combo = getChild<LLComboBox>(getImageSizeComboName());
  79. S32 selected_idx = combo->getFirstSelectedIndex();
  80. const bool show = selected_idx == (combo->getItemCount() - 1); // Custom selected
  81. getChild<LLUICtrl>(getWidthSpinnerName())->setVisible(show);
  82. getChild<LLUICtrl>(getHeightSpinnerName())->setVisible(show);
  83. }
  84. // virtual
  85. void LLPanelSnapshotInventory::updateControls(const LLSD& info)
  86. {
  87. const bool have_snapshot = info.has("have-snapshot") ? info["have-snapshot"].asBoolean() : true;
  88. getChild<LLUICtrl>("save_btn")->setEnabled(have_snapshot);
  89. }
  90. void LLPanelSnapshotInventory::onSend()
  91. {
  92. LLFloaterSnapshot::saveTexture();
  93. LLFloaterSnapshot::postSave();
  94. }