Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MOJO_SERIVCES_WINDOW_MANAGER_FOCUS_CONTROLLER_H_ | |
| 6 #define MOJO_SERIVCES_WINDOW_MANAGER_FOCUS_CONTROLLER_H_ | |
| 7 | |
| 8 #include "base/compiler_specific.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/observer_list.h" | |
| 11 #include "base/scoped_observer.h" | |
| 12 #include "mojo/services/public/cpp/view_manager/view_observer.h" | |
| 13 #include "ui/events/event_handler.h" | |
| 14 | |
| 15 namespace mojo { | |
| 16 | |
| 17 class FocusControllerObserver; | |
| 18 class FocusRules; | |
| 19 | |
| 20 // TODO: Maybe write a better comments. | |
|
sky
2014/11/10 20:45:30
At least write a description for the class.
| |
| 21 | |
| 22 class FocusController : public ui::EventHandler, | |
| 23 public ViewObserver { | |
| 24 public: | |
| 25 // |rules| cannot be NULL. | |
| 26 explicit FocusController(FocusRules* rules); | |
| 27 virtual ~FocusController(); | |
| 28 | |
| 29 void AddObserver(FocusControllerObserver* observer); | |
| 30 void RemoveObserver(FocusControllerObserver* observer); | |
| 31 | |
| 32 void ActivateView(View* view); | |
| 33 void DeactivateView(View* view); | |
| 34 View* GetActiveView(); | |
| 35 View* GetActivatableView(View* view); | |
| 36 View* GetToplevelView(View* view); | |
| 37 bool CanActivateView(View* view) const; | |
| 38 | |
| 39 void FocusView(View* view); | |
| 40 | |
| 41 void ResetFocusWithinActiveView(View* view); | |
| 42 View* GetFocusedView(); | |
| 43 | |
| 44 // Overridden from ui::EventHandler: | |
| 45 void OnKeyEvent(ui::KeyEvent* event) override; | |
| 46 void OnMouseEvent(ui::MouseEvent* event) override; | |
| 47 void OnScrollEvent(ui::ScrollEvent* event) override; | |
| 48 void OnTouchEvent(ui::TouchEvent* event) override; | |
| 49 void OnGestureEvent(ui::GestureEvent* event) override; | |
| 50 | |
| 51 // Overridden from ViewObserver: | |
| 52 void OnTreeChanging(const TreeChangeParams& params) override; | |
| 53 void OnTreeChanged(const TreeChangeParams& params) override; | |
| 54 void OnViewVisibilityChanged(View* view) override; | |
| 55 void OnViewDestroying(View* view) override; | |
| 56 | |
| 57 private: | |
| 58 | |
|
sky
2014/11/10 20:45:30
nit: generally no newline here.
| |
| 59 // Internal implementation that sets the focused view, fires events etc. | |
| 60 // This function must be called with a valid focusable view. | |
| 61 void SetFocusedView(View* view); | |
| 62 | |
| 63 // Internal implementation that sets the active window, fires events etc. | |
| 64 // This function must be called with a valid |activatable_window|. | |
| 65 // |requested window| refers to the window that was passed in to an external | |
| 66 // request (e.g. FocusWindow or ActivateWindow). It may be NULL, e.g. if | |
| 67 // SetActiveWindow was not called by an external request. |activatable_window| | |
| 68 // refers to the actual window to be activated, which may be different. | |
| 69 void SetActiveView(View* requested_view, | |
| 70 View* activatable_view); | |
| 71 | |
| 72 // Called when a window's disposition changed such that it and its hierarchy | |
| 73 // are no longer focusable/activatable. |next| is a valid window that is used | |
| 74 // as a starting point for finding a window to focus next based on rules. | |
| 75 void ViewLostFocusFromDispositionChange(View* view, View* next); | |
| 76 | |
| 77 // Called when an attempt is made to focus or activate a window via an input | |
| 78 // event targeted at that window. Rules determine the best focusable window | |
| 79 // for the input window. | |
| 80 void ViewFocusedFromInputEvent(View* view); | |
| 81 | |
| 82 View* active_view_; | |
| 83 View* focused_view_; | |
| 84 | |
| 85 bool updating_focus_; | |
| 86 bool updating_activation_; | |
| 87 | |
| 88 scoped_ptr<FocusRules> rules_; | |
| 89 | |
| 90 ObserverList<FocusControllerObserver> focus_controller_observers_; | |
| 91 | |
| 92 ScopedObserver<View, ViewObserver> observer_manager_; | |
| 93 | |
| 94 DISALLOW_COPY_AND_ASSIGN(FocusController); | |
| 95 }; | |
| 96 | |
| 97 } // namespace mojo | |
| 98 | |
| 99 #endif // MOJO_SERIVCES_WINDOW_MANAGER_FOCUS_CONTROLLER_H_ | |
| OLD | NEW |