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

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

Issue 271013002: Compute minimum widths for the toolbar components. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 width() - pre_label_width - GetBubbleOuterPadding(false), 93 width() - pre_label_width - GetBubbleOuterPadding(false),
94 height()); 94 height());
95 } 95 }
96 96
97 gfx::Size IconLabelBubbleView::GetSizeForLabelWidth(int width) const { 97 gfx::Size IconLabelBubbleView::GetSizeForLabelWidth(int width) const {
98 gfx::Size size(GetPreLabelWidth() + width + GetBubbleOuterPadding(false), 0); 98 gfx::Size size(GetPreLabelWidth() + width + GetBubbleOuterPadding(false), 0);
99 size.SetToMax(background_painter_->GetMinimumSize()); 99 size.SetToMax(background_painter_->GetMinimumSize());
100 return size; 100 return size;
101 } 101 }
102 102
103 gfx::Size IconLabelBubbleView::GetSizeForLabelText(
104 const base::string16& text) const {
105 views::Label label(text, label_->font_list());
106 return GetSizeForLabelWidth(label.GetPreferredSize().width());
107 }
108
103 void IconLabelBubbleView::OnMouseEntered(const ui::MouseEvent& event) { 109 void IconLabelBubbleView::OnMouseEntered(const ui::MouseEvent& event) {
104 in_hover_ = true; 110 in_hover_ = true;
105 if (hover_background_painter_.get()) 111 if (hover_background_painter_.get())
106 SchedulePaint(); 112 SchedulePaint();
107 } 113 }
108 114
109 void IconLabelBubbleView::OnMouseExited(const ui::MouseEvent& event) { 115 void IconLabelBubbleView::OnMouseExited(const ui::MouseEvent& event) {
110 in_hover_ = false; 116 in_hover_ = false;
111 if (hover_background_painter_.get()) 117 if (hover_background_painter_.get())
112 SchedulePaint(); 118 SchedulePaint();
113 } 119 }
114 120
115 // static 121 // static
116 int IconLabelBubbleView::GetBubbleOuterPadding(bool by_icon) { 122 int IconLabelBubbleView::GetBubbleOuterPadding(bool by_icon) {
117 return LocationBarView::kItemPadding - LocationBarView::kBubblePadding + 123 return LocationBarView::kItemPadding - LocationBarView::kBubblePadding +
118 (by_icon ? 0 : LocationBarView::kIconInternalPadding); 124 (by_icon ? 0 : LocationBarView::kIconInternalPadding);
119 } 125 }
120 126
121 void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) { 127 void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) {
122 views::Painter* painter = (in_hover_ && hover_background_painter_) ? 128 views::Painter* painter = (in_hover_ && hover_background_painter_) ?
123 hover_background_painter_.get() : background_painter_.get(); 129 hover_background_painter_.get() : background_painter_.get();
124 painter->Paint(canvas, size()); 130 painter->Paint(canvas, size());
125 } 131 }
126 132
127 int IconLabelBubbleView::GetPreLabelWidth() const { 133 int IconLabelBubbleView::GetPreLabelWidth() const {
128 const int image_width = image_->GetPreferredSize().width(); 134 const int image_width = image_->GetPreferredSize().width();
129 return GetBubbleOuterPadding(true) + 135 return GetBubbleOuterPadding(true) +
130 (image_width ? (image_width + LocationBarView::kItemPadding) : 0); 136 (image_width ? (image_width + LocationBarView::kItemPadding) : 0);
131 } 137 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698