| 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 #include "chrome/browser/ui/views/location_bar/icon_label_bubble_view.h" | 5 #include "chrome/browser/ui/views/location_bar/icon_label_bubble_view.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 9 #include "grit/theme_resources.h" | 9 #include "grit/theme_resources.h" |
| 10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // Height will be ignored by the LocationBarView. | 86 // Height will be ignored by the LocationBarView. |
| 87 return GetSizeForLabelWidth(label_->GetPreferredSize().width()); | 87 return GetSizeForLabelWidth(label_->GetPreferredSize().width()); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void IconLabelBubbleView::Layout() { | 90 void IconLabelBubbleView::Layout() { |
| 91 image_->SetBounds(GetBubbleOuterPadding(!is_extension_icon_), 0, | 91 image_->SetBounds(GetBubbleOuterPadding(!is_extension_icon_), 0, |
| 92 image_->GetPreferredSize().width(), height()); | 92 image_->GetPreferredSize().width(), height()); |
| 93 const int pre_label_width = GetPreLabelWidth(); | 93 const int pre_label_width = GetPreLabelWidth(); |
| 94 label_->SetBounds(pre_label_width, 0, | 94 label_->SetBounds(pre_label_width, 0, |
| 95 width() - pre_label_width - GetBubbleOuterPadding(false), | 95 width() - pre_label_width - GetBubbleOuterPadding(false), |
| 96 label_->GetPreferredSize().height()); | 96 height()); |
| 97 } | 97 } |
| 98 | 98 |
| 99 gfx::Size IconLabelBubbleView::GetSizeForLabelWidth(int width) const { | 99 gfx::Size IconLabelBubbleView::GetSizeForLabelWidth(int width) const { |
| 100 gfx::Size size(GetPreLabelWidth() + width + GetBubbleOuterPadding(false), 0); | 100 gfx::Size size(GetPreLabelWidth() + width + GetBubbleOuterPadding(false), 0); |
| 101 size.SetToMax(background_painter_->GetMinimumSize()); | 101 size.SetToMax(background_painter_->GetMinimumSize()); |
| 102 return size; | 102 return size; |
| 103 } | 103 } |
| 104 | 104 |
| 105 void IconLabelBubbleView::OnMouseEntered(const ui::MouseEvent& event) { | 105 void IconLabelBubbleView::OnMouseEntered(const ui::MouseEvent& event) { |
| 106 in_hover_ = true; | 106 in_hover_ = true; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 124 views::Painter* painter = (in_hover_ && hover_background_painter_) ? | 124 views::Painter* painter = (in_hover_ && hover_background_painter_) ? |
| 125 hover_background_painter_.get() : background_painter_.get(); | 125 hover_background_painter_.get() : background_painter_.get(); |
| 126 painter->Paint(canvas, size()); | 126 painter->Paint(canvas, size()); |
| 127 } | 127 } |
| 128 | 128 |
| 129 int IconLabelBubbleView::GetPreLabelWidth() const { | 129 int IconLabelBubbleView::GetPreLabelWidth() const { |
| 130 const int image_width = image_->GetPreferredSize().width(); | 130 const int image_width = image_->GetPreferredSize().width(); |
| 131 return GetBubbleOuterPadding(true) + | 131 return GetBubbleOuterPadding(true) + |
| 132 (image_width ? (image_width + LocationBarView::GetItemPadding()) : 0); | 132 (image_width ? (image_width + LocationBarView::GetItemPadding()) : 0); |
| 133 } | 133 } |
| OLD | NEW |