summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
authorRichard Nelson <richard@lindenlab.com>2009-09-30 01:00:51 +0000
committerRichard Nelson <richard@lindenlab.com>2009-09-30 01:00:51 +0000
commit6c70154cd1e5757e879f3f7463c0fedd69d82b63 (patch)
tree6be070977098f7b9b060ee202528f99c6d30979b /indra/llui
parent6d887be5895286f6b65ea751014f33bd9e0faac4 (diff)
converted focus change callbacks to use signals
replaced mFocusChangedSignal that PE added with our hierarchical focus mgmt reviewed by Leyla
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llcombobox.cpp1
-rw-r--r--indra/llui/llfocusmgr.cpp42
-rw-r--r--indra/llui/llfocusmgr.h27
-rw-r--r--indra/llui/llmultisliderctrl.cpp2
-rw-r--r--indra/llui/llscrollbar.h6
-rw-r--r--indra/llui/llsliderctrl.cpp2
-rw-r--r--indra/llui/llspinctrl.cpp2
-rw-r--r--indra/llui/lluictrl.cpp10
-rw-r--r--indra/llui/lluictrl.h7
-rw-r--r--indra/llui/llview.cpp10
-rw-r--r--indra/llui/llview.h4
11 files changed, 21 insertions, 92 deletions
diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp
index 58aeb61728..0170ac0c6a 100644
--- a/indra/llui/llcombobox.cpp
+++ b/indra/llui/llcombobox.cpp
@@ -483,7 +483,6 @@ void LLComboBox::createLineEditor(const LLComboBox::Params& p)
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);
diff --git a/indra/llui/llfocusmgr.cpp b/indra/llui/llfocusmgr.cpp
index ab9b59e252..279cbaa923 100644
--- a/indra/llui/llfocusmgr.cpp
+++ b/indra/llui/llfocusmgr.cpp
@@ -41,11 +41,6 @@ const F32 FOCUS_FADE_TIME = 0.3f;
// NOTE: the LLFocusableElement implementation has been moved here from lluictrl.cpp.
LLFocusableElement::LLFocusableElement()
-: mFocusLostCallback(NULL),
- mFocusReceivedCallback(NULL),
- mFocusChangedCallback(NULL),
- mTopLostCallback(NULL),
- mFocusCallbackUserData(NULL)
{
}
@@ -68,35 +63,19 @@ LLFocusableElement::~LLFocusableElement()
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
@@ -188,12 +167,9 @@ void LLFocusMgr::setKeyboardFocus(LLFocusableElement* new_focus, BOOL lock, BOOL
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
@@ -216,10 +192,6 @@ void LLFocusMgr::setKeyboardFocus(LLFocusableElement* new_focus, BOOL lock, BOOL
{
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();
}
}
diff --git a/indra/llui/llfocusmgr.h b/indra/llui/llfocusmgr.h
index 2c2dae216a..2fa4e124fb 100644
--- a/indra/llui/llfocusmgr.h
+++ b/indra/llui/llfocusmgr.h
@@ -54,11 +54,12 @@ public:
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);
@@ -68,11 +69,10 @@ protected:
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;
};
@@ -124,11 +124,6 @@ public:
void unlockFocus();
BOOL focusLocked() const { return mLockedView != NULL; }
- void addFocusChangeCallback(const boost::signals2::signal<void ()>::slot_type& cb)
- {
- mFocusChangeSignal.connect(cb);
- }
-
private:
LLUICtrl* mLockedView;
@@ -155,8 +150,6 @@ private:
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;
diff --git a/indra/llui/llmultisliderctrl.cpp b/indra/llui/llmultisliderctrl.cpp
index 01a3b5fdc7..0fbb7ced54 100644
--- a/indra/llui/llmultisliderctrl.cpp
+++ b/indra/llui/llmultisliderctrl.cpp
@@ -140,7 +140,7 @@ LLMultiSliderCtrl::LLMultiSliderCtrl(const LLMultiSliderCtrl::Params& p)
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);
diff --git a/indra/llui/llscrollbar.h b/indra/llui/llscrollbar.h
index 7e72331a3f..7e88b16561 100644
--- a/indra/llui/llscrollbar.h
+++ b/indra/llui/llscrollbar.h
@@ -130,12 +130,6 @@ public:
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 );
diff --git a/indra/llui/llsliderctrl.cpp b/indra/llui/llsliderctrl.cpp
index 15584c8dc7..fb71b60725 100644
--- a/indra/llui/llsliderctrl.cpp
+++ b/indra/llui/llsliderctrl.cpp
@@ -143,7 +143,7 @@ LLSliderCtrl::LLSliderCtrl(const LLSliderCtrl::Params& p)
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);
diff --git a/indra/llui/llspinctrl.cpp b/indra/llui/llspinctrl.cpp
index 3a96bc8f93..83d71006aa 100644
--- a/indra/llui/llspinctrl.cpp
+++ b/indra/llui/llspinctrl.cpp
@@ -142,7 +142,7 @@ LLSpinCtrl::LLSpinCtrl(const LLSpinCtrl::Params& p)
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
diff --git a/indra/llui/lluictrl.cpp b/indra/llui/lluictrl.cpp
index 8807e26f6b..2cd9c8844e 100644
--- a/indra/llui/lluictrl.cpp
+++ b/indra/llui/lluictrl.cpp
@@ -114,7 +114,6 @@ void LLUICtrl::initFromParams(const Params& p)
}
setTabStop(p.tab_stop);
- setFocusLostCallback(p.focus_lost_callback());
if (p.initial_value.isProvided()
&& !p.control_name.isProvided())
@@ -800,14 +799,7 @@ namespace LLInitParam
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,
diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h
index 3add9393ea..0ca3acfa1c 100644
--- a/indra/llui/lluictrl.h
+++ b/indra/llui/lluictrl.h
@@ -124,8 +124,6 @@ public:
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;
@@ -309,11 +307,6 @@ namespace LLInitParam
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);
diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp
index 256c776293..10cb3fb377 100644
--- a/indra/llui/llview.cpp
+++ b/indra/llui/llview.cpp
@@ -466,16 +466,6 @@ LLRect LLView::getRequiredRect()
return mRect;
}
-//virtual
-void LLView::onFocusLost()
-{
-}
-
-//virtual
-void LLView::onFocusReceived()
-{
-}
-
BOOL LLView::focusNextRoot()
{
LLView::child_list_t result = LLView::getFocusRootsQuery().run(this);
diff --git a/indra/llui/llview.h b/indra/llui/llview.h
index bf3b5d0614..7a37d6f430 100644
--- a/indra/llui/llview.h
+++ b/indra/llui/llview.h
@@ -405,10 +405,6 @@ public:
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,