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

Side by Side Diff: views/focus/focus_search.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/focus_manager_unittest.cc ('k') | views/focus/focus_search.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_WIDGET_FOCUS_SEARCH_H_ 5 #ifndef VIEWS_FOCUS_FOCUS_SEARCH_H_
6 #define VIEWS_WIDGET_FOCUS_SEARCH_H_ 6 #define VIEWS_FOCUS_FOCUS_SEARCH_H_
7 #pragma once 7 #pragma once
8 8
9 #include "views/view.h" 9 #include "ui/views/focus/focus_search.h"
10 // TODO(tfarina): remove this file once all includes have been updated.
10 11
11 namespace views { 12 #endif // VIEWS_FOCUS_FOCUS_SEARCH_H_
12
13 class FocusTraversable;
14
15 // FocusSearch is an object that implements the algorithm to find the
16 // next view to focus.
17 class VIEWS_EXPORT FocusSearch {
18 public:
19 // The direction in which the focus traversal is going.
20 // TODO (jcampan): add support for lateral (left, right) focus traversal. The
21 // goal is to switch to focusable views on the same level when using the arrow
22 // keys (ala Windows: in a dialog box, arrow keys typically move between the
23 // dialog OK, Cancel buttons).
24 enum Direction {
25 UP = 0,
26 DOWN
27 };
28
29 // Constructor.
30 // - |root| is the root of the view hierarchy to traverse. Focus will be
31 // trapped inside.
32 // - |cycle| should be true if you want FindNextFocusableView to cycle back
33 // to the first view within this root when the traversal reaches
34 // the end. If this is true, then if you pass a valid starting
35 // view to FindNextFocusableView you will always get a valid view
36 // out, even if it's the same view.
37 // - |accessibility_mode| should be true if full keyboard accessibility is
38 // needed and you want to check IsAccessibilityFocusableInRootView(),
39 // rather than IsFocusableInRootView().
40 FocusSearch(View* root, bool cycle, bool accessibility_mode);
41 virtual ~FocusSearch() {}
42
43 // Finds the next view that should be focused and returns it. If a
44 // FocusTraversable is found while searching for the focusable view,
45 // returns NULL and sets |focus_traversable| to the FocusTraversable
46 // and |focus_traversable_view| to the view associated with the
47 // FocusTraversable.
48 //
49 // Return NULL if the end of the focus loop is reached, unless this object
50 // was initialized with |cycle|=true, in which case it goes back to the
51 // beginning when it reaches the end of the traversal.
52 // - |starting_view| is the view that should be used as the starting point
53 // when looking for the previous/next view. It may be NULL (in which case
54 // the first/last view should be used depending if normal/reverse).
55 // - |reverse| whether we should find the next (reverse is false) or the
56 // previous (reverse is true) view.
57 // - |direction| specifies whether we are traversing down (meaning we should
58 // look into child views) or traversing up (don't look at child views).
59 // - |check_starting_view| is true if starting_view may obtain the next focus.
60 // - |focus_traversable| is set to the focus traversable that should be
61 // traversed if one is found (in which case the call returns NULL).
62 // - |focus_traversable_view| is set to the view associated with the
63 // FocusTraversable set in the previous parameter (it is used as the
64 // starting view when looking for the next focusable view).
65 virtual View* FindNextFocusableView(View* starting_view,
66 bool reverse,
67 Direction direction,
68 bool check_starting_view,
69 FocusTraversable** focus_traversable,
70 View** focus_traversable_view);
71
72 private:
73 // Convenience method that returns true if a view is focusable and does not
74 // belong to the specified group.
75 bool IsViewFocusableCandidate(View* v, int skip_group_id);
76
77 // Convenience method; returns true if a view is not NULL and is focusable
78 // (checking IsAccessibilityFocusableInRootView() if accessibility_mode_ is
79 // true).
80 bool IsFocusable(View* v);
81
82 // Returns the view selected for the group of the selected view. If the view
83 // does not belong to a group or if no view is selected in the group, the
84 // specified view is returned.
85 View* FindSelectedViewForGroup(View* view);
86
87 // Get the parent, but stay within the root. Returns NULL if asked for
88 // the parent of root_.
89 View* GetParent(View* view);
90
91 // Returns the next focusable view or view containing a FocusTraversable
92 // (NULL if none was found), starting at the starting_view.
93 // |check_starting_view|, |can_go_up| and |can_go_down| controls the
94 // traversal of the views hierarchy. |skip_group_id| specifies a group_id,
95 // -1 means no group. All views from a group are traversed in one pass.
96 View* FindNextFocusableViewImpl(View* starting_view,
97 bool check_starting_view,
98 bool can_go_up,
99 bool can_go_down,
100 int skip_group_id,
101 FocusTraversable** focus_traversable,
102 View** focus_traversable_view);
103
104 // Same as FindNextFocusableViewImpl but returns the previous focusable view.
105 View* FindPreviousFocusableViewImpl(View* starting_view,
106 bool check_starting_view,
107 bool can_go_up,
108 bool can_go_down,
109 int skip_group_id,
110 FocusTraversable** focus_traversable,
111 View** focus_traversable_view);
112
113 View* root_;
114 bool cycle_;
115 bool accessibility_mode_;
116
117 DISALLOW_COPY_AND_ASSIGN(FocusSearch);
118 };
119
120 } // namespace views
121
122 #endif // VIEWS_WIDGET_FOCUS_SEARCH_H_
OLDNEW
« no previous file with comments | « views/focus/focus_manager_unittest.cc ('k') | views/focus/focus_search.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698