Chromium Code Reviews| Index: chrome/browser/ui/views/location_bar/location_bar_decoration_view.cc |
| diff --git a/chrome/browser/ui/views/location_bar/location_bar_decoration_view.cc b/chrome/browser/ui/views/location_bar/location_bar_decoration_view.cc |
| index 8b214e24084ee23279c1f960a4a3ef9e6ccae187..28d7d383558004716cb55d7bd5e8ca4f664e16b4 100644 |
| --- a/chrome/browser/ui/views/location_bar/location_bar_decoration_view.cc |
| +++ b/chrome/browser/ui/views/location_bar/location_bar_decoration_view.cc |
| @@ -12,7 +12,6 @@ |
| #include "third_party/skia/include/core/SkShader.h" |
| #include "ui/base/animation/slide_animation.h" |
| #include "ui/base/animation/tween.h" |
| -#include "ui/base/resource/resource_bundle.h" |
| #include "ui/gfx/canvas.h" |
| #include "ui/gfx/skia_util.h" |
| #include "ui/views/border.h" |
| @@ -22,9 +21,8 @@ namespace { |
| // Animation parameters. |
| const int kFrameRateHz = 60; |
| // Margins for animated box (pixels). |
| -const int kTextMargin = 4; |
| +const int kTextMargin = 5; |
|
Peter Kasting
2012/09/15 00:23:46
Should the icon margin and text margins match? Sh
Greg Billock
2012/09/15 04:58:20
The text margin is between the text and other cont
Peter Kasting
2012/09/17 20:04:27
Nah, don't worry about it.
|
| const int kIconLeftMargin = 4; |
| - |
| } |
| LocationBarDecorationView::LocationBarDecorationView( |
| @@ -46,6 +44,8 @@ LocationBarDecorationView::~LocationBarDecorationView() { |
| gfx::Size LocationBarDecorationView::GetPreferredSize() { |
| gfx::Size preferred_size(views::ImageView::GetPreferredSize()); |
| + if (!GetImageSize(&preferred_size)) |
|
Peter Kasting
2012/09/15 00:23:46
I don't actually understand what this is doing. I
Greg Billock
2012/09/15 04:58:20
Me either. This is a failed attempt to get the ver
|
| + preferred_size.set_height(background_painter_.height()); |
| preferred_size.set_height(std::max(preferred_size.height(), |
| background_painter_.height())); |
| // When view is animated |visible_text_size_| > 0, it is 0 otherwise. |
| @@ -93,6 +93,10 @@ int LocationBarDecorationView::GetBuiltInHorizontalPadding() const { |
| return GetBuiltInHorizontalPaddingImpl(); |
| } |
| +void LocationBarDecorationView::SetFont(const gfx::Font& font) { |
| + font_ = font; |
| +} |
| + |
| void LocationBarDecorationView::StartLabelAnimation(string16 animated_text, |
| int duration_ms) { |
| if (!slide_animator_.get()) { |
| @@ -106,8 +110,7 @@ void LocationBarDecorationView::StartLabelAnimation(string16 animated_text, |
| // Initialize animated string. It will be cleared when animation is |
| // completed. |
| animated_text_ = animated_text; |
| - text_size_ = ui::ResourceBundle::GetSharedInstance().GetFont( |
| - ui::ResourceBundle::MediumFont).GetStringWidth(animated_text); |
| + text_size_ = font_.GetStringWidth(animated_text); |
| text_size_ += 2 * kTextMargin + kIconLeftMargin; |
| slide_animator_->Show(); |
| } |
| @@ -171,9 +174,9 @@ void LocationBarDecorationView::OnPaint(gfx::Canvas* canvas) { |
| views::ImageView::OnPaint(canvas); |
| // Paint text to the right of the icon. |
| - ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| - canvas->DrawStringInt(animated_text_, |
| - rb.GetFont(ui::ResourceBundle::MediumFont), SK_ColorBLACK, |
| + LOG(INFO) << "ImageBnds=" << GetImageBounds().right() << " " << GetImageBounds().width(); |
|
Peter Kasting
2012/09/15 00:23:46
Don't check these in. (Multiple places)
Greg Billock
2012/09/15 04:58:20
Yeah, this is leftover trying to diagnose this hei
|
| + LOG(INFO) << "height=" << height(); |
| + canvas->DrawStringInt(animated_text_, font_, SK_ColorDKGRAY, |
|
Peter Kasting
2012/09/15 00:23:46
This should not be hardcoding a text color. We sh
Greg Billock
2012/09/15 04:58:20
Got it. I'll change this to take a color and call
|
| GetImageBounds().right() + kTextMargin, 0, |
| width() - GetImageBounds().width(), height(), |
| gfx::Canvas::TEXT_ALIGN_LEFT | gfx::Canvas::TEXT_VALIGN_MIDDLE); |
| @@ -185,6 +188,7 @@ void LocationBarDecorationView::OnPaint(gfx::Canvas* canvas) { |
| void LocationBarDecorationView::OnPaintBackground(gfx::Canvas* canvas) { |
| if (force_draw_text_ || (slide_animator_.get() && |
| (slide_animator_->is_animating() || pause_animation_))) { |
| + LOG(INFO) << "Paint bg " << size().width() << " " << size().height(); |
| background_painter_.Paint(canvas, size()); |
| } else { |
| views::ImageView::OnPaintBackground(canvas); |