OLD | NEW |
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/common/shelf/shelf_button.h" | 5 #include "ash/common/shelf/shelf_button.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/common/ash_constants.h" | 9 #include "ash/common/ash_constants.h" |
10 #include "ash/common/shelf/ink_drop_button_listener.h" | 10 #include "ash/common/shelf/ink_drop_button_listener.h" |
(...skipping 14 matching lines...) Expand all Loading... |
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 namespace { | 30 namespace { |
31 | 31 |
32 const int kIconSize = 32; | 32 const int kIconSize = 32; |
33 const int kAttentionThrobDurationMS = 800; | 33 const int kAttentionThrobDurationMS = 800; |
34 const int kMaxAnimationSeconds = 10; | 34 const int kMaxAnimationSeconds = 10; |
35 const int kIndicatorOffsetFromBottom = 2; | 35 const int kIndicatorOffsetFromBottom = 3; |
36 const int kIndicatorRadiusDip = 2; | 36 const int kIndicatorRadiusDip = 2; |
37 const SkColor kIndicatorColor = SK_ColorWHITE; | 37 const SkColor kIndicatorColor = SK_ColorWHITE; |
38 | 38 |
39 // Shelf item ripple constants. | 39 // Shelf item ripple constants. |
40 const int kInkDropSmallSize = 48; | 40 const int kInkDropSmallSize = 48; |
41 const int kInkDropLargeSize = 60; | 41 const int kInkDropLargeSize = 60; |
42 | 42 |
43 // Padding from the edge of the shelf to the application icon when the shelf | 43 // Padding from the edge of the shelf to the application icon when the shelf |
44 // is horizontally and vertically aligned, respectively. | 44 // is horizontally and vertically aligned, respectively. |
45 const int kIconPaddingHorizontal = 7; | 45 const int kIconPaddingHorizontal = 7; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 gfx::ScopedCanvas scoped(canvas); | 139 gfx::ScopedCanvas scoped(canvas); |
140 if (show_attention_) { | 140 if (show_attention_) { |
141 SkAlpha alpha = ShelfButtonAnimation::GetInstance()->HasObserver(this) | 141 SkAlpha alpha = ShelfButtonAnimation::GetInstance()->HasObserver(this) |
142 ? ShelfButtonAnimation::GetInstance()->GetAlpha() | 142 ? ShelfButtonAnimation::GetInstance()->GetAlpha() |
143 : SK_AlphaOPAQUE; | 143 : SK_AlphaOPAQUE; |
144 canvas->SaveLayerAlpha(alpha); | 144 canvas->SaveLayerAlpha(alpha); |
145 } | 145 } |
146 | 146 |
147 DCHECK_EQ(width(), height()); | 147 DCHECK_EQ(width(), height()); |
148 DCHECK_EQ(kIndicatorRadiusDip, width() / 2); | 148 DCHECK_EQ(kIndicatorRadiusDip, width() / 2); |
| 149 const float dsf = canvas->UndoDeviceScaleFactor(); |
| 150 const int kStrokeWidthPx = 1; |
| 151 gfx::PointF center = gfx::RectF(GetLocalBounds()).CenterPoint(); |
| 152 center.Scale(dsf); |
| 153 |
| 154 // Fill the center. |
149 cc::PaintFlags flags; | 155 cc::PaintFlags flags; |
150 flags.setColor(kIndicatorColor); | 156 flags.setColor(kIndicatorColor); |
151 flags.setFlags(cc::PaintFlags::kAntiAlias_Flag); | 157 flags.setFlags(cc::PaintFlags::kAntiAlias_Flag); |
152 canvas->DrawCircle(gfx::Point(width() / 2, height() / 2), | 158 canvas->DrawCircle(center, dsf * kIndicatorRadiusDip - kStrokeWidthPx, |
153 kIndicatorRadiusDip, flags); | 159 flags); |
| 160 |
| 161 // Stroke the border. |
| 162 flags.setColor(SkColorSetA(SK_ColorBLACK, 0x4D)); |
| 163 flags.setStyle(SkPaint::kStroke_Style); |
| 164 canvas->DrawCircle( |
| 165 center, dsf * kIndicatorRadiusDip - kStrokeWidthPx / 2.0f, flags); |
154 } | 166 } |
155 | 167 |
156 // ShelfButtonAnimation::Observer | 168 // ShelfButtonAnimation::Observer |
157 void AnimationProgressed() override { | 169 void AnimationProgressed() override { |
158 UpdateAnimating(); | 170 UpdateAnimating(); |
159 SchedulePaint(); | 171 SchedulePaint(); |
160 } | 172 } |
161 | 173 |
162 void ShowAttention(bool show) { | 174 void ShowAttention(bool show) { |
163 if (show_attention_ == show) | 175 if (show_attention_ == show) |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 icon_view_->SetHorizontalAlignment(is_horizontal_shelf | 505 icon_view_->SetHorizontalAlignment(is_horizontal_shelf |
494 ? views::ImageView::CENTER | 506 ? views::ImageView::CENTER |
495 : views::ImageView::LEADING); | 507 : views::ImageView::LEADING); |
496 icon_view_->SetVerticalAlignment(is_horizontal_shelf | 508 icon_view_->SetVerticalAlignment(is_horizontal_shelf |
497 ? views::ImageView::LEADING | 509 ? views::ImageView::LEADING |
498 : views::ImageView::CENTER); | 510 : views::ImageView::CENTER); |
499 SchedulePaint(); | 511 SchedulePaint(); |
500 } | 512 } |
501 | 513 |
502 } // namespace ash | 514 } // namespace ash |
OLD | NEW |