/indra/newview/llsidepanelinventorysubpanel.cpp

https://bitbucket.org/lindenlab/viewer-beta/ · C++ · 145 lines · 92 code · 21 blank · 32 comment · 2 complexity · 5d197b37a1022f4945402fed27db3c40 MD5 · raw file

  1. /**
  2. * @file llsidepanelinventorysubpanel.cpp
  3. * @brief A floater which shows an inventory item's properties.
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #include "llviewerprecompiledheaders.h"
  27. #include "llsidepanelinventorysubpanel.h"
  28. #include "roles_constants.h"
  29. #include "llagent.h"
  30. #include "llavataractions.h"
  31. #include "llbutton.h"
  32. #include "llfloaterreg.h"
  33. #include "llgroupactions.h"
  34. #include "llinventorymodel.h"
  35. #include "lllineeditor.h"
  36. #include "llradiogroup.h"
  37. #include "llviewercontrol.h"
  38. #include "llviewerobjectlist.h"
  39. ///----------------------------------------------------------------------------
  40. /// Class LLSidepanelInventorySubpanel
  41. ///----------------------------------------------------------------------------
  42. // Default constructor
  43. LLSidepanelInventorySubpanel::LLSidepanelInventorySubpanel(const LLPanel::Params& p)
  44. : LLPanel(p),
  45. mIsDirty(TRUE),
  46. mIsEditing(FALSE),
  47. mCancelBtn(NULL),
  48. mSaveBtn(NULL)
  49. {
  50. }
  51. // Destroys the object
  52. LLSidepanelInventorySubpanel::~LLSidepanelInventorySubpanel()
  53. {
  54. }
  55. // virtual
  56. BOOL LLSidepanelInventorySubpanel::postBuild()
  57. {
  58. mSaveBtn = getChild<LLButton>("save_btn");
  59. mSaveBtn->setClickedCallback(boost::bind(&LLSidepanelInventorySubpanel::onSaveButtonClicked, this));
  60. mCancelBtn = getChild<LLButton>("cancel_btn");
  61. mCancelBtn->setClickedCallback(boost::bind(&LLSidepanelInventorySubpanel::onCancelButtonClicked, this));
  62. return TRUE;
  63. }
  64. void LLSidepanelInventorySubpanel::setVisible(BOOL visible)
  65. {
  66. if (visible)
  67. {
  68. dirty();
  69. }
  70. LLPanel::setVisible(visible);
  71. }
  72. void LLSidepanelInventorySubpanel::setIsEditing(BOOL edit)
  73. {
  74. mIsEditing = edit;
  75. mIsDirty = TRUE;
  76. }
  77. BOOL LLSidepanelInventorySubpanel::getIsEditing() const
  78. {
  79. return TRUE; // Default everything to edit mode since we're not using an edit button anymore.
  80. // return mIsEditing;
  81. }
  82. void LLSidepanelInventorySubpanel::reset()
  83. {
  84. mIsDirty = TRUE;
  85. }
  86. void LLSidepanelInventorySubpanel::draw()
  87. {
  88. if (mIsDirty)
  89. {
  90. refresh();
  91. updateVerbs();
  92. mIsDirty = FALSE;
  93. }
  94. LLPanel::draw();
  95. }
  96. void LLSidepanelInventorySubpanel::dirty()
  97. {
  98. mIsDirty = TRUE;
  99. setIsEditing(FALSE);
  100. }
  101. void LLSidepanelInventorySubpanel::updateVerbs()
  102. {
  103. mSaveBtn->setVisible(mIsEditing);
  104. mCancelBtn->setVisible(mIsEditing);
  105. }
  106. void LLSidepanelInventorySubpanel::onEditButtonClicked()
  107. {
  108. setIsEditing(TRUE);
  109. refresh();
  110. updateVerbs();
  111. }
  112. void LLSidepanelInventorySubpanel::onSaveButtonClicked()
  113. {
  114. save();
  115. setIsEditing(FALSE);
  116. refresh();
  117. updateVerbs();
  118. }
  119. void LLSidepanelInventorySubpanel::onCancelButtonClicked()
  120. {
  121. setIsEditing(FALSE);
  122. refresh();
  123. updateVerbs();
  124. }