diff options
Diffstat (limited to 'indra/llui/llfocusmgr.cpp')
-rw-r--r-- | indra/llui/llfocusmgr.cpp | 52 |
1 files changed, 39 insertions, 13 deletions
diff --git a/indra/llui/llfocusmgr.cpp b/indra/llui/llfocusmgr.cpp index a66f147dcc..3899897c5f 100644 --- a/indra/llui/llfocusmgr.cpp +++ b/indra/llui/llfocusmgr.cpp @@ -49,7 +49,6 @@ LLFocusMgr::LLFocusMgr() mDefaultKeyboardFocus( NULL ), mKeystrokesOnly(FALSE), mTopCtrl( NULL ), - mFocusWeight(0.f), mAppHasFocus(TRUE) // Macs don't seem to notify us that we've gotten focus, so default to true #ifdef _DEBUG , mMouseCaptorName("none") @@ -98,8 +97,6 @@ void LLFocusMgr::setKeyboardFocus(LLUICtrl* new_focus, BOOL lock, BOOL keystroke return; } - //llinfos << "Keyboard focus handled by " << (new_focus ? new_focus->getName() : "nothing") << llendl; - mKeystrokesOnly = keystrokes_only; if( new_focus != mKeyboardFocus ) @@ -107,18 +104,48 @@ void LLFocusMgr::setKeyboardFocus(LLUICtrl* new_focus, BOOL lock, BOOL keystroke mLastKeyboardFocus = mKeyboardFocus; mKeyboardFocus = new_focus; - if( mLastKeyboardFocus ) + 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 = mKeyboardFocus; ctrl && ctrl != LLUI::getRootView(); ctrl = ctrl->getParent()) { - mLastKeyboardFocus->onFocusLost(); + if (ctrl) + { + new_focus_list.push_front(ctrl->getHandle()); + } } - // clear out any existing flash - if (new_focus) + view_handle_list_t::iterator new_focus_iter = new_focus_list.begin(); + view_handle_list_t::iterator old_focus_iter = mCachedKeyboardFocusList.begin(); + + // compare the new focus sub-tree to the old focus sub-tree + // iterate through the lists in lockstep until we get to a non-common ancestor + while ((new_focus_iter != new_focus_list.end()) && + (old_focus_iter != mCachedKeyboardFocusList.end()) && + ((*new_focus_iter) == (*old_focus_iter))) { - mFocusWeight = 0.f; - new_focus->onFocusReceived(); + new_focus_iter++; + old_focus_iter++; } - mFocusTimer.reset(); + + // call onFocusLost on all remaining in the old focus list + while (old_focus_iter != mCachedKeyboardFocusList.end()) + { + if (old_focus_iter->get() != NULL) { + old_focus_iter->get()->onFocusLost(); + } + old_focus_iter++; + } + + // call onFocusReceived on all remaining in the new focus list + while (new_focus_iter != new_focus_list.end()) + { + new_focus_iter->get()->onFocusReceived(); + new_focus_iter++; + } + + // cache the new focus list for next time + swap(mCachedKeyboardFocusList, new_focus_list); #ifdef _DEBUG mKeyboardFocusName = new_focus ? new_focus->getName() : std::string("none"); @@ -318,7 +345,7 @@ void LLFocusMgr::unlockFocus() F32 LLFocusMgr::getFocusFlashAmt() const { - return clamp_rescale(getFocusTime(), 0.f, FOCUS_FADE_TIME, mFocusWeight, 0.f); + return clamp_rescale(mFocusFlashTimer.getElapsedTimeF32(), 0.f, FOCUS_FADE_TIME, 1.f, 0.f); } LLColor4 LLFocusMgr::getFocusColor() const @@ -335,8 +362,7 @@ LLColor4 LLFocusMgr::getFocusColor() const void LLFocusMgr::triggerFocusFlash() { - mFocusTimer.reset(); - mFocusWeight = 1.f; + mFocusFlashTimer.reset(); } void LLFocusMgr::setAppHasFocus(BOOL focus) |