| OLD | NEW | 
|    1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 
|    2 // Use of this source code is governed by a BSD-style license that can be |    2 // Use of this source code is governed by a BSD-style license that can be | 
|    3 // found in the LICENSE file. |    3 // found in the LICENSE file. | 
|    4  |    4  | 
|    5 #ifndef UI_VIEWS_FOCUS_FOCUS_MANAGER_H_ |    5 #ifndef UI_VIEWS_FOCUS_FOCUS_MANAGER_H_ | 
|    6 #define UI_VIEWS_FOCUS_FOCUS_MANAGER_H_ |    6 #define UI_VIEWS_FOCUS_FOCUS_MANAGER_H_ | 
|    7  |    7  | 
|    8 #include <list> |    8 #include <list> | 
|    9 #include <map> |    9 #include <map> | 
|   10  |   10  | 
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  143   }; |  143   }; | 
|  144  |  144  | 
|  145   enum FocusCycleWrappingBehavior { |  145   enum FocusCycleWrappingBehavior { | 
|  146     kWrap, |  146     kWrap, | 
|  147     kNoWrap |  147     kNoWrap | 
|  148   }; |  148   }; | 
|  149  |  149  | 
|  150   FocusManager(Widget* widget, FocusManagerDelegate* delegate); |  150   FocusManager(Widget* widget, FocusManagerDelegate* delegate); | 
|  151   virtual ~FocusManager(); |  151   virtual ~FocusManager(); | 
|  152  |  152  | 
|  153   // Processes the passed key event for accelerators and tab traversal. |  153   // Processes the passed key event for accelerators and keyboard traversal. | 
|  154   // Returns false if the event has been consumed and should not be processed |  154   // Returns false if the event has been consumed and should not be processed | 
|  155   // further. |  155   // further. | 
|  156   bool OnKeyEvent(const ui::KeyEvent& event); |  156   bool OnKeyEvent(const ui::KeyEvent& event); | 
|  157  |  157  | 
|  158   // Returns true is the specified is part of the hierarchy of the window |  158   // Returns true is the specified is part of the hierarchy of the window | 
|  159   // associated with this FocusManager. |  159   // associated with this FocusManager. | 
|  160   bool ContainsView(View* view); |  160   bool ContainsView(View* view); | 
|  161  |  161  | 
|  162   // Advances the focus (backward if reverse is true). |  162   // Advances the focus (backward if reverse is true). | 
|  163   void AdvanceFocus(bool reverse); |  163   void AdvanceFocus(bool reverse); | 
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  289   // order to trap keyboard focus within that pane. If |wrap| is kWrap, |  289   // order to trap keyboard focus within that pane. If |wrap| is kWrap, | 
|  290   // it keeps cycling within this widget, otherwise it returns false after |  290   // it keeps cycling within this widget, otherwise it returns false after | 
|  291   // reaching the last pane so that focus can cycle to another widget. |  291   // reaching the last pane so that focus can cycle to another widget. | 
|  292   bool RotatePaneFocus(Direction direction, FocusCycleWrappingBehavior wrap); |  292   bool RotatePaneFocus(Direction direction, FocusCycleWrappingBehavior wrap); | 
|  293  |  293  | 
|  294   // Convenience method that returns true if the passed |key_event| should |  294   // Convenience method that returns true if the passed |key_event| should | 
|  295   // trigger tab traversal (if it is a TAB key press with or without SHIFT |  295   // trigger tab traversal (if it is a TAB key press with or without SHIFT | 
|  296   // pressed). |  296   // pressed). | 
|  297   static bool IsTabTraversalKeyEvent(const ui::KeyEvent& key_event); |  297   static bool IsTabTraversalKeyEvent(const ui::KeyEvent& key_event); | 
|  298  |  298  | 
 |  299   // Sets whether arrow key traversal is enabled. When enabled, right/down key | 
 |  300   // behaves like tab and left/up key behaves like shift-tab. Note when this | 
 |  301   // is enabled, the arrow key movement within grouped views are disabled. | 
 |  302   static void set_arrow_key_traversal_enabled(bool enabled) { | 
 |  303     arrow_key_traversal_enabled_ = enabled; | 
 |  304   } | 
 |  305   // Returns whether arrow key traversal is enabled. | 
 |  306   static bool arrow_key_traversal_enabled() { | 
 |  307     return arrow_key_traversal_enabled_; | 
 |  308   } | 
 |  309  | 
|  299  private: |  310  private: | 
|  300   // Returns the next focusable view. |  311   // Returns the next focusable view. | 
|  301   View* GetNextFocusableView(View* starting_view, bool reverse, bool dont_loop); |  312   View* GetNextFocusableView(View* starting_view, bool reverse, bool dont_loop); | 
|  302  |  313  | 
|  303   // Returns the focusable view found in the FocusTraversable specified starting |  314   // Returns the focusable view found in the FocusTraversable specified starting | 
|  304   // at the specified view. This traverses down along the FocusTraversable |  315   // at the specified view. This traverses down along the FocusTraversable | 
|  305   // hierarchy. |  316   // hierarchy. | 
|  306   // Returns NULL if no focusable view were found. |  317   // Returns NULL if no focusable view were found. | 
|  307   View* FindFocusableView(FocusTraversable* focus_traversable, |  318   View* FindFocusableView(FocusTraversable* focus_traversable, | 
|  308                           View* starting_view, |  319                           View* starting_view, | 
|  309                           bool reverse); |  320                           bool reverse); | 
|  310  |  321  | 
 |  322   // Process arrow key traversal. Returns true if the event has been consumed | 
 |  323   // and should not be processed further. | 
 |  324   bool ProcessArrowKeyTraversal(const ui::KeyEvent& event); | 
 |  325  | 
|  311   // Keeps track of whether shortcut handling is currently suspended. |  326   // Keeps track of whether shortcut handling is currently suspended. | 
|  312   static bool shortcut_handling_suspended_; |  327   static bool shortcut_handling_suspended_; | 
|  313  |  328  | 
 |  329   // Whether arrow key traversal is enabled. | 
 |  330   static bool arrow_key_traversal_enabled_; | 
 |  331  | 
|  314   // The top-level Widget this FocusManager is associated with. |  332   // The top-level Widget this FocusManager is associated with. | 
|  315   Widget* widget_; |  333   Widget* widget_; | 
|  316  |  334  | 
|  317   // The object which handles an accelerator when |accelerator_manager_| doesn't |  335   // The object which handles an accelerator when |accelerator_manager_| doesn't | 
|  318   // handle it. |  336   // handle it. | 
|  319   scoped_ptr<FocusManagerDelegate> delegate_; |  337   scoped_ptr<FocusManagerDelegate> delegate_; | 
|  320  |  338  | 
|  321   // The view that currently is focused. |  339   // The view that currently is focused. | 
|  322   View* focused_view_; |  340   View* focused_view_; | 
|  323  |  341  | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
|  336  |  354  | 
|  337   // See description above getter. |  355   // See description above getter. | 
|  338   bool is_changing_focus_; |  356   bool is_changing_focus_; | 
|  339  |  357  | 
|  340   DISALLOW_COPY_AND_ASSIGN(FocusManager); |  358   DISALLOW_COPY_AND_ASSIGN(FocusManager); | 
|  341 }; |  359 }; | 
|  342  |  360  | 
|  343 }  // namespace views |  361 }  // namespace views | 
|  344  |  362  | 
|  345 #endif  // UI_VIEWS_FOCUS_FOCUS_MANAGER_H_ |  363 #endif  // UI_VIEWS_FOCUS_FOCUS_MANAGER_H_ | 
| OLD | NEW |