| 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/layout_constants.h" | 8 #include "chrome/browser/ui/views/layout_constants.h" |
| 9 #include "ui/base/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
| 10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // Height will be ignored by the LocationBarView. | 98 // Height will be ignored by the LocationBarView. |
| 99 return GetSizeForLabelWidth(label_->GetPreferredSize().width()); | 99 return GetSizeForLabelWidth(label_->GetPreferredSize().width()); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void IconLabelBubbleView::Layout() { | 102 void IconLabelBubbleView::Layout() { |
| 103 const int image_width = image()->GetPreferredSize().width(); | 103 const int image_width = image()->GetPreferredSize().width(); |
| 104 image_->SetBounds(std::min((width() - image_width) / 2, | 104 image_->SetBounds(std::min((width() - image_width) / 2, |
| 105 GetBubbleOuterPadding(!is_extension_icon_)), | 105 GetBubbleOuterPadding(!is_extension_icon_)), |
| 106 0, image_->GetPreferredSize().width(), height()); | 106 0, image_->GetPreferredSize().width(), height()); |
| 107 | 107 |
| 108 const int padding = GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING); | 108 const int padding = GetLayoutConstant(ICON_LABEL_VIEW_INTERNAL_PADDING); |
| 109 int pre_label_width = | 109 int pre_label_width = |
| 110 GetBubbleOuterPadding(true) + (image_width ? (image_width + padding) : 0); | 110 GetBubbleOuterPadding(true) + (image_width ? (image_width + padding) : 0); |
| 111 label_->SetBounds(pre_label_width, 0, | 111 label_->SetBounds(pre_label_width, 0, |
| 112 width() - pre_label_width - GetBubbleOuterPadding(false), | 112 width() - pre_label_width - GetBubbleOuterPadding(false), |
| 113 height()); | 113 height()); |
| 114 } | 114 } |
| 115 | 115 |
| 116 gfx::Size IconLabelBubbleView::GetSizeForLabelWidth(int width) const { | 116 gfx::Size IconLabelBubbleView::GetSizeForLabelWidth(int width) const { |
| 117 gfx::Size size(image_->GetPreferredSize()); | 117 gfx::Size size(image_->GetPreferredSize()); |
| 118 if (ShouldShowBackground()) { | 118 if (ShouldShowBackground()) { |
| 119 const int image_width = image_->GetPreferredSize().width(); | 119 const int image_width = image_->GetPreferredSize().width(); |
| 120 const int padding = GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING); | 120 const int padding = GetLayoutConstant(ICON_LABEL_VIEW_INTERNAL_PADDING); |
| 121 const int non_label_width = | 121 const int non_label_width = |
| 122 GetBubbleOuterPadding(true) + | 122 GetBubbleOuterPadding(true) + |
| 123 (image_width ? (image_width + padding) : 0) + | 123 (image_width ? (image_width + padding) : 0) + |
| 124 GetBubbleOuterPadding(false); | 124 GetBubbleOuterPadding(false); |
| 125 size = gfx::Size(WidthMultiplier() * (width + non_label_width), 0); | 125 size = gfx::Size(WidthMultiplier() * (width + non_label_width), 0); |
| 126 size.SetToMax(background_painter_->GetMinimumSize()); | 126 size.SetToMax(background_painter_->GetMinimumSize()); |
| 127 } | 127 } |
| 128 | 128 |
| 129 return size; | 129 return size; |
| 130 } | 130 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 152 const char* IconLabelBubbleView::GetClassName() const { | 152 const char* IconLabelBubbleView::GetClassName() const { |
| 153 return "IconLabelBubbleView"; | 153 return "IconLabelBubbleView"; |
| 154 } | 154 } |
| 155 | 155 |
| 156 void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) { | 156 void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) { |
| 157 if (!ShouldShowBackground()) | 157 if (!ShouldShowBackground()) |
| 158 return; | 158 return; |
| 159 if (background_painter_) | 159 if (background_painter_) |
| 160 background_painter_->Paint(canvas, size()); | 160 background_painter_->Paint(canvas, size()); |
| 161 } | 161 } |
| OLD | NEW |