diff options
author | Jacek Antonelli | 2008-08-15 23:44:54 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:54 -0500 |
commit | b2afb8800bb033a04bb3ecdf0363068d56648ef1 (patch) | |
tree | 3568129b5bbddb47cd39d622b4137a8fbff4abaf /linden/indra/llui/llfocusmgr.cpp | |
parent | Second Life viewer sources 1.14.0.1 (diff) | |
download | meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.zip meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.gz meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.bz2 meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.xz |
Second Life viewer sources 1.15.0.2
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llui/llfocusmgr.cpp | 70 |
1 files changed, 30 insertions, 40 deletions
diff --git a/linden/indra/llui/llfocusmgr.cpp b/linden/indra/llui/llfocusmgr.cpp index f02996b..f79164e 100644 --- a/linden/indra/llui/llfocusmgr.cpp +++ b/linden/indra/llui/llfocusmgr.cpp | |||
@@ -4,6 +4,7 @@ | |||
4 | * | 4 | * |
5 | * Copyright (c) 2002-2007, Linden Research, Inc. | 5 | * Copyright (c) 2002-2007, Linden Research, Inc. |
6 | * | 6 | * |
7 | * Second Life Viewer Source Code | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | 8 | * The source code in this file ("Source Code") is provided by Linden Lab |
8 | * to you under the terms of the GNU General Public License, version 2.0 | 9 | * to you under the terms of the GNU General Public License, version 2.0 |
9 | * ("GPL"), unless you have obtained a separate licensing agreement | 10 | * ("GPL"), unless you have obtained a separate licensing agreement |
@@ -40,18 +41,16 @@ LLFocusMgr::LLFocusMgr() | |||
40 | mLockedView( NULL ), | 41 | mLockedView( NULL ), |
41 | mKeyboardLockedFocusLostCallback( NULL ), | 42 | mKeyboardLockedFocusLostCallback( NULL ), |
42 | mMouseCaptor( NULL ), | 43 | mMouseCaptor( NULL ), |
43 | mMouseCaptureLostCallback( NULL ), | ||
44 | mKeyboardFocus( NULL ), | 44 | mKeyboardFocus( NULL ), |
45 | mDefaultKeyboardFocus( NULL ), | 45 | mDefaultKeyboardFocus( NULL ), |
46 | mKeyboardFocusLostCallback( NULL ), | 46 | mKeyboardFocusLostCallback( NULL ), |
47 | mTopView( NULL ), | 47 | mTopCtrl( NULL ), |
48 | mTopViewLostCallback( NULL ), | ||
49 | mFocusWeight(0.f), | 48 | mFocusWeight(0.f), |
50 | mAppHasFocus(TRUE) // Macs don't seem to notify us that we've gotten focus, so default to true | 49 | mAppHasFocus(TRUE) // Macs don't seem to notify us that we've gotten focus, so default to true |
51 | #ifdef _DEBUG | 50 | #ifdef _DEBUG |
52 | , mMouseCaptorName("none") | 51 | , mMouseCaptorName("none") |
53 | , mKeyboardFocusName("none") | 52 | , mKeyboardFocusName("none") |
54 | , mTopViewName("none") | 53 | , mTopCtrlName("none") |
55 | #endif | 54 | #endif |
56 | { | 55 | { |
57 | } | 56 | } |
@@ -65,7 +64,7 @@ void LLFocusMgr::releaseFocusIfNeeded( LLView* view ) | |||
65 | { | 64 | { |
66 | if( childHasMouseCapture( view ) ) | 65 | if( childHasMouseCapture( view ) ) |
67 | { | 66 | { |
68 | setMouseCapture( NULL, NULL ); | 67 | setMouseCapture( NULL ); |
69 | } | 68 | } |
70 | 69 | ||
71 | if( childHasKeyboardFocus( view )) | 70 | if( childHasKeyboardFocus( view )) |
@@ -82,9 +81,9 @@ void LLFocusMgr::releaseFocusIfNeeded( LLView* view ) | |||
82 | } | 81 | } |
83 | } | 82 | } |
84 | 83 | ||
85 | if( childIsTopView( view ) ) | 84 | if( childIsTopCtrl( view ) ) |
86 | { | 85 | { |
87 | setTopView( NULL, NULL ); | 86 | setTopCtrl( NULL ); |
88 | } | 87 | } |
89 | } | 88 | } |
90 | 89 | ||
@@ -127,13 +126,13 @@ void LLFocusMgr::setKeyboardFocus(LLUICtrl* new_focus, FocusLostCallback on_focu | |||
127 | 126 | ||
128 | // If we've got a default keyboard focus, and the caller is | 127 | // If we've got a default keyboard focus, and the caller is |
129 | // releasing keyboard focus, move to the default. | 128 | // releasing keyboard focus, move to the default. |
130 | if (mDefaultKeyboardFocus != NULL && new_focus == NULL) | 129 | if (mDefaultKeyboardFocus != NULL && mKeyboardFocus == NULL) |
131 | { | 130 | { |
132 | mDefaultKeyboardFocus->setFocus(TRUE); | 131 | mDefaultKeyboardFocus->setFocus(TRUE); |
133 | } | 132 | } |
134 | 133 | ||
135 | LLView* focus_subtree = new_focus; | 134 | LLView* focus_subtree = mKeyboardFocus; |
136 | LLView* viewp = new_focus; | 135 | LLView* viewp = mKeyboardFocus; |
137 | // find root-most focus root | 136 | // find root-most focus root |
138 | while(viewp) | 137 | while(viewp) |
139 | { | 138 | { |
@@ -147,13 +146,13 @@ void LLFocusMgr::setKeyboardFocus(LLUICtrl* new_focus, FocusLostCallback on_focu | |||
147 | 146 | ||
148 | if (focus_subtree) | 147 | if (focus_subtree) |
149 | { | 148 | { |
150 | mFocusHistory[focus_subtree->mViewHandle] = new_focus ? new_focus->mViewHandle : LLViewHandle::sDeadHandle; | 149 | mFocusHistory[focus_subtree->mViewHandle] = mKeyboardFocus ? mKeyboardFocus->mViewHandle : LLViewHandle::sDeadHandle; |
151 | } | 150 | } |
152 | } | 151 | } |
153 | 152 | ||
154 | if (lock) | 153 | if (lock) |
155 | { | 154 | { |
156 | mLockedView = new_focus; | 155 | mLockedView = mKeyboardFocus; |
157 | mKeyboardLockedFocusLostCallback = on_focus_lost; | 156 | mKeyboardLockedFocusLostCallback = on_focus_lost; |
158 | } | 157 | } |
159 | } | 158 | } |
@@ -217,16 +216,13 @@ void LLFocusMgr::removeKeyboardFocusWithoutCallback( LLView* focus ) | |||
217 | } | 216 | } |
218 | 217 | ||
219 | 218 | ||
220 | void LLFocusMgr::setMouseCapture( LLMouseHandler* new_captor, void (*on_capture_lost)(LLMouseHandler* old_captor) ) | 219 | void LLFocusMgr::setMouseCapture( LLMouseHandler* new_captor ) |
221 | { | 220 | { |
222 | //if (mFocusLocked) | 221 | //if (mFocusLocked) |
223 | //{ | 222 | //{ |
224 | // return; | 223 | // return; |
225 | //} | 224 | //} |
226 | 225 | ||
227 | void (*old_callback)(LLMouseHandler*) = mMouseCaptureLostCallback; | ||
228 | mMouseCaptureLostCallback = on_capture_lost; | ||
229 | |||
230 | if( new_captor != mMouseCaptor ) | 226 | if( new_captor != mMouseCaptor ) |
231 | { | 227 | { |
232 | LLMouseHandler* old_captor = mMouseCaptor; | 228 | LLMouseHandler* old_captor = mMouseCaptor; |
@@ -249,9 +245,9 @@ void LLFocusMgr::setMouseCapture( LLMouseHandler* new_captor, void (*on_capture_ | |||
249 | } | 245 | } |
250 | */ | 246 | */ |
251 | 247 | ||
252 | if( old_callback ) | 248 | if( old_captor ) |
253 | { | 249 | { |
254 | old_callback( old_captor ); | 250 | old_captor->onMouseCaptureLost(); |
255 | } | 251 | } |
256 | 252 | ||
257 | #ifdef _DEBUG | 253 | #ifdef _DEBUG |
@@ -269,7 +265,6 @@ void LLFocusMgr::removeMouseCaptureWithoutCallback( LLMouseHandler* captor ) | |||
269 | if( mMouseCaptor == captor ) | 265 | if( mMouseCaptor == captor ) |
270 | { | 266 | { |
271 | mMouseCaptor = NULL; | 267 | mMouseCaptor = NULL; |
272 | mMouseCaptureLostCallback = NULL; | ||
273 | #ifdef _DEBUG | 268 | #ifdef _DEBUG |
274 | mMouseCaptorName = "none"; | 269 | mMouseCaptorName = "none"; |
275 | #endif | 270 | #endif |
@@ -277,9 +272,9 @@ void LLFocusMgr::removeMouseCaptureWithoutCallback( LLMouseHandler* captor ) | |||
277 | } | 272 | } |
278 | 273 | ||
279 | 274 | ||
280 | BOOL LLFocusMgr::childIsTopView( LLView* parent ) | 275 | BOOL LLFocusMgr::childIsTopCtrl( LLView* parent ) |
281 | { | 276 | { |
282 | LLView* top_view = mTopView; | 277 | LLView* top_view = (LLView*)mTopCtrl; |
283 | while( top_view ) | 278 | while( top_view ) |
284 | { | 279 | { |
285 | if( top_view == parent ) | 280 | if( top_view == parent ) |
@@ -294,36 +289,25 @@ BOOL LLFocusMgr::childIsTopView( LLView* parent ) | |||
294 | 289 | ||
295 | 290 | ||
296 | // set new_top = NULL to release top_view. | 291 | // set new_top = NULL to release top_view. |
297 | void LLFocusMgr::setTopView( LLView* new_top, void (*on_top_lost)(LLView* old_top) ) | 292 | void LLFocusMgr::setTopCtrl( LLUICtrl* new_top ) |
298 | { | 293 | { |
299 | void (*old_callback)(LLView*) = mTopViewLostCallback; | 294 | if( new_top != mTopCtrl ) |
300 | mTopViewLostCallback = on_top_lost; | ||
301 | |||
302 | if( new_top != mTopView ) | ||
303 | { | 295 | { |
304 | LLView* old_top = mTopView; | 296 | mTopCtrl = new_top; |
305 | mTopView = new_top; | ||
306 | if( old_callback ) | ||
307 | { | ||
308 | old_callback( old_top ); | ||
309 | } | ||
310 | |||
311 | mTopView = new_top; | ||
312 | 297 | ||
313 | #ifdef _DEBUG | 298 | #ifdef _DEBUG |
314 | mTopViewName = new_top ? new_top->getName() : "none"; | 299 | mTopCtrlName = new_top ? new_top->getName() : "none"; |
315 | #endif | 300 | #endif |
316 | } | 301 | } |
317 | } | 302 | } |
318 | 303 | ||
319 | void LLFocusMgr::removeTopViewWithoutCallback( LLView* top_view ) | 304 | void LLFocusMgr::removeTopCtrlWithoutCallback( LLUICtrl* top_view ) |
320 | { | 305 | { |
321 | if( mTopView == top_view ) | 306 | if( mTopCtrl == top_view ) |
322 | { | 307 | { |
323 | mTopView = NULL; | 308 | mTopCtrl = NULL; |
324 | mTopViewLostCallback = NULL; | ||
325 | #ifdef _DEBUG | 309 | #ifdef _DEBUG |
326 | mTopViewName = "none"; | 310 | mTopCtrlName = "none"; |
327 | #endif | 311 | #endif |
328 | } | 312 | } |
329 | } | 313 | } |
@@ -362,6 +346,12 @@ void LLFocusMgr::setAppHasFocus(BOOL focus) | |||
362 | { | 346 | { |
363 | triggerFocusFlash(); | 347 | triggerFocusFlash(); |
364 | } | 348 | } |
349 | |||
350 | // release focus from "top ctrl"s, which generally hides them | ||
351 | if (!focus && mTopCtrl && mTopCtrl->hasFocus()) | ||
352 | { | ||
353 | mTopCtrl->setFocus(FALSE); | ||
354 | } | ||
365 | mAppHasFocus = focus; | 355 | mAppHasFocus = focus; |
366 | } | 356 | } |
367 | 357 | ||