PageRenderTime 79ms CodeModel.GetById 3ms app.highlight 67ms RepoModel.GetById 1ms app.codeStats 1ms

/indra/newview/llnavigationbar.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 700 lines | 497 code | 95 blank | 108 comment | 64 complexity | 5e24d8d727b8d6c88e5770a584bcc529 MD5 | raw file
  1/** 
  2 * @file llnavigationbar.cpp
  3 * @brief Navigation bar implementation
  4 *
  5 * $LicenseInfo:firstyear=2009&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#include "llviewerprecompiledheaders.h"
 28
 29#include "llnavigationbar.h"
 30
 31#include "v2math.h"
 32
 33#include "llregionhandle.h"
 34
 35#include "llfloaterreg.h"
 36#include "llfocusmgr.h"
 37#include "lliconctrl.h"
 38#include "llmenugl.h"
 39
 40#include "llagent.h"
 41#include "llviewerregion.h"
 42#include "lllandmarkactions.h"
 43#include "lllocationhistory.h"
 44#include "lllocationinputctrl.h"
 45#include "llpaneltopinfobar.h"
 46#include "llteleporthistory.h"
 47#include "llsearchcombobox.h"
 48#include "llslurl.h"
 49#include "llurlregistry.h"
 50#include "llurldispatcher.h"
 51#include "llviewerinventory.h"
 52#include "llviewermenu.h"
 53#include "llviewerparcelmgr.h"
 54#include "llworldmapmessage.h"
 55#include "llappviewer.h"
 56#include "llviewercontrol.h"
 57#include "llweb.h"
 58#include "llhints.h"
 59
 60#include "llinventorymodel.h"
 61#include "lllandmarkactions.h"
 62
 63#include "llfavoritesbar.h"
 64#include "llagentui.h"
 65
 66#include <boost/regex.hpp>
 67
 68//-- LLTeleportHistoryMenuItem -----------------------------------------------
 69
 70/**
 71 * Item look varies depending on the type (backward/current/forward). 
 72 */
 73class LLTeleportHistoryMenuItem : public LLMenuItemCallGL
 74{
 75public:
 76	typedef enum e_item_type
 77	{
 78		TYPE_BACKWARD,
 79		TYPE_CURRENT,
 80		TYPE_FORWARD,
 81	} EType;
 82
 83	struct Params : public LLInitParam::Block<Params, LLMenuItemCallGL::Params>
 84	{
 85		Mandatory<EType>		item_type;
 86		Optional<const LLFontGL*> back_item_font,
 87								current_item_font,
 88								forward_item_font;
 89		Optional<std::string>	back_item_image,
 90								forward_item_image;
 91		Optional<S32>			image_hpad,
 92								image_vpad;
 93		Params()
 94		:	item_type(),
 95			back_item_font("back_item_font"),
 96			current_item_font("current_item_font"),
 97			forward_item_font("forward_item_font"),
 98			back_item_image("back_item_image"),
 99			forward_item_image("forward_item_image"),
100			image_hpad("image_hpad"),
101			image_vpad("image_vpad")
102		{}
103	};
104
105	/*virtual*/ void	draw();
106	/*virtual*/ void	onMouseEnter(S32 x, S32 y, MASK mask);
107	/*virtual*/ void	onMouseLeave(S32 x, S32 y, MASK mask);
108
109private:
110	LLTeleportHistoryMenuItem(const Params&);
111	friend class LLUICtrlFactory;
112
113	static const S32			ICON_WIDTH			= 16;
114	static const S32			ICON_HEIGHT			= 16;
115
116	LLIconCtrl*		mArrowIcon;
117};
118
119static LLDefaultChildRegistry::Register<LLTeleportHistoryMenuItem> r("teleport_history_menu_item");
120
121
122LLTeleportHistoryMenuItem::LLTeleportHistoryMenuItem(const Params& p)
123:	LLMenuItemCallGL(p),
124	mArrowIcon(NULL)
125{
126	// Set appearance depending on the item type.
127	if (p.item_type == TYPE_BACKWARD)
128	{
129		setFont( p.back_item_font );
130	}
131	else if (p.item_type == TYPE_CURRENT)
132	{
133		setFont( p.current_item_font );
134	}
135	else
136	{
137		setFont( p.forward_item_font );
138	}
139
140	LLIconCtrl::Params icon_params;
141	icon_params.name("icon");
142	LLRect rect(0, ICON_HEIGHT, ICON_WIDTH, 0);
143	rect.translate( p.image_hpad, p.image_vpad );
144	icon_params.rect( rect );
145	icon_params.mouse_opaque(false);
146	icon_params.follows.flags(FOLLOWS_LEFT | FOLLOWS_TOP);
147	icon_params.visible(false);
148
149	mArrowIcon = LLUICtrlFactory::create<LLIconCtrl> (icon_params);
150
151	// no image for the current item
152	if (p.item_type == TYPE_BACKWARD)
153		mArrowIcon->setValue( p.back_item_image() );
154	else if (p.item_type == TYPE_FORWARD)
155		mArrowIcon->setValue( p.forward_item_image() );
156
157	addChild(mArrowIcon);
158}
159
160void LLTeleportHistoryMenuItem::draw()
161{
162	// Draw menu item itself.
163	LLMenuItemCallGL::draw();
164
165	// Draw children if any. *TODO: move this to LLMenuItemGL?
166	LLUICtrl::draw();
167}
168
169void LLTeleportHistoryMenuItem::onMouseEnter(S32 x, S32 y, MASK mask)
170{
171	mArrowIcon->setVisible(TRUE);
172}
173
174void LLTeleportHistoryMenuItem::onMouseLeave(S32 x, S32 y, MASK mask)
175{
176	mArrowIcon->setVisible(FALSE);
177}
178
179static LLDefaultChildRegistry::Register<LLPullButton> menu_button("pull_button");
180
181LLPullButton::LLPullButton(const LLPullButton::Params& params) :
182	LLButton(params)
183{
184	setDirectionFromName(params.direction);
185}
186boost::signals2::connection LLPullButton::setClickDraggingCallback(const commit_signal_t::slot_type& cb)
187{
188	return mClickDraggingSignal.connect(cb);
189}
190
191/*virtual*/
192void LLPullButton::onMouseLeave(S32 x, S32 y, MASK mask)
193{
194	LLButton::onMouseLeave(x, y, mask);
195
196	if (mMouseDownTimer.getStarted()) //an user have done a mouse down, if the timer started. see LLButton::handleMouseDown for details
197	{
198		const LLVector2 cursor_direction = LLVector2(F32(x), F32(y)) - mLastMouseDown;
199		/* For now cursor_direction points to the direction of mouse movement
200		 * Need to decide whether should we fire a signal. 
201		 * We fire if angle between mDraggingDirection and cursor_direction is less that 45 degree
202		 * Note:
203		 * 0.5 * F_PI_BY_TWO equals to PI/4 radian that equals to angle of 45 degrees
204		 */
205		if (angle_between(mDraggingDirection, cursor_direction) < 0.5 * F_PI_BY_TWO)//call if angle < pi/4 
206		{
207			mClickDraggingSignal(this, LLSD());
208		}
209	}
210
211}
212
213/*virtual*/
214BOOL LLPullButton::handleMouseDown(S32 x, S32 y, MASK mask)
215{
216	BOOL handled = LLButton::handleMouseDown(x, y, mask);
217	if (handled)
218	{
219		//if mouse down was handled by button, 
220		//capture mouse position to calculate the direction of  mouse move  after mouseLeave event 
221		mLastMouseDown.set(F32(x), F32(y));
222	}
223	return handled;
224}
225
226/*virtual*/
227BOOL LLPullButton::handleMouseUp(S32 x, S32 y, MASK mask)
228{
229	// reset data to get ready for next circle 
230	mLastMouseDown.clear();
231	return LLButton::handleMouseUp(x, y, mask);
232}
233/**
234 * this function is setting up dragging direction vector. 
235 * Last one is just unit vector. It points to direction of mouse drag that we need to handle   
236 */
237void LLPullButton::setDirectionFromName(const std::string& name)
238{
239	if (name == "left")
240	{
241		mDraggingDirection.set(F32(-1), F32(0));
242	}
243	else if (name == "right")
244	{
245		mDraggingDirection.set(F32(0), F32(1));
246	}
247	else if (name == "down")
248	{
249		mDraggingDirection.set(F32(0), F32(-1));
250	}
251	else if (name == "up")
252	{
253		mDraggingDirection.set(F32(0), F32(1));
254	}
255}
256
257//-- LNavigationBar ----------------------------------------------------------
258
259/*
260TODO:
261- Load navbar height from saved settings (as it's done for status bar) or think of a better way.
262*/
263
264LLNavigationBar::LLNavigationBar()
265:	mTeleportHistoryMenu(NULL),
266	mBtnBack(NULL),
267	mBtnForward(NULL),
268	mBtnHome(NULL),
269	mCmbLocation(NULL),
270	mPurgeTPHistoryItems(false),
271	mSaveToLocationHistory(false)
272{
273	buildFromFile( "panel_navigation_bar.xml");
274
275	// set a listener function for LoginComplete event
276	LLAppViewer::instance()->setOnLoginCompletedCallback(boost::bind(&LLNavigationBar::handleLoginComplete, this));
277}
278
279LLNavigationBar::~LLNavigationBar()
280{
281	mTeleportFinishConnection.disconnect();
282	mTeleportFailedConnection.disconnect();
283}
284
285BOOL LLNavigationBar::postBuild()
286{
287	mBtnBack	= getChild<LLPullButton>("back_btn");
288	mBtnForward	= getChild<LLPullButton>("forward_btn");
289	mBtnHome	= getChild<LLButton>("home_btn");
290	
291	mCmbLocation= getChild<LLLocationInputCtrl>("location_combo");
292
293	mBtnBack->setEnabled(FALSE);
294	mBtnBack->setClickedCallback(boost::bind(&LLNavigationBar::onBackButtonClicked, this));
295	mBtnBack->setHeldDownCallback(boost::bind(&LLNavigationBar::onBackOrForwardButtonHeldDown, this,_1, _2));
296	mBtnBack->setClickDraggingCallback(boost::bind(&LLNavigationBar::showTeleportHistoryMenu, this,_1));
297	
298	mBtnForward->setEnabled(FALSE);
299	mBtnForward->setClickedCallback(boost::bind(&LLNavigationBar::onForwardButtonClicked, this));
300	mBtnForward->setHeldDownCallback(boost::bind(&LLNavigationBar::onBackOrForwardButtonHeldDown, this, _1, _2));
301	mBtnForward->setClickDraggingCallback(boost::bind(&LLNavigationBar::showTeleportHistoryMenu, this,_1));
302
303	mBtnHome->setClickedCallback(boost::bind(&LLNavigationBar::onHomeButtonClicked, this));
304
305	mCmbLocation->setCommitCallback(boost::bind(&LLNavigationBar::onLocationSelection, this));
306
307	mTeleportFinishConnection = LLViewerParcelMgr::getInstance()->
308		setTeleportFinishedCallback(boost::bind(&LLNavigationBar::onTeleportFinished, this, _1));
309
310	mTeleportFailedConnection = LLViewerParcelMgr::getInstance()->
311		setTeleportFailedCallback(boost::bind(&LLNavigationBar::onTeleportFailed, this));
312	
313	mDefaultNbRect = getRect();
314	mDefaultFpRect = getChild<LLFavoritesBarCtrl>("favorite")->getRect();
315
316	// we'll be notified on teleport history changes
317	LLTeleportHistory::getInstance()->setHistoryChangedCallback(
318			boost::bind(&LLNavigationBar::onTeleportHistoryChanged, this));
319
320	LLHints::registerHintTarget("nav_bar", getHandle());
321
322	return TRUE;
323}
324
325void LLNavigationBar::setVisible(BOOL visible)
326{
327	// change visibility of grandparent layout_panel to animate in and out
328	if (getParent()) 
329	{
330		//to avoid some mysterious bugs like EXT-3352, at least try to log an incorrect parent to ping  about a problem. 
331		if(getParent()->getName() != "nav_bar_container")
332		{
333			LL_WARNS("LLNavigationBar")<<"NavigationBar has an unknown name of the parent: "<<getParent()->getName()<< LL_ENDL;
334		}
335		getParent()->setVisible(visible);	
336	}
337}
338
339void LLNavigationBar::draw()
340{
341	if(mPurgeTPHistoryItems)
342	{
343		LLTeleportHistory::getInstance()->purgeItems();
344		mPurgeTPHistoryItems = false;
345	}
346
347	if (isBackgroundVisible())
348	{
349		static LLUICachedControl<S32> drop_shadow_floater ("DropShadowFloater", 0);
350		static LLUIColor color_drop_shadow = LLUIColorTable::instance().getColor("ColorDropShadow");
351		gl_drop_shadow(0, getRect().getHeight(), getRect().getWidth(), 0,
352                           color_drop_shadow, drop_shadow_floater );
353	}
354
355	LLPanel::draw();
356}
357
358BOOL LLNavigationBar::handleRightMouseDown(S32 x, S32 y, MASK mask)
359{
360	BOOL handled = childrenHandleRightMouseDown( x, y, mask) != NULL;
361	if(!handled && !gMenuHolder->hasVisibleMenu())
362	{
363		show_navbar_context_menu(this,x,y);
364		handled = true;
365	}
366					
367	return handled;
368}
369
370void LLNavigationBar::onBackButtonClicked()
371{
372	LLTeleportHistory::getInstance()->goBack();
373}
374
375void LLNavigationBar::onBackOrForwardButtonHeldDown(LLUICtrl* ctrl, const LLSD& param)
376{
377	if (param["count"].asInteger() == 0)
378		showTeleportHistoryMenu(ctrl);
379}
380
381void LLNavigationBar::onForwardButtonClicked()
382{
383	LLTeleportHistory::getInstance()->goForward();
384}
385
386void LLNavigationBar::onHomeButtonClicked()
387{
388	gAgent.teleportHome();
389}
390
391void LLNavigationBar::onTeleportHistoryMenuItemClicked(const LLSD& userdata)
392{
393	int idx = userdata.asInteger();
394	LLTeleportHistory::getInstance()->goToItem(idx);
395}
396
397// This is called when user presses enter in the location input
398// or selects a location from the typed locations dropdown.
399void LLNavigationBar::onLocationSelection()
400{
401	std::string typed_location = mCmbLocation->getSimple();
402	LLStringUtil::trim(typed_location);
403
404	// Will not teleport to empty location.
405	if (typed_location.empty())
406		return;
407	//get selected item from combobox item
408	LLSD value = mCmbLocation->getSelectedValue();
409	if(value.isUndefined() && !mCmbLocation->getTextEntry()->isDirty())
410	{
411		// At this point we know that: there is no selected item in list and text field has NOT been changed
412		// So there is no sense to try to change the location
413		return;
414	}
415	/* since navbar list support autocompletion it contains several types of item: landmark, teleport hystory item,
416	 * typed by user slurl or region name. Let's find out which type of item the user has selected 
417	 * to make decision about adding this location into typed history. see mSaveToLocationHistory
418	 * Note:
419	 * Only TYPED_REGION_SLURL item will be added into LLLocationHistory 
420	 */  
421	
422	if(value.has("item_type"))
423	{
424
425		switch(value["item_type"].asInteger())
426		{
427		case LANDMARK:
428			
429			if(value.has("AssetUUID"))
430			{
431				
432				gAgent.teleportViaLandmark( LLUUID(value["AssetUUID"].asString()));
433				return;
434			}
435			else
436			{
437				LLInventoryModel::item_array_t landmark_items =
438						LLLandmarkActions::fetchLandmarksByName(typed_location,
439								FALSE);
440				if (!landmark_items.empty())
441				{
442					gAgent.teleportViaLandmark( landmark_items[0]->getAssetUUID());
443					return; 
444				}
445			}
446			break;
447			
448		case TELEPORT_HISTORY:
449			//in case of teleport item was selected, teleport by position too.
450		case TYPED_REGION_SLURL:
451			if(value.has("global_pos"))
452			{
453				gAgent.teleportViaLocation(LLVector3d(value["global_pos"]));
454				return;
455			}
456			break;
457			
458		default:
459			break;		
460		}
461	}
462	//Let's parse slurl or region name
463	
464	std::string region_name;
465	LLVector3 local_coords(128, 128, 0);
466	// Is the typed location a SLURL?
467	LLSLURL slurl = LLSLURL(typed_location);
468	if (slurl.getType() == LLSLURL::LOCATION)
469	{
470	  region_name = slurl.getRegion();
471	  local_coords = slurl.getPosition();
472	}
473	else if(!slurl.isValid())
474	{
475	  // we have to do this check after previous, because LLUrlRegistry contains handlers for slurl too  
476	  // but we need to know whether typed_location is a simple http url.
477	  if (LLUrlRegistry::instance().isUrl(typed_location)) 
478	    {
479		// display http:// URLs in the media browser, or
480		// anything else is sent to the search floater
481		LLWeb::loadURL(typed_location);
482		return;
483	  }
484	  else
485	  {
486	      // assume that an user has typed the {region name} or possible {region_name, parcel}
487	      region_name  = typed_location.substr(0,typed_location.find(','));
488	    }
489	}
490	else
491	{
492	  // was an app slurl, home, whatever.  Bail
493	  return;
494	}
495	
496	// Resolve the region name to its global coordinates.
497	// If resolution succeeds we'll teleport.
498	LLWorldMapMessage::url_callback_t cb = boost::bind(
499			&LLNavigationBar::onRegionNameResponse, this,
500			typed_location, region_name, local_coords, _1, _2, _3, _4);
501	mSaveToLocationHistory = true;
502	LLWorldMapMessage::getInstance()->sendNamedRegionRequest(region_name, cb, std::string("unused"), false);
503}
504
505void LLNavigationBar::onTeleportFailed()
506{
507	mSaveToLocationHistory = false;
508}
509
510void LLNavigationBar::onTeleportFinished(const LLVector3d& global_agent_pos)
511{
512	if (!mSaveToLocationHistory)
513		return;
514	LLLocationHistory* lh = LLLocationHistory::getInstance();
515
516	//TODO*: do we need convert slurl into readable format?
517	std::string location;
518	/*NOTE:
519	 * We can't use gAgent.getPositionAgent() in case of local teleport to build location.
520	 * At this moment gAgent.getPositionAgent() contains previous coordinates.
521	 * according to EXT-65 agent position is being reseted on each frame.  
522	 */
523		LLAgentUI::buildLocationString(location, LLAgentUI::LOCATION_FORMAT_NO_MATURITY,
524					gAgent.getPosAgentFromGlobal(global_agent_pos));
525	std::string tooltip (LLSLURL(gAgent.getRegion()->getName(), global_agent_pos).getSLURLString());
526	
527	LLLocationHistoryItem item (location,
528			global_agent_pos, tooltip,TYPED_REGION_SLURL);// we can add into history only TYPED location
529	//Touch it, if it is at list already, add new location otherwise
530	if ( !lh->touchItem(item) ) {
531		lh->addItem(item);
532	}
533
534	lh->save();
535	
536	mSaveToLocationHistory = false;
537	
538}
539
540void LLNavigationBar::onTeleportHistoryChanged()
541{
542	// Update navigation controls.
543	LLTeleportHistory* h = LLTeleportHistory::getInstance();
544	int cur_item = h->getCurrentItemIndex();
545	mBtnBack->setEnabled(cur_item > 0);
546	mBtnForward->setEnabled(cur_item < ((int)h->getItems().size() - 1));
547}
548
549void LLNavigationBar::rebuildTeleportHistoryMenu()
550{
551	// Has the pop-up menu been built?
552	if (mTeleportHistoryMenu)
553	{
554		// Clear it.
555		mTeleportHistoryMenu->empty();
556	}
557	else
558	{
559		// Create it.
560		LLMenuGL::Params menu_p;
561		menu_p.name("popup");
562		menu_p.can_tear_off(false);
563		menu_p.visible(false);
564		menu_p.bg_visible(true);
565		menu_p.scrollable(true);
566		mTeleportHistoryMenu = LLUICtrlFactory::create<LLMenuGL>(menu_p);
567		
568		addChild(mTeleportHistoryMenu);
569	}
570	
571	// Populate the menu with teleport history items.
572	LLTeleportHistory* hist = LLTeleportHistory::getInstance();
573	const LLTeleportHistory::slurl_list_t& hist_items = hist->getItems();
574	int cur_item = hist->getCurrentItemIndex();
575	
576	// Items will be shown in the reverse order, just like in Firefox.
577	for (int i = (int)hist_items.size()-1; i >= 0; i--)
578	{
579		LLTeleportHistoryMenuItem::EType type;
580		if (i < cur_item)
581			type = LLTeleportHistoryMenuItem::TYPE_BACKWARD;
582		else if (i > cur_item)
583			type = LLTeleportHistoryMenuItem::TYPE_FORWARD;
584		else
585			type = LLTeleportHistoryMenuItem::TYPE_CURRENT;
586
587		LLTeleportHistoryMenuItem::Params item_params;
588		item_params.label = item_params.name = hist_items[i].mTitle;
589		item_params.item_type = type;
590		item_params.on_click.function(boost::bind(&LLNavigationBar::onTeleportHistoryMenuItemClicked, this, i));
591		LLTeleportHistoryMenuItem* new_itemp = LLUICtrlFactory::create<LLTeleportHistoryMenuItem>(item_params);
592		//new_itemp->setFont()
593		mTeleportHistoryMenu->addChild(new_itemp);
594	}
595}
596
597void LLNavigationBar::onRegionNameResponse(
598		std::string typed_location,
599		std::string region_name,
600		LLVector3 local_coords,
601		U64 region_handle, const std::string& url, const LLUUID& snapshot_id, bool teleport)
602{
603	// Invalid location?
604	if (region_handle)
605	{
606		// Teleport to the location.
607		LLVector3d region_pos = from_region_handle(region_handle);
608		LLVector3d global_pos = region_pos + (LLVector3d) local_coords;
609
610		llinfos << "Teleporting to: " << LLSLURL(region_name,	global_pos).getSLURLString()  << llendl;
611		gAgent.teleportViaLocation(global_pos);
612	}
613	else if (gSavedSettings.getBOOL("SearchFromAddressBar"))
614	{
615		invokeSearch(typed_location);
616	}
617}
618
619void	LLNavigationBar::showTeleportHistoryMenu(LLUICtrl* btn_ctrl)
620{
621	// Don't show the popup if teleport history is empty.
622	if (LLTeleportHistory::getInstance()->isEmpty())
623	{
624		lldebugs << "Teleport history is empty, will not show the menu." << llendl;
625		return;
626	}
627	
628	rebuildTeleportHistoryMenu();
629
630	if (mTeleportHistoryMenu == NULL)
631		return;
632	
633	mTeleportHistoryMenu->updateParent(LLMenuGL::sMenuContainer);
634	const S32 MENU_SPAWN_PAD = -1;
635	LLMenuGL::showPopup(btn_ctrl, mTeleportHistoryMenu, 0, MENU_SPAWN_PAD);
636	LLButton* nav_button = dynamic_cast<LLButton*>(btn_ctrl);
637	if(nav_button)
638	{
639		if(mHistoryMenuConnection.connected())
640		{
641			LL_WARNS("Navgationbar")<<"mHistoryMenuConnection should be disconnected at this moment."<<LL_ENDL;
642			mHistoryMenuConnection.disconnect();
643		}
644		mHistoryMenuConnection = gMenuHolder->setMouseUpCallback(boost::bind(&LLNavigationBar::onNavigationButtonHeldUp, this, nav_button));
645		// pressed state will be update after mouseUp in  onBackOrForwardButtonHeldUp();
646		nav_button->setForcePressedState(true);
647	}
648	// *HACK pass the mouse capturing to the drop-down menu
649	// it need to let menu handle mouseup event
650	gFocusMgr.setMouseCapture(gMenuHolder);
651}
652/**
653 * Taking into account the HACK above,  this callback-function is responsible for correct handling of mouseUp event in case of holding-down the navigation buttons..
654 * We need to process this case separately to update a pressed state of navigation button.
655 */
656void LLNavigationBar::onNavigationButtonHeldUp(LLButton* nav_button)
657{
658	if(nav_button)
659	{
660		nav_button->setForcePressedState(false);
661	}
662	if(gFocusMgr.getMouseCapture() == gMenuHolder)
663	{
664		// we had passed mouseCapture in  showTeleportHistoryMenu()
665		// now we MUST release mouseCapture to continue a proper mouseevent workflow. 
666		gFocusMgr.setMouseCapture(NULL);
667	}
668	//gMenuHolder is using to display bunch of menus. Disconnect signal to avoid unnecessary calls.    
669	mHistoryMenuConnection.disconnect();
670}
671
672void LLNavigationBar::handleLoginComplete()
673{
674	LLTeleportHistory::getInstance()->handleLoginComplete();
675	LLPanelTopInfoBar::instance().handleLoginComplete();
676	mCmbLocation->handleLoginComplete();
677}
678
679void LLNavigationBar::invokeSearch(std::string search_text)
680{
681	LLFloaterReg::showInstance("search", LLSD().with("category", "all").with("query", LLSD(search_text)));
682}
683
684void LLNavigationBar::clearHistoryCache()
685{
686	mCmbLocation->removeall();
687	LLLocationHistory* lh = LLLocationHistory::getInstance();
688	lh->removeItems();
689	lh->save();	
690	mPurgeTPHistoryItems= true;
691}
692
693int LLNavigationBar::getDefNavBarHeight()
694{
695	return mDefaultNbRect.getHeight();
696}
697int LLNavigationBar::getDefFavBarHeight()
698{
699	return mDefaultFpRect.getHeight();
700}