| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/location_bar/icon_label_bubble_view.h" | 5 #include "chrome/browser/views/location_bar/icon_label_bubble_view.h" |
| 6 | 6 |
| 7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
| 8 #include "chrome/browser/views/location_bar/location_bar_view.h" | 8 #include "chrome/browser/views/location_bar/location_bar_view.h" |
| 9 #include "gfx/canvas.h" | 9 #include "gfx/canvas.h" |
| 10 #include "views/controls/image_view.h" | 10 #include "views/controls/image_view.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 } | 36 } |
| 37 | 37 |
| 38 void IconLabelBubbleView::SetFont(const gfx::Font& font) { | 38 void IconLabelBubbleView::SetFont(const gfx::Font& font) { |
| 39 label_->SetFont(font); | 39 label_->SetFont(font); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void IconLabelBubbleView::SetLabel(const std::wstring& label) { | 42 void IconLabelBubbleView::SetLabel(const std::wstring& label) { |
| 43 label_->SetText(label); | 43 label_->SetText(label); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void IconLabelBubbleView::SetImage(const SkBitmap& bitmap) { |
| 47 image_->SetImage(bitmap); |
| 48 } |
| 49 |
| 46 void IconLabelBubbleView::Paint(gfx::Canvas* canvas) { | 50 void IconLabelBubbleView::Paint(gfx::Canvas* canvas) { |
| 47 int y_offset = (GetParent()->height() - height()) / 2; | 51 int y_offset = (GetParent()->height() - height()) / 2; |
| 48 canvas->TranslateInt(0, y_offset); | 52 canvas->TranslateInt(0, y_offset); |
| 49 background_painter_.Paint(width(), height(), canvas); | 53 background_painter_.Paint(width(), height(), canvas); |
| 50 canvas->TranslateInt(0, -y_offset); | 54 canvas->TranslateInt(0, -y_offset); |
| 51 } | 55 } |
| 52 | 56 |
| 53 gfx::Size IconLabelBubbleView::GetPreferredSize() { | 57 gfx::Size IconLabelBubbleView::GetPreferredSize() { |
| 54 gfx::Size size(GetNonLabelSize()); | 58 gfx::Size size(GetNonLabelSize()); |
| 55 size.Enlarge(label_->GetPreferredSize().width(), 0); | 59 size.Enlarge(label_->GetPreferredSize().width(), 0); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 70 } | 74 } |
| 71 | 75 |
| 72 gfx::Size IconLabelBubbleView::GetNonLabelSize() { | 76 gfx::Size IconLabelBubbleView::GetNonLabelSize() { |
| 73 return gfx::Size(GetNonLabelWidth(), background_painter_.height()); | 77 return gfx::Size(GetNonLabelWidth(), background_painter_.height()); |
| 74 } | 78 } |
| 75 | 79 |
| 76 int IconLabelBubbleView::GetNonLabelWidth() { | 80 int IconLabelBubbleView::GetNonLabelWidth() { |
| 77 return kImageOffset + image_->GetPreferredSize().width() + kLabelOffset + | 81 return kImageOffset + image_->GetPreferredSize().width() + kLabelOffset + |
| 78 kLabelPadding; | 82 kLabelPadding; |
| 79 } | 83 } |
| OLD | NEW |