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

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

Issue 1724963002: Color the ink drop ripple and hover effects based on theming. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: self review and format Created 4 years, 10 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
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/layout_constants.h" 8 #include "chrome/browser/ui/layout_constants.h"
9 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h" 9 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h"
10 #include "ui/base/material_design/material_design_controller.h" 10 #include "ui/base/material_design/material_design_controller.h"
11 #include "ui/base/resource/resource_bundle.h" 11 #include "ui/base/resource/resource_bundle.h"
12 #include "ui/gfx/canvas.h" 12 #include "ui/gfx/canvas.h"
13 #include "ui/gfx/color_utils.h" 13 #include "ui/gfx/color_utils.h"
14 #include "ui/native_theme/native_theme.h" 14 #include "ui/native_theme/native_theme.h"
15 #include "ui/views/animation/ink_drop_hover.h"
15 #include "ui/views/controls/image_view.h" 16 #include "ui/views/controls/image_view.h"
16 #include "ui/views/painter.h" 17 #include "ui/views/painter.h"
17 18
18 namespace { 19 namespace {
19 20
20 SkColor CalculateImageColor(gfx::ImageSkia* image) { 21 SkColor CalculateImageColor(gfx::ImageSkia* image) {
21 // We grab the color of the middle pixel of the image, which we treat as 22 // We grab the color of the middle pixel of the image, which we treat as
22 // the representative color of the entire image (reasonable, given the current 23 // the representative color of the entire image (reasonable, given the current
23 // appearance of these assets). 24 // appearance of these assets).
24 const SkBitmap& bitmap(image->GetRepresentation(1.0f).sk_bitmap()); 25 const SkBitmap& bitmap(image->GetRepresentation(1.0f).sk_bitmap());
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 return; 133 return;
133 134
134 bool inverted = color_utils::IsDark(GetParentBackgroundColor()); 135 bool inverted = color_utils::IsDark(GetParentBackgroundColor());
135 SkColor border_color = inverted ? SK_ColorWHITE : GetBorderColor(); 136 SkColor border_color = inverted ? SK_ColorWHITE : GetBorderColor();
136 SkColor background_color = 137 SkColor background_color =
137 inverted ? SK_ColorWHITE : SkColorSetA(border_color, 0x13); 138 inverted ? SK_ColorWHITE : SkColorSetA(border_color, 0x13);
138 set_background(new BackgroundWith1PxBorder(background_color, border_color)); 139 set_background(new BackgroundWith1PxBorder(background_color, border_color));
139 SetLabelBackgroundColor(background_color); 140 SetLabelBackgroundColor(background_color);
140 } 141 }
141 142
143 void IconLabelBubbleView::AddInkDropLayer(ui::Layer* ink_drop_layer) {
144 image()->SetPaintToLayer(true);
145 image()->SetFillsBoundsOpaquely(false);
146 InkDropHostView::AddInkDropLayer(ink_drop_layer);
147 }
148
149 void IconLabelBubbleView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) {
150 InkDropHostView::RemoveInkDropLayer(ink_drop_layer);
151 image()->SetFillsBoundsOpaquely(true);
sky 2016/02/25 00:38:32 this isn't needed (because you destroy the layer o
Evan Stade 2016/02/25 01:34:28 good call. This is a copy-pasta error so I've upda
sky 2016/02/25 02:26:55 Seems like a weird limitation on view and layer. T
152 image()->SetPaintToLayer(false);
153 }
154
155 scoped_ptr<views::InkDropHover> IconLabelBubbleView::CreateInkDropHover()
156 const {
157 // Location bar views don't show hover effect.
158 return nullptr;
159 }
160
161 SkColor IconLabelBubbleView::GetInkDropBaseColor() const {
162 return color_utils::DeriveDefaultIconColor(GetTextColor());
163 }
164
142 SkColor IconLabelBubbleView::GetParentBackgroundColor() const { 165 SkColor IconLabelBubbleView::GetParentBackgroundColor() const {
143 return ui::MaterialDesignController::IsModeMaterial() 166 return ui::MaterialDesignController::IsModeMaterial()
144 ? GetNativeTheme()->GetSystemColor( 167 ? GetNativeTheme()->GetSystemColor(
145 ui::NativeTheme::kColorId_TextfieldDefaultBackground) 168 ui::NativeTheme::kColorId_TextfieldDefaultBackground)
146 : parent_background_color_; 169 : parent_background_color_;
147 } 170 }
148 171
149 gfx::Size IconLabelBubbleView::GetSizeForLabelWidth(int width) const { 172 gfx::Size IconLabelBubbleView::GetSizeForLabelWidth(int width) const {
150 gfx::Size size(image_->GetPreferredSize()); 173 gfx::Size size(image_->GetPreferredSize());
151 if (ShouldShowBackground()) { 174 if (ShouldShowBackground()) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 } 220 }
198 221
199 void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) { 222 void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) {
200 if (!ShouldShowBackground()) 223 if (!ShouldShowBackground())
201 return; 224 return;
202 if (background_painter_) 225 if (background_painter_)
203 background_painter_->Paint(canvas, size()); 226 background_painter_->Paint(canvas, size());
204 if (background()) 227 if (background())
205 background()->Paint(canvas, this); 228 background()->Paint(canvas, this);
206 } 229 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698