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
master
Vadim Savchuk 2010-01-20 19:49:41 +02:00
parent da00631c63
commit 8758fac712
5 changed files with 22 additions and 14 deletions

View File

@ -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);
}

View File

@ -221,6 +221,11 @@ protected:
*/
void sendUpdate();
/**
* Called when snapshot image changes.
*/
void onSnapshotChanged();
/**
* Callback for Pick snapshot, name and description changed event.
*/

View File

@ -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();
}
}
}

View File

@ -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;

View File

@ -61,6 +61,7 @@
height="197"
width="280"
layout="topleft"
no_commit_on_selection="true"
top="20"
left="10"
name="pick_snapshot" />