Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc

Issue 273223002: views: Make view::Views::GetPreferredSize() const. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More compile fix for ToT Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 } 72 }
73 73
74 void IconLabelBubbleView::SetLabel(const base::string16& label) { 74 void IconLabelBubbleView::SetLabel(const base::string16& label) {
75 label_->SetText(label); 75 label_->SetText(label);
76 } 76 }
77 77
78 void IconLabelBubbleView::SetImage(const gfx::ImageSkia& image_skia) { 78 void IconLabelBubbleView::SetImage(const gfx::ImageSkia& image_skia) {
79 image_->SetImage(image_skia); 79 image_->SetImage(image_skia);
80 } 80 }
81 81
82 gfx::Size IconLabelBubbleView::GetPreferredSize() { 82 gfx::Size IconLabelBubbleView::GetPreferredSize() const {
83 // Height will be ignored by the LocationBarView. 83 // Height will be ignored by the LocationBarView.
84 return GetSizeForLabelWidth(label_->GetPreferredSize().width()); 84 return GetSizeForLabelWidth(label_->GetPreferredSize().width());
85 } 85 }
86 86
87 void IconLabelBubbleView::Layout() { 87 void IconLabelBubbleView::Layout() {
88 image_->SetBounds(GetBubbleOuterPadding(!is_extension_icon_), 0, 88 image_->SetBounds(GetBubbleOuterPadding(!is_extension_icon_), 0,
89 image_->GetPreferredSize().width(), height()); 89 image_->GetPreferredSize().width(), height());
90 const int pre_label_width = GetPreLabelWidth(); 90 const int pre_label_width = GetPreLabelWidth();
91 label_->SetBounds(pre_label_width, 0, 91 label_->SetBounds(pre_label_width, 0,
92 width() - pre_label_width - GetBubbleOuterPadding(false), 92 width() - pre_label_width - GetBubbleOuterPadding(false),
(...skipping 28 matching lines...) Expand all
121 views::Painter* painter = (in_hover_ && hover_background_painter_) ? 121 views::Painter* painter = (in_hover_ && hover_background_painter_) ?
122 hover_background_painter_.get() : background_painter_.get(); 122 hover_background_painter_.get() : background_painter_.get();
123 painter->Paint(canvas, size()); 123 painter->Paint(canvas, size());
124 } 124 }
125 125
126 int IconLabelBubbleView::GetPreLabelWidth() const { 126 int IconLabelBubbleView::GetPreLabelWidth() const {
127 const int image_width = image_->GetPreferredSize().width(); 127 const int image_width = image_->GetPreferredSize().width();
128 return GetBubbleOuterPadding(true) + 128 return GetBubbleOuterPadding(true) +
129 (image_width ? (image_width + LocationBarView::kItemPadding) : 0); 129 (image_width ? (image_width + LocationBarView::kItemPadding) : 0);
130 } 130 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698