From 4886682d0458f901fc5b24ed8b58300b93489ac9 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 22 Feb 2023 21:28:04 +0200 Subject: SL-19108 Multi instance snapshot floater --- indra/newview/llfloaterchangeitemthumbnail.cpp | 40 +++++++++++++++++++--- indra/newview/llfloaterchangeitemthumbnail.h | 1 + indra/newview/llfloatersimplesnapshot.cpp | 40 ++++++++++++++-------- indra/newview/llfloatersimplesnapshot.h | 8 +++-- indra/newview/llviewermenufile.cpp | 7 +--- .../default/xui/en/floater_simple_snapshot.xml | 4 +-- 6 files changed, 71 insertions(+), 29 deletions(-) diff --git a/indra/newview/llfloaterchangeitemthumbnail.cpp b/indra/newview/llfloaterchangeitemthumbnail.cpp index a78100374d..ab9d6135f8 100644 --- a/indra/newview/llfloaterchangeitemthumbnail.cpp +++ b/indra/newview/llfloaterchangeitemthumbnail.cpp @@ -356,18 +356,41 @@ void LLFloaterChangeItemThumbnail::onUploadLocal(void *userdata) { floaterp->closeFloater(); } + floaterp = self->mSnapshotHandle.get(); + if (floaterp) + { + floaterp->closeFloater(); + } } void LLFloaterChangeItemThumbnail::onUploadSnapshot(void *userdata) { LLFloaterChangeItemThumbnail *self = (LLFloaterChangeItemThumbnail*)userdata; - LLFloaterReg::toggleInstanceOrBringToFront("simple_snapshot"); - LLFloaterSimpleSnapshot* snapshot_floater = LLFloaterSimpleSnapshot::getInstance(); - if (snapshot_floater) + LLFloater* floaterp = self->mSnapshotHandle.get(); + // Show the dialog + if (floaterp) + { + floaterp->openFloater(); + } + else + { + LLSD key; + key["item_id"] = self->mItemId; + key["task_id"] = self->mTaskId; + LLFloaterSimpleSnapshot* snapshot_floater = (LLFloaterSimpleSnapshot*)LLFloaterReg::showInstance("simple_snapshot", key, true); + if (snapshot_floater) + { + self->addDependentFloater(snapshot_floater); + self->mSnapshotHandle = snapshot_floater->getHandle(); + snapshot_floater->setOwner(self); + } + } + + floaterp = self->mPickerHandle.get(); + if (floaterp) { - snapshot_floater->setInventoryId(self->mItemId); - snapshot_floater->setTaskId(self->mTaskId); + floaterp->closeFloater(); } } @@ -380,6 +403,11 @@ void LLFloaterChangeItemThumbnail::onUseTexture(void *userdata) self->showTexturePicker(obj->getThumbnailUUID()); } + LLFloater* floaterp = self->mSnapshotHandle.get(); + if (floaterp) + { + floaterp->closeFloater(); + } } void LLFloaterChangeItemThumbnail::onCopyToClipboard(void *userdata) @@ -482,6 +510,8 @@ void LLFloaterChangeItemThumbnail::showTexturePicker(const LLUUID &thumbnail_id) texture_floaterp->setBakeTextureEnabled(FALSE); texture_floaterp->setCanApplyImmediately(false); texture_floaterp->setCanApply(false, true); + + addDependentFloater(texture_floaterp); } floaterp->openFloater(); diff --git a/indra/newview/llfloaterchangeitemthumbnail.h b/indra/newview/llfloaterchangeitemthumbnail.h index e40d649361..250f895078 100644 --- a/indra/newview/llfloaterchangeitemthumbnail.h +++ b/indra/newview/llfloaterchangeitemthumbnail.h @@ -98,5 +98,6 @@ private: LLButton *mRemoveImageBtn; LLHandle mPickerHandle; + LLHandle mSnapshotHandle; }; #endif // LL_LLFLOATERCHANGEITEMTHUMBNAIL_H diff --git a/indra/newview/llfloatersimplesnapshot.cpp b/indra/newview/llfloatersimplesnapshot.cpp index 096db132ac..0bf4bb4fc3 100644 --- a/indra/newview/llfloatersimplesnapshot.cpp +++ b/indra/newview/llfloatersimplesnapshot.cpp @@ -228,6 +228,8 @@ void LLFloaterSimpleSnapshot::Impl::setStatus(EStatus status, bool ok, const std LLFloaterSimpleSnapshot::LLFloaterSimpleSnapshot(const LLSD& key) : LLFloaterSnapshotBase(key) + , mOwner(NULL) + , mContextConeOpacity(0.f) { impl = new Impl(this); } @@ -249,13 +251,9 @@ BOOL LLFloaterSimpleSnapshot::postBuild() LLSnapshotLivePreview::Params p; p.rect(full_screen_rect); LLSnapshotLivePreview* previewp = new LLSnapshotLivePreview(p); - LLView* parent_view = gSnapshotFloaterView->getParent(); - parent_view->addChild(previewp); - - //move snapshot floater to special purpose snapshotfloaterview - gFloaterView->removeChild(this); - gSnapshotFloaterView->addChild(this); + // Do not move LLFloaterSimpleSnapshot floater into gSnapshotFloaterView + // since it can be a dependednt floater and does not draw UI impl->mPreviewHandle = previewp->getHandle(); previewp->setContainer(this); @@ -275,6 +273,12 @@ const S32 PREVIEW_OFFSET_Y = 70; void LLFloaterSimpleSnapshot::draw() { + if (mOwner) + { + static LLCachedControl max_opacity(gSavedSettings, "PickerContextOpacity", 0.4f); + drawConeToOwner(mContextConeOpacity, max_opacity, mOwner); + } + LLSnapshotLivePreview* previewp = getPreviewView(); if (previewp && (previewp->isSnapshotActive() || previewp->getThumbnailLock())) @@ -323,6 +327,9 @@ void LLFloaterSimpleSnapshot::onOpen(const LLSD& key) impl->updateControls(this); impl->setStatus(ImplBase::STATUS_READY); + + mInventoryId = key["item_id"].asUUID(); + mTaskId = key["task_id"].asUUID(); } void LLFloaterSimpleSnapshot::onCancel() @@ -406,27 +413,32 @@ void LLFloaterSimpleSnapshot::uploadImageUploadFile(const std::string &temp_file boost::bind(post_thumbnail_image_coro, cap_url, temp_file, data)); } -// static void LLFloaterSimpleSnapshot::update() { - LLFloaterSimpleSnapshot* inst = findInstance(); - if (inst != NULL) + // initializes snapshots when needed + LLFloaterReg::const_instance_list_t& inst_list = LLFloaterReg::getFloaterList("simple_snapshot"); + for (LLFloaterReg::const_instance_list_t::const_iterator iter = inst_list.begin(); + iter != inst_list.end(); ++iter) { - inst->impl->updateLivePreview(); + LLFloaterSimpleSnapshot* floater = dynamic_cast(*iter); + if (floater) + { + floater->impl->updateLivePreview(); + } } } // static -LLFloaterSimpleSnapshot* LLFloaterSimpleSnapshot::findInstance() +LLFloaterSimpleSnapshot* LLFloaterSimpleSnapshot::findInstance(const LLSD &key) { - return LLFloaterReg::findTypedInstance("simple_snapshot"); + return LLFloaterReg::findTypedInstance("simple_snapshot", key); } // static -LLFloaterSimpleSnapshot* LLFloaterSimpleSnapshot::getInstance() +LLFloaterSimpleSnapshot* LLFloaterSimpleSnapshot::getInstance(const LLSD &key) { - return LLFloaterReg::getTypedInstance("simple_snapshot"); + return LLFloaterReg::getTypedInstance("simple_snapshot", key); } void LLFloaterSimpleSnapshot::saveTexture() diff --git a/indra/newview/llfloatersimplesnapshot.h b/indra/newview/llfloatersimplesnapshot.h index 59cb526704..1b51325afc 100644 --- a/indra/newview/llfloatersimplesnapshot.h +++ b/indra/newview/llfloatersimplesnapshot.h @@ -50,8 +50,8 @@ public: static void update(); - static LLFloaterSimpleSnapshot* getInstance(); - static LLFloaterSimpleSnapshot* findInstance(); + static LLFloaterSimpleSnapshot* getInstance(const LLSD &key); + static LLFloaterSimpleSnapshot* findInstance(const LLSD &key); void saveTexture(); const LLRect& getThumbnailPlaceholderRect() { return mThumbnailPlaceholder->getRect(); } @@ -59,6 +59,7 @@ public: void setInventoryId(const LLUUID &inventory_id) { mInventoryId = inventory_id; } LLUUID getInventoryId() { return mInventoryId; } void setTaskId(const LLUUID &task_id) { mTaskId = task_id; } + void setOwner(LLView *owner_view) { mOwner = owner_view; } void postSave(); static void uploadThumbnail(const std::string &file_path, const LLUUID &inventory_id, const LLUUID &task_id); @@ -75,6 +76,9 @@ private: LLUUID mInventoryId; LLUUID mTaskId; + + LLView* mOwner; + F32 mContextConeOpacity; }; ///---------------------------------------------------------------------------- diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index ab8ec8a288..6c07c28d81 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -664,9 +664,7 @@ class LLFileEnableCloseAllWindows : public view_listener_t bool handleEvent(const LLSD& userdata) { LLFloaterSnapshot* floater_snapshot = LLFloaterSnapshot::findInstance(); - LLFloaterSimpleSnapshot* floater_outfit_snapshot = LLFloaterSimpleSnapshot::findInstance(); - bool is_floaters_snapshot_opened = (floater_snapshot && floater_snapshot->isInVisibleChain()) - || (floater_outfit_snapshot && floater_outfit_snapshot->isInVisibleChain()); + bool is_floaters_snapshot_opened = (floater_snapshot && floater_snapshot->isInVisibleChain()); bool open_children = gFloaterView->allChildrenClosed() && !is_floaters_snapshot_opened; return !open_children && !LLNotificationsUI::LLToast::isAlertToastShown(); } @@ -681,9 +679,6 @@ class LLFileCloseAllWindows : public view_listener_t LLFloaterSnapshot* floater_snapshot = LLFloaterSnapshot::findInstance(); if (floater_snapshot) floater_snapshot->closeFloater(app_quitting); - LLFloaterSimpleSnapshot* floater_outfit_snapshot = LLFloaterSimpleSnapshot::findInstance(); - if (floater_outfit_snapshot) - floater_outfit_snapshot->closeFloater(app_quitting); if (gMenuHolder) gMenuHolder->hideMenus(); return true; } diff --git a/indra/newview/skins/default/xui/en/floater_simple_snapshot.xml b/indra/newview/skins/default/xui/en/floater_simple_snapshot.xml index 97ea59593e..484ad159d1 100644 --- a/indra/newview/skins/default/xui/en/floater_simple_snapshot.xml +++ b/indra/newview/skins/default/xui/en/floater_simple_snapshot.xml @@ -2,13 +2,13 @@