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

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

Issue 2724403005: Add a 1px border stroke to the shelf button active app indicator. (Closed)
Patch Set: adjust color and position Created 3 years, 9 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 | « no previous file | no next file » | 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/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
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698