diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-27 21:17:54 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-27 21:17:54 +0000 |
commit | 6d8c2eb2ec43dc9dff0d9b3b198a9874457591d6 (patch) | |
tree | f16662b2f9663887221d14c5913be7c7c2d1f7dc /ui/views | |
parent | ad4489a238b46b310a196dde52d56388484a8ff7 (diff) | |
download | chromium_src-6d8c2eb2ec43dc9dff0d9b3b198a9874457591d6.zip chromium_src-6d8c2eb2ec43dc9dff0d9b3b198a9874457591d6.tar.gz chromium_src-6d8c2eb2ec43dc9dff0d9b3b198a9874457591d6.tar.bz2 |
Make the find text and match count align on the baseline. Previously
they were off by 1 pixel.
BUG=none
TEST=none, visual change only.
Review URL: https://chromiumcodereview.appspot.com/11419170
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169754 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views')
-rw-r--r-- | ui/views/controls/label.h | 1 | ||||
-rw-r--r-- | ui/views/controls/textfield/native_textfield_views.cc | 4 | ||||
-rw-r--r-- | ui/views/controls/textfield/native_textfield_views.h | 1 | ||||
-rw-r--r-- | ui/views/controls/textfield/native_textfield_win.cc | 4 | ||||
-rw-r--r-- | ui/views/controls/textfield/native_textfield_win.h | 1 | ||||
-rw-r--r-- | ui/views/controls/textfield/native_textfield_wrapper.h | 4 | ||||
-rw-r--r-- | ui/views/controls/textfield/textfield.cc | 9 | ||||
-rw-r--r-- | ui/views/controls/textfield/textfield.h | 1 |
8 files changed, 25 insertions, 0 deletions
diff --git a/ui/views/controls/label.h b/ui/views/controls/label.h index a8ccc90..4bfa466 100644 --- a/ui/views/controls/label.h +++ b/ui/views/controls/label.h @@ -77,6 +77,7 @@ class VIEWS_EXPORT Label : public View { // Sets the background color. This won't be explicitly drawn, but the label // will force the text color to be readable over it. void SetBackgroundColor(SkColor color); + SkColor background_color() const { return background_color_; } // Enables a drop shadow underneath the text. void SetShadowColors(SkColor enabled_color, SkColor disabled_color); diff --git a/ui/views/controls/textfield/native_textfield_views.cc b/ui/views/controls/textfield/native_textfield_views.cc index 7ecb2e9..6d6343b 100644 --- a/ui/views/controls/textfield/native_textfield_views.cc +++ b/ui/views/controls/textfield/native_textfield_views.cc @@ -595,6 +595,10 @@ int NativeTextfieldViews::GetFontHeight() { return GetRenderText()->GetFont().GetHeight(); } +int NativeTextfieldViews::GetTextfieldBaseline() const { + return GetRenderText()->GetFont().GetBaseline(); +} + void NativeTextfieldViews::ExecuteTextCommand(int command_id) { ExecuteCommand(command_id); } diff --git a/ui/views/controls/textfield/native_textfield_views.h b/ui/views/controls/textfield/native_textfield_views.h index 1a6f3da..5d7bf59 100644 --- a/ui/views/controls/textfield/native_textfield_views.h +++ b/ui/views/controls/textfield/native_textfield_views.h @@ -127,6 +127,7 @@ class VIEWS_EXPORT NativeTextfieldViews : public TouchSelectionClientView, virtual void ApplyDefaultStyle() OVERRIDE; virtual void ClearEditHistory() OVERRIDE; virtual int GetFontHeight() OVERRIDE; + virtual int GetTextfieldBaseline() const OVERRIDE; virtual void ExecuteTextCommand(int command_id) OVERRIDE; // ui::SimpleMenuModel::Delegate overrides diff --git a/ui/views/controls/textfield/native_textfield_win.cc b/ui/views/controls/textfield/native_textfield_win.cc index 8d2d669..916b19d 100644 --- a/ui/views/controls/textfield/native_textfield_win.cc +++ b/ui/views/controls/textfield/native_textfield_win.cc @@ -421,6 +421,10 @@ int NativeTextfieldWin::GetFontHeight() { return textfield_->font().GetHeight(); } +int NativeTextfieldWin::GetTextfieldBaseline() const { + return textfield_->font().GetBaseline(); +} + void NativeTextfieldWin::ExecuteTextCommand(int command_id) { ExecuteCommand(command_id); } diff --git a/ui/views/controls/textfield/native_textfield_win.h b/ui/views/controls/textfield/native_textfield_win.h index 875ac8a..fda34dd 100644 --- a/ui/views/controls/textfield/native_textfield_win.h +++ b/ui/views/controls/textfield/native_textfield_win.h @@ -103,6 +103,7 @@ class NativeTextfieldWin virtual void ApplyDefaultStyle() OVERRIDE; virtual void ClearEditHistory() OVERRIDE; virtual int GetFontHeight() OVERRIDE; + virtual int GetTextfieldBaseline() const OVERRIDE; virtual void ExecuteTextCommand(int command_id) OVERRIDE; // ui::SimpleMenuModel::Delegate: diff --git a/ui/views/controls/textfield/native_textfield_wrapper.h b/ui/views/controls/textfield/native_textfield_wrapper.h index b696637..f5a6c5d 100644 --- a/ui/views/controls/textfield/native_textfield_wrapper.h +++ b/ui/views/controls/textfield/native_textfield_wrapper.h @@ -157,6 +157,10 @@ class VIEWS_EXPORT NativeTextfieldWrapper { // Get the height in pixels of the first font used in this textfield. virtual int GetFontHeight() = 0; + // Returns the baseline of the textfield. This should not take into account + // any insets. + virtual int GetTextfieldBaseline() const = 0; + // Performs the action associated with the specified command id. Not called // ExecuteCommand to avoid name clash. virtual void ExecuteTextCommand(int command_id) = 0; diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc index 95c999c..88f9766 100644 --- a/ui/views/controls/textfield/textfield.cc +++ b/ui/views/controls/textfield/textfield.cc @@ -373,6 +373,15 @@ void Textfield::Layout() { } } +int Textfield::GetBaseline() const { + gfx::Insets insets; + if (draw_border_ && native_wrapper_) + insets = native_wrapper_->CalculateInsets(); + const int baseline = native_wrapper_ ? + native_wrapper_->GetTextfieldBaseline() : font_.GetBaseline(); + return insets.top() + baseline; +} + gfx::Size Textfield::GetPreferredSize() { gfx::Insets insets; if (draw_border_ && native_wrapper_) diff --git a/ui/views/controls/textfield/textfield.h b/ui/views/controls/textfield/textfield.h index 7a5a238a..880c13d 100644 --- a/ui/views/controls/textfield/textfield.h +++ b/ui/views/controls/textfield/textfield.h @@ -246,6 +246,7 @@ class VIEWS_EXPORT Textfield : public View { // Overridden from View: virtual void Layout() OVERRIDE; + virtual int GetBaseline() const OVERRIDE; virtual gfx::Size GetPreferredSize() OVERRIDE; virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE; virtual bool SkipDefaultKeyEventProcessing(const ui::KeyEvent& e) OVERRIDE; |