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

Side by Side Diff: ash/shelf/shelf_button.cc

Issue 2849953004: SV Test
Patch Set: Created 3 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
« no previous file with comments | « ash/BUILD.gn ('k') | ash/system/fractional_view/scale_detailed_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ash/shelf/shelf_button.h" 5 #include "ash/shelf/shelf_button.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/ash_constants.h" 9 #include "ash/ash_constants.h"
10 #include "ash/shelf/ink_drop_button_listener.h" 10 #include "ash/shelf/ink_drop_button_listener.h"
11 #include "ash/shelf/shelf_constants.h" 11 #include "ash/shelf/shelf_constants.h"
12 #include "ash/shelf/shelf_view.h" 12 #include "ash/shelf/shelf_view.h"
13 #include "ash/shelf/wm_shelf.h" 13 #include "ash/shelf/wm_shelf.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "skia/ext/image_operations.h" 16 #include "skia/ext/image_operations.h"
17 #include "ui/accessibility/ax_node_data.h" 17 #include "ui/accessibility/ax_node_data.h"
18 #include "ui/compositor/layer.h" 18 #include "ui/compositor/layer.h"
19 #include "ui/gfx/animation/animation_delegate.h" 19 #include "ui/gfx/animation/animation_delegate.h"
20 #include "ui/gfx/animation/throb_animation.h" 20 #include "ui/gfx/animation/throb_animation.h"
21 #include "ui/gfx/canvas.h" 21 #include "ui/gfx/canvas.h"
22 #include "ui/gfx/geometry/vector2d.h" 22 #include "ui/gfx/geometry/vector2d.h"
23 #include "ui/gfx/image/image_skia_operations.h" 23 #include "ui/gfx/image/image_skia_operations.h"
24 #include "ui/gfx/scoped_canvas.h" 24 #include "ui/gfx/scoped_canvas.h"
25 #include "ui/gfx/skbitmap_operations.h" 25 #include "ui/gfx/skbitmap_operations.h"
26 #include "ui/views/animation/ink_drop_impl.h" 26 #include "ui/views/animation/ink_drop_impl.h"
27 #include "ui/views/animation/square_ink_drop_ripple.h" 27 #include "ui/views/animation/square_ink_drop_ripple.h"
28 #include "ui/views/controls/image_view.h" 28 #include "ui/views/controls/image_view.h"
29 29
30 #include "base/debug/stack_trace.h"
31
30 namespace { 32 namespace {
31 33
32 const int kIconSize = 32; 34 const int kIconSize = 32;
33 const int kAttentionThrobDurationMS = 800; 35 const int kAttentionThrobDurationMS = 800;
34 const int kMaxAnimationSeconds = 10; 36 const int kMaxAnimationSeconds = 10;
35 const int kIndicatorOffsetFromBottom = 3; 37 const int kIndicatorOffsetFromBottom = 3;
36 const int kIndicatorRadiusDip = 2; 38 const int kIndicatorRadiusDip = 2;
37 const SkColor kIndicatorColor = SK_ColorWHITE; 39 const SkColor kIndicatorColor = SK_ColorWHITE;
38 40
39 // Shelf item ripple constants. 41 // Shelf item ripple constants.
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 137 }
136 138
137 // views::View: 139 // views::View:
138 void OnPaint(gfx::Canvas* canvas) override { 140 void OnPaint(gfx::Canvas* canvas) override {
139 gfx::ScopedCanvas scoped(canvas); 141 gfx::ScopedCanvas scoped(canvas);
140 if (show_attention_) { 142 if (show_attention_) {
141 SkAlpha alpha = ShelfButtonAnimation::GetInstance()->HasObserver(this) 143 SkAlpha alpha = ShelfButtonAnimation::GetInstance()->HasObserver(this)
142 ? ShelfButtonAnimation::GetInstance()->GetAlpha() 144 ? ShelfButtonAnimation::GetInstance()->GetAlpha()
143 : SK_AlphaOPAQUE; 145 : SK_AlphaOPAQUE;
144 canvas->SaveLayerAlpha(alpha); 146 canvas->SaveLayerAlpha(alpha);
147 LOG(ERROR) << "Alpha: " << alpha;
145 } 148 }
146 149
147 DCHECK_EQ(width(), height()); 150 DCHECK_EQ(width(), height());
148 DCHECK_EQ(kIndicatorRadiusDip, width() / 2); 151 DCHECK_EQ(kIndicatorRadiusDip, width() / 2);
149 const float dsf = canvas->UndoDeviceScaleFactor(); 152 const float dsf = canvas->UndoDeviceScaleFactor();
150 const int kStrokeWidthPx = 1; 153 const int kStrokeWidthPx = 1;
151 gfx::PointF center = gfx::RectF(GetLocalBounds()).CenterPoint(); 154 gfx::PointF center = gfx::RectF(GetLocalBounds()).CenterPoint();
152 center.Scale(dsf); 155 center.Scale(dsf);
156 LOG(ERROR) << "CENTER:" << GetLocalBounds().ToString()
157 << ", center = " << center.ToString()
158 << ", dsf=" << dsf
159 << ", image scale=" << canvas->image_scale();
153 160
154 // Fill the center. 161 // Fill the center.
155 cc::PaintFlags flags; 162 cc::PaintFlags flags;
156 flags.setColor(kIndicatorColor); 163 flags.setColor(kIndicatorColor);
157 flags.setAntiAlias(true); 164 flags.setAntiAlias(true);
158 canvas->DrawCircle(center, dsf * kIndicatorRadiusDip - kStrokeWidthPx, 165 canvas->DrawCircle(center, dsf * kIndicatorRadiusDip - kStrokeWidthPx,
159 flags); 166 flags);
160 167
161 // Stroke the border. 168 // Stroke the border.
162 flags.setColor(SkColorSetA(SK_ColorBLACK, 0x4D)); 169 flags.setColor(SkColorSetA(SK_ColorBLACK, 0x4D));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 shelf_view_(shelf_view), 216 shelf_view_(shelf_view),
210 icon_view_(new views::ImageView()), 217 icon_view_(new views::ImageView()),
211 indicator_(new AppStatusIndicatorView()), 218 indicator_(new AppStatusIndicatorView()),
212 state_(STATE_NORMAL), 219 state_(STATE_NORMAL),
213 destroyed_flag_(nullptr) { 220 destroyed_flag_(nullptr) {
214 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); 221 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY);
215 SetInkDropMode(InkDropMode::ON); 222 SetInkDropMode(InkDropMode::ON);
216 set_ink_drop_base_color(kShelfInkDropBaseColor); 223 set_ink_drop_base_color(kShelfInkDropBaseColor);
217 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity); 224 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity);
218 225
226 //indicator_->SetPaintToLayer();
227 //indicator_->layer()->SetFillsBoundsOpaquely(false);
228
219 const gfx::ShadowValue kShadows[] = { 229 const gfx::ShadowValue kShadows[] = {
220 gfx::ShadowValue(gfx::Vector2d(0, 2), 0, SkColorSetARGB(0x1A, 0, 0, 0)), 230 gfx::ShadowValue(gfx::Vector2d(0, 2), 0, SkColorSetARGB(0x1A, 0, 0, 0)),
221 gfx::ShadowValue(gfx::Vector2d(0, 3), 1, SkColorSetARGB(0x1A, 0, 0, 0)), 231 gfx::ShadowValue(gfx::Vector2d(0, 3), 1, SkColorSetARGB(0x1A, 0, 0, 0)),
222 gfx::ShadowValue(gfx::Vector2d(0, 0), 1, SkColorSetARGB(0x54, 0, 0, 0)), 232 gfx::ShadowValue(gfx::Vector2d(0, 0), 1, SkColorSetARGB(0x54, 0, 0, 0)),
223 }; 233 };
224 icon_shadows_.assign(kShadows, kShadows + arraysize(kShadows)); 234 icon_shadows_.assign(kShadows, kShadows + arraysize(kShadows));
225 235
226 // TODO: refactor the layers so each button doesn't require 2. 236 // TODO: refactor the layers so each button doesn't require 2.
227 icon_view_->SetPaintToLayer(); 237 //icon_view_->SetPaintToLayer();
228 icon_view_->layer()->SetFillsBoundsOpaquely(false); 238 //icon_view_->layer()->SetFillsBoundsOpaquely(false);
229 icon_view_->SetHorizontalAlignment(views::ImageView::CENTER); 239 icon_view_->SetHorizontalAlignment(views::ImageView::CENTER);
230 icon_view_->SetVerticalAlignment(views::ImageView::LEADING); 240 icon_view_->SetVerticalAlignment(views::ImageView::LEADING);
231 // Do not make this interactive, so that events are sent to ShelfView. 241 // Do not make this interactive, so that events are sent to ShelfView.
232 icon_view_->set_can_process_events_within_subtree(false); 242 icon_view_->set_can_process_events_within_subtree(false);
233 243
244 AddChildView(icon_view_);
234 AddChildView(indicator_); 245 AddChildView(indicator_);
235 AddChildView(icon_view_);
236 } 246 }
237 247
238 ShelfButton::~ShelfButton() { 248 ShelfButton::~ShelfButton() {
239 if (destroyed_flag_) 249 if (destroyed_flag_)
240 *destroyed_flag_ = true; 250 *destroyed_flag_ = true;
241 } 251 }
242 252
243 void ShelfButton::SetShadowedImage(const gfx::ImageSkia& image) { 253 void ShelfButton::SetShadowedImage(const gfx::ImageSkia& image) {
244 icon_view_->SetImage(gfx::ImageSkiaOperations::CreateImageWithDropShadow( 254 icon_view_->SetImage(gfx::ImageSkiaOperations::CreateImageWithDropShadow(
245 image, icon_shadows_)); 255 image, icon_shadows_));
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 icon_view_->SetHorizontalAlignment(is_horizontal_shelf 515 icon_view_->SetHorizontalAlignment(is_horizontal_shelf
506 ? views::ImageView::CENTER 516 ? views::ImageView::CENTER
507 : views::ImageView::LEADING); 517 : views::ImageView::LEADING);
508 icon_view_->SetVerticalAlignment(is_horizontal_shelf 518 icon_view_->SetVerticalAlignment(is_horizontal_shelf
509 ? views::ImageView::LEADING 519 ? views::ImageView::LEADING
510 : views::ImageView::CENTER); 520 : views::ImageView::CENTER);
511 SchedulePaint(); 521 SchedulePaint();
512 } 522 }
513 523
514 } // namespace ash 524 } // namespace ash
OLDNEW
« no previous file with comments | « ash/BUILD.gn ('k') | ash/system/fractional_view/scale_detailed_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698