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

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: sky review 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/border.h" 16 #include "ui/views/border.h"
16 #include "ui/views/controls/image_view.h" 17 #include "ui/views/controls/image_view.h"
17 #include "ui/views/painter.h" 18 #include "ui/views/painter.h"
18 19
19 namespace { 20 namespace {
20 21
21 SkColor CalculateImageColor(gfx::ImageSkia* image) { 22 SkColor CalculateImageColor(gfx::ImageSkia* image) {
22 // We grab the color of the middle pixel of the image, which we treat as 23 // We grab the color of the middle pixel of the image, which we treat as
23 // the representative color of the entire image (reasonable, given the current 24 // the representative color of the entire image (reasonable, given the current
24 // appearance of these assets). 25 // appearance of these assets).
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 return; 142 return;
142 143
143 bool inverted = color_utils::IsDark(GetParentBackgroundColor()); 144 bool inverted = color_utils::IsDark(GetParentBackgroundColor());
144 SkColor border_color = inverted ? SK_ColorWHITE : GetBorderColor(); 145 SkColor border_color = inverted ? SK_ColorWHITE : GetBorderColor();
145 SkColor background_color = 146 SkColor background_color =
146 inverted ? SK_ColorWHITE : SkColorSetA(border_color, 0x13); 147 inverted ? SK_ColorWHITE : SkColorSetA(border_color, 0x13);
147 set_background(new BackgroundWith1PxBorder(background_color, border_color)); 148 set_background(new BackgroundWith1PxBorder(background_color, border_color));
148 SetLabelBackgroundColor(background_color); 149 SetLabelBackgroundColor(background_color);
149 } 150 }
150 151
152 void IconLabelBubbleView::AddInkDropLayer(ui::Layer* ink_drop_layer) {
153 image()->SetPaintToLayer(true);
154 image()->SetFillsBoundsOpaquely(false);
155 InkDropHostView::AddInkDropLayer(ink_drop_layer);
156 }
157
158 void IconLabelBubbleView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) {
159 InkDropHostView::RemoveInkDropLayer(ink_drop_layer);
160 image()->SetPaintToLayer(false);
161 }
162
163 scoped_ptr<views::InkDropHover> IconLabelBubbleView::CreateInkDropHover()
164 const {
165 // Location bar views don't show hover effect.
166 return nullptr;
167 }
168
169 SkColor IconLabelBubbleView::GetInkDropBaseColor() const {
170 return color_utils::DeriveDefaultIconColor(GetTextColor());
171 }
172
151 SkColor IconLabelBubbleView::GetParentBackgroundColor() const { 173 SkColor IconLabelBubbleView::GetParentBackgroundColor() const {
152 return ui::MaterialDesignController::IsModeMaterial() 174 return ui::MaterialDesignController::IsModeMaterial()
153 ? GetNativeTheme()->GetSystemColor( 175 ? GetNativeTheme()->GetSystemColor(
154 ui::NativeTheme::kColorId_TextfieldDefaultBackground) 176 ui::NativeTheme::kColorId_TextfieldDefaultBackground)
155 : parent_background_color_; 177 : parent_background_color_;
156 } 178 }
157 179
158 gfx::Size IconLabelBubbleView::GetSizeForLabelWidth(int width) const { 180 gfx::Size IconLabelBubbleView::GetSizeForLabelWidth(int width) const {
159 gfx::Size size(image_->GetPreferredSize()); 181 gfx::Size size(image_->GetPreferredSize());
160 if (ShouldShowBackground()) { 182 if (ShouldShowBackground()) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) { 230 void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) {
209 if (!ShouldShowBackground()) 231 if (!ShouldShowBackground())
210 return; 232 return;
211 if (background_painter_) { 233 if (background_painter_) {
212 views::Painter::PaintPainterAt(canvas, background_painter_.get(), 234 views::Painter::PaintPainterAt(canvas, background_painter_.get(),
213 GetContentsBounds()); 235 GetContentsBounds());
214 } 236 }
215 if (background()) 237 if (background())
216 background()->Paint(canvas, this); 238 background()->Paint(canvas, this);
217 } 239 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/location_bar/icon_label_bubble_view.h ('k') | chrome/browser/ui/views/toolbar/app_menu_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698