From 8758fac7124ff07f2a003bf5719c19a4dab170b9 Mon Sep 17 00:00:00 2001
From: Vadim Savchuk <vsavchuk@productengine.com>
Date: Wed, 20 Jan 2010 19:49:41 +0200
Subject: Fixed bug EXT-4369 ([BSI] Changing image in "Pick" doesn't trigger
 "Save Pick" button to be active) * Changed the Save button to react on
 texture picker commit, not on selection. * Added an optional
 "no_commit_on_selection" parameter to LLTextureCtrl   to commit only when
 user presses the OK button in the picker or changes   the texture via DnD,
 i.e. browsing in the picker doesn't commit.

--HG--
branch : product-engine
---
 indra/newview/llpanelpick.cpp                        | 20 +++++++-------------
 indra/newview/llpanelpick.h                          |  5 +++++
 indra/newview/lltexturectrl.cpp                      |  7 ++++++-
 indra/newview/lltexturectrl.h                        |  3 +++
 .../newview/skins/default/xui/en/panel_edit_pick.xml |  1 +
 5 files changed, 22 insertions(+), 14 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llpanelpick.cpp b/indra/newview/llpanelpick.cpp
index e7615929c8..5ac0587550 100644
--- a/indra/newview/llpanelpick.cpp
+++ b/indra/newview/llpanelpick.cpp
@@ -448,7 +448,7 @@ BOOL LLPanelPickEdit::postBuild()
 {
 	LLPanelPickInfo::postBuild();
 
-	mSnapshotCtrl->setOnSelectCallback(boost::bind(&LLPanelPickEdit::onPickChanged, this, _1));
+	mSnapshotCtrl->setCommitCallback(boost::bind(&LLPanelPickEdit::onSnapshotChanged, this));
 
 	LLLineEditor* line_edit = getChild<LLLineEditor>("pick_name");
 	line_edit->setKeystrokeCallback(boost::bind(&LLPanelPickEdit::onPickChanged, this, _1), NULL);
@@ -537,16 +537,14 @@ void LLPanelPickEdit::sendUpdate()
 	}
 }
 
+void LLPanelPickEdit::onSnapshotChanged()
+{
+	enableSaveButton(true);
+}
+
 void LLPanelPickEdit::onPickChanged(LLUICtrl* ctrl)
 {
-	if(isDirty())
-	{
-		enableSaveButton(true);
-	}
-	else
-	{
-		enableSaveButton(false);
-	}
+	enableSaveButton(isDirty());
 }
 
 void LLPanelPickEdit::resetData()
@@ -613,10 +611,6 @@ void LLPanelPickEdit::initTexturePickerMouseEvents()
 	mSnapshotCtrl->setMouseEnterCallback(boost::bind(&LLPanelPickEdit::onTexturePickerMouseEnter, this, _1));
 	mSnapshotCtrl->setMouseLeaveCallback(boost::bind(&LLPanelPickEdit::onTexturePickerMouseLeave, this, _1));
 	
-	// *WORKAROUND: Needed for EXT-1625: enabling save button each time when picker is opened, even if 
-	// texture wasn't changed (see Steve's comment).
-	mSnapshotCtrl->setMouseDownCallback(boost::bind(&LLPanelPickEdit::enableSaveButton, this, true));
-	
 	text_icon->setVisible(FALSE);
 }
 		
diff --git a/indra/newview/llpanelpick.h b/indra/newview/llpanelpick.h
index 62c3b20c0d..4f27760a8d 100644
--- a/indra/newview/llpanelpick.h
+++ b/indra/newview/llpanelpick.h
@@ -221,6 +221,11 @@ protected:
 	 */
 	void sendUpdate();
 
+	/**
+	 * Called when snapshot image changes.
+	 */
+	void onSnapshotChanged();
+	
 	/**
 	 * Callback for Pick snapshot, name and description changed event.
 	 */
diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp
index b980f65e68..9c4825763b 100644
--- a/indra/newview/lltexturectrl.cpp
+++ b/indra/newview/lltexturectrl.cpp
@@ -878,6 +878,7 @@ LLTextureCtrl::LLTextureCtrl(const LLTextureCtrl::Params& p)
 {
 	setAllowNoTexture(p.allow_no_texture);
 	setCanApplyImmediately(p.can_apply_immediately);
+	mCommitOnSelection = !p.no_commit_on_selection;
 
 	LLTextBox::Params params(p.caption_text);
 	params.name(p.label);
@@ -1122,7 +1123,11 @@ void LLTextureCtrl::onFloaterCommit(ETexturePickOp op)
 			}
 			else
 			{
-				onCommit();
+				// If the "no_commit_on_selection" parameter is set
+				// we commit only when user presses OK in the picker
+				// (i.e. op == TEXTURE_SELECT) or changes texture via DnD.
+				if (mCommitOnSelection || op == TEXTURE_SELECT)
+					onCommit();
 			}
 		}
 	}
diff --git a/indra/newview/lltexturectrl.h b/indra/newview/lltexturectrl.h
index fb1d591e32..023329a9b2 100644
--- a/indra/newview/lltexturectrl.h
+++ b/indra/newview/lltexturectrl.h
@@ -74,6 +74,7 @@ public:
 		Optional<std::string>	default_image_name;
 		Optional<bool>			allow_no_texture;
 		Optional<bool>			can_apply_immediately;
+		Optional<bool>			no_commit_on_selection; // don't commit unless it's DnD or OK button press
 		Optional<S32>			label_width;
 		Optional<LLUIColor>		border_color;
 		
@@ -88,6 +89,7 @@ public:
 			default_image_name("default_image_name"),
 			allow_no_texture("allow_no_texture"),
 			can_apply_immediately("can_apply_immediately"),
+			no_commit_on_selection("no_commit_on_selection", false),
 		    label_width("label_width", -1),
 			border_color("border_color"),
 			multiselect_text("multiselect_text"),
@@ -204,6 +206,7 @@ private:
 	PermissionMask			 mImmediateFilterPermMask;
 	PermissionMask			 mNonImmediateFilterPermMask;
 	BOOL					 mCanApplyImmediately;
+	BOOL					 mCommitOnSelection;
 	BOOL					 mNeedsRawImageData;
 	LLViewBorder*			 mBorder;
 	BOOL					 mValid;
diff --git a/indra/newview/skins/default/xui/en/panel_edit_pick.xml b/indra/newview/skins/default/xui/en/panel_edit_pick.xml
index 15eff4b67c..8e39697a16 100644
--- a/indra/newview/skins/default/xui/en/panel_edit_pick.xml
+++ b/indra/newview/skins/default/xui/en/panel_edit_pick.xml
@@ -61,6 +61,7 @@
      height="197"
      width="280"
      layout="topleft"
+     no_commit_on_selection="true"
      top="20"
      left="10"
      name="pick_snapshot" />
-- 
cgit v1.2.3