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

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

Issue 16254009: Revert "Increase omnibox size by 2 px. Increase nominal font size in omnibox to 16 px." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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/utf_string_conversions.h" 7 #include "base/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"
11 #include "ui/gfx/canvas.h" 11 #include "ui/gfx/canvas.h"
12 #include "ui/gfx/color_utils.h" 12 #include "ui/gfx/color_utils.h"
13 #include "ui/views/controls/image_view.h" 13 #include "ui/views/controls/image_view.h"
14 #include "ui/views/controls/label.h" 14 #include "ui/views/controls/label.h"
15 #include "ui/views/painter.h" 15 #include "ui/views/painter.h"
16 16
17 17
18 IconLabelBubbleView::IconLabelBubbleView(const int background_images[], 18 IconLabelBubbleView::IconLabelBubbleView(const int background_images[],
19 int contained_image, 19 int contained_image,
20 const gfx::Font& font, 20 const gfx::Font& font,
21 int font_y_offset, 21 int font_y_offset,
22 SkColor text_color, 22 SkColor text_color,
23 SkColor parent_background_color, 23 SkColor parent_background_color,
24 bool elide_in_middle) 24 bool elide_in_middle)
25 : background_painter_( 25 : background_painter_(new views::HorizontalPainter(background_images)),
26 views::Painter::CreateImageGridPainter(background_images)),
27 image_(new views::ImageView()), 26 image_(new views::ImageView()),
28 label_(new views::Label()), 27 label_(new views::Label()),
29 is_extension_icon_(false) { 28 is_extension_icon_(false) {
30 image_->SetImage( 29 image_->SetImage(
31 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 30 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
32 contained_image)); 31 contained_image));
33 AddChildView(image_); 32 AddChildView(image_);
34 33
35 label_->set_border(views::Border::CreateEmptyBorder(font_y_offset, 0, 0, 0)); 34 label_->set_border(views::Border::CreateEmptyBorder(font_y_offset, 0, 0, 0));
36 label_->SetFont(font); 35 label_->SetFont(font);
37 label_->SetEnabledColor(text_color); 36 label_->SetEnabledColor(text_color);
38 // Calculate the actual background color for the label. The background images 37 // Calculate the actual background color for the label. The background images
39 // are painted atop |parent_background_color|. We grab the color of the 38 // are painted atop |parent_background_color|. We grab the color of the
40 // middle pixel of the middle image of the background, which we treat as the 39 // middle pixel of the middle image of the background, which we treat as the
41 // representative color of the entire background (reasonable, given the 40 // representative color of the entire background (reasonable, given the
42 // current appearance of these images). Then we alpha-blend it over the 41 // current appearance of these images). Then we alpha-blend it over the
43 // parent background color to determine the actual color the label text will 42 // parent background color to determine the actual color the label text will
44 // sit atop. 43 // sit atop.
45 const SkBitmap& bitmap( 44 const SkBitmap& bitmap(
46 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 45 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
47 background_images[4])->GetRepresentation( 46 background_images[1])->GetRepresentation(
48 ui::SCALE_FACTOR_100P).sk_bitmap()); 47 ui::SCALE_FACTOR_100P).sk_bitmap());
49 SkAutoLockPixels pixel_lock(bitmap); 48 SkAutoLockPixels pixel_lock(bitmap);
50 SkColor background_image_color = 49 SkColor background_image_color =
51 bitmap.getColor(bitmap.width() / 2, bitmap.height() / 2); 50 bitmap.getColor(bitmap.width() / 2, bitmap.height() / 2);
52 // Tricky bit: We alpha blend an opaque version of |background_image_color| 51 // Tricky bit: We alpha blend an opaque version of |background_image_color|
53 // against |parent_background_color| using the original image grid color's 52 // against |parent_background_color| using the original image grid color's
54 // alpha. This is because AlphaBlend(a, b, 255) always returns |a| unchanged 53 // alpha. This is because AlphaBlend(a, b, 255) always returns |a| unchanged
55 // even if |a| is a color with non-255 alpha. 54 // even if |a| is a color with non-255 alpha.
56 label_->SetBackgroundColor( 55 label_->SetBackgroundColor(
57 color_utils::AlphaBlend(SkColorSetA(background_image_color, 255), 56 color_utils::AlphaBlend(SkColorSetA(background_image_color, 255),
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 100
102 void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) { 101 void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) {
103 background_painter_->Paint(canvas, size()); 102 background_painter_->Paint(canvas, size());
104 } 103 }
105 104
106 int IconLabelBubbleView::GetPreLabelWidth() const { 105 int IconLabelBubbleView::GetPreLabelWidth() const {
107 const int image_width = image_->GetPreferredSize().width(); 106 const int image_width = image_->GetPreferredSize().width();
108 return GetBubbleOuterPadding(true) + 107 return GetBubbleOuterPadding(true) +
109 (image_width ? (image_width + LocationBarView::GetItemPadding()) : 0); 108 (image_width ? (image_width + LocationBarView::GetItemPadding()) : 0);
110 } 109 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/location_bar/ev_bubble_view.cc ('k') | chrome/browser/ui/views/location_bar/location_bar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698