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/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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 return GetThrobAnimation().GetCurrentValue(); | 70 return GetThrobAnimation().GetCurrentValue(); |
71 } | 71 } |
72 | 72 |
73 private: | 73 private: |
74 ShelfButtonAnimation() | 74 ShelfButtonAnimation() |
75 : animation_(this) { | 75 : animation_(this) { |
76 animation_.SetThrobDuration(kAttentionThrobDurationMS); | 76 animation_.SetThrobDuration(kAttentionThrobDurationMS); |
77 animation_.SetTweenType(gfx::Tween::SMOOTH_IN_OUT); | 77 animation_.SetTweenType(gfx::Tween::SMOOTH_IN_OUT); |
78 } | 78 } |
79 | 79 |
80 virtual ~ShelfButtonAnimation() { | 80 ~ShelfButtonAnimation() override {} |
81 } | |
82 | 81 |
83 gfx::ThrobAnimation& GetThrobAnimation() { | 82 gfx::ThrobAnimation& GetThrobAnimation() { |
84 if (!animation_.is_animating()) { | 83 if (!animation_.is_animating()) { |
85 animation_.Reset(); | 84 animation_.Reset(); |
86 animation_.StartThrobbing(-1 /*throb indefinitely*/); | 85 animation_.StartThrobbing(-1 /*throb indefinitely*/); |
87 } | 86 } |
88 return animation_; | 87 return animation_; |
89 } | 88 } |
90 | 89 |
91 // gfx::AnimationDelegate | 90 // gfx::AnimationDelegate |
92 virtual void AnimationProgressed(const gfx::Animation* animation) override { | 91 void AnimationProgressed(const gfx::Animation* animation) override { |
93 if (animation != &animation_) | 92 if (animation != &animation_) |
94 return; | 93 return; |
95 if (!animation_.is_animating()) | 94 if (!animation_.is_animating()) |
96 return; | 95 return; |
97 FOR_EACH_OBSERVER(Observer, observers_, AnimationProgressed()); | 96 FOR_EACH_OBSERVER(Observer, observers_, AnimationProgressed()); |
98 } | 97 } |
99 | 98 |
100 gfx::ThrobAnimation animation_; | 99 gfx::ThrobAnimation animation_; |
101 ObserverList<Observer> observers_; | 100 ObserverList<Observer> observers_; |
102 | 101 |
(...skipping 10 matching lines...) Expand all Loading... |
113 class ShelfButton::BarView : public views::ImageView, | 112 class ShelfButton::BarView : public views::ImageView, |
114 public ShelfButtonAnimation::Observer { | 113 public ShelfButtonAnimation::Observer { |
115 public: | 114 public: |
116 BarView(ShelfButton* host) | 115 BarView(ShelfButton* host) |
117 : host_(host), | 116 : host_(host), |
118 show_attention_(false) { | 117 show_attention_(false) { |
119 // Make sure the events reach the parent view for handling. | 118 // Make sure the events reach the parent view for handling. |
120 set_interactive(false); | 119 set_interactive(false); |
121 } | 120 } |
122 | 121 |
123 virtual ~BarView() { | 122 ~BarView() override { |
124 if (show_attention_) | 123 if (show_attention_) |
125 ShelfButtonAnimation::GetInstance()->RemoveObserver(this); | 124 ShelfButtonAnimation::GetInstance()->RemoveObserver(this); |
126 } | 125 } |
127 | 126 |
128 // views::View: | 127 // views::View: |
129 virtual void OnPaint(gfx::Canvas* canvas) override { | 128 void OnPaint(gfx::Canvas* canvas) override { |
130 if (show_attention_) { | 129 if (show_attention_) { |
131 int alpha = ShelfButtonAnimation::GetInstance()->GetAlpha(); | 130 int alpha = ShelfButtonAnimation::GetInstance()->GetAlpha(); |
132 canvas->SaveLayerAlpha(alpha); | 131 canvas->SaveLayerAlpha(alpha); |
133 views::ImageView::OnPaint(canvas); | 132 views::ImageView::OnPaint(canvas); |
134 canvas->Restore(); | 133 canvas->Restore(); |
135 } else { | 134 } else { |
136 views::ImageView::OnPaint(canvas); | 135 views::ImageView::OnPaint(canvas); |
137 } | 136 } |
138 } | 137 } |
139 | 138 |
140 // ShelfButtonAnimation::Observer | 139 // ShelfButtonAnimation::Observer |
141 virtual void AnimationProgressed() override { | 140 void AnimationProgressed() override { |
142 UpdateBounds(); | 141 UpdateBounds(); |
143 SchedulePaint(); | 142 SchedulePaint(); |
144 } | 143 } |
145 | 144 |
146 void SetBarBoundsRect(const gfx::Rect& bounds) { | 145 void SetBarBoundsRect(const gfx::Rect& bounds) { |
147 base_bounds_ = bounds; | 146 base_bounds_ = bounds; |
148 UpdateBounds(); | 147 UpdateBounds(); |
149 } | 148 } |
150 | 149 |
151 void ShowAttention(bool show) { | 150 void ShowAttention(bool show) { |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 views::ImageView::CENTER, | 540 views::ImageView::CENTER, |
542 views::ImageView::CENTER, | 541 views::ImageView::CENTER, |
543 views::ImageView::LEADING)); | 542 views::ImageView::LEADING)); |
544 bar_->SchedulePaint(); | 543 bar_->SchedulePaint(); |
545 } | 544 } |
546 | 545 |
547 bar_->SetVisible(bar_id != 0 && state_ != STATE_NORMAL); | 546 bar_->SetVisible(bar_id != 0 && state_ != STATE_NORMAL); |
548 } | 547 } |
549 | 548 |
550 } // namespace ash | 549 } // namespace ash |
OLD | NEW |