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

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

Issue 1932433002: Update activity indicator from a light bar to a point (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« ash/shelf/shelf_button.h ('K') | « ash/shelf/shelf_button.h ('k') | 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/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/ash_switches.h" 10 #include "ash/ash_switches.h"
(...skipping 19 matching lines...) Expand all
30 namespace { 30 namespace {
31 31
32 // Size of the bar. This is along the opposite axis of the shelf. For example, 32 // Size of the bar. This is along the opposite axis of the shelf. For example,
33 // if the shelf is aligned horizontally then this is the height of the bar. 33 // if the shelf is aligned horizontally then this is the height of the bar.
34 const int kBarSize = 3; 34 const int kBarSize = 3;
35 const int kIconSize = 32; 35 const int kIconSize = 32;
36 const int kIconPad = 5; 36 const int kIconPad = 5;
37 const int kIconPadVertical = 6; 37 const int kIconPadVertical = 6;
38 const int kAttentionThrobDurationMS = 800; 38 const int kAttentionThrobDurationMS = 800;
39 const int kMaxAnimationSeconds = 10; 39 const int kMaxAnimationSeconds = 10;
40 const int kShelfIconHeight = 48;
41 const int kShelfIconWidth = 48;
42 const int kBarPadVertical = 3;
43 const int kBarRadius = 2;
40 44
41 // Simple AnimationDelegate that owns a single ThrobAnimation instance to 45 // Simple AnimationDelegate that owns a single ThrobAnimation instance to
42 // keep all Draw Attention animations in sync. 46 // keep all Draw Attention animations in sync.
43 class ShelfButtonAnimation : public gfx::AnimationDelegate { 47 class ShelfButtonAnimation : public gfx::AnimationDelegate {
44 public: 48 public:
45 class Observer { 49 class Observer {
46 public: 50 public:
47 virtual void AnimationProgressed() = 0; 51 virtual void AnimationProgressed() = 0;
48 52
49 protected: 53 protected:
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 int bar_id = 0; 483 int bar_id = 0;
480 if (state_ & (STATE_ACTIVE)) 484 if (state_ & (STATE_ACTIVE))
481 bar_id = IDR_ASH_SHELF_UNDERLINE_ACTIVE; 485 bar_id = IDR_ASH_SHELF_UNDERLINE_ACTIVE;
482 else if (state_ & STATE_ATTENTION) 486 else if (state_ & STATE_ATTENTION)
483 bar_id = IDR_ASH_SHELF_UNDERLINE_ATTENTION; 487 bar_id = IDR_ASH_SHELF_UNDERLINE_ATTENTION;
484 else if (state_ & STATE_RUNNING) 488 else if (state_ & STATE_RUNNING)
485 bar_id = IDR_ASH_SHELF_UNDERLINE_RUNNING; 489 bar_id = IDR_ASH_SHELF_UNDERLINE_RUNNING;
486 490
487 if (bar_id != 0) { 491 if (bar_id != 0) {
488 Shelf* shelf = shelf_view_->shelf(); 492 Shelf* shelf = shelf_view_->shelf();
489 ResourceBundle* rb = &ResourceBundle::GetSharedInstance(); 493 // ResourceBundle* rb = &ResourceBundle::GetSharedInstance();
varkha 2016/04/28 16:49:03 nit: You probably want to remove this before landi
yiyix 2016/05/02 15:55:04 I keep these lines, so it is easier to add the ash
490 gfx::ImageSkia image = *rb->GetImageNamed(bar_id).ToImageSkia(); 494 // gfx::ImageSkia image = *rb->GetImageNamed(bar_id).ToImageSkia();
bruthig 2016/04/27 18:56:00 FYI You will need to 'hide' this feature behind th
yiyix 2016/05/02 15:55:03 Done.
495 gfx::Canvas canvas(gfx::Size(kShelfIconHeight, kShelfIconWidth),
496 kShelfIconHeight, true /* is_opaque */);
497 GetActivityIndicatorImage(canvas);
498 gfx::ImageSkia image = gfx::ImageSkia(canvas.ExtractImageRep());
491 if (!shelf->IsHorizontalAlignment()) { 499 if (!shelf->IsHorizontalAlignment()) {
492 image = gfx::ImageSkiaOperations::CreateRotatedImage( 500 image = gfx::ImageSkiaOperations::CreateRotatedImage(
493 image, shelf->alignment() == SHELF_ALIGNMENT_LEFT 501 image, shelf->alignment() == SHELF_ALIGNMENT_LEFT
494 ? SkBitmapOperations::ROTATION_90_CW 502 ? SkBitmapOperations::ROTATION_90_CW
495 : SkBitmapOperations::ROTATION_270_CW); 503 : SkBitmapOperations::ROTATION_270_CW);
496 } 504 }
497 bar_->SetImage(image); 505 bar_->SetImage(image);
498 bar_->SetHorizontalAlignment(shelf->SelectValueForShelfAlignment( 506 bar_->SetHorizontalAlignment(shelf->SelectValueForShelfAlignment(
499 views::ImageView::CENTER, views::ImageView::LEADING, 507 views::ImageView::CENTER, views::ImageView::LEADING,
500 views::ImageView::TRAILING)); 508 views::ImageView::TRAILING));
501 bar_->SetVerticalAlignment(shelf->SelectValueForShelfAlignment( 509 bar_->SetVerticalAlignment(shelf->SelectValueForShelfAlignment(
502 views::ImageView::TRAILING, views::ImageView::CENTER, 510 views::ImageView::TRAILING, views::ImageView::CENTER,
503 views::ImageView::CENTER)); 511 views::ImageView::CENTER));
504 bar_->SchedulePaint(); 512 bar_->SchedulePaint();
505 } 513 }
506
507 bar_->SetVisible(bar_id != 0 && state_ != STATE_NORMAL); 514 bar_->SetVisible(bar_id != 0 && state_ != STATE_NORMAL);
508 } 515 }
509 516
517 void ShelfButton::GetActivityIndicatorImage(gfx::Canvas& canvas) {
518 SkCanvas* skcanvas = canvas.sk_canvas();
519 SkPaint paint;
bruthig 2016/04/27 18:56:00 Make sure to #include everything you use. i.e. Sk
yiyix 2016/05/02 15:55:04 Done.
520 paint.setColor(SK_ColorWHITE);
bruthig 2016/04/27 18:56:00 nit: Assign SK_ColorWHITE to a constant above and
yiyix 2016/05/02 15:55:03 Done.
521 int patVertical = kBarPadVertical + kBarRadius;
bruthig 2016/04/27 18:56:00 Should this be 'padVertical'?
yiyix 2016/05/02 15:55:03 Done.
522 skcanvas->drawCircle(kShelfIconWidth / 2, kShelfIconHeight - patVertical, 2,
bruthig 2016/04/27 18:56:00 Is it necessary to paint to the SkCanvas or would
yiyix 2016/05/02 15:55:04 Good catch. I draw the circle in Canvas now.
523 paint);
524 }
525
510 } // namespace ash 526 } // namespace ash
OLDNEW
« ash/shelf/shelf_button.h ('K') | « ash/shelf/shelf_button.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698