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

Side by Side Diff: ui/views/view.h

Issue 1898633004: Views: Add new SetFocusBehavior method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 4 years, 8 months 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 UI_VIEWS_VIEW_H_ 5 #ifndef UI_VIEWS_VIEW_H_
6 #define UI_VIEWS_VIEW_H_ 6 #define UI_VIEWS_VIEW_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 // 109 //
110 ///////////////////////////////////////////////////////////////////////////// 110 /////////////////////////////////////////////////////////////////////////////
111 class VIEWS_EXPORT View : public ui::LayerDelegate, 111 class VIEWS_EXPORT View : public ui::LayerDelegate,
112 public ui::LayerOwner, 112 public ui::LayerOwner,
113 public ui::AcceleratorTarget, 113 public ui::AcceleratorTarget,
114 public ui::EventTarget, 114 public ui::EventTarget,
115 public ui::EventHandler { 115 public ui::EventHandler {
116 public: 116 public:
117 typedef std::vector<View*> Views; 117 typedef std::vector<View*> Views;
118 118
119 enum class FocusBehavior {
120 // Use when the view is to be focusable both in default and full keyboard
tapted 2016/04/20 04:16:28 nit: view -> View. Also `full keyboard access` is
karandeepb 2016/04/21 03:16:33 Done. Although the existing comment for IsAccessib
121 // access mode.
122 ALWAYS,
123
124 // Use when view is never focusable. Default.
tapted 2016/04/20 04:16:28 nit: view -> View. Also the default should come fi
sky 2016/04/20 19:26:02 And 'view' -> 'the view'
karandeepb 2016/04/21 03:16:33 Done.
karandeepb 2016/04/21 03:16:33 Done.
125 NEVER,
126
127 // Use when the view is to be made focusable only during full keyboard mode.
tapted 2016/04/20 04:16:28 // The View is focusable only in accessibility mod
karandeepb 2016/04/21 03:16:33 Done.
128 ACCESSIBLE_ONLY,
129 };
130
119 struct ViewHierarchyChangedDetails { 131 struct ViewHierarchyChangedDetails {
120 ViewHierarchyChangedDetails() 132 ViewHierarchyChangedDetails()
121 : is_add(false), 133 : is_add(false),
122 parent(NULL), 134 parent(NULL),
123 child(NULL), 135 child(NULL),
124 move_view(NULL) {} 136 move_view(NULL) {}
125 137
126 ViewHierarchyChangedDetails(bool is_add, 138 ViewHierarchyChangedDetails(bool is_add,
127 View* parent, 139 View* parent,
128 View* child, 140 View* child,
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 // Returns the view that should be selected next when pressing Shift-Tab. 772 // Returns the view that should be selected next when pressing Shift-Tab.
761 View* GetPreviousFocusableView(); 773 View* GetPreviousFocusableView();
762 774
763 // Sets the component that should be selected next when pressing Tab, and 775 // Sets the component that should be selected next when pressing Tab, and
764 // makes the current view the precedent view of the specified one. 776 // makes the current view the precedent view of the specified one.
765 // Note that by default views are linked in the order they have been added to 777 // Note that by default views are linked in the order they have been added to
766 // their container. Use this method if you want to modify the order. 778 // their container. Use this method if you want to modify the order.
767 // IMPORTANT NOTE: loops in the focus hierarchy are not supported. 779 // IMPORTANT NOTE: loops in the focus hierarchy are not supported.
768 void SetNextFocusableView(View* view); 780 void SetNextFocusableView(View* view);
769 781
770 // Sets whether this view is capable of taking focus. It will clear focus if 782 // Sets |focusable_| and |accessibility_focusable_| corresponding to the given
771 // the focused view is set to be non-focusable. 783 // |focus_behavior|.
tapted 2016/04/20 04:16:28 If we get rid of Set[Accessibility]Focusable (I th
karandeepb 2016/04/21 03:16:33 Done.
772 // Note that this is false by default so that a view used as a container does 784 void SetFocusBehavior(FocusBehavior focus_behavior);
773 // not get the focus.
774 void SetFocusable(bool focusable);
775 785
776 // Returns true if this view is |focusable_|, |enabled_| and drawn. 786 // Returns true if this view is |focusable_|, |enabled_| and drawn.
777 bool IsFocusable() const; 787 bool IsFocusable() const;
778 788
779 // Return whether this view is focusable when the user requires full keyboard 789 // Return whether this view is focusable when the user requires full keyboard
780 // access, even though it may not be normally focusable. 790 // access, even though it may not be normally focusable.
781 bool IsAccessibilityFocusable() const; 791 bool IsAccessibilityFocusable() const;
782 792
783 // Set whether this view can be made focusable if the user requires
784 // full keyboard access, even though it's not normally focusable. It will
785 // clear focus if the focused view is set to be non-focusable.
786 // Note that this is false by default.
787 void SetAccessibilityFocusable(bool accessibility_focusable);
788
789 // Convenience method to retrieve the FocusManager associated with the 793 // Convenience method to retrieve the FocusManager associated with the
790 // Widget that contains this view. This can return NULL if this view is not 794 // Widget that contains this view. This can return NULL if this view is not
791 // part of a view hierarchy with a Widget. 795 // part of a view hierarchy with a Widget.
792 virtual FocusManager* GetFocusManager(); 796 virtual FocusManager* GetFocusManager();
793 virtual const FocusManager* GetFocusManager() const; 797 virtual const FocusManager* GetFocusManager() const;
794 798
795 // Request keyboard focus. The receiving view will become the focused view. 799 // Request keyboard focus. The receiving view will become the focused view.
796 virtual void RequestFocus(); 800 virtual void RequestFocus();
797 801
798 // Invoked when a view is about to be requested for focus due to the focus 802 // Invoked when a view is about to be requested for focus due to the focus
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 // FocusManager yet, if possible. 1381 // FocusManager yet, if possible.
1378 void RegisterPendingAccelerators(); 1382 void RegisterPendingAccelerators();
1379 1383
1380 // Unregisters all the keyboard accelerators associated with this view. 1384 // Unregisters all the keyboard accelerators associated with this view.
1381 // |leave_data_intact| if true does not remove data from accelerators_ array, 1385 // |leave_data_intact| if true does not remove data from accelerators_ array,
1382 // so it could be re-registered with other focus manager 1386 // so it could be re-registered with other focus manager
1383 void UnregisterAccelerators(bool leave_data_intact); 1387 void UnregisterAccelerators(bool leave_data_intact);
1384 1388
1385 // Focus --------------------------------------------------------------------- 1389 // Focus ---------------------------------------------------------------------
1386 1390
1391 // Helper method for SetFocusBehavior(..).
1392 // Sets whether this view is capable of taking focus. It will clear focus if
1393 // the focused view is set to be non-focusable.
1394 // Note that this is false by default so that a view used as a container does
1395 // not get the focus.
1396 void SetFocusable(bool focusable);
sky 2016/04/20 19:26:02 Is this temporary? We should only have SetFocusBeh
karandeepb 2016/04/21 03:16:33 Done.
1397
1398 // Helper method for SetFocusBehavior(..).
1399 // Set whether this view can be made focusable if the user requires
tapted 2016/04/20 04:16:28 nit: rewrap
karandeepb 2016/04/21 03:16:33 Removed this.
1400 // full keyboard access, even though it's not normally focusable. It will
1401 // clear focus if the focused view is set to be non-focusable.
1402 // Note that this is false by default.
1403 void SetAccessibilityFocusable(bool accessibility_focusable);
1404
1387 // Initialize the previous/next focusable views of the specified view relative 1405 // Initialize the previous/next focusable views of the specified view relative
1388 // to the view at the specified index. 1406 // to the view at the specified index.
1389 void InitFocusSiblings(View* view, int index); 1407 void InitFocusSiblings(View* view, int index);
1390 1408
1391 // Helper function to advance focus, in case the currently focused view has 1409 // Helper function to advance focus, in case the currently focused view has
1392 // become unfocusable. 1410 // become unfocusable.
1393 void AdvanceFocusIfNecessary(); 1411 void AdvanceFocusIfNecessary();
1394 1412
1395 // System events ------------------------------------------------------------- 1413 // System events -------------------------------------------------------------
1396 1414
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1569 // Belongs to this view, but it's reference-counted on some platforms 1587 // Belongs to this view, but it's reference-counted on some platforms
1570 // so we can't use a scoped_ptr. It's dereferenced in the destructor. 1588 // so we can't use a scoped_ptr. It's dereferenced in the destructor.
1571 NativeViewAccessibility* native_view_accessibility_; 1589 NativeViewAccessibility* native_view_accessibility_;
1572 1590
1573 DISALLOW_COPY_AND_ASSIGN(View); 1591 DISALLOW_COPY_AND_ASSIGN(View);
1574 }; 1592 };
1575 1593
1576 } // namespace views 1594 } // namespace views
1577 1595
1578 #endif // UI_VIEWS_VIEW_H_ 1596 #endif // UI_VIEWS_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698