diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-22 23:02:15 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-22 23:02:15 +0000 |
commit | a37bea8f194682046c02a681ccc743e5c6bd2098 (patch) | |
tree | ebf8b10609d3abe48e5876d4e9afc1d2c17d5bc7 /chrome/views/controls/button/checkbox.h | |
parent | 528ad8be61f87ef874a3da9be49c2d73575b7e33 (diff) | |
download | chromium_src-a37bea8f194682046c02a681ccc743e5c6bd2098.zip chromium_src-a37bea8f194682046c02a681ccc743e5c6bd2098.tar.gz chromium_src-a37bea8f194682046c02a681ccc743e5c6bd2098.tar.bz2 |
Fix focus rects for checkboxes and radio buttons:
- add concept of default insets to view which get added to any other insets provided by the user. used by label to provide room for a focus border.
- provide the ability for the label to paint its focus border even if it isn't focused. needed because the outer container (the checkbox) gets focus but the inner label does not, however the label knows best the location of its text around which the focus border must be drawn.
please note:
- also make it easier to click checkboxes by not resetting mouse_pressed_handler_ in RootView when a view decides it doesn't want to handle a drag. this is so we can still receive mousereleased notifications when the mouse is released... it's "difficult" to click checkboxes and radio buttons when you accidentally drag a little on their label. (this is the root view change).
- fix slight alignment issue on the general page of options.
Also fix a slight error in my last radio checkbox - clicking on a checked radio button should still focus it.
http://crbug.com/10834
TEST=visit options, Minor Tweaks. click the "always ask before downloading" checkbox and observe that the focus rect tightly surrounds the text label instead of stretching to the right side of the dialog.
Visit options, click an already-checked radio button. observe that it takes focus.
Visit options, click on any checkbox or radio button, drag slightly then release (still within the bounds of the item). note the item is now toggled or selected. click down then drag out and release, note that it is not toggled or selected.
Review URL: http://codereview.chromium.org/92004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14265 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/views/controls/button/checkbox.h')
-rw-r--r-- | chrome/views/controls/button/checkbox.h | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/chrome/views/controls/button/checkbox.h b/chrome/views/controls/button/checkbox.h index b9def2c..54f4e06 100644 --- a/chrome/views/controls/button/checkbox.h +++ b/chrome/views/controls/button/checkbox.h @@ -41,7 +41,7 @@ class Checkbox : public NativeButton { // Overridden from View: virtual gfx::Size GetPreferredSize(); virtual void Layout(); - virtual void Paint(ChromeCanvas* canvas); + virtual void PaintFocusBorder(ChromeCanvas* canvas); virtual View* GetViewForPoint(const gfx::Point& point); virtual View* GetViewForPoint(const gfx::Point& point, bool can_create_floating); @@ -50,6 +50,9 @@ class Checkbox : public NativeButton { virtual void OnMouseExited(const MouseEvent& e); virtual bool OnMousePressed(const MouseEvent& e); virtual void OnMouseReleased(const MouseEvent& e, bool canceled); + virtual bool OnMouseDragged(const MouseEvent& e); + virtual void WillGainFocus(); + virtual void WillLoseFocus(); protected: virtual std::string GetClassName() const; @@ -58,14 +61,14 @@ class Checkbox : public NativeButton { virtual void CreateWrapper(); virtual void InitBorder(); - private: - // Called from the constructor to create and configure the checkbox label. - void Init(const std::wstring& label_text); - // Returns true if the event (in Checkbox coordinates) is within the bounds of // the label. bool HitTestLabel(const MouseEvent& e); + private: + // Called from the constructor to create and configure the checkbox label. + void Init(const std::wstring& label_text); + // The checkbox's label. We don't use the OS version because of transparency // and sizing issues. Label* label_; |