| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 VIEWS_FOCUS_EXTERNAL_FOCUS_TRACKER_H_ | 5 #ifndef VIEWS_FOCUS_EXTERNAL_FOCUS_TRACKER_H_ |
| 6 #define VIEWS_FOCUS_EXTERNAL_FOCUS_TRACKER_H_ | 6 #define VIEWS_FOCUS_EXTERNAL_FOCUS_TRACKER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "views/focus/focus_manager.h" | 9 #include "views/focus/focus_manager.h" |
| 10 | 10 |
| 11 namespace views { | 11 namespace views { |
| 12 | 12 |
| 13 class View; | 13 class View; |
| 14 class ViewStorage; | 14 class ViewStorage; |
| 15 | 15 |
| 16 // ExternalFocusTracker tracks the last focused view which belongs to the | 16 // ExternalFocusTracker tracks the last focused view which belongs to the |
| 17 // provided focus manager and is not either the provided parent view or one of | 17 // provided focus manager and is not either the provided parent view or one of |
| 18 // its descendants. This is generally used if the parent view want to return | 18 // its descendants. This is generally used if the parent view want to return |
| 19 // focus to some other view once it is dismissed. The parent view and the focus | 19 // focus to some other view once it is dismissed. The parent view and the focus |
| 20 // manager must exist for the duration of the tracking. If the focus manager | 20 // manager must exist for the duration of the tracking. If the focus manager |
| 21 // must be deleted before this object is deleted, make sure to call | 21 // must be deleted before this object is deleted, make sure to call |
| 22 // SetFocusManager(NULL) first. | 22 // SetFocusManager(NULL) first. |
| 23 // | 23 // |
| 24 // Typical use: When a view is added to the view hierarchy, it instantiates an | 24 // Typical use: When a view is added to the view hierarchy, it instantiates an |
| 25 // ExternalFocusTracker and passes in itself and its focus manager. Then, | 25 // ExternalFocusTracker and passes in itself and its focus manager. Then, |
| 26 // when that view wants to return focus to the last focused view which is not | 26 // when that view wants to return focus to the last focused view which is not |
| 27 // itself and not a descandant of itself, (usually when it is being closed) | 27 // itself and not a descandant of itself, (usually when it is being closed) |
| 28 // it calls FocusLastFocusedExternalView. | 28 // it calls FocusLastFocusedExternalView. |
| 29 class VIEWS_API ExternalFocusTracker : public FocusChangeListener { | 29 class VIEWS_EXPORT ExternalFocusTracker : public FocusChangeListener { |
| 30 public: | 30 public: |
| 31 ExternalFocusTracker(View* parent_view, FocusManager* focus_manager); | 31 ExternalFocusTracker(View* parent_view, FocusManager* focus_manager); |
| 32 | 32 |
| 33 virtual ~ExternalFocusTracker(); | 33 virtual ~ExternalFocusTracker(); |
| 34 // FocusChangeListener implementation. | 34 // FocusChangeListener implementation. |
| 35 virtual void FocusWillChange(View* focused_before, View* focused_now); | 35 virtual void FocusWillChange(View* focused_before, View* focused_now); |
| 36 | 36 |
| 37 // Focuses last focused view which is not a child of parent view and is not | 37 // Focuses last focused view which is not a child of parent view and is not |
| 38 // parent view itself. Returns true if focus for a view was requested, false | 38 // parent view itself. Returns true if focus for a view was requested, false |
| 39 // otherwise. | 39 // otherwise. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 68 // The parent view of views which we should not track focus changes to. We | 68 // The parent view of views which we should not track focus changes to. We |
| 69 // also do not track changes to parent_view_ itself. | 69 // also do not track changes to parent_view_ itself. |
| 70 View* parent_view_; | 70 View* parent_view_; |
| 71 | 71 |
| 72 DISALLOW_COPY_AND_ASSIGN(ExternalFocusTracker); | 72 DISALLOW_COPY_AND_ASSIGN(ExternalFocusTracker); |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 } // namespace views | 75 } // namespace views |
| 76 | 76 |
| 77 #endif // VIEWS_FOCUS_EXTERNAL_FOCUS_TRACKER_H_ | 77 #endif // VIEWS_FOCUS_EXTERNAL_FOCUS_TRACKER_H_ |
| OLD | NEW |