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

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: 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
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>
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 // Register a keyboard accelerator for the specified target. If multiple 178 // Register a keyboard accelerator for the specified target. If multiple
179 // targets are registered for an accelerator, a target registered later has 179 // targets are registered for an accelerator, a target registered later has
180 // higher priority. 180 // higher priority.
181 // Note that we are currently limited to accelerators that are either: 181 // Note that we are currently limited to accelerators that are either:
182 // - a key combination including Ctrl or Alt 182 // - a key combination including Ctrl or Alt
183 // - the escape key 183 // - the escape key
184 // - the enter key 184 // - the enter key
185 // - any F key (F1, F2, F3 ...) 185 // - any F key (F1, F2, F3 ...)
186 // - any browser specific keys (as available on special keyboards) 186 // - any browser specific keys (as available on special keyboards)
187 void RegisterAccelerator(const Accelerator& accelerator, 187 void RegisterAccelerator(const Accelerator& accelerator,
188 AcceleratorTarget* target); 188 ui::AcceleratorTarget* target);
189 189
190 // Unregister the specified keyboard accelerator for the specified target. 190 // Unregister the specified keyboard accelerator for the specified target.
191 void UnregisterAccelerator(const Accelerator& accelerator, 191 void UnregisterAccelerator(const Accelerator& accelerator,
192 AcceleratorTarget* target); 192 ui::AcceleratorTarget* target);
193 193
194 // Unregister all keyboard accelerator for the specified target. 194 // Unregister all keyboard accelerator for the specified target.
195 void UnregisterAccelerators(AcceleratorTarget* target); 195 void UnregisterAccelerators(ui::AcceleratorTarget* target);
196 196
197 // Activate the target associated with the specified accelerator. 197 // Activate the target associated with the specified accelerator.
198 // First, AcceleratorPressed handler of the most recently registered target 198 // First, AcceleratorPressed handler of the most recently registered target
199 // is called, and if that handler processes the event (i.e. returns true), 199 // is called, and if that handler processes the event (i.e. returns true),
200 // this method immediately returns. If not, we do the same thing on the next 200 // this method immediately returns. If not, we do the same thing on the next
201 // target, and so on. 201 // target, and so on.
202 // Returns true if an accelerator was activated. 202 // Returns true if an accelerator was activated.
203 bool ProcessAccelerator(const Accelerator& accelerator); 203 bool ProcessAccelerator(const Accelerator& accelerator);
204 204
205 // Called by a RootView when a view within its hierarchy is removed 205 // Called by a RootView when a view within its hierarchy is removed
206 // from its parent. This will only be called by a RootView in a 206 // from its parent. This will only be called by a RootView in a
207 // hierarchy of Widgets that this FocusManager is attached to the 207 // hierarchy of Widgets that this FocusManager is attached to the
208 // parent Widget of. 208 // parent Widget of.
209 void ViewRemoved(View* removed); 209 void ViewRemoved(View* removed);
210 210
211 // Adds/removes a listener. The FocusChangeListener is notified every time 211 // Adds/removes a listener. The FocusChangeListener is notified every time
212 // the focused view is about to change. 212 // the focused view is about to change.
213 void AddFocusChangeListener(FocusChangeListener* listener); 213 void AddFocusChangeListener(FocusChangeListener* listener);
214 void RemoveFocusChangeListener(FocusChangeListener* listener); 214 void RemoveFocusChangeListener(FocusChangeListener* listener);
215 215
216 // Returns the AcceleratorTarget that should be activated for the specified 216 // Returns the AcceleratorTarget that should be activated for the specified
217 // keyboard accelerator, or NULL if no view is registered for that keyboard 217 // keyboard accelerator, or NULL if no view is registered for that keyboard
218 // accelerator. 218 // accelerator.
219 AcceleratorTarget* GetCurrentTargetForAccelerator( 219 ui::AcceleratorTarget* GetCurrentTargetForAccelerator(
220 const Accelerator& accelertor) const; 220 const Accelerator& accelertor) const;
221 221
222 // Sets the focus to the specified native view. 222 // Sets the focus to the specified native view.
223 virtual void FocusNativeView(gfx::NativeView native_view); 223 virtual void FocusNativeView(gfx::NativeView native_view);
224 224
225 // Clears the native view having the focus. 225 // Clears the native view having the focus.
226 virtual void ClearNativeFocus(); 226 virtual void ClearNativeFocus();
227 227
228 // Convenience method that returns true if the passed |key_event| should 228 // Convenience method that returns true if the passed |key_event| should
229 // trigger tab traversal (if it is a TAB key press with or without SHIFT 229 // trigger tab traversal (if it is a TAB key press with or without SHIFT
(...skipping 19 matching lines...) Expand all
249 View* focused_view_; 249 View* focused_view_;
250 250
251 // The storage id used in the ViewStorage to store/restore the view that last 251 // The storage id used in the ViewStorage to store/restore the view that last
252 // had focus. 252 // had focus.
253 int stored_focused_view_storage_id_; 253 int stored_focused_view_storage_id_;
254 254
255 // The reason why the focus most recently changed. 255 // The reason why the focus most recently changed.
256 FocusChangeReason focus_change_reason_; 256 FocusChangeReason focus_change_reason_;
257 257
258 // The accelerators and associated targets. 258 // The accelerators and associated targets.
259 typedef std::list<AcceleratorTarget*> AcceleratorTargetList; 259 typedef std::list<ui::AcceleratorTarget*> AcceleratorTargetList;
260 typedef std::map<Accelerator, AcceleratorTargetList> AcceleratorMap; 260 typedef std::map<Accelerator, AcceleratorTargetList> AcceleratorMap;
261 AcceleratorMap accelerators_; 261 AcceleratorMap accelerators_;
262 262
263 // The list of registered FocusChange listeners. 263 // The list of registered FocusChange listeners.
264 ObserverList<FocusChangeListener, true> focus_change_listeners_; 264 ObserverList<FocusChangeListener, true> focus_change_listeners_;
265 265
266 // See description above getter. 266 // See description above getter.
267 bool is_changing_focus_; 267 bool is_changing_focus_;
268 268
269 DISALLOW_COPY_AND_ASSIGN(FocusManager); 269 DISALLOW_COPY_AND_ASSIGN(FocusManager);
270 }; 270 };
271 271
272 } // namespace views 272 } // namespace views
273 273
274 #endif // VIEWS_FOCUS_FOCUS_MANAGER_H_ 274 #endif // VIEWS_FOCUS_FOCUS_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698