Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: views/focus/external_focus_tracker.h

Issue 8588064: views: Move bubble, events, focus and layout to ui/views/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/focus/accelerator_handler_win.cc ('k') | views/focus/external_focus_tracker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ui/views/focus/external_focus_tracker.h"
10 10 // TODO(tfarina): remove this file once all includes have been updated.
11 namespace views {
12
13 class View;
14 class ViewStorage;
15
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
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
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
22 // SetFocusManager(NULL) first.
23 //
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,
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)
28 // it calls FocusLastFocusedExternalView.
29 class VIEWS_EXPORT ExternalFocusTracker : public FocusChangeListener {
30 public:
31 ExternalFocusTracker(View* parent_view, FocusManager* focus_manager);
32
33 virtual ~ExternalFocusTracker();
34 // FocusChangeListener implementation.
35 virtual void OnWillChangeFocus(View* focused_before, View* focused_now);
36 virtual void OnDidChangeFocus(View* focused_before, View* focused_now);
37
38 // Focuses last focused view which is not a child of parent view and is not
39 // parent view itself. Returns true if focus for a view was requested, false
40 // otherwise.
41 void FocusLastFocusedExternalView();
42
43 // Sets the focus manager whose focus we are tracking. |focus_manager| can
44 // be NULL, but no focus changes will be tracked. This is useful if the focus
45 // manager went away, but you might later want to start tracking with a new
46 // manager later, or call FocusLastFocusedExternalView to focus the previous
47 // view.
48 void SetFocusManager(FocusManager* focus_manager);
49
50 private:
51 // Store the provided view. This view will be focused when
52 // FocusLastFocusedExternalView is called.
53 void StoreLastFocusedView(View* view);
54
55 // Store the currently focused view for our view manager and register as a
56 // listener for future focus changes.
57 void StartTracking();
58
59 // Focus manager which we are a listener for.
60 FocusManager* focus_manager_;
61
62 // ID of the last focused view, which we store in view_storage_.
63 int last_focused_view_storage_id_;
64
65 // Used to store the last focused view which is not a child of
66 // ExternalFocusTracker.
67 ViewStorage* view_storage_;
68
69 // The parent view of views which we should not track focus changes to. We
70 // also do not track changes to parent_view_ itself.
71 View* parent_view_;
72
73 DISALLOW_COPY_AND_ASSIGN(ExternalFocusTracker);
74 };
75
76 } // namespace views
77 11
78 #endif // VIEWS_FOCUS_EXTERNAL_FOCUS_TRACKER_H_ 12 #endif // VIEWS_FOCUS_EXTERNAL_FOCUS_TRACKER_H_
OLDNEW
« no previous file with comments | « views/focus/accelerator_handler_win.cc ('k') | views/focus/external_focus_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698