Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 744 // Overridden from AcceleratorTarget: | 744 // Overridden from AcceleratorTarget: |
| 745 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 745 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
| 746 | 746 |
| 747 // Returns whether accelerators are enabled for this view. Accelerators are | 747 // Returns whether accelerators are enabled for this view. Accelerators are |
| 748 // enabled if the containing widget is visible and the view is enabled() and | 748 // enabled if the containing widget is visible and the view is enabled() and |
| 749 // IsDrawn() | 749 // IsDrawn() |
| 750 bool CanHandleAccelerators() const override; | 750 bool CanHandleAccelerators() const override; |
| 751 | 751 |
| 752 // Focus --------------------------------------------------------------------- | 752 // Focus --------------------------------------------------------------------- |
| 753 | 753 |
| 754 enum FocusBehavior { | |
|
tapted
2016/03/15 05:05:32
enums are always declared before methods in the cl
karandeepb
2016/03/17 07:24:47
Done.
| |
| 755 ALWAYS, // Use when the view is to be focusable both in default and full | |
|
tapted
2016/03/15 05:05:32
nit: if we can't fit in a line, we usually just co
karandeepb
2016/03/17 07:24:47
Done.
| |
| 756 // keyboard access mode. | |
| 757 NEVER, // Default. | |
| 758 ACCESSIBLE_ONLY, // Use when the view is to be made focusable only during | |
| 759 // full keyboard mode. | |
| 760 CONTROL // Use for controls. On Mac, this is the same as ACCESSIBLE_ONLY | |
|
tapted
2016/03/15 05:05:32
nit: CONTROL,
karandeepb
2016/03/17 07:24:47
Done.
| |
| 761 // mode, while on other platforms it corresponds to ALWAYS. | |
| 762 }; | |
| 763 | |
| 754 // Returns whether this view currently has the focus. | 764 // Returns whether this view currently has the focus. |
| 755 virtual bool HasFocus() const; | 765 virtual bool HasFocus() const; |
| 756 | 766 |
| 757 // Returns the view that should be selected next when pressing Tab. | 767 // Returns the view that should be selected next when pressing Tab. |
| 758 View* GetNextFocusableView(); | 768 View* GetNextFocusableView(); |
| 759 const View* GetNextFocusableView() const; | 769 const View* GetNextFocusableView() const; |
| 760 | 770 |
| 761 // Returns the view that should be selected next when pressing Shift-Tab. | 771 // Returns the view that should be selected next when pressing Shift-Tab. |
| 762 View* GetPreviousFocusableView(); | 772 View* GetPreviousFocusableView(); |
| 763 | 773 |
| 764 // Sets the component that should be selected next when pressing Tab, and | 774 // Sets the component that should be selected next when pressing Tab, and |
| 765 // makes the current view the precedent view of the specified one. | 775 // makes the current view the precedent view of the specified one. |
| 766 // Note that by default views are linked in the order they have been added to | 776 // Note that by default views are linked in the order they have been added to |
| 767 // their container. Use this method if you want to modify the order. | 777 // their container. Use this method if you want to modify the order. |
| 768 // IMPORTANT NOTE: loops in the focus hierarchy are not supported. | 778 // IMPORTANT NOTE: loops in the focus hierarchy are not supported. |
| 769 void SetNextFocusableView(View* view); | 779 void SetNextFocusableView(View* view); |
| 770 | 780 |
| 781 // Sets |focusable_| and |accessibility_focusable_| corresponding to the given | |
| 782 // |focus_behavior|. | |
| 783 void SetFocusBehavior(FocusBehavior focus_behavior); | |
| 784 | |
| 771 // Sets whether this view is capable of taking focus. It will clear focus if | 785 // Sets whether this view is capable of taking focus. It will clear focus if |
| 772 // the focused view is set to be non-focusable. | 786 // the focused view is set to be non-focusable. |
| 773 // Note that this is false by default so that a view used as a container does | 787 // Note that this is false by default so that a view used as a container does |
| 774 // not get the focus. | 788 // not get the focus. |
| 789 // TODO(karandeepb): Make private. | |
| 775 void SetFocusable(bool focusable); | 790 void SetFocusable(bool focusable); |
| 776 | 791 |
| 777 // Returns true if this view is |focusable_|, |enabled_| and drawn. | 792 // Returns true if this view is |focusable_|, |enabled_| and drawn. |
| 778 bool IsFocusable() const; | 793 bool IsFocusable() const; |
| 779 | 794 |
| 780 // Return whether this view is focusable when the user requires full keyboard | 795 // Return whether this view is focusable when the user requires full keyboard |
| 781 // access, even though it may not be normally focusable. | 796 // access, even though it may not be normally focusable. |
| 782 bool IsAccessibilityFocusable() const; | 797 bool IsAccessibilityFocusable() const; |
| 783 | 798 |
| 784 // Set whether this view can be made focusable if the user requires | 799 // Set whether this view can be made focusable if the user requires |
| 785 // full keyboard access, even though it's not normally focusable. It will | 800 // full keyboard access, even though it's not normally focusable. It will |
| 786 // clear focus if the focused view is set to be non-focusable. | 801 // clear focus if the focused view is set to be non-focusable. |
| 787 // Note that this is false by default. | 802 // Note that this is false by default. |
| 803 // TODO(karandeepb): Make private. | |
| 788 void SetAccessibilityFocusable(bool accessibility_focusable); | 804 void SetAccessibilityFocusable(bool accessibility_focusable); |
| 789 | 805 |
| 790 // Convenience method to retrieve the FocusManager associated with the | 806 // Convenience method to retrieve the FocusManager associated with the |
| 791 // Widget that contains this view. This can return NULL if this view is not | 807 // Widget that contains this view. This can return NULL if this view is not |
| 792 // part of a view hierarchy with a Widget. | 808 // part of a view hierarchy with a Widget. |
| 793 virtual FocusManager* GetFocusManager(); | 809 virtual FocusManager* GetFocusManager(); |
| 794 virtual const FocusManager* GetFocusManager() const; | 810 virtual const FocusManager* GetFocusManager() const; |
| 795 | 811 |
| 796 // Request keyboard focus. The receiving view will become the focused view. | 812 // Request keyboard focus. The receiving view will become the focused view. |
| 797 virtual void RequestFocus(); | 813 virtual void RequestFocus(); |
| (...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1570 // Belongs to this view, but it's reference-counted on some platforms | 1586 // Belongs to this view, but it's reference-counted on some platforms |
| 1571 // so we can't use a scoped_ptr. It's dereferenced in the destructor. | 1587 // so we can't use a scoped_ptr. It's dereferenced in the destructor. |
| 1572 NativeViewAccessibility* native_view_accessibility_; | 1588 NativeViewAccessibility* native_view_accessibility_; |
| 1573 | 1589 |
| 1574 DISALLOW_COPY_AND_ASSIGN(View); | 1590 DISALLOW_COPY_AND_ASSIGN(View); |
| 1575 }; | 1591 }; |
| 1576 | 1592 |
| 1577 } // namespace views | 1593 } // namespace views |
| 1578 | 1594 |
| 1579 #endif // UI_VIEWS_VIEW_H_ | 1595 #endif // UI_VIEWS_VIEW_H_ |
| OLD | NEW |