diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2022-06-25 16:50:23 +0300 |
---|---|---|
committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2022-06-25 16:50:23 +0300 |
commit | 63daefb39afba64110a48572ac629c83fb31a7c7 (patch) | |
tree | 65cc9ff1e1d2529e2a48e0c69422794d23b6a022 /indra/newview | |
parent | 5cf5aa44cabf9bc142551e568c2e69954d06640f (diff) |
SL-17640 Materials Upload UI #3
Fixed issues in button layout
Added 'unsaved changes' notification
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llmaterialeditor.cpp | 75 | ||||
-rw-r--r-- | indra/newview/llmaterialeditor.h | 7 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_material_editor.xml | 19 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/notifications.xml | 17 |
4 files changed, 104 insertions, 14 deletions
diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 3c9d722b87..e3206947d5 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -47,6 +47,7 @@ // Default constructor LLMaterialEditor::LLMaterialEditor(const LLSD& key) : LLFloater(key) + , mHasUnsavedChanges(false) { } @@ -66,9 +67,44 @@ BOOL LLMaterialEditor::postBuild() childSetAction("save_as", boost::bind(&LLMaterialEditor::onClickSaveAs, this)); childSetAction("cancel", boost::bind(&LLMaterialEditor::onClickCancel, this)); + boost::function<void(LLUICtrl*, void*)> changes_callback = [this](LLUICtrl * ctrl, void*) { setHasUnsavedChanges(true); }; + + childSetCommitCallback("double sided", changes_callback, NULL); + + // Albedo + childSetCommitCallback("albedo color", changes_callback, NULL); + childSetCommitCallback("transparency", changes_callback, NULL); + childSetCommitCallback("alpha mode", changes_callback, NULL); + childSetCommitCallback("alpha cutoff", changes_callback, NULL); + + // Metallic-Roughness + childSetCommitCallback("metalness factor", changes_callback, NULL); + childSetCommitCallback("roughness factor", changes_callback, NULL); + + // Metallic-Roughness + childSetCommitCallback("metalness factor", changes_callback, NULL); + childSetCommitCallback("roughness factor", changes_callback, NULL); + + // Emissive + childSetCommitCallback("emissive color", changes_callback, NULL); + + childSetVisible("unsaved_changes", mHasUnsavedChanges); + return LLFloater::postBuild(); } +void LLMaterialEditor::onClickCloseBtn(bool app_quitting) +{ + if (app_quitting) + { + closeFloater(app_quitting); + } + else + { + onClickCancel(); + } +} + LLUUID LLMaterialEditor::getAlbedoId() { return mAlbedoTextureCtrl->getValue().asUUID(); @@ -230,10 +266,19 @@ void LLMaterialEditor::setDoubleSided(bool double_sided) childSetValue("double sided", double_sided); } +void LLMaterialEditor::setHasUnsavedChanges(bool value) +{ + if (value != mHasUnsavedChanges) + { + mHasUnsavedChanges = value; + childSetVisible("unsaved_changes", value); + } +} + void LLMaterialEditor::onCommitAlbedoTexture(LLUICtrl * ctrl, const LLSD & data) { // might be better to use arrays, to have a single callback - // and not to repeat the same thing for each tecture controls + // and not to repeat the same thing for each tecture control LLUUID new_val = mAlbedoTextureCtrl->getValue().asUUID(); if (new_val == mAlbedoTextureUploadId && mAlbedoTextureUploadId.notNull()) { @@ -243,6 +288,7 @@ void LLMaterialEditor::onCommitAlbedoTexture(LLUICtrl * ctrl, const LLSD & data) { childSetValue("albedo_upload_fee", getString("no_upload_fee_string")); } + setHasUnsavedChanges(true); } void LLMaterialEditor::onCommitMetallicTexture(LLUICtrl * ctrl, const LLSD & data) @@ -256,6 +302,7 @@ void LLMaterialEditor::onCommitMetallicTexture(LLUICtrl * ctrl, const LLSD & dat { childSetValue("metallic_upload_fee", getString("no_upload_fee_string")); } + setHasUnsavedChanges(true); } void LLMaterialEditor::onCommitEmissiveTexture(LLUICtrl * ctrl, const LLSD & data) @@ -269,6 +316,7 @@ void LLMaterialEditor::onCommitEmissiveTexture(LLUICtrl * ctrl, const LLSD & dat { childSetValue("emissive_upload_fee", getString("no_upload_fee_string")); } + setHasUnsavedChanges(true); } void LLMaterialEditor::onCommitNormalTexture(LLUICtrl * ctrl, const LLSD & data) @@ -282,6 +330,7 @@ void LLMaterialEditor::onCommitNormalTexture(LLUICtrl * ctrl, const LLSD & data) { childSetValue("normal_upload_fee", getString("no_upload_fee_string")); } + setHasUnsavedChanges(true); } @@ -386,10 +435,10 @@ void LLMaterialEditor::onClickSaveAs() LLSD args; args["DESC"] = mMaterialName; - LLNotificationsUtil::add("SaveMaterialAs", args, LLSD(), boost::bind(&LLMaterialEditor::onSaveAsCommitCallback, this, _1, _2)); + LLNotificationsUtil::add("SaveMaterialAs", args, LLSD(), boost::bind(&LLMaterialEditor::onSaveAsMsgCallback, this, _1, _2)); } -void LLMaterialEditor::onSaveAsCommitCallback(const LLSD& notification, const LLSD& response) +void LLMaterialEditor::onSaveAsMsgCallback(const LLSD& notification, const LLSD& response) { S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if (0 == option) @@ -410,8 +459,23 @@ void LLMaterialEditor::onSaveAsCommitCallback(const LLSD& notification, const LL void LLMaterialEditor::onClickCancel() { - // Todo: confirm usaved changes - closeFloater(); + if (mHasUnsavedChanges) + { + LLNotificationsUtil::add("UsavedMaterialChanges", LLSD(), LLSD(), boost::bind(&LLMaterialEditor::onCancelMsgCallback, this, _1, _2)); + } + else + { + closeFloater(); + } +} + +void LLMaterialEditor::onCancelMsgCallback(const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + if (0 == option) + { + closeFloater(); + } } class LLMaterialFilePicker : public LLFilePickerThread @@ -701,6 +765,7 @@ void LLMaterialFilePicker::loadMaterial(const std::string& filename) std::string new_material = LLTrans::getString("New Material"); mME->setMaterialName(new_material); + mME->setHasUnsavedChanges(true); mME->openFloater(); mME->applyToSelection(); diff --git a/indra/newview/llmaterialeditor.h b/indra/newview/llmaterialeditor.h index 1584f2c136..7f9c6c0b63 100644 --- a/indra/newview/llmaterialeditor.h +++ b/indra/newview/llmaterialeditor.h @@ -43,11 +43,13 @@ public: void onClickSave(); void onClickSaveAs(); - void onSaveAsCommitCallback(const LLSD& notification, const LLSD& response); + void onSaveAsMsgCallback(const LLSD& notification, const LLSD& response); void onClickCancel(); + void onCancelMsgCallback(const LLSD& notification, const LLSD& response); // llpanel BOOL postBuild() override; + void onClickCloseBtn(bool app_quitting = false) override; LLUUID getAlbedoId(); void setAlbedoId(const LLUUID& id); @@ -88,6 +90,8 @@ public: bool getDoubleSided(); void setDoubleSided(bool double_sided); + void setHasUnsavedChanges(bool value); + void onCommitAlbedoTexture(LLUICtrl* ctrl, const LLSD& data); void onCommitMetallicTexture(LLUICtrl* ctrl, const LLSD& data); void onCommitEmissiveTexture(LLUICtrl* ctrl, const LLSD& data); @@ -105,6 +109,7 @@ private: LLUUID mEmissiveTextureUploadId; LLUUID mNormalTextureUploadId; + bool mHasUnsavedChanges; std::string mMaterialName; }; diff --git a/indra/newview/skins/default/xui/en/floater_material_editor.xml b/indra/newview/skins/default/xui/en/floater_material_editor.xml index 815a53a887..36315d3b04 100644 --- a/indra/newview/skins/default/xui/en/floater_material_editor.xml +++ b/indra/newview/skins/default/xui/en/floater_material_editor.xml @@ -27,7 +27,7 @@ layout="topleft" left="5" mouse_opaque="false" - name="Texture" + name="albedo_texture_pnl" top_pad="5" > <text @@ -182,7 +182,7 @@ layout="topleft" left="5" mouse_opaque="false" - name="Texture" + name="metallic_texture_pnl" top_pad="5" > <text @@ -283,7 +283,7 @@ layout="topleft" left="5" mouse_opaque="false" - name="Texture" + name="emissive_texture_pnl" top_pad="5" > <text @@ -379,6 +379,7 @@ left="5" mouse_opaque="false" top_pad="5" + name="normal_texture_pnl" > <text type="string" @@ -423,15 +424,17 @@ <panel follows="right|bottom" width="246" - height="82" + height="97" layout="bottomright" top_delta="-2" - left="0" + left="5" name="button_panel" > <text type="string" + name="unsaved_changes" font.style="BOLD" + text_color="DrYellow" length="1" follows="left|top" height="10" @@ -449,7 +452,7 @@ layout="topleft" name="save" top_pad="7" - left="5" + left="0" width="120" /> <button follows="left|top" @@ -466,7 +469,7 @@ length="1" follows="left|top" height="10" - width="240" + width="220" layout="topleft" left="10" top_pad="5" @@ -478,7 +481,7 @@ bevel_style="none" height="0" layout="topleft" - left="5" + left="0" name="button_border" top_pad="7" width="246"/> diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index 23a9632ada..0ca3e043e7 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -9068,6 +9068,23 @@ Please enter a non-empty name <notification icon="alertmodal.tga" + name="UsavedMaterialChanges" + type="alertmodal"> + You have unsaved changes. + <form name="form"> + <button + index="0" + name="discard" + text="Discard changes"/> + <button + index="1" + name="keep" + text="Keep editing"/> + </form> + </notification> + + <notification + icon="alertmodal.tga" name="LivePreviewUnavailable" type="alert"> |