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

Side by Side Diff: ash/common/frame/caption_buttons/frame_caption_button.cc

Issue 2618383004: Revert of Move more vector icons to respective directories and update code to (Closed)
Patch Set: Created 3 years, 11 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
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/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
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 const gfx::VectorIcon& icon_definition) { 59 gfx::VectorIconId icon_image_id) {
60 gfx::ImageSkia new_icon_image = gfx::CreateVectorIcon( 60 gfx::ImageSkia new_icon_image = gfx::CreateVectorIcon(
61 icon_definition, 61 icon_image_id, use_light_images_ ? SK_ColorWHITE : gfx::kChromeIconGrey);
62 use_light_images_ ? SK_ColorWHITE : gfx::kChromeIconGrey);
63 62
64 // The early return is dependent on |animate| because callers use SetImage() 63 // The early return is dependent on |animate| because callers use SetImage()
65 // with ANIMATE_NO to progress the crossfade animation to the end. 64 // with ANIMATE_NO to progress the crossfade animation to the end.
66 if (icon == icon_ && 65 if (icon == icon_ &&
67 (animate == ANIMATE_YES || !swap_images_animation_->is_animating()) && 66 (animate == ANIMATE_YES || !swap_images_animation_->is_animating()) &&
68 new_icon_image.BackedBySameObjectAs(icon_image_)) { 67 new_icon_image.BackedBySameObjectAs(icon_image_)) {
69 return; 68 return;
70 } 69 }
71 70
72 if (animate == ANIMATE_YES) 71 if (animate == ANIMATE_YES)
73 crossfade_icon_image_ = icon_image_; 72 crossfade_icon_image_ = icon_image_;
74 73
75 icon_ = icon; 74 icon_ = icon;
76 icon_definition_ = &icon_definition; 75 icon_image_id_ = icon_image_id;
77 icon_image_ = new_icon_image; 76 icon_image_ = new_icon_image;
78 77
79 if (animate == ANIMATE_YES) { 78 if (animate == ANIMATE_YES) {
80 swap_images_animation_->Reset(0); 79 swap_images_animation_->Reset(0);
81 swap_images_animation_->SetSlideDuration(kSwapImagesAnimationDurationMs); 80 swap_images_animation_->SetSlideDuration(kSwapImagesAnimationDurationMs);
82 swap_images_animation_->Show(); 81 swap_images_animation_->Show();
83 } else { 82 } else {
84 swap_images_animation_->Reset(1); 83 swap_images_animation_->Reset(1);
85 } 84 }
86 PreferredSizeChanged(); 85 PreferredSizeChanged();
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 alpha *= inactive_alpha; 181 alpha *= inactive_alpha;
183 } 182 }
184 183
185 SkPaint paint; 184 SkPaint paint;
186 paint.setAlpha(alpha); 185 paint.setAlpha(alpha);
187 canvas->DrawImageInt(to_center, (width() - to_center.width()) / 2, 186 canvas->DrawImageInt(to_center, (width() - to_center.width()) / 2,
188 (height() - to_center.height()) / 2, paint); 187 (height() - to_center.height()) / 2, paint);
189 } 188 }
190 189
191 } // namespace ash 190 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698