summaryrefslogtreecommitdiff
path: root/indra/newview/llfloaterchangeitemthumbnail.cpp
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2023-02-17 18:54:50 +0200
committerAndrey Kleshchev <andreykproductengine@lindenlab.com>2023-02-17 23:09:52 +0200
commit8fdd6849995748b144b811d2e9585aeb2c56562d (patch)
treedbfe292dea37082f5da28021b25f1b99b9dd8e9a /indra/newview/llfloaterchangeitemthumbnail.cpp
parentf2d46651b92d949a63d2b3a5dd774dce6a6752c7 (diff)
SL-19108 WIP Managing inventory thumbnail #3
Diffstat (limited to 'indra/newview/llfloaterchangeitemthumbnail.cpp')
-rw-r--r--indra/newview/llfloaterchangeitemthumbnail.cpp125
1 files changed, 109 insertions, 16 deletions
diff --git a/indra/newview/llfloaterchangeitemthumbnail.cpp b/indra/newview/llfloaterchangeitemthumbnail.cpp
index 05b9b89dd3..90fecd07ba 100644
--- a/indra/newview/llfloaterchangeitemthumbnail.cpp
+++ b/indra/newview/llfloaterchangeitemthumbnail.cpp
@@ -29,14 +29,17 @@
#include "llfloaterchangeitemthumbnail.h"
#include "llbutton.h"
+#include "llclipboard.h"
#include "lliconctrl.h"
#include "llinventoryicon.h"
#include "llinventorymodel.h"
#include "llinventoryobserver.h"
#include "lllineeditor.h"
#include "lltextbox.h"
+#include "lltexturectrl.h"
#include "llthumbnailctrl.h"
#include "llviewerobjectlist.h"
+#include "llwindow.h"
LLFloaterChangeItemThumbnail::LLFloaterChangeItemThumbnail(const LLSD& key)
@@ -151,7 +154,7 @@ void LLFloaterChangeItemThumbnail::inventoryChanged(LLViewerObject* object,
refreshFromInventory();
}
-void LLFloaterChangeItemThumbnail::refreshFromInventory()
+LLViewerInventoryItem* LLFloaterChangeItemThumbnail::getItem()
{
LLViewerInventoryItem* item = NULL;
if (mTaskId.isNull())
@@ -178,10 +181,16 @@ void LLFloaterChangeItemThumbnail::refreshFromInventory()
item = static_cast<LLViewerInventoryItem*>(object->getInventoryObject(mItemId));
}
- else
- {
- closeFloater();
- }
+ }
+ return item;
+}
+
+void LLFloaterChangeItemThumbnail::refreshFromInventory()
+{
+ LLViewerInventoryItem* item = getItem();
+ if (!item)
+ {
+ closeFloater();
}
if (item)
@@ -220,16 +229,9 @@ void LLFloaterChangeItemThumbnail::refreshFromItem(LLViewerInventoryItem* item)
mCopyToClipboardBtn->setEnabled(thumbnail_id.notNull());
mRemoveImageBtn->setEnabled(thumbnail_id.notNull() && (item->getActualType() != LLAssetType::AT_TEXTURE) || (item->getAssetUUID() != thumbnail_id));
-}
-
-void LLFloaterChangeItemThumbnail::startObjectInventoryObserver()
-{
-
-}
-
-void LLFloaterChangeItemThumbnail::stopObjectInventoryObserver()
-{
+ // todo: some elements might not support setting thumbnails
+ // since they already have them
}
void LLFloaterChangeItemThumbnail::onUploadLocal(void *userdata)
@@ -244,22 +246,113 @@ void LLFloaterChangeItemThumbnail::onUploadSnapshot(void *userdata)
void LLFloaterChangeItemThumbnail::onUseTexture(void *userdata)
{
+ LLFloaterChangeItemThumbnail *self = (LLFloaterChangeItemThumbnail*)userdata;
+ LLViewerInventoryItem* item = self->getItem();
+ if (item)
+ {
+ self->showTexturePicker(item->getThumbnailUUID());
+ }
}
void LLFloaterChangeItemThumbnail::onCopyToClipboard(void *userdata)
{
-
+ LLFloaterChangeItemThumbnail *self = (LLFloaterChangeItemThumbnail*)userdata;
+ LLViewerInventoryItem* item = self->getItem();
+ if (item)
+ {
+ LLClipboard::instance().addToClipboard(item->getThumbnailUUID());
+ }
}
void LLFloaterChangeItemThumbnail::onPasteFromClipboard(void *userdata)
{
-
+ LLFloaterChangeItemThumbnail *self = (LLFloaterChangeItemThumbnail*)userdata;
+ std::vector<LLUUID> objects;
+ LLClipboard::instance().pasteFromClipboard(objects);
+ if (objects.size() > 0)
+ {
+ LLViewerInventoryItem* item = self->getItem();
+ if (item)
+ {
+ item->setThumbnailUUID(objects[0]);
+ }
+ }
}
void LLFloaterChangeItemThumbnail::onRemove(void *userdata)
{
+ LLFloaterChangeItemThumbnail *self = (LLFloaterChangeItemThumbnail*)userdata;
+ LLViewerInventoryItem* item = self->getItem();
+ if (item)
+ {
+ item->setThumbnailUUID(LLUUID::null);
+ }
+}
+
+void LLFloaterChangeItemThumbnail::showTexturePicker(const LLUUID &thumbnail_id)
+{
+ // show hourglass cursor when loading inventory window
+ getWindow()->setCursor(UI_CURSOR_WAIT);
+ LLFloater* floaterp = mPickerHandle.get();
+ // Show the dialog
+ if (floaterp)
+ {
+ floaterp->openFloater();
+ }
+ else
+ {
+ floaterp = new LLFloaterTexturePicker(
+ this,
+ thumbnail_id,
+ thumbnail_id,
+ thumbnail_id,
+ FALSE,
+ TRUE,
+ "SELECT PHOTO",
+ PERM_NONE,
+ PERM_NONE,
+ PERM_NONE,
+ FALSE,
+ NULL);
+
+ mPickerHandle = floaterp->getHandle();
+
+ LLFloaterTexturePicker* texture_floaterp = dynamic_cast<LLFloaterTexturePicker*>(floaterp);
+ if (texture_floaterp)
+ {
+ //texture_floaterp->setTextureSelectedCallback();
+ //texture_floaterp->setOnUpdateImageStatsCallback();
+ texture_floaterp->setOnFloaterCommitCallback([this](LLTextureCtrl::ETexturePickOp op, LLUUID id)
+ {
+ if (op == LLTextureCtrl::TEXTURE_SELECT)
+ {
+ onTexturePickerCommit(id);
+ }
+ }
+ );
+
+ texture_floaterp->setLocalTextureEnabled(FALSE);
+ texture_floaterp->setBakeTextureEnabled(FALSE);
+ texture_floaterp->setCanApplyImmediately(false);
+ texture_floaterp->setCanApply(false, true);
+ }
+
+ floaterp->openFloater();
+ }
+ floaterp->setFocus(TRUE);
+}
+
+void LLFloaterChangeItemThumbnail::onTexturePickerCommit(LLUUID id)
+{
+ LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mPickerHandle.get();
+ LLViewerInventoryItem* item = getItem();
+
+ if (item && floaterp)
+ {
+ item->setThumbnailUUID(floaterp->getAssetID());
+ }
}
void LLFloaterChangeItemThumbnail::onButtonMouseEnter(LLUICtrl* button, const LLSD& param, EToolTipState state)