llsidepanelinventorysubpanel.cpp
上传用户:king477883
上传日期:2021-03-01
资源大小:9553k
文件大小:4k
源码类别:

游戏引擎

开发平台:

C++ Builder

  1. /** 
  2.  * @file llsidepanelinventorysubpanel.cpp
  3.  * @brief A floater which shows an inventory item's properties.
  4.  *
  5.  * $LicenseInfo:firstyear=2002&license=viewergpl$
  6.  * 
  7.  * Copyright (c) 2002-2010, 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 "llsidepanelinventorysubpanel.h"
  34. #include "roles_constants.h"
  35. #include "llagent.h"
  36. #include "llavataractions.h"
  37. #include "llbutton.h"
  38. #include "llfloaterreg.h"
  39. #include "llgroupactions.h"
  40. #include "llinventorymodel.h"
  41. #include "lllineeditor.h"
  42. #include "llradiogroup.h"
  43. #include "llviewercontrol.h"
  44. #include "llviewerobjectlist.h"
  45. ///----------------------------------------------------------------------------
  46. /// Class LLSidepanelInventorySubpanel
  47. ///----------------------------------------------------------------------------
  48. // Default constructor
  49. LLSidepanelInventorySubpanel::LLSidepanelInventorySubpanel()
  50.   : LLPanel(),
  51. mIsDirty(TRUE),
  52. mIsEditing(FALSE),
  53. mCancelBtn(NULL),
  54. mSaveBtn(NULL)
  55. {
  56. }
  57. // Destroys the object
  58. LLSidepanelInventorySubpanel::~LLSidepanelInventorySubpanel()
  59. {
  60. }
  61. // virtual
  62. BOOL LLSidepanelInventorySubpanel::postBuild()
  63. {
  64. mSaveBtn = getChild<LLButton>("save_btn");
  65. mSaveBtn->setClickedCallback(boost::bind(&LLSidepanelInventorySubpanel::onSaveButtonClicked, this));
  66. mCancelBtn = getChild<LLButton>("cancel_btn");
  67. mCancelBtn->setClickedCallback(boost::bind(&LLSidepanelInventorySubpanel::onCancelButtonClicked, this));
  68. return TRUE;
  69. }
  70. void LLSidepanelInventorySubpanel::setVisible(BOOL visible)
  71. {
  72. if (visible)
  73. {
  74. dirty();
  75. }
  76. LLPanel::setVisible(visible);
  77. }
  78. void LLSidepanelInventorySubpanel::setIsEditing(BOOL edit)
  79. {
  80. mIsEditing = edit;
  81. mIsDirty = TRUE;
  82. }
  83. BOOL LLSidepanelInventorySubpanel::getIsEditing() const
  84. {
  85. return TRUE; // Default everything to edit mode since we're not using an edit button anymore.
  86. // return mIsEditing;
  87. }
  88. void LLSidepanelInventorySubpanel::reset()
  89. {
  90. mIsDirty = TRUE;
  91. }
  92. void LLSidepanelInventorySubpanel::draw()
  93. {
  94. if (mIsDirty)
  95. {
  96. refresh();
  97. updateVerbs();
  98. mIsDirty = FALSE;
  99. }
  100. LLPanel::draw();
  101. }
  102. void LLSidepanelInventorySubpanel::dirty()
  103. {
  104. mIsDirty = TRUE;
  105. setIsEditing(FALSE);
  106. }
  107. void LLSidepanelInventorySubpanel::updateVerbs()
  108. {
  109. mSaveBtn->setVisible(mIsEditing);
  110. mCancelBtn->setVisible(mIsEditing);
  111. }
  112. void LLSidepanelInventorySubpanel::onEditButtonClicked()
  113. {
  114. setIsEditing(TRUE);
  115. refresh();
  116. updateVerbs();
  117. }
  118. void LLSidepanelInventorySubpanel::onSaveButtonClicked()
  119. {
  120. save();
  121. setIsEditing(FALSE);
  122. refresh();
  123. updateVerbs();
  124. }
  125. void LLSidepanelInventorySubpanel::onCancelButtonClicked()
  126. {
  127. setIsEditing(FALSE);
  128. refresh();
  129. updateVerbs();
  130. }