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

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

Issue 108063004: Give up focus if the focused view becomes unfocusable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years 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
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 <algorithm> 8 #include <algorithm>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 // Gets the maximum size of the view. Currently only used for sizing shell 270 // Gets the maximum size of the view. Currently only used for sizing shell
271 // windows. 271 // windows.
272 virtual gfx::Size GetMaximumSize(); 272 virtual gfx::Size GetMaximumSize();
273 273
274 // Return the height necessary to display this view with the provided width. 274 // Return the height necessary to display this view with the provided width.
275 // View's implementation returns the value from getPreferredSize.cy. 275 // View's implementation returns the value from getPreferredSize.cy.
276 // Override if your View's preferred height depends upon the width (such 276 // Override if your View's preferred height depends upon the width (such
277 // as with Labels). 277 // as with Labels).
278 virtual int GetHeightForWidth(int w); 278 virtual int GetHeightForWidth(int w);
279 279
280 // Set whether this view is visible. Painting is scheduled as needed. 280 // Sets whether this view is visible. Painting is scheduled as needed. Also,
281 // clears focus if the focused view or one of its ancestors is set to be
282 // hidden.
281 virtual void SetVisible(bool visible); 283 virtual void SetVisible(bool visible);
282 284
283 // Return whether a view is visible 285 // Return whether a view is visible
284 bool visible() const { return visible_; } 286 bool visible() const { return visible_; }
285 287
286 // Returns true if this view is drawn on screen. 288 // Returns true if this view is drawn on screen.
287 virtual bool IsDrawn() const; 289 virtual bool IsDrawn() const;
288 290
289 // Set whether this view is enabled. A disabled view does not receive keyboard 291 // Set whether this view is enabled. A disabled view does not receive keyboard
290 // or mouse inputs. If |enabled| differs from the current value, SchedulePaint 292 // or mouse inputs. If |enabled| differs from the current value, SchedulePaint
291 // is invoked. 293 // is invoked. Also, clears focus if the focused view is disabled.
292 void SetEnabled(bool enabled); 294 void SetEnabled(bool enabled);
293 295
294 // Returns whether the view is enabled. 296 // Returns whether the view is enabled.
295 bool enabled() const { return enabled_; } 297 bool enabled() const { return enabled_; }
296 298
297 // This indicates that the view completely fills its bounds in an opaque 299 // This indicates that the view completely fills its bounds in an opaque
298 // color. This doesn't affect compositing but is a hint to the compositor to 300 // color. This doesn't affect compositing but is a hint to the compositor to
299 // optimize painting. 301 // optimize painting.
300 // Note that this method does not implicitly create a layer if one does not 302 // Note that this method does not implicitly create a layer if one does not
301 // already exist for the View, but is a no-op in that case. 303 // already exist for the View, but is a no-op in that case.
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 // Returns the view that should be selected next when pressing Shift-Tab. 760 // Returns the view that should be selected next when pressing Shift-Tab.
759 View* GetPreviousFocusableView(); 761 View* GetPreviousFocusableView();
760 762
761 // Sets the component that should be selected next when pressing Tab, and 763 // Sets the component that should be selected next when pressing Tab, and
762 // makes the current view the precedent view of the specified one. 764 // makes the current view the precedent view of the specified one.
763 // Note that by default views are linked in the order they have been added to 765 // Note that by default views are linked in the order they have been added to
764 // their container. Use this method if you want to modify the order. 766 // their container. Use this method if you want to modify the order.
765 // IMPORTANT NOTE: loops in the focus hierarchy are not supported. 767 // IMPORTANT NOTE: loops in the focus hierarchy are not supported.
766 void SetNextFocusableView(View* view); 768 void SetNextFocusableView(View* view);
767 769
768 // Sets whether this view is capable of taking focus. 770 // Sets whether this view is capable of taking focus. It will clear focus if
771 // the focused view is set to be non-focusable.
769 // Note that this is false by default so that a view used as a container does 772 // Note that this is false by default so that a view used as a container does
770 // not get the focus. 773 // not get the focus.
771 void set_focusable(bool focusable) { focusable_ = focusable; } 774 void SetFocusable(bool focusable);
772 775
773 // Returns true if this view is capable of taking focus. 776 // Returns true if this view is capable of taking focus.
774 bool focusable() const { return focusable_ && enabled_ && visible_; } 777 bool focusable() const { return focusable_ && enabled_ && visible_; }
775 778
776 // Returns true if this view is |focusable_|, |enabled_| and drawn. 779 // Returns true if this view is |focusable_|, |enabled_| and drawn.
777 virtual bool IsFocusable() const; 780 virtual bool IsFocusable() const;
778 781
779 // Return whether this view is focusable when the user requires full keyboard 782 // Return whether this view is focusable when the user requires full keyboard
780 // access, even though it may not be normally focusable. 783 // access, even though it may not be normally focusable.
781 bool IsAccessibilityFocusable() const; 784 bool IsAccessibilityFocusable() const;
782 785
783 // Set whether this view can be made focusable if the user requires 786 // Set whether this view can be made focusable if the user requires
784 // full keyboard access, even though it's not normally focusable. 787 // full keyboard access, even though it's not normally focusable. It will
788 // clear focus if the focused view is set to be non-focusable.
785 // Note that this is false by default. 789 // Note that this is false by default.
786 void set_accessibility_focusable(bool accessibility_focusable) { 790 void SetAccessibilityFocusable(bool accessibility_focusable);
787 accessibility_focusable_ = accessibility_focusable;
788 }
789 791
790 // Convenience method to retrieve the FocusManager associated with the 792 // Convenience method to retrieve the FocusManager associated with the
791 // Widget that contains this view. This can return NULL if this view is not 793 // Widget that contains this view. This can return NULL if this view is not
792 // part of a view hierarchy with a Widget. 794 // part of a view hierarchy with a Widget.
793 virtual FocusManager* GetFocusManager(); 795 virtual FocusManager* GetFocusManager();
794 virtual const FocusManager* GetFocusManager() const; 796 virtual const FocusManager* GetFocusManager() const;
795 797
796 // Request keyboard focus. The receiving view will become the focused view. 798 // Request keyboard focus. The receiving view will become the focused view.
797 virtual void RequestFocus(); 799 virtual void RequestFocus();
798 800
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 // Belongs to this view, but it's reference-counted on some platforms 1559 // Belongs to this view, but it's reference-counted on some platforms
1558 // so we can't use a scoped_ptr. It's dereferenced in the destructor. 1560 // so we can't use a scoped_ptr. It's dereferenced in the destructor.
1559 NativeViewAccessibility* native_view_accessibility_; 1561 NativeViewAccessibility* native_view_accessibility_;
1560 1562
1561 DISALLOW_COPY_AND_ASSIGN(View); 1563 DISALLOW_COPY_AND_ASSIGN(View);
1562 }; 1564 };
1563 1565
1564 } // namespace views 1566 } // namespace views
1565 1567
1566 #endif // UI_VIEWS_VIEW_H_ 1568 #endif // UI_VIEWS_VIEW_H_
OLDNEW
« no previous file with comments | « ui/views/touchui/touch_editing_menu.cc ('k') | ui/views/view.cc » ('j') | ui/views/view.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698