llfocusmgr.h

Go to the documentation of this file.
00001 
00032 // Singleton that manages keyboard and mouse focus
00033 
00034 #ifndef LL_LLFOCUSMGR_H
00035 #define LL_LLFOCUSMGR_H
00036 
00037 #include "llstring.h"
00038 #include "llframetimer.h"
00039 #include "llview.h"
00040 
00041 class LLUICtrl;
00042 class LLMouseHandler;
00043 
00044 class LLFocusMgr
00045 {
00046 public:
00047         LLFocusMgr();
00048         ~LLFocusMgr() { mFocusHistory.clear(); }
00049 
00050         // Mouse Captor
00051         void                    setMouseCapture(LLMouseHandler* new_captor);    // new_captor = NULL to release the mouse.
00052         LLMouseHandler* getMouseCapture() const { return mMouseCaptor; } 
00053         void                    removeMouseCaptureWithoutCallback( const LLMouseHandler* captor );
00054         BOOL                    childHasMouseCapture( const LLView* parent ) const;
00055 
00056         // Keyboard Focus
00057         void                    setKeyboardFocus(LLUICtrl* new_focus, BOOL lock = FALSE, BOOL keystrokes_only = FALSE);         // new_focus = NULL to release the focus.
00058         LLUICtrl*               getKeyboardFocus() const { return mKeyboardFocus; }  
00059         LLUICtrl*               getLastKeyboardFocus() const { return mLastKeyboardFocus; }  
00060         BOOL                    childHasKeyboardFocus( const LLView* parent ) const;
00061         void                    removeKeyboardFocusWithoutCallback( const LLView* focus );
00062         BOOL                    getKeystrokesOnly() { return mKeystrokesOnly; }
00063         void                    setKeystrokesOnly(BOOL keystrokes_only) { mKeystrokesOnly = keystrokes_only; }
00064 
00065         F32                             getFocusTime() const { return mFocusTimer.getElapsedTimeF32(); }
00066         F32                             getFocusFlashAmt() const;
00067         S32                             getFocusFlashWidth() const { return llround(lerp(1.f, 3.f, getFocusFlashAmt())); }
00068         LLColor4                getFocusColor() const;
00069         void                    triggerFocusFlash();
00070         BOOL                    getAppHasFocus() const { return mAppHasFocus; }
00071         void                    setAppHasFocus(BOOL focus);
00072         LLUICtrl*               getLastFocusForGroup(LLView* subtree_root) const;
00073         void                    clearLastFocusForGroup(LLView* subtree_root);
00074 
00075         // If setKeyboardFocus(NULL) is called, and there is a non-NULL default
00076         // keyboard focus view, focus goes there. JC
00077         void                    setDefaultKeyboardFocus(LLUICtrl* default_focus) { mDefaultKeyboardFocus = default_focus; }
00078         LLUICtrl*               getDefaultKeyboardFocus() const { return mDefaultKeyboardFocus; }
00079 
00080         
00081         // Top View
00082         void                    setTopCtrl(LLUICtrl* new_top);
00083         LLUICtrl*               getTopCtrl() const                                      { return mTopCtrl; }
00084         void                    removeTopCtrlWithoutCallback( const LLUICtrl* top_view );
00085         BOOL                    childIsTopCtrl( const LLView* parent ) const;
00086 
00087         // All Three
00088         void                    releaseFocusIfNeeded( const LLView* top_view );
00089         void                    lockFocus();
00090         void                    unlockFocus();
00091         BOOL                    focusLocked() const { return mLockedView != NULL; }
00092 
00093 private:
00094         LLUICtrl*                       mLockedView;
00095 
00096         // Mouse Captor
00097         LLMouseHandler*         mMouseCaptor;                           // Mouse events are premptively routed to this object
00098 
00099         // Keyboard Focus
00100         LLUICtrl*                       mKeyboardFocus;                         // Keyboard events are preemptively routed to this object
00101         LLUICtrl*                       mLastKeyboardFocus;                     // who last had focus
00102         LLUICtrl*                       mDefaultKeyboardFocus;
00103         BOOL                            mKeystrokesOnly;
00104 
00105         // Top View
00106         LLUICtrl*                       mTopCtrl;
00107 
00108         LLFrameTimer            mFocusTimer;
00109         F32                                     mFocusWeight;
00110 
00111         BOOL                            mAppHasFocus;
00112 
00113         typedef std::map<LLHandle<LLView>, LLHandle<LLView> > focus_history_map_t;
00114         focus_history_map_t mFocusHistory;
00115 
00116         #ifdef _DEBUG
00117                 LLString                mMouseCaptorName;
00118                 LLString                mKeyboardFocusName;
00119                 LLString                mTopCtrlName;
00120         #endif
00121 };
00122 
00123 extern LLFocusMgr gFocusMgr;
00124 
00125 #endif  // LL_LLFOCUSMGR_H
00126 
00127 

Generated on Fri May 16 08:32:52 2008 for SecondLife by  doxygen 1.5.5