Commits

Steven Bennetts  committed f5c6dbb

merge -r 1879-1884 https://svn.aws.productengine.com/secondlife/pe/stable-2
* Major Bugs: EXT-1248 EXT-1127 EXT-844 EXT-1160
* Changes: EXT-1139 (places context menu)

  • Participants
  • Parent commits 7e8f998

Comments (0)

Files changed (14)

File indra/newview/llchannelmanager.cpp

 	p.channel_align = CA_RIGHT;
 
 	// Getting a Channel for our notifications
-	return dynamic_cast<LLScreenChannel*> (LLChannelManager::getInstance()->createChannel(p));
+	return dynamic_cast<LLScreenChannel*> (LLChannelManager::getInstance()->getChannel(p));
 }
 
 //--------------------------------------------------------------------------

File indra/newview/lllandmarkactions.cpp

 #include "llagentui.h"
 
 
-class LLFetchlLandmarkByAgentPos : public LLInventoryCollectFunctor
+class LLFetchlLandmarkByPos : public LLInventoryCollectFunctor
 {
-	
+private:
+	LLVector3d mPos;
 public:
+	LLFetchlLandmarkByPos(const LLVector3d& pos) :
+		mPos(pos)
+	{}
+
 	/*virtual*/ bool operator()(LLInventoryCategory* cat, LLInventoryItem* item)
 	{
 		if (!item || item->getType() != LLAssetType::AT_LANDMARK)
 		LLVector3d landmark_global_pos;
 		if (!landmark->getGlobalPos(landmark_global_pos))
 			return false;
-		LLVector3d a_pos = gAgent.getPositionGlobal();
 		//we have to round off each coordinates to compare positions properly
-		return llround(a_pos.mdV[VX]) ==  llround(landmark_global_pos.mdV[VX])
-				&& llround(a_pos.mdV[VY]) ==  llround(landmark_global_pos.mdV[VY])
-				&& llround(a_pos.mdV[VZ]) ==  llround(landmark_global_pos.mdV[VZ]);
+		return llround(mPos.mdV[VX]) ==  llround(landmark_global_pos.mdV[VX])
+				&& llround(mPos.mdV[VY]) ==  llround(landmark_global_pos.mdV[VY])
+				&& llround(mPos.mdV[VZ]) ==  llround(landmark_global_pos.mdV[VZ]);
 	}
 };
 
 }
 
 
-LLViewerInventoryItem* LLLandmarkActions::findLandmarkForAgentPos()
+LLViewerInventoryItem* LLLandmarkActions::findLandmarkForGlobalPos(const LLVector3d &pos)
 {
 	// Determine whether there are landmarks pointing to the current parcel.
 	LLInventoryModel::cat_array_t cats;
 	LLInventoryModel::item_array_t items;
-	LLFetchlLandmarkByAgentPos is_current_pos_landmark;
+	LLFetchlLandmarkByPos is_current_pos_landmark(pos);
 	gInventory.collectDescendentsIf(gInventory.getRootFolderID(),
 		cats,
 		items,
 	return items[0];
 }
 
+LLViewerInventoryItem* LLLandmarkActions::findLandmarkForAgentPos()
+{
+	return findLandmarkForGlobalPos(gAgent.getPositionGlobal());
+}
+
 bool LLLandmarkActions::canCreateLandmarkHere()
 {
 	LLParcel* agent_parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();

File indra/newview/lllandmarkactions.h

 	static bool landmarkAlreadyExists();
 
 	/**
+	 * @brief Searches landmark for global position.
+	 * @return Returns landmark or NULL.
+	 * 
+	 * *TODO: dzaporozhan: There can be many landmarks for single parcel.
+	 */
+	static LLViewerInventoryItem* findLandmarkForGlobalPos(const LLVector3d &pos);
+
+	/**
 	 * @brief Searches landmark for agent global position.
 	 * @return Returns landmark or NULL.
 	 * 
 	 */
 	static LLViewerInventoryItem* findLandmarkForAgentPos();
 
+
 	/**
 	 * @brief Checks whether agent has rights to create landmark for current parcel.
 	 */

File indra/newview/llnotificationalerthandler.cpp

 
 	// Getting a Channel for our notifications
 	mChannel = LLChannelManager::getInstance()->getChannel(p);
-	mChannel->setShowToasts(true);
+	mChannel->setCanStoreToasts(false);
 }
 
 //--------------------------------------------------------------------------

File indra/newview/lloutputmonitorctrl.cpp

 	const F32 LEVEL_1 = LLVoiceClient::OVERDRIVEN_POWER_LEVEL * 2.f / 3.f;
 	const F32 LEVEL_2 = LLVoiceClient::OVERDRIVEN_POWER_LEVEL;
 
-	if (mIsParentVisible && getVisible() && mAutoUpdate && !mIsMuted && mSpeakerId.notNull())
+	if (getVisible() && mAutoUpdate && !mIsMuted && mSpeakerId.notNull())
 	{
 		setPower(gVoiceClient->getCurrentPower(mSpeakerId));
 		setIsTalking(gVoiceClient->getIsSpeaking(mSpeakerId));
 		gl_rect_2d(0, monh, monw, 0, sColorBound, FALSE);
 }
 
-void LLOutputMonitorCtrl::handleVisibilityChange(BOOL new_visibility)
-{
-	mIsParentVisible = new_visibility;
-	LLView::handleVisibilityChange(new_visibility);
-}
-
 void LLOutputMonitorCtrl::setSpeakerId(const LLUUID& speaker_id)
 {
 	if (speaker_id.isNull()) return;

File indra/newview/lloutputmonitorctrl.h

 
 	// llview overrides
 	virtual void	draw();
-	void handleVisibilityChange(BOOL new_visibility);
-
 
 	void			setPower(F32 val);
 	F32				getPower(F32 val) const { return mPower; }
 	F32				mPower;
 	bool			mIsMuted;
 	bool			mIsTalking;
-	/** Stores flag whether parent is visible. If not it will not update indicator*/
-	bool			mIsParentVisible;
 	LLPointer<LLUIImage> mImageMute;
 	LLPointer<LLUIImage> mImageOff;
 	LLPointer<LLUIImage> mImageOn;

File indra/newview/llpanelteleporthistory.cpp

 #include "llaccordionctrltab.h"
 #include "llflatlistview.h"
 #include "lltextbox.h"
+#include "llviewermenu.h"
+#include "llviewerinventory.h"
+#include "lllandmarkactions.h"
+#include "llclipboard.h"
 
 class LLTeleportHistoryFlatItem : public LLPanel
 {
 public:
-	LLTeleportHistoryFlatItem(S32 index, const std::string &region_name);
+	LLTeleportHistoryFlatItem(S32 index, LLTeleportHistoryPanel::ContextMenu *context_menu, const std::string &region_name);
 	virtual ~LLTeleportHistoryFlatItem() {};
 
 	virtual BOOL postBuild();
 
 	void onMouseEnter(S32 x, S32 y, MASK mask);
 	void onMouseLeave(S32 x, S32 y, MASK mask);
+	virtual BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
+
+	static void showPlaceInfoPanel(S32 index);
 private:
 	void onInfoBtnClick();
 
 	LLButton* mInfoBtn;
+	LLTeleportHistoryPanel::ContextMenu *mContextMenu;
 
 	S32 mIndex;
 	std::string mRegionName;
 };
 
-LLTeleportHistoryFlatItem::LLTeleportHistoryFlatItem(S32 index, const std::string &region_name)
+LLTeleportHistoryFlatItem::LLTeleportHistoryFlatItem(S32 index, LLTeleportHistoryPanel::ContextMenu *context_menu, const std::string &region_name)
 :	LLPanel(),
 	mIndex(index),
+	mContextMenu(context_menu),
 	mRegionName(region_name)
 {
 	LLUICtrlFactory::getInstance()->buildPanel(this, "panel_teleport_history_item.xml");
 	LLPanel::onMouseLeave(x, y, mask);
 }
 
-void LLTeleportHistoryFlatItem::onInfoBtnClick()
+// virtual
+BOOL LLTeleportHistoryFlatItem::handleRightMouseDown(S32 x, S32 y, MASK mask)
+{
+	if (mContextMenu)
+		mContextMenu->show(this, mIndex, x, y);
+
+	return LLPanel::handleRightMouseDown(x, y, mask);
+}
+
+void LLTeleportHistoryFlatItem::showPlaceInfoPanel(S32 index)
 {
 	LLSD params;
-	params["id"] = mIndex;
+	params["id"] = index;
 	params["type"] = "teleport_history";
 
 	LLSideTray::getInstance()->showPanel("panel_places", params);
 }
 
+void LLTeleportHistoryFlatItem::onInfoBtnClick()
+{
+	LLTeleportHistoryFlatItem::showPlaceInfoPanel(mIndex);
+}
+
+LLTeleportHistoryPanel::ContextMenu::ContextMenu() :
+	mMenu(NULL)
+{
+}
+
+void LLTeleportHistoryPanel::ContextMenu::show(LLView* spawning_view, S32 index, S32 x, S32 y)
+{
+	if (mMenu)
+	{
+		//preventing parent (menu holder) from deleting already "dead" context menus on exit
+		LLView* parent = mMenu->getParent();
+		if (parent)
+		{
+			parent->removeChild(mMenu);
+			mMenu->setParent(NULL);
+		}
+		delete mMenu;
+	}
+
+	mIndex = index;
+	mMenu = createMenu();
+
+	LLViewerInventoryItem *landmark = LLLandmarkActions::findLandmarkForGlobalPos(
+		LLTeleportHistoryStorage::getInstance()->getItems()[index].mGlobalPos);
+
+	mMenu->setItemEnabled("Make Landmark", !landmark || landmark->getUUID().isNull());
+
+	mMenu->show(x, y);
+	LLMenuGL::showPopup(spawning_view, mMenu, x, y);
+}
+
+LLContextMenu* LLTeleportHistoryPanel::ContextMenu::createMenu()
+{
+	// set up the callbacks for all of the avatar menu items
+	// (N.B. callbacks don't take const refs as mID is local scope)
+	LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar;
+
+	registrar.add("TeleportHistory.Teleport",	boost::bind(&LLTeleportHistoryPanel::ContextMenu::onTeleport, this));
+	registrar.add("TeleportHistory.MoreInformation",boost::bind(&LLTeleportHistoryPanel::ContextMenu::onInfo, this));
+	registrar.add("TeleportHistory.Copy",		boost::bind(&LLTeleportHistoryPanel::ContextMenu::onCopy, this));
+	registrar.add("TeleportHistory.MakeLandmark",	boost::bind(&LLTeleportHistoryPanel::ContextMenu::onMakeLandmark, this));
+
+	// create the context menu from the XUI
+	return LLUICtrlFactory::getInstance()->createFromFile<LLContextMenu>(
+		"menu_teleport_history_item.xml", LLMenuGL::sMenuContainer, LLViewerMenuHolderGL::child_registry_t::instance());
+}
+
+void LLTeleportHistoryPanel::ContextMenu::onTeleport()
+{
+	LLTeleportHistoryStorage::getInstance()->goToItem(mIndex);
+}
+
+void LLTeleportHistoryPanel::ContextMenu::onInfo()
+{
+	LLTeleportHistoryFlatItem::showPlaceInfoPanel(mIndex);
+}
+
+//static
+void LLTeleportHistoryPanel::ContextMenu::gotSLURLCallback(const std::string& slurl)
+{
+	gClipboard.copyFromString(utf8str_to_wstring(slurl));
+}
+
+void LLTeleportHistoryPanel::ContextMenu::onCopy()
+{
+	LLVector3d globalPos = LLTeleportHistoryStorage::getInstance()->getItems()[mIndex].mGlobalPos;
+	LLLandmarkActions::getSLURLfromPosGlobal(globalPos,
+		boost::bind(&LLTeleportHistoryPanel::ContextMenu::gotSLURLCallback, _1), false);
+}
+
+void LLTeleportHistoryPanel::ContextMenu::onMakeLandmark()
+{
+	//FIXME: it creates landmark for current agent positon, not for the global position of item of teleport history
+	LLSideTray::getInstance()->showPanel("panel_places", LLSD().insert("type", "create_landmark"));
+}
+
 // Not yet implemented; need to remove buildPanel() from constructor when we switch
 //static LLRegisterPanelClassWrapper<LLTeleportHistoryPanel> t_teleport_history("panel_teleport_history");
 
 		mFilterSubString(LLStringUtil::null),
 		mTeleportHistory(NULL),
 		mHistoryAccordion(NULL),
+		mAccordionTabMenu(NULL),
 		mLastSelectedScrollList(NULL)
 {
 	LLUICtrlFactory::getInstance()->buildPanel(this, "panel_teleport_history.xml");
 			if (dynamic_cast<LLAccordionCtrlTab*>(*iter))
 			{
 				LLAccordionCtrlTab* tab = (LLAccordionCtrlTab*)*iter;
+				tab->setRightMouseDownCallback(boost::bind(&LLTeleportHistoryPanel::onAccordionTabRightClick, this, _1, _2, _3, _4));
+
 				mItemContainers.put(tab);
 
 				LLFlatListView* fl = getFlatListViewFromTab(tab);
 
 		if (curr_flat_view)
 		{			
-			curr_flat_view->addItem(new LLTeleportHistoryFlatItem(index, (*iter).mTitle));
+			curr_flat_view->addItem(new LLTeleportHistoryFlatItem(index, &mContextMenu, (*iter).mTitle));
 		}
 
 		index--;
 	LLSideTray::getInstance()->showPanel("panel_places", key);*/
 }
 
+void LLTeleportHistoryPanel::onAccordionTabRightClick(LLView *view, S32 x, S32 y, MASK mask)
+{
+	LLAccordionCtrlTab *tab = (LLAccordionCtrlTab *) view;
+
+	// If click occurred below the header, don't show this menu
+	if (y < tab->getRect().getHeight() - tab->getHeaderHeight() - tab->getPaddingBottom())
+		return;
+
+	if (mAccordionTabMenu)
+	{
+		//preventing parent (menu holder) from deleting already "dead" context menus on exit
+		LLView* parent = mAccordionTabMenu->getParent();
+		if (parent)
+		{
+			parent->removeChild(mAccordionTabMenu);
+			mAccordionTabMenu->setParent(NULL);
+		}
+		delete mAccordionTabMenu;
+	}
+
+	// set up the callbacks for all of the avatar menu items
+	// (N.B. callbacks don't take const refs as mID is local scope)
+	LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar;
+
+	registrar.add("TeleportHistory.TabOpen",	boost::bind(&LLTeleportHistoryPanel::onAccordionTabOpen, this, tab));
+	registrar.add("TeleportHistory.TabClose",	boost::bind(&LLTeleportHistoryPanel::onAccordionTabClose, this, tab));
+
+	// create the context menu from the XUI
+	mAccordionTabMenu = LLUICtrlFactory::getInstance()->createFromFile<LLContextMenu>(
+		"menu_teleport_history_tab.xml", LLMenuGL::sMenuContainer, LLViewerMenuHolderGL::child_registry_t::instance());
+
+	mAccordionTabMenu->setItemVisible("TabOpen", !tab->isExpanded() ? true : false);
+	mAccordionTabMenu->setItemVisible("TabClose", tab->isExpanded() ? true : false);
+
+	mAccordionTabMenu->show(x, y);
+	LLMenuGL::showPopup(tab, mAccordionTabMenu, x, y);
+}
+
+void LLTeleportHistoryPanel::onAccordionTabOpen(LLAccordionCtrlTab *tab)
+{
+	tab->setDisplayChildren(true);
+	mHistoryAccordion->arrange();
+}
+
+void LLTeleportHistoryPanel::onAccordionTabClose(LLAccordionCtrlTab *tab)
+{
+	tab->setDisplayChildren(false);
+	mHistoryAccordion->arrange();
+}
+
 LLFlatListView* LLTeleportHistoryPanel::getFlatListViewFromTab(LLAccordionCtrlTab *tab)
 {
 	for (child_list_const_iter_t iter = tab->beginChild(); iter != tab->endChild(); iter++)

File indra/newview/llpanelteleporthistory.h

 
 #include "llpanelplacestab.h"
 #include "llteleporthistory.h"
+#include "llmenugl.h"
 
 class LLTeleportHistoryStorage;
 class LLAccordionCtrl;
 class LLTeleportHistoryPanel : public LLPanelPlacesTab
 {
 public:
+	class ContextMenu
+	{
+	public:
+		ContextMenu();
+		void show(LLView* spawning_view, S32 index, S32 x, S32 y);
+		
+	private:
+		LLContextMenu* createMenu();
+		void onTeleport();
+		void onInfo();
+		void onCopy();
+		void onMakeLandmark();
+
+		static void gotSLURLCallback(const std::string& slurl);
+		
+		LLContextMenu* mMenu;
+		S32 mIndex;
+	};
+
 	LLTeleportHistoryPanel();
 	virtual ~LLTeleportHistoryPanel();
 
 private:
 
 	static void onDoubleClickItem(void* user_data);
+	void onAccordionTabRightClick(LLView *view, S32 x, S32 y, MASK mask);
+	void onAccordionTabOpen(LLAccordionCtrlTab *tab);
+	void onAccordionTabClose(LLAccordionCtrlTab *tab);
 	void showTeleportHistory();
 	void handleItemSelect(LLFlatListView* );
 	LLFlatListView* getFlatListViewFromTab(LLAccordionCtrlTab *);
 
 	typedef LLDynamicArray<LLAccordionCtrlTab*> item_containers_t;
 	item_containers_t mItemContainers;
+
+	ContextMenu mContextMenu;
+	LLContextMenu*			mAccordionTabMenu;
 };
 
 #endif //LL_LLPANELTELEPORTHISTORY_H

File indra/newview/llscreenchannel.cpp

 												,mOverflowToastHidden(false)
 												,mIsHovering(false)
 												,mControlHovering(false)
-												,mShowToasts(false)
+												,mShowToasts(true)
 {	
 	mID = id;
 	mOverflowFormatString = LLTrans::getString("OverflowInfoChannelString");
 {
 	bool store_toast = false, show_toast = false;
 
-	show_toast = mWasStartUpToastShown && (mShowToasts || p.force_show);
+	mDisplayToastsAlways ? show_toast = true : show_toast = mWasStartUpToastShown && (mShowToasts || p.force_show);
 	store_toast = !show_toast && p.can_be_stored && mCanStoreToasts;
 
 	if(!show_toast && !store_toast)

File indra/newview/llsyswellwindow.cpp

 //---------------------------------------------------------------------------------
 void LLSysWellWindow::setMinimized(BOOL minimize)
 {
-	setVisible(!minimize);
+	// we don't show empty Message Well window
+	setVisible(!minimize && !isWindowEmpty());
 
 	LLFloater::setMinimized(minimize);
 }

File indra/newview/lltoast.cpp

 using namespace LLNotificationsUI;
 
 //--------------------------------------------------------------------------
-LLToast::LLToast(LLToast::Params p) :	LLFloater(LLSD()), 
+LLToast::LLToast(LLToast::Params p) :	LLModalDialog(LLSD(), p.is_modal),
 										mPanel(p.panel), 
 										mTimerValue(p.timer_period),  
 										mNotificationID(p.notif_id),  
 										mCanFade(p.can_fade),
 										mCanBeStored(p.can_be_stored),
 										mHideBtnEnabled(p.enable_hide_btn),
-										mIsModal(p.is_modal),
 										mHideBtn(NULL),
 										mNotification(p.notification),
 										mHideBtnPressed(false)
 		mHideBtn->setClickedCallback(boost::bind(&LLToast::hide,this));
 	}
 
-	if(mIsModal)
-	{
-		gFocusMgr.setMouseCapture( this );
-		gFocusMgr.setTopCtrl( this );
-		setFocus(TRUE);
-	}
-
 	// init callbacks if present
 	if(!p.on_delete_toast.empty())
 		mOnDeleteToastSignal.connect(p.on_delete_toast);
 LLToast::~LLToast()
 {	
 	mOnToastDestroyedSignal(this);
-	if(mIsModal)
-	{
-		gFocusMgr.unlockFocus();
-		gFocusMgr.releaseFocusIfNeeded( this );
-	}
 }
 
 //--------------------------------------------------------------------------
 }
 
 //--------------------------------------------------------------------------
-void LLToast::setModal(bool modal)
-{
-	mIsModal = modal;
-	if(mIsModal)
-	{
-		gFocusMgr.setMouseCapture( this );
-		gFocusMgr.setTopCtrl( this );
-		setFocus(TRUE);
-	}
-}
-
-//--------------------------------------------------------------------------
 void LLToast::setVisible(BOOL show)
 {
 	if(show)

File indra/newview/lltoast.h

 
 
 #include "llpanel.h"
-#include "llfloater.h"
+#include "llmodaldialog.h"
 #include "lltimer.h"
 #include "llnotifications.h"
 
  * Represents toast pop-up.
  * This is a parent view for all toast panels.
  */
-class LLToast : public LLFloater
+class LLToast : public LLModalDialog
 {
 public:
 	typedef boost::function<void (LLToast* toast)> toast_callback_t;
 	void setCanBeStored(bool can_be_stored) { mCanBeStored = can_be_stored; }
 	//
 	bool getCanBeStored() { return mCanBeStored; }
-	//
-	void setModal(bool modal);
 
 
 	// Registers signals/callbacks for events
 
 	LLColor4	mBgColor;
 	bool		mCanFade;
-	bool		mIsModal;
 	bool		mCanBeStored;
 	bool		mHideBtnEnabled;
 	bool		mHideBtnPressed;

File indra/newview/skins/default/xui/en/menu_teleport_history_item.xml

+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<context_menu
+ layout="topleft"
+ name="Teleport History Item Context Menu">
+    <menu_item_call
+     label="Teleport"
+     layout="topleft"
+     name="Teleport">
+        <menu_item_call.on_click
+         function="TeleportHistory.Teleport" />
+    </menu_item_call>
+    <menu_item_call
+     label="More Information"
+     layout="topleft"
+     name="More Information">
+        <menu_item_call.on_click
+         function="TeleportHistory.MoreInformation" />
+    </menu_item_call>
+    <menu_item_call
+     label="Copy"
+     layout="topleft"
+     name="Copy">
+        <menu_item_call.on_click
+         function="TeleportHistory.Copy" />
+    </menu_item_call>
+    <menu_item_call
+     label="Make Landmark"
+     layout="topleft"
+     name="Make Landmark">
+        <menu_item_call.on_click
+         function="TeleportHistory.MakeLandmark" />
+    </menu_item_call>
+</context_menu>

File indra/newview/skins/default/xui/en/menu_teleport_history_tab.xml

+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<context_menu
+ layout="topleft"
+ name="Teleport History Item Context Menu">
+    <menu_item_call
+     label="Open"
+     layout="topleft"
+     name="TabOpen">
+        <menu_item_call.on_click
+         function="TeleportHistory.TabOpen" />
+    </menu_item_call>
+    <menu_item_call
+     label="Close"
+     layout="topleft"
+     name="TabClose">
+        <menu_item_call.on_click
+         function="TeleportHistory.TabClose" />
+    </menu_item_call>
+</context_menu>