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

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

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