1. simon_linden
  2. viewer-rabbit

Commits

richard_linden  committed c884737

converted focus change callbacks to use signals
replaced mFocusChangedSignal that PE added with our hierarchical focus mgmt

reviewed by Leyla

  • Participants
  • Parent commits 2872899
  • Branches default

Comments (0)

Files changed (27)

File indra/llui/llcombobox.cpp

View file
 		params.max_length_bytes(mMaxChars);
 		params.commit_callback.function(boost::bind(&LLComboBox::onTextCommit, this, _2));
 		params.keystroke_callback(boost::bind(&LLComboBox::onTextEntry, this, _1));
-		params.focus_lost_callback(NULL);
 		params.handle_edit_keys_directly(true);
 		params.commit_on_focus_lost(false);
 		params.follows.flags(FOLLOWS_ALL);

File indra/llui/llfocusmgr.cpp

View file
 // NOTE: the LLFocusableElement implementation has been moved here from lluictrl.cpp.
 
 LLFocusableElement::LLFocusableElement()
-:	mFocusLostCallback(NULL),
-	mFocusReceivedCallback(NULL),
-	mFocusChangedCallback(NULL),
-	mTopLostCallback(NULL),
-	mFocusCallbackUserData(NULL)
 {
 }
 
 
 void LLFocusableElement::onFocusReceived()
 {
-	if( mFocusReceivedCallback )
-	{
-		mFocusReceivedCallback( this, mFocusCallbackUserData );
-	}
-	if( mFocusChangedCallback )
-	{
-		mFocusChangedCallback( this, mFocusCallbackUserData );
-	}
+	mFocusReceivedCallback(this);
+	mFocusChangedCallback(this);
 }
 
 void LLFocusableElement::onFocusLost()
 {
-	if( mFocusLostCallback )
-	{
-		mFocusLostCallback( this, mFocusCallbackUserData );
-	}
-
-	if( mFocusChangedCallback )
-	{
-		mFocusChangedCallback( this, mFocusCallbackUserData );
-	}
+	mFocusLostCallback(this);
+	mFocusChangedCallback(this);
 }
 
 void LLFocusableElement::onTopLost()
 {
-	if (mTopLostCallback)
-	{
-		mTopLostCallback(this, mFocusCallbackUserData);
-	}
+	mTopLostCallback(this);
 }
 
 BOOL LLFocusableElement::hasFocus() const
 		view_handle_list_t new_focus_list;
 
 		// walk up the tree to root and add all views to the new_focus_list
-		for (LLView* ctrl = dynamic_cast<LLView*>(mKeyboardFocus); ctrl && ctrl != LLUI::getRootView(); ctrl = ctrl->getParent())
+		for (LLView* ctrl = dynamic_cast<LLView*>(mKeyboardFocus); ctrl; ctrl = ctrl->getParent())
 		{
-			if (ctrl) 
-			{
-				new_focus_list.push_back(ctrl->getHandle());
-			}
+			new_focus_list.push_back(ctrl->getHandle());
 		}
 
 		// remove all common ancestors since their focus is unchanged
 			{
 				mCachedKeyboardFocusList.pop_front();
 				old_focus_view->onFocusLost();
-
-				// part of fix of EXT-996
-				// this need to handle event when user click inside in-world area
-				mFocusChangeSignal();
 			}
 		}
 

File indra/llui/llfocusmgr.h

View file
 	virtual void	setFocus( BOOL b );
 	virtual BOOL	hasFocus() const;
 
-	typedef boost::function<void(LLFocusableElement*, void*)> focus_callback_t;
-	void	setFocusLostCallback(focus_callback_t cb, void* user_data = NULL)	{ mFocusLostCallback = cb; mFocusCallbackUserData = user_data; }
-	void	setFocusReceivedCallback(focus_callback_t cb, void* user_data = NULL)	{ mFocusReceivedCallback = cb; mFocusCallbackUserData = user_data; }
-	void	setFocusChangedCallback(focus_callback_t cb, void* user_data = NULL )	{ mFocusChangedCallback = cb; mFocusCallbackUserData = user_data; }
-	void	setTopLostCallback(focus_callback_t cb, void* user_data = NULL )	{ mTopLostCallback = cb; mFocusCallbackUserData = user_data; }
+	typedef boost::signals2::signal<void(LLFocusableElement*)> focus_signal_t;
+	
+	boost::signals2::connection setFocusLostCallback( const focus_signal_t::slot_type& cb)	{ return mFocusLostCallback.connect(cb);}
+	boost::signals2::connection	setFocusReceivedCallback(const focus_signal_t::slot_type& cb)	{ return mFocusReceivedCallback.connect(cb);}
+	boost::signals2::connection	setFocusChangedCallback(const focus_signal_t::slot_type& cb)	{ return mFocusChangedCallback.connect(cb);}
+	void	setTopLostCallback(const focus_signal_t::slot_type& cb)	{ mTopLostCallback.connect(cb);}
 
 	// These were brought up the hierarchy from LLView so that we don't have to use dynamic_cast when dealing with keyboard focus.
 	virtual BOOL	handleKey(KEY key, MASK mask, BOOL called_from_parent);
 	virtual void	onFocusReceived();
 	virtual void	onFocusLost();
 	virtual void	onTopLost();	// called when registered as top ctrl and user clicks elsewhere
-	focus_callback_t mFocusLostCallback;
-	focus_callback_t mFocusReceivedCallback;
-	focus_callback_t mFocusChangedCallback;
-	focus_callback_t mTopLostCallback;
-	void*			mFocusCallbackUserData;
+	focus_signal_t  mFocusLostCallback;
+	focus_signal_t  mFocusReceivedCallback;
+	focus_signal_t  mFocusChangedCallback;
+	focus_signal_t  mTopLostCallback;
 };
 
 
 	void			unlockFocus();
 	BOOL			focusLocked() const { return mLockedView != NULL; }
 
-	void			addFocusChangeCallback(const boost::signals2::signal<void ()>::slot_type& cb)
-	{
-		mFocusChangeSignal.connect(cb);
-	}
-
 private:
 	LLUICtrl*			mLockedView;
 
 	typedef std::map<LLHandle<LLView>, LLHandle<LLView> > focus_history_map_t;
 	focus_history_map_t mFocusHistory;
 
-	boost::signals2::signal<void()>	mFocusChangeSignal;
-
 	#ifdef _DEBUG
 		std::string		mMouseCaptorName;
 		std::string		mKeyboardFocusName;

File indra/llui/llmultisliderctrl.cpp

View file
 			params.prevalidate_callback(&LLLineEditor::prevalidateFloat);
 			params.follows.flags(FOLLOWS_LEFT | FOLLOWS_BOTTOM);
 			mEditor = LLUICtrlFactory::create<LLLineEditor> (params);
-			mEditor->setFocusReceivedCallback( &LLMultiSliderCtrl::onEditorGainFocus );
+			mEditor->setFocusReceivedCallback( boost::bind(LLMultiSliderCtrl::onEditorGainFocus, _1, this) );
 			// don't do this, as selecting the entire text is single clicking in some cases
 			// and double clicking in others
 			//mEditor->setSelectAllonFocusReceived(TRUE);

File indra/llui/llscrollbar.h

View file
 	void				onLineUpBtnPressed(const LLSD& data);
 	void				onLineDownBtnPressed(const LLSD& data);
 
-	void				setBGColor(const LLUIColor& color) { mBGColor = color; }
-	const LLUIColor&	getBGColor() const { return mBGColor; }
-
-	void				setBGVisible() { mBGVisible = true; }
-	bool				getBGVisible() const { return mBGVisible; }
-
 private:
 	void				updateThumbRect();
 	void				changeLine(S32 delta, BOOL update_thumb );

File indra/llui/llsliderctrl.cpp

View file
 			line_p.prevalidate_callback(&LLLineEditor::prevalidateFloat);
 			mEditor = LLUICtrlFactory::create<LLLineEditor>(line_p);
 
-			mEditor->setFocusReceivedCallback( &LLSliderCtrl::onEditorGainFocus, this );
+			mEditor->setFocusReceivedCallback( boost::bind(&LLSliderCtrl::onEditorGainFocus, _1, this ));
 			// don't do this, as selecting the entire text is single clicking in some cases
 			// and double clicking in others
 			//mEditor->setSelectAllonFocusReceived(TRUE);

File indra/llui/llspinctrl.cpp

View file
 	params.prevalidate_callback(&LLLineEditor::prevalidateFloat);
 	params.follows.flags(FOLLOWS_LEFT | FOLLOWS_BOTTOM);
 	mEditor = LLUICtrlFactory::create<LLLineEditor> (params);
-	mEditor->setFocusReceivedCallback( &LLSpinCtrl::onEditorGainFocus, this );
+	mEditor->setFocusReceivedCallback( boost::bind(&LLSpinCtrl::onEditorGainFocus, _1, this ));
 	//RN: this seems to be a BAD IDEA, as it makes the editor behavior different when it has focus
 	// than when it doesn't.  Instead, if you always have to double click to select all the text, 
 	// it's easier to understand

File indra/llui/lluictrl.cpp

View file
 	}
 
 	setTabStop(p.tab_stop);
-	setFocusLostCallback(p.focus_lost_callback());
 
 	if (p.initial_value.isProvided() 
 		&& !p.control_name.isProvided())
     	return false;
     }
     
-    template<> 
-	bool ParamCompare<LLUICtrl::focus_callback_t>::equals(
-		const LLUICtrl::focus_callback_t &a, 
-		const LLUICtrl::focus_callback_t &b)
-    {
-    	return false;
-    }
-    
+   
     template<> 
 	bool ParamCompare<LLUICtrl::enable_callback_t>::equals(
 		const LLUICtrl::enable_callback_t &a, 

File indra/llui/lluictrl.h

View file
 		Optional<CommitCallbackParam>	mouseenter_callback;
 		Optional<CommitCallbackParam>	mouseleave_callback;
 		
-		Optional<focus_callback_t>		focus_lost_callback;
-		
 		Optional<std::string>			control_name;
 		Optional<EnableControls>		enabled_controls;
 		Optional<ControlVisibility>		controls_visibility;
 		const LLUICtrl::enable_callback_t &a, 
 		const LLUICtrl::enable_callback_t &b); 
     
-	template<> 
-	bool ParamCompare<LLUICtrl::focus_callback_t>::equals(
-		const LLUICtrl::focus_callback_t &a, 
-		const LLUICtrl::focus_callback_t &b); 
-	
     template<>
 	bool ParamCompare<LLLazyValue<LLColor4> >::equals(
 		const LLLazyValue<LLColor4> &a, const LLLazyValue<LLColor4> &b); 

File indra/llui/llview.cpp

View file
 	return mRect;
 }
 
-//virtual
-void LLView::onFocusLost()
-{
-}
-
-//virtual
-void LLView::onFocusReceived()
-{
-}
-
 BOOL LLView::focusNextRoot()
 {
 	LLView::child_list_t result = LLView::getFocusRootsQuery().run(this);

File indra/llui/llview.h

View file
 	BOOL getSaveToXML() const { return mSaveToXML; }
 	void setSaveToXML(BOOL b) { mSaveToXML = b; }
 
-	// inherited from LLFocusableElement
-	/* virtual */ void onFocusLost();
-	/* virtual */ void onFocusReceived();
-
 	typedef enum e_hit_test_type
 	{
 		HIT_TEST_USE_BOUNDING_RECT,

File indra/newview/llchatbar.cpp

View file
 
 	mInputEditor = getChild<LLLineEditor>("Chat Editor");
 	mInputEditor->setKeystrokeCallback(&onInputEditorKeystroke, this);
-	mInputEditor->setFocusLostCallback(&onInputEditorFocusLost, this);
-	mInputEditor->setFocusReceivedCallback( &onInputEditorGainFocus, this );
+	mInputEditor->setFocusLostCallback(boost::bind(&LLChatBar::onInputEditorFocusLost));
+	mInputEditor->setFocusReceivedCallback(boost::bind(&LLChatBar::onInputEditorGainFocus));
 	mInputEditor->setCommitOnFocusLost( FALSE );
 	mInputEditor->setRevertOnEsc( FALSE );
 	mInputEditor->setIgnoreTab(TRUE);
 }
 
 // static
-void LLChatBar::onInputEditorFocusLost( LLFocusableElement* caller, void* userdata)
+void LLChatBar::onInputEditorFocusLost()
 {
 	// stop typing animation
 	gAgent.stopTyping();
 }
 
 // static
-void LLChatBar::onInputEditorGainFocus( LLFocusableElement* caller, void* userdata )
+void LLChatBar::onInputEditorGainFocus()
 {
 	LLFloaterChat::setHistoryCursorAndScrollToEnd();
 }

File indra/newview/llchatbar.h

View file
 
 	static void	onTabClick( void* userdata );
 	static void	onInputEditorKeystroke(LLLineEditor* caller, void* userdata);
-	static void	onInputEditorFocusLost(LLFocusableElement* caller,void* userdata);
-	static void	onInputEditorGainFocus(LLFocusableElement* caller,void* userdata);
+	static void	onInputEditorFocusLost();
+	static void	onInputEditorGainFocus();
 
 	void onCommitGesture(LLUICtrl* ctrl);
 

File indra/newview/llfloaterland.cpp

View file
 	mSelectedObjects = getChild<LLTextBox>("selected_objects_text");
 	mCleanOtherObjectsTime = getChild<LLLineEditor>("clean other time");
 
-	mCleanOtherObjectsTime->setFocusLostCallback(onLostFocus, this);
+	mCleanOtherObjectsTime->setFocusLostCallback(boost::bind(onLostFocus, _1, this));
 	mCleanOtherObjectsTime->setCommitCallback(onCommitClean, this);
 	childSetPrevalidate("clean other time", LLLineEditor::prevalidateNonNegativeS32);
 	

File indra/newview/llfloaterpostcard.cpp

View file
 	childSetValue("name_form", LLSD(name_string));
 
 	// For the first time a user focusess to .the msg box, all text will be selected.
-	getChild<LLUICtrl>("msg_form")->setFocusChangedCallback(onMsgFormFocusRecieved, this);
+	getChild<LLUICtrl>("msg_form")->setFocusChangedCallback(boost::bind(onMsgFormFocusRecieved, _1, this));
 	
 	childSetFocus("to_form", TRUE);
 

File indra/newview/llfolderview.cpp

View file
 		mRenamer->setVisible( TRUE );
 		// set focus will fail unless item is visible
 		mRenamer->setFocus( TRUE );
-		mRenamer->setTopLostCallback(onRenamerLost);
+		mRenamer->setTopLostCallback(boost::bind(onRenamerLost, _1));
 		gFocusMgr.setTopCtrl( mRenamer );
 	}
 }
 ///----------------------------------------------------------------------------
 
 //static 
-void LLFolderView::onRenamerLost( LLFocusableElement* renamer, void* user_data)
+void LLFolderView::onRenamerLost( LLFocusableElement* renamer)
 {
 	LLUICtrl* uictrl = dynamic_cast<LLUICtrl*>(renamer);
 	if (uictrl)

File indra/newview/llfolderview.h

View file
 	LLScrollContainer* mScrollContainer;  // NULL if this is not a child of a scroll container.
 
 	void commitRename( const LLSD& data );
-	static void onRenamerLost( LLFocusableElement* renamer, void* user_data);
+	static void onRenamerLost( LLFocusableElement* renamer);
 
 	void finishRenamingItem( void );
 	void closeRenamer( void );

File indra/newview/llimfloater.cpp

View file
 	}
 // 	LLUICtrlFactory::getInstance()->buildFloater(this, "floater_im_session.xml");
 
-	gFocusMgr.addFocusChangeCallback(boost::bind(&LLIMFloater::focusChangeCallback, this));
+	LLUI::getRootView()->setFocusLostCallback(boost::bind(&LLIMFloater::focusChangeCallback, this));
 
 	mCloseSignal.connect(boost::bind(&LLIMFloater::onClose, this));
 }
 	// enable line history support for instant message bar
 	mInputEditor->setEnableLineHistory(TRUE);
 	
-	mInputEditor->setFocusReceivedCallback( onInputEditorFocusReceived, this );
-	mInputEditor->setFocusLostCallback( onInputEditorFocusLost, this );
+	mInputEditor->setFocusReceivedCallback( boost::bind(onInputEditorFocusReceived, _1, this) );
+	mInputEditor->setFocusLostCallback( boost::bind(onInputEditorFocusLost, _1, this) );
 	mInputEditor->setKeystrokeCallback( onInputEditorKeystroke, this );
 	mInputEditor->setCommitOnFocusLost( FALSE );
 	mInputEditor->setRevertOnEsc( FALSE );
 void LLIMFloater::focusChangeCallback()
 {
 	// hide docked floater if user clicked inside in-world area
-	if (isDocked() && gFocusMgr.getKeyboardFocus() == NULL)
+	if (isDocked())
 	{
 		setVisible(false);
 	}

File indra/newview/llimpanel.cpp

View file
 	mVoiceChannel = NULL;
 
 	//delete focus lost callback
-	if(mInputEditor)
-	{
-		mInputEditor->setFocusLostCallback( NULL );
-	}
+	mFocusCallbackConnection.disconnect();
 }
 
 BOOL LLFloaterIMPanel::postBuild() 
 	mVisibleSignal.connect(boost::bind(&LLFloaterIMPanel::onVisibilityChange, this, _2));
 	
 	mInputEditor = getChild<LLLineEditor>("chat_editor");
-	mInputEditor->setFocusReceivedCallback( onInputEditorFocusReceived, this );
-	mInputEditor->setFocusLostCallback( onInputEditorFocusLost, this );
+	mInputEditor->setFocusReceivedCallback( boost::bind(onInputEditorFocusReceived, _1, this) );
+	mFocusCallbackConnection = mInputEditor->setFocusLostCallback( boost::bind(onInputEditorFocusLost, _1, this));
 	mInputEditor->setKeystrokeCallback( onInputEditorKeystroke, this );
 	mInputEditor->setCommitCallback( onCommitChat, this );
 	mInputEditor->setCommitOnFocusLost( FALSE );

File indra/newview/llimpanel.h

View file
 	// Timer to detect when user has stopped typing.
 	LLFrameTimer mLastKeystrokeTimer;
 
+	boost::signals2::connection mFocusCallbackConnection;
+
 	void disableWhileSessionStarting();
 };
 

File indra/newview/lllocationinputctrl.cpp

View file
 	params.max_length_bytes(p.max_chars);
 	params.commit_callback.function(boost::bind(&LLComboBox::onTextCommit, this, _2));
 	params.keystroke_callback(boost::bind(&LLComboBox::onTextEntry, this, _1));
-	params.focus_lost_callback(NULL);
 	params.handle_edit_keys_directly(true);
 	params.commit_on_focus_lost(false);
 	params.follows.flags(FOLLOWS_ALL);

File indra/newview/llnearbychatbar.cpp

View file
 
 	mChatBox->setCommitCallback(boost::bind(&LLNearbyChatBar::onChatBoxCommit, this));
 	mChatBox->setKeystrokeCallback(&onChatBoxKeystroke, this);
-	mChatBox->setFocusLostCallback(&onChatBoxFocusLost, this);
+	mChatBox->setFocusLostCallback(boost::bind(&onChatBoxFocusLost, _1, this));
 
 	mChatBox->setIgnoreArrowKeys(TRUE);
 	mChatBox->setCommitOnFocusLost( FALSE );

File indra/newview/llpanelclassified.cpp

View file
     mNameEditor = getChild<LLLineEditor>("given_name_editor");
 	mNameEditor->setMaxTextLength(DB_PARCEL_NAME_LEN);
 	mNameEditor->setCommitOnFocusLost(TRUE);
-	mNameEditor->setFocusReceivedCallback(focusReceived, this);
+	mNameEditor->setFocusReceivedCallback(boost::bind(focusReceived, _1, this));
 	mNameEditor->setCommitCallback(onCommitAny, this);
 	mNameEditor->setPrevalidate( LLLineEditor::prevalidateASCII );
 
     mDescEditor = getChild<LLTextEditor>("desc_editor");
 	mDescEditor->setCommitOnFocusLost(TRUE);
-	mDescEditor->setFocusReceivedCallback(focusReceived, this);
+	mDescEditor->setFocusReceivedCallback(boost::bind(focusReceived, _1, this));
 	mDescEditor->setCommitCallback(onCommitAny, this);
 	
     mLocationEditor = getChild<LLLineEditor>("location_editor");

File indra/newview/llpanelgroupgeneral.cpp

View file
 	if(mEditCharter)
 	{
 		mEditCharter->setCommitCallback(onCommitAny, this);
-		mEditCharter->setFocusReceivedCallback(onFocusEdit, this);
-		mEditCharter->setFocusChangedCallback(onFocusEdit, this);
+		mEditCharter->setFocusReceivedCallback(boost::bind(onFocusEdit, _1, this));
+		mEditCharter->setFocusChangedCallback(boost::bind(onFocusEdit, _1, this));
 	}
 
 

File indra/newview/llpanelgrouproles.cpp

View file
 
 	mRoleDescription->setCommitOnFocusLost(TRUE);
 	mRoleDescription->setCommitCallback(onDescriptionCommit, this);
-	mRoleDescription->setFocusReceivedCallback(onDescriptionFocus, this);
+	mRoleDescription->setFocusReceivedCallback(boost::bind(onDescriptionFocus, _1, this));
 
 	setFooterEnabled(FALSE);
 

File indra/newview/llpanellogin.cpp

View file
 
 	LLComboBox* server_choice_combo = sInstance->getChild<LLComboBox>("server_combo");
 	server_choice_combo->setCommitCallback(onSelectServer, NULL);
-	server_choice_combo->setFocusLostCallback(onServerComboLostFocus);
+	server_choice_combo->setFocusLostCallback(boost::bind(onServerComboLostFocus, _1));
 
 	childSetAction("connect_btn", onClickConnect, this);
 
 	loadLoginPage();
 }
 
-void LLPanelLogin::onServerComboLostFocus(LLFocusableElement* fe, void*)
+void LLPanelLogin::onServerComboLostFocus(LLFocusableElement* fe)
 {
 	if (!sInstance) return;
 

File indra/newview/llpanellogin.h

View file
 	static void onClickForgotPassword(void*);
 	static void onPassKey(LLLineEditor* caller, void* user_data);
 	static void onSelectServer(LLUICtrl*, void*);
-	static void onServerComboLostFocus(LLFocusableElement*, void*);
+	static void onServerComboLostFocus(LLFocusableElement*);
 	
 private:
 	LLPointer<LLUIImage> mLogoImage;