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/frame/caption_buttons/frame_caption_button.h" | 5 #include "ash/common/frame/caption_buttons/frame_caption_button.h" |
6 | 6 |
7 #include "ui/gfx/animation/slide_animation.h" | 7 #include "ui/gfx/animation/slide_animation.h" |
8 #include "ui/gfx/animation/throb_animation.h" | 8 #include "ui/gfx/animation/throb_animation.h" |
9 #include "ui/gfx/canvas.h" | 9 #include "ui/gfx/canvas.h" |
10 #include "ui/gfx/color_palette.h" | 10 #include "ui/gfx/color_palette.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 // Do not flip the gfx::Canvas passed to the OnPaint() method. The snap left | 50 // Do not flip the gfx::Canvas passed to the OnPaint() method. The snap left |
51 // and snap right button icons should not be flipped. The other icons are | 51 // and snap right button icons should not be flipped. The other icons are |
52 // horizontally symmetrical. | 52 // horizontally symmetrical. |
53 } | 53 } |
54 | 54 |
55 FrameCaptionButton::~FrameCaptionButton() {} | 55 FrameCaptionButton::~FrameCaptionButton() {} |
56 | 56 |
57 void FrameCaptionButton::SetImage(CaptionButtonIcon icon, | 57 void FrameCaptionButton::SetImage(CaptionButtonIcon icon, |
58 Animate animate, | 58 Animate animate, |
59 gfx::VectorIconId icon_image_id) { | 59 const gfx::VectorIcon& icon_definition) { |
60 gfx::ImageSkia new_icon_image = gfx::CreateVectorIcon( | 60 gfx::ImageSkia new_icon_image = gfx::CreateVectorIcon( |
61 icon_image_id, use_light_images_ ? SK_ColorWHITE : gfx::kChromeIconGrey); | 61 icon_definition, |
| 62 use_light_images_ ? SK_ColorWHITE : gfx::kChromeIconGrey); |
62 | 63 |
63 // The early return is dependent on |animate| because callers use SetImage() | 64 // The early return is dependent on |animate| because callers use SetImage() |
64 // with ANIMATE_NO to progress the crossfade animation to the end. | 65 // with ANIMATE_NO to progress the crossfade animation to the end. |
65 if (icon == icon_ && | 66 if (icon == icon_ && |
66 (animate == ANIMATE_YES || !swap_images_animation_->is_animating()) && | 67 (animate == ANIMATE_YES || !swap_images_animation_->is_animating()) && |
67 new_icon_image.BackedBySameObjectAs(icon_image_)) { | 68 new_icon_image.BackedBySameObjectAs(icon_image_)) { |
68 return; | 69 return; |
69 } | 70 } |
70 | 71 |
71 if (animate == ANIMATE_YES) | 72 if (animate == ANIMATE_YES) |
72 crossfade_icon_image_ = icon_image_; | 73 crossfade_icon_image_ = icon_image_; |
73 | 74 |
74 icon_ = icon; | 75 icon_ = icon; |
75 icon_image_id_ = icon_image_id; | 76 icon_definition_ = &icon_definition; |
76 icon_image_ = new_icon_image; | 77 icon_image_ = new_icon_image; |
77 | 78 |
78 if (animate == ANIMATE_YES) { | 79 if (animate == ANIMATE_YES) { |
79 swap_images_animation_->Reset(0); | 80 swap_images_animation_->Reset(0); |
80 swap_images_animation_->SetSlideDuration(kSwapImagesAnimationDurationMs); | 81 swap_images_animation_->SetSlideDuration(kSwapImagesAnimationDurationMs); |
81 swap_images_animation_->Show(); | 82 swap_images_animation_->Show(); |
82 } else { | 83 } else { |
83 swap_images_animation_->Reset(1); | 84 swap_images_animation_->Reset(1); |
84 } | 85 } |
85 PreferredSizeChanged(); | 86 PreferredSizeChanged(); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 alpha *= inactive_alpha; | 182 alpha *= inactive_alpha; |
182 } | 183 } |
183 | 184 |
184 SkPaint paint; | 185 SkPaint paint; |
185 paint.setAlpha(alpha); | 186 paint.setAlpha(alpha); |
186 canvas->DrawImageInt(to_center, (width() - to_center.width()) / 2, | 187 canvas->DrawImageInt(to_center, (width() - to_center.width()) / 2, |
187 (height() - to_center.height()) / 2, paint); | 188 (height() - to_center.height()) / 2, paint); |
188 } | 189 } |
189 | 190 |
190 } // namespace ash | 191 } // namespace ash |
OLD | NEW |