OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/views/location_bar/location_bar_view.h" | 7 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
8 #include "ui/base/resource/resource_bundle.h" | 8 #include "ui/base/resource/resource_bundle.h" |
9 #include "ui/gfx/canvas.h" | 9 #include "ui/gfx/canvas.h" |
10 #include "views/controls/image_view.h" | 10 #include "views/controls/image_view.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 } | 39 } |
40 | 40 |
41 void IconLabelBubbleView::SetLabel(const std::wstring& label) { | 41 void IconLabelBubbleView::SetLabel(const std::wstring& label) { |
42 label_->SetText(label); | 42 label_->SetText(label); |
43 } | 43 } |
44 | 44 |
45 void IconLabelBubbleView::SetImage(const SkBitmap& bitmap) { | 45 void IconLabelBubbleView::SetImage(const SkBitmap& bitmap) { |
46 image_->SetImage(bitmap); | 46 image_->SetImage(bitmap); |
47 } | 47 } |
48 | 48 |
49 void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) { | |
50 background_painter_.Paint(width(), height(), canvas); | |
51 } | |
52 | |
53 gfx::Size IconLabelBubbleView::GetPreferredSize() { | 49 gfx::Size IconLabelBubbleView::GetPreferredSize() { |
54 gfx::Size size(GetNonLabelSize()); | 50 gfx::Size size(GetNonLabelSize()); |
55 size.Enlarge(label_->GetPreferredSize().width(), 0); | 51 size.Enlarge(label_->GetPreferredSize().width(), 0); |
56 return size; | 52 return size; |
57 } | 53 } |
58 | 54 |
59 void IconLabelBubbleView::Layout() { | 55 void IconLabelBubbleView::Layout() { |
60 image_->SetBounds(kBubbleOuterPadding, 0, image_->GetPreferredSize().width(), | 56 image_->SetBounds(kBubbleOuterPadding, 0, image_->GetPreferredSize().width(), |
61 height()); | 57 height()); |
62 const int label_height = label_->GetPreferredSize().height(); | 58 const int label_height = label_->GetPreferredSize().height(); |
63 label_->SetBounds(image_->x() + image_->width() + | 59 label_->SetBounds(image_->x() + image_->width() + |
64 item_padding_ , (height() - label_height) / 2, | 60 item_padding_ , (height() - label_height) / 2, |
65 width() - GetNonLabelWidth(), label_height); | 61 width() - GetNonLabelWidth(), label_height); |
66 } | 62 } |
67 | 63 |
68 void IconLabelBubbleView::SetElideInMiddle(bool elide_in_middle) { | 64 void IconLabelBubbleView::SetElideInMiddle(bool elide_in_middle) { |
69 label_->SetElideInMiddle(elide_in_middle); | 65 label_->SetElideInMiddle(elide_in_middle); |
70 } | 66 } |
71 | 67 |
72 gfx::Size IconLabelBubbleView::GetNonLabelSize() { | 68 gfx::Size IconLabelBubbleView::GetNonLabelSize() { |
73 return gfx::Size(GetNonLabelWidth(), background_painter_.height()); | 69 return gfx::Size(GetNonLabelWidth(), background_painter_.height()); |
74 } | 70 } |
75 | 71 |
| 72 void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) { |
| 73 background_painter_.Paint(width(), height(), canvas); |
| 74 } |
| 75 |
76 int IconLabelBubbleView::GetNonLabelWidth() { | 76 int IconLabelBubbleView::GetNonLabelWidth() { |
77 return kBubbleOuterPadding + image_->GetPreferredSize().width() + | 77 return kBubbleOuterPadding + image_->GetPreferredSize().width() + |
78 item_padding_ + kBubbleOuterPadding; | 78 item_padding_ + kBubbleOuterPadding; |
79 } | 79 } |
OLD | NEW |