Chromium Code Reviews| 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 128 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(); | |
|
Daniel Erat
2017/03/03 23:15:52
i don't know much about device scale factors, but
Evan Stade
2017/03/04 01:02:22
the scopedcanvas above takes care of that. Technic
Daniel Erat
2017/03/04 01:17:05
ah, sorry. i missed both the fact that a ScopedCan
| |
| 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, 0x29)); | |
| 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 |