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

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

Issue 8508055: Move views::Accelerator to ui in order to use it from aura code. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase 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
« no previous file with comments | « views/focus/accelerator_handler_wayland.cc ('k') | views/focus/focus_manager.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_FOCUS_MANAGER_H_ 5 #ifndef VIEWS_FOCUS_FOCUS_MANAGER_H_
6 #define VIEWS_FOCUS_FOCUS_MANAGER_H_ 6 #define VIEWS_FOCUS_FOCUS_MANAGER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "ui/base/models/accelerator.h"
14 #include "ui/gfx/native_widget_types.h" 15 #include "ui/gfx/native_widget_types.h"
15 #include "views/accelerator.h" 16 #include "views/views_export.h"
17 #include "views/events/event.h"
16 18
17 // The FocusManager class is used to handle focus traversal, store/restore 19 // The FocusManager class is used to handle focus traversal, store/restore
18 // focused views and handle keyboard accelerators. 20 // focused views and handle keyboard accelerators.
19 // 21 //
20 // There are 2 types of focus: 22 // There are 2 types of focus:
21 // - the native focus, which is the focus that an gfx::NativeView has. 23 // - the native focus, which is the focus that an gfx::NativeView has.
22 // - the view focus, which is the focus that a views::View has. 24 // - the view focus, which is the focus that a views::View has.
23 // 25 //
24 // Each native view must register with their Focus Manager so the focus manager 26 // Each native view must register with their Focus Manager so the focus manager
25 // gets notified when they are focused (and keeps track of the native focus) and 27 // gets notified when they are focused (and keeps track of the native focus) and
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 182
181 // Register a keyboard accelerator for the specified target. If multiple 183 // Register a keyboard accelerator for the specified target. If multiple
182 // targets are registered for an accelerator, a target registered later has 184 // targets are registered for an accelerator, a target registered later has
183 // higher priority. 185 // higher priority.
184 // Note that we are currently limited to accelerators that are either: 186 // Note that we are currently limited to accelerators that are either:
185 // - a key combination including Ctrl or Alt 187 // - a key combination including Ctrl or Alt
186 // - the escape key 188 // - the escape key
187 // - the enter key 189 // - the enter key
188 // - any F key (F1, F2, F3 ...) 190 // - any F key (F1, F2, F3 ...)
189 // - any browser specific keys (as available on special keyboards) 191 // - any browser specific keys (as available on special keyboards)
190 void RegisterAccelerator(const Accelerator& accelerator, 192 void RegisterAccelerator(const ui::Accelerator& accelerator,
191 AcceleratorTarget* target); 193 ui::AcceleratorTarget* target);
192 194
193 // Unregister the specified keyboard accelerator for the specified target. 195 // Unregister the specified keyboard accelerator for the specified target.
194 void UnregisterAccelerator(const Accelerator& accelerator, 196 void UnregisterAccelerator(const ui::Accelerator& accelerator,
195 AcceleratorTarget* target); 197 ui::AcceleratorTarget* target);
196 198
197 // Unregister all keyboard accelerator for the specified target. 199 // Unregister all keyboard accelerator for the specified target.
198 void UnregisterAccelerators(AcceleratorTarget* target); 200 void UnregisterAccelerators(ui::AcceleratorTarget* target);
199 201
200 // Activate the target associated with the specified accelerator. 202 // Activate the target associated with the specified accelerator.
201 // First, AcceleratorPressed handler of the most recently registered target 203 // First, AcceleratorPressed handler of the most recently registered target
202 // is called, and if that handler processes the event (i.e. returns true), 204 // is called, and if that handler processes the event (i.e. returns true),
203 // this method immediately returns. If not, we do the same thing on the next 205 // this method immediately returns. If not, we do the same thing on the next
204 // target, and so on. 206 // target, and so on.
205 // Returns true if an accelerator was activated. 207 // Returns true if an accelerator was activated.
206 bool ProcessAccelerator(const Accelerator& accelerator); 208 bool ProcessAccelerator(const ui::Accelerator& accelerator);
207 209
208 // Called by a RootView when a view within its hierarchy is removed 210 // Called by a RootView when a view within its hierarchy is removed
209 // from its parent. This will only be called by a RootView in a 211 // from its parent. This will only be called by a RootView in a
210 // hierarchy of Widgets that this FocusManager is attached to the 212 // hierarchy of Widgets that this FocusManager is attached to the
211 // parent Widget of. 213 // parent Widget of.
212 void ViewRemoved(View* removed); 214 void ViewRemoved(View* removed);
213 215
214 // Adds/removes a listener. The FocusChangeListener is notified every time 216 // Adds/removes a listener. The FocusChangeListener is notified every time
215 // the focused view is about to change. 217 // the focused view is about to change.
216 void AddFocusChangeListener(FocusChangeListener* listener); 218 void AddFocusChangeListener(FocusChangeListener* listener);
217 void RemoveFocusChangeListener(FocusChangeListener* listener); 219 void RemoveFocusChangeListener(FocusChangeListener* listener);
218 220
219 // Returns the AcceleratorTarget that should be activated for the specified 221 // Returns the AcceleratorTarget that should be activated for the specified
220 // keyboard accelerator, or NULL if no view is registered for that keyboard 222 // keyboard accelerator, or NULL if no view is registered for that keyboard
221 // accelerator. 223 // accelerator.
222 AcceleratorTarget* GetCurrentTargetForAccelerator( 224 ui::AcceleratorTarget* GetCurrentTargetForAccelerator(
223 const Accelerator& accelertor) const; 225 const ui::Accelerator& accelertor) const;
224 226
225 // Sets the focus to the specified native view. 227 // Sets the focus to the specified native view.
226 virtual void FocusNativeView(gfx::NativeView native_view); 228 virtual void FocusNativeView(gfx::NativeView native_view);
227 229
228 // Clears the native view having the focus. 230 // Clears the native view having the focus.
229 virtual void ClearNativeFocus(); 231 virtual void ClearNativeFocus();
230 232
231 // Convenience method that returns true if the passed |key_event| should 233 // Convenience method that returns true if the passed |key_event| should
232 // trigger tab traversal (if it is a TAB key press with or without SHIFT 234 // trigger tab traversal (if it is a TAB key press with or without SHIFT
233 // pressed). 235 // pressed).
(...skipping 18 matching lines...) Expand all
252 View* focused_view_; 254 View* focused_view_;
253 255
254 // The storage id used in the ViewStorage to store/restore the view that last 256 // The storage id used in the ViewStorage to store/restore the view that last
255 // had focus. 257 // had focus.
256 int stored_focused_view_storage_id_; 258 int stored_focused_view_storage_id_;
257 259
258 // The reason why the focus most recently changed. 260 // The reason why the focus most recently changed.
259 FocusChangeReason focus_change_reason_; 261 FocusChangeReason focus_change_reason_;
260 262
261 // The accelerators and associated targets. 263 // The accelerators and associated targets.
262 typedef std::list<AcceleratorTarget*> AcceleratorTargetList; 264 typedef std::list<ui::AcceleratorTarget*> AcceleratorTargetList;
263 typedef std::map<Accelerator, AcceleratorTargetList> AcceleratorMap; 265 typedef std::map<ui::Accelerator, AcceleratorTargetList> AcceleratorMap;
264 AcceleratorMap accelerators_; 266 AcceleratorMap accelerators_;
265 267
266 // The list of registered FocusChange listeners. 268 // The list of registered FocusChange listeners.
267 ObserverList<FocusChangeListener, true> focus_change_listeners_; 269 ObserverList<FocusChangeListener, true> focus_change_listeners_;
268 270
269 // See description above getter. 271 // See description above getter.
270 bool is_changing_focus_; 272 bool is_changing_focus_;
271 273
272 DISALLOW_COPY_AND_ASSIGN(FocusManager); 274 DISALLOW_COPY_AND_ASSIGN(FocusManager);
273 }; 275 };
274 276
275 } // namespace views 277 } // namespace views
276 278
277 #endif // VIEWS_FOCUS_FOCUS_MANAGER_H_ 279 #endif // VIEWS_FOCUS_FOCUS_MANAGER_H_
OLDNEW
« no previous file with comments | « views/focus/accelerator_handler_wayland.cc ('k') | views/focus/focus_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698