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/frame/caption_buttons/frame_caption_button.h" | 5 #include "ash/frame/caption_buttons/frame_caption_button.h" |
6 | 6 |
7 #include "ui/base/resource/resource_bundle.h" | 7 #include "ui/base/resource/resource_bundle.h" |
8 #include "ui/gfx/animation/slide_animation.h" | 8 #include "ui/gfx/animation/slide_animation.h" |
9 #include "ui/gfx/animation/throb_animation.h" | 9 #include "ui/gfx/animation/throb_animation.h" |
10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 NotifyClick(*event); | 163 NotifyClick(*event); |
164 event->StopPropagation(); | 164 event->StopPropagation(); |
165 } | 165 } |
166 } | 166 } |
167 CustomButton::OnGestureEvent(event); | 167 CustomButton::OnGestureEvent(event); |
168 } | 168 } |
169 | 169 |
170 void FrameCaptionButton::PaintCentered(gfx::Canvas* canvas, | 170 void FrameCaptionButton::PaintCentered(gfx::Canvas* canvas, |
171 const gfx::ImageSkia& to_center, | 171 const gfx::ImageSkia& to_center, |
172 int alpha) { | 172 int alpha) { |
173 if (!paint_as_active_) | 173 if (!paint_as_active_) { |
174 alpha *= kInactiveIconAlpha; | 174 // Paint icons as active when they are hovered over or pressed. |
175 double inactive_alpha = kInactiveIconAlpha; | |
176 if (hover_animation_->is_animating() || state() == STATE_HOVERED) { | |
oshima
2015/03/17 17:31:39
if (hover_animation_->is_animating())
inactive_a
benwells
2015/03/17 23:24:54
Done.
| |
177 inactive_alpha = | |
178 hover_animation_->is_animating() | |
179 ? hover_animation_->CurrentValueBetween(inactive_alpha, 1.0f) | |
180 : 1.0f; | |
181 } else if (state() == STATE_PRESSED) { | |
182 inactive_alpha = 1.0f; | |
183 } | |
184 alpha *= inactive_alpha; | |
185 } | |
175 | 186 |
176 SkPaint paint; | 187 SkPaint paint; |
177 paint.setAlpha(alpha); | 188 paint.setAlpha(alpha); |
178 canvas->DrawImageInt(to_center, | 189 canvas->DrawImageInt(to_center, |
179 (width() - to_center.width()) / 2, | 190 (width() - to_center.width()) / 2, |
180 (height() - to_center.height()) / 2, | 191 (height() - to_center.height()) / 2, |
181 paint); | 192 paint); |
182 } | 193 } |
183 | 194 |
184 } // namespace ash | 195 } // namespace ash |
OLD | NEW |