SL-19108 WIP Managing inventory thumbnail #2
parent
ec02220f06
commit
f2d46651b9
|
|
@ -28,14 +28,261 @@
|
|||
|
||||
#include "llfloaterchangeitemthumbnail.h"
|
||||
|
||||
#include "llbutton.h"
|
||||
#include "lliconctrl.h"
|
||||
#include "llinventoryicon.h"
|
||||
#include "llinventorymodel.h"
|
||||
#include "llinventoryobserver.h"
|
||||
#include "lllineeditor.h"
|
||||
#include "lltextbox.h"
|
||||
#include "llthumbnailctrl.h"
|
||||
#include "llviewerobjectlist.h"
|
||||
|
||||
|
||||
LLFloaterChangeItemThumbnail::LLFloaterChangeItemThumbnail(const LLSD& key)
|
||||
: LLPreview(key)
|
||||
: LLFloater(key)
|
||||
, mObserverInitialized(false)
|
||||
, mTooltipState(TOOLTIP_NONE)
|
||||
{
|
||||
}
|
||||
|
||||
LLFloaterChangeItemThumbnail::~LLFloaterChangeItemThumbnail()
|
||||
{
|
||||
gInventory.removeObserver(this);
|
||||
removeVOInventoryListener();
|
||||
}
|
||||
|
||||
BOOL LLFloaterChangeItemThumbnail::postBuild()
|
||||
{
|
||||
mItemNameText = getChild<LLUICtrl>("item_name");
|
||||
mItemTypeIcon = getChild<LLIconCtrl>("item_type_icon");
|
||||
mThumbnailCtrl = getChild<LLThumbnailCtrl>("item_thumbnail");
|
||||
mToolTipTextBox = getChild<LLTextBox>("tooltip_text");
|
||||
|
||||
LLSD tooltip_text;
|
||||
mToolTipTextBox->setValue(tooltip_text);
|
||||
|
||||
LLButton *upload_local = getChild<LLButton>("upload_local");
|
||||
upload_local->setClickedCallback(onUploadLocal, (void*)this);
|
||||
upload_local->setMouseEnterCallback(boost::bind(&LLFloaterChangeItemThumbnail::onButtonMouseEnter, this, _1, _2, TOOLTIP_UPLOAD_LOCAL));
|
||||
upload_local->setMouseLeaveCallback(boost::bind(&LLFloaterChangeItemThumbnail::onButtonMouseLeave, this, _1, _2, TOOLTIP_UPLOAD_LOCAL));
|
||||
|
||||
LLButton *upload_snapshot = getChild<LLButton>("upload_snapshot");
|
||||
upload_snapshot->setClickedCallback(onUploadSnapshot, (void*)this);
|
||||
upload_snapshot->setMouseEnterCallback(boost::bind(&LLFloaterChangeItemThumbnail::onButtonMouseEnter, this, _1, _2, TOOLTIP_UPLOAD_SNAPSHOT));
|
||||
upload_snapshot->setMouseLeaveCallback(boost::bind(&LLFloaterChangeItemThumbnail::onButtonMouseLeave, this, _1, _2, TOOLTIP_UPLOAD_SNAPSHOT));
|
||||
|
||||
LLButton *use_texture = getChild<LLButton>("use_texture");
|
||||
use_texture->setClickedCallback(onUseTexture, (void*)this);
|
||||
use_texture->setMouseEnterCallback(boost::bind(&LLFloaterChangeItemThumbnail::onButtonMouseEnter, this, _1, _2, TOOLTIP_USE_TEXTURE));
|
||||
use_texture->setMouseLeaveCallback(boost::bind(&LLFloaterChangeItemThumbnail::onButtonMouseLeave, this, _1, _2, TOOLTIP_USE_TEXTURE));
|
||||
|
||||
mCopyToClipboardBtn = getChild<LLButton>("copy_to_clipboard");
|
||||
mCopyToClipboardBtn->setClickedCallback(onCopyToClipboard, (void*)this);
|
||||
mCopyToClipboardBtn->setMouseEnterCallback(boost::bind(&LLFloaterChangeItemThumbnail::onButtonMouseEnter, this, _1, _2, TOOLTIP_COPY_TO_CLIPBOARD));
|
||||
mCopyToClipboardBtn->setMouseLeaveCallback(boost::bind(&LLFloaterChangeItemThumbnail::onButtonMouseLeave, this, _1, _2, TOOLTIP_COPY_TO_CLIPBOARD));
|
||||
|
||||
mPasteFromClipboardBtn = getChild<LLButton>("paste_from_clipboard");
|
||||
mPasteFromClipboardBtn->setClickedCallback(onPasteFromClipboard, (void*)this);
|
||||
mPasteFromClipboardBtn->setMouseEnterCallback(boost::bind(&LLFloaterChangeItemThumbnail::onButtonMouseEnter, this, _1, _2, TOOLTIP_COPY_FROM_CLIPBOARD));
|
||||
mPasteFromClipboardBtn->setMouseLeaveCallback(boost::bind(&LLFloaterChangeItemThumbnail::onButtonMouseLeave, this, _1, _2, TOOLTIP_COPY_FROM_CLIPBOARD));
|
||||
|
||||
mRemoveImageBtn = getChild<LLButton>("remove_image");
|
||||
mRemoveImageBtn->setClickedCallback(onRemove, (void*)this);
|
||||
mRemoveImageBtn->setMouseEnterCallback(boost::bind(&LLFloaterChangeItemThumbnail::onButtonMouseEnter, this, _1, _2, TOOLTIP_REMOVE));
|
||||
mRemoveImageBtn->setMouseLeaveCallback(boost::bind(&LLFloaterChangeItemThumbnail::onButtonMouseLeave, this, _1, _2, TOOLTIP_REMOVE));
|
||||
|
||||
return LLFloater::postBuild();
|
||||
}
|
||||
|
||||
void LLFloaterChangeItemThumbnail::onOpen(const LLSD& key)
|
||||
{
|
||||
if (!key.has("item_id") && !key.isUUID())
|
||||
{
|
||||
closeFloater();
|
||||
}
|
||||
|
||||
if (key.isUUID())
|
||||
{
|
||||
mItemId = key.asUUID();
|
||||
}
|
||||
else
|
||||
{
|
||||
mItemId = key["item_id"].asUUID();
|
||||
mTaskId = key["task_id"].asUUID();
|
||||
}
|
||||
|
||||
refreshFromInventory();
|
||||
}
|
||||
|
||||
void LLFloaterChangeItemThumbnail::changed(U32 mask)
|
||||
{
|
||||
//LLInventoryObserver
|
||||
|
||||
if (mTaskId.notNull() || mItemId.isNull())
|
||||
{
|
||||
// Task inventory or not set up yet
|
||||
return;
|
||||
}
|
||||
|
||||
const std::set<LLUUID>& mChangedItemIDs = gInventory.getChangedIDs();
|
||||
std::set<LLUUID>::const_iterator it;
|
||||
|
||||
for (it = mChangedItemIDs.begin(); it != mChangedItemIDs.end(); it++)
|
||||
{
|
||||
// set dirty for 'item profile panel' only if changed item is the item for which 'item profile panel' is shown (STORM-288)
|
||||
if (*it == mItemId)
|
||||
{
|
||||
// if there's a change we're interested in.
|
||||
if ((mask & (LLInventoryObserver::LABEL | LLInventoryObserver::INTERNAL | LLInventoryObserver::REMOVE)) != 0)
|
||||
{
|
||||
refreshFromInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LLFloaterChangeItemThumbnail::inventoryChanged(LLViewerObject* object,
|
||||
LLInventoryObject::object_list_t* inventory,
|
||||
S32 serial_num,
|
||||
void* user_data)
|
||||
{
|
||||
//LLVOInventoryListener
|
||||
refreshFromInventory();
|
||||
}
|
||||
|
||||
void LLFloaterChangeItemThumbnail::refreshFromInventory()
|
||||
{
|
||||
LLViewerInventoryItem* item = NULL;
|
||||
if (mTaskId.isNull())
|
||||
{
|
||||
// it is in agent inventory
|
||||
if (!mObserverInitialized)
|
||||
{
|
||||
gInventory.addObserver(this);
|
||||
mObserverInitialized = true;
|
||||
}
|
||||
|
||||
item = gInventory.getItem(mItemId);
|
||||
}
|
||||
else
|
||||
{
|
||||
LLViewerObject* object = gObjectList.findObject(mTaskId);
|
||||
if (object)
|
||||
{
|
||||
if (!mObserverInitialized)
|
||||
{
|
||||
registerVOInventoryListener(object, NULL);
|
||||
mObserverInitialized = false;
|
||||
}
|
||||
|
||||
item = static_cast<LLViewerInventoryItem*>(object->getInventoryObject(mItemId));
|
||||
}
|
||||
else
|
||||
{
|
||||
closeFloater();
|
||||
}
|
||||
}
|
||||
|
||||
if (item)
|
||||
{
|
||||
// This floater probably shouldn't be be possible to open
|
||||
// for imcomplete items
|
||||
llassert(item->isFinished());
|
||||
|
||||
const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH);
|
||||
bool in_trash = (item->getUUID() == trash_id) || gInventory.isObjectDescendentOf(item->getUUID(), trash_id);
|
||||
if (in_trash)
|
||||
{
|
||||
// Close properties when moving to trash
|
||||
// Aren't supposed to view properties from trash
|
||||
closeFloater();
|
||||
}
|
||||
else
|
||||
{
|
||||
refreshFromItem(item);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
closeFloater();
|
||||
}
|
||||
}
|
||||
|
||||
void LLFloaterChangeItemThumbnail::refreshFromItem(LLViewerInventoryItem* item)
|
||||
{
|
||||
LLUIImagePtr icon_img = LLInventoryIcon::getIcon(item->getType(), item->getInventoryType(), item->getFlags(), FALSE);
|
||||
mItemTypeIcon->setImage(icon_img);
|
||||
mItemNameText->setValue(item->getName());
|
||||
|
||||
LLUUID thumbnail_id = item->getThumbnailUUID();
|
||||
mThumbnailCtrl->setValue(thumbnail_id);
|
||||
|
||||
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()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void LLFloaterChangeItemThumbnail::onUploadLocal(void *userdata)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void LLFloaterChangeItemThumbnail::onUploadSnapshot(void *userdata)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void LLFloaterChangeItemThumbnail::onUseTexture(void *userdata)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void LLFloaterChangeItemThumbnail::onCopyToClipboard(void *userdata)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void LLFloaterChangeItemThumbnail::onPasteFromClipboard(void *userdata)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void LLFloaterChangeItemThumbnail::onRemove(void *userdata)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void LLFloaterChangeItemThumbnail::onButtonMouseEnter(LLUICtrl* button, const LLSD& param, EToolTipState state)
|
||||
{
|
||||
mTooltipState = state;
|
||||
|
||||
std::string tooltip_text;
|
||||
std::string tooltip_name = "tooltip_" + button->getName();
|
||||
if (hasString(tooltip_name))
|
||||
{
|
||||
tooltip_text = getString(tooltip_name);
|
||||
}
|
||||
|
||||
mToolTipTextBox->setValue(tooltip_text);
|
||||
}
|
||||
|
||||
void LLFloaterChangeItemThumbnail::onButtonMouseLeave(LLUICtrl* button, const LLSD& param, EToolTipState state)
|
||||
{
|
||||
if (mTooltipState == state)
|
||||
{
|
||||
mTooltipState = TOOLTIP_NONE;
|
||||
LLSD tooltip_text;
|
||||
mToolTipTextBox->setValue(tooltip_text);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,11 +28,71 @@
|
|||
#define LL_LLFLOATERCHANGEITEMTHUMBNAIL_H
|
||||
|
||||
#include "llfloater.h"
|
||||
#include "llinventoryobserver.h"
|
||||
#include "llvoinventorylistener.h"
|
||||
|
||||
class LLFloaterChangeItemThumbnail : public LLFloater
|
||||
class LLButton;
|
||||
class LLIconCtrl;
|
||||
class LLTextBox;
|
||||
class LLThumbnailCtrl;
|
||||
class LLUICtrl;
|
||||
class LLViewerInventoryItem;
|
||||
|
||||
class LLFloaterChangeItemThumbnail : public LLFloater, public LLInventoryObserver, public LLVOInventoryListener
|
||||
{
|
||||
public:
|
||||
LLFloaterChangeItemThumbnail(const LLSD& key);
|
||||
~LLFloaterChangeItemThumbnail();
|
||||
|
||||
BOOL postBuild() override;
|
||||
void onOpen(const LLSD& key) override;
|
||||
|
||||
void changed(U32 mask) override;
|
||||
void inventoryChanged(LLViewerObject* object,
|
||||
LLInventoryObject::object_list_t* inventory,
|
||||
S32 serial_num,
|
||||
void* user_data) override;
|
||||
|
||||
private:
|
||||
|
||||
void refreshFromInventory();
|
||||
void refreshFromItem(LLViewerInventoryItem* item);
|
||||
|
||||
void startObjectInventoryObserver();
|
||||
void stopObjectInventoryObserver();
|
||||
|
||||
static void onUploadLocal(void*);
|
||||
static void onUploadSnapshot(void*);
|
||||
static void onUseTexture(void*);
|
||||
static void onCopyToClipboard(void*);
|
||||
static void onPasteFromClipboard(void*);
|
||||
static void onRemove(void*);
|
||||
|
||||
enum EToolTipState
|
||||
{
|
||||
TOOLTIP_NONE,
|
||||
TOOLTIP_UPLOAD_LOCAL,
|
||||
TOOLTIP_UPLOAD_SNAPSHOT,
|
||||
TOOLTIP_USE_TEXTURE,
|
||||
TOOLTIP_COPY_TO_CLIPBOARD,
|
||||
TOOLTIP_COPY_FROM_CLIPBOARD,
|
||||
TOOLTIP_REMOVE,
|
||||
};
|
||||
|
||||
void onButtonMouseEnter(LLUICtrl* button, const LLSD& param, EToolTipState state);
|
||||
void onButtonMouseLeave(LLUICtrl* button, const LLSD& param, EToolTipState state);
|
||||
|
||||
bool mObserverInitialized;
|
||||
EToolTipState mTooltipState;
|
||||
LLUUID mItemId;
|
||||
LLUUID mTaskId;
|
||||
|
||||
LLIconCtrl *mItemTypeIcon;
|
||||
LLUICtrl *mItemNameText;
|
||||
LLThumbnailCtrl *mThumbnailCtrl;
|
||||
LLTextBox *mToolTipTextBox;
|
||||
LLButton *mCopyToClipboardBtn;
|
||||
LLButton *mPasteFromClipboardBtn;
|
||||
LLButton *mRemoveImageBtn;
|
||||
};
|
||||
#endif // LL_LLFLOATERCHANGEITEMTHUMBNAIL_H
|
||||
|
|
|
|||
|
|
@ -878,6 +878,13 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id,
|
|||
disabled_items.push_back(std::string("Rename"));
|
||||
}
|
||||
}
|
||||
|
||||
LLViewerInventoryItem* inv_item = gInventory.getItem(mUUID);
|
||||
items.push_back(std::string("thumbnail"));
|
||||
if (!inv_item || !inv_item->getPermissions().allowOperationBy(PERM_MODIFY, gAgent.getID()))
|
||||
{
|
||||
disabled_items.push_back(std::string("thumbnail"));
|
||||
}
|
||||
|
||||
if (show_asset_id)
|
||||
{
|
||||
|
|
@ -885,7 +892,6 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id,
|
|||
|
||||
bool is_asset_knowable = false;
|
||||
|
||||
LLViewerInventoryItem* inv_item = gInventory.getItem(mUUID);
|
||||
if (inv_item)
|
||||
{
|
||||
is_asset_knowable = LLAssetType::lookupIsAssetIDKnowable(inv_item->getType());
|
||||
|
|
|
|||
|
|
@ -750,7 +750,7 @@ void LLSidepanelItemInfo::changed(U32 mask)
|
|||
const LLUUID& item_id = getItemID();
|
||||
if (getObjectID().notNull() || item_id.isNull())
|
||||
{
|
||||
// Tasl inventory or not set up yet
|
||||
// Task inventory or not set up yet
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,33 @@
|
|||
name="change_item_thumbnail"
|
||||
help_topic="change_item_thumbnail"
|
||||
title="CHANGE ITEM IMAGE"
|
||||
width="320">
|
||||
width="319">
|
||||
|
||||
<floater.string
|
||||
name="tooltip_upload_local">
|
||||
Upload from computer
|
||||
</floater.string>
|
||||
<floater.string
|
||||
name="tooltip_upload_snapshot">
|
||||
Use snapshot tool
|
||||
</floater.string>
|
||||
<floater.string
|
||||
name="tooltip_use_texture">
|
||||
Choose texture
|
||||
</floater.string>
|
||||
<floater.string
|
||||
name="tooltip_copy_to_clipboard">
|
||||
Copy to clipboard
|
||||
</floater.string>
|
||||
<floater.string
|
||||
name="tooltip_paste_from_clipboard">
|
||||
Paste from clipboard
|
||||
</floater.string>
|
||||
<floater.string
|
||||
name="tooltip_remove_image">
|
||||
Remove image
|
||||
</floater.string>
|
||||
|
||||
<icon
|
||||
follows="top|left"
|
||||
height="16"
|
||||
|
|
@ -28,13 +54,14 @@
|
|||
left_pad="5"
|
||||
max_length_bytes="127"
|
||||
name="item_name"
|
||||
width="286" />
|
||||
width="286"
|
||||
enabled="false"/>
|
||||
|
||||
<thumbnail
|
||||
name="item_thumbnail"
|
||||
follows="top|left"
|
||||
layout="topleft"
|
||||
left="31"
|
||||
left="32"
|
||||
top_pad="9"
|
||||
height="256"
|
||||
width="256"
|
||||
|
|
@ -45,11 +72,10 @@
|
|||
height="32"
|
||||
label="A"
|
||||
layout="topleft"
|
||||
left="37"
|
||||
left="38"
|
||||
name="upload_local"
|
||||
top_pad="9"
|
||||
width="32" />
|
||||
|
||||
<button
|
||||
follows="right|bottom"
|
||||
height="32"
|
||||
|
|
@ -59,7 +85,6 @@
|
|||
name="upload_snapshot"
|
||||
top_delta="0"
|
||||
width="32" />
|
||||
|
||||
<button
|
||||
follows="right|bottom"
|
||||
height="32"
|
||||
|
|
@ -69,34 +94,31 @@
|
|||
name="use_texture"
|
||||
top_delta="0"
|
||||
width="32" />
|
||||
|
||||
<button
|
||||
follows="right|bottom"
|
||||
height="32"
|
||||
label="D"
|
||||
layout="topleft"
|
||||
left_pad="10"
|
||||
name="to_clipboard"
|
||||
name="copy_to_clipboard"
|
||||
top_delta="0"
|
||||
width="32" />
|
||||
|
||||
<button
|
||||
follows="right|bottom"
|
||||
height="32"
|
||||
label="E"
|
||||
layout="topleft"
|
||||
left_pad="10"
|
||||
name="from_clipboard"
|
||||
name="paste_from_clipboard"
|
||||
top_delta="0"
|
||||
width="32" />
|
||||
|
||||
<button
|
||||
follows="right|bottom"
|
||||
height="32"
|
||||
label="F"
|
||||
layout="topleft"
|
||||
left_pad="10"
|
||||
name="remove"
|
||||
name="remove_image"
|
||||
top_delta="0"
|
||||
width="32" />
|
||||
|
||||
|
|
@ -109,7 +131,7 @@
|
|||
layout="topleft"
|
||||
left="5"
|
||||
right="-5"
|
||||
name="LabelOwnerTitle"
|
||||
name="tooltip_text"
|
||||
top_pad="12"
|
||||
width="78">
|
||||
tooltip
|
||||
|
|
|
|||
Loading…
Reference in New Issue