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

Side by Side Diff: chrome/browser/ui/views/toolbar/app_menu_animation.cc

Issue 2843413003: [Views] App Menu Icon Update (Closed)
Patch Set: Fixes for msw Created 3 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "chrome/browser/ui/views/toolbar/app_menu_animation.h" 5 #include "chrome/browser/ui/views/toolbar/app_menu_animation.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "cc/paint/paint_flags.h" 8 #include "cc/paint/paint_flags.h"
9 #include "chrome/browser/ui/views/toolbar/app_menu_button.h" 9 #include "chrome/browser/ui/views/toolbar/app_menu_button.h"
10 #include "ui/gfx/animation/tween.h" 10 #include "ui/gfx/animation/tween.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 flags.setColor(color); 117 flags.setColor(color);
118 flags.setStrokeWidth(bounds.height() * kCloseStroke); 118 flags.setStrokeWidth(bounds.height() * kCloseStroke);
119 flags.setStrokeCap(cc::PaintFlags::kRound_Cap); 119 flags.setStrokeCap(cc::PaintFlags::kRound_Cap);
120 flags.setStyle(cc::PaintFlags::kFill_Style); 120 flags.setStyle(cc::PaintFlags::kFill_Style);
121 flags.setAntiAlias(true); 121 flags.setAntiAlias(true);
122 122
123 gfx::SizeF dot_size = gfx::SizeF(dot_width, dot_height); 123 gfx::SizeF dot_size = gfx::SizeF(dot_width, dot_height);
124 canvas->DrawRoundRect(gfx::RectF(point, dot_size), 2.0, flags); 124 canvas->DrawRoundRect(gfx::RectF(point, dot_size), 2.0, flags);
125 } 125 }
126 126
127 AppMenuAnimation::AppMenuAnimation(AppMenuButton* owner, 127 AppMenuAnimation::AppMenuAnimation(AppMenuButton* owner, SkColor initial_color)
128 bool should_animate_closed)
129 : owner_(owner), 128 : owner_(owner),
130 should_animate_closed_(should_animate_closed),
131 animation_(base::MakeUnique<gfx::SlideAnimation>(this)), 129 animation_(base::MakeUnique<gfx::SlideAnimation>(this)),
132 bottom_dot_(base::TimeDelta(), 130 bottom_dot_(base::TimeDelta(),
133 kBottomWidthOpenInterval, 131 kBottomWidthOpenInterval,
134 kBottomStrokeOpenInterval), 132 kBottomStrokeOpenInterval),
135 middle_dot_(base::TimeDelta::FromMilliseconds(kDotDelayMs), 133 middle_dot_(base::TimeDelta::FromMilliseconds(kDotDelayMs),
136 kMiddleWidthOpenInterval, 134 kMiddleWidthOpenInterval,
137 kMiddleStrokeOpenInterval), 135 kMiddleStrokeOpenInterval),
138 top_dot_(base::TimeDelta::FromMilliseconds(kDotDelayMs * 2), 136 top_dot_(base::TimeDelta::FromMilliseconds(kDotDelayMs * 2),
139 kTopWidthOpenInterval, 137 kTopWidthOpenInterval,
140 kTopStrokeOpenInterval), 138 kTopStrokeOpenInterval),
141 start_color_(gfx::kPlaceholderColor), 139 start_color_(initial_color),
142 severity_color_(gfx::kPlaceholderColor) { 140 severity_color_(initial_color) {
143 animation_->SetSlideDuration(kOpenDurationMs); 141 animation_->SetSlideDuration(kOpenDurationMs);
144 animation_->SetTweenType(gfx::Tween::FAST_OUT_SLOW_IN); 142 animation_->SetTweenType(gfx::Tween::FAST_OUT_SLOW_IN);
145 } 143 }
146 144
147 AppMenuAnimation::~AppMenuAnimation() {} 145 AppMenuAnimation::~AppMenuAnimation() {}
148 146
149 void AppMenuAnimation::PaintAppMenu(gfx::Canvas* canvas, 147 void AppMenuAnimation::PaintAppMenu(gfx::Canvas* canvas,
150 const gfx::Rect& bounds) { 148 const gfx::Rect& bounds) {
151 gfx::PointF middle_point = gfx::PointF(bounds.CenterPoint()); 149 gfx::PointF middle_point = gfx::PointF(bounds.CenterPoint());
152 float y_offset = kDotYOffset * bounds.height(); 150 float y_offset = kDotYOffset * bounds.height();
153 gfx::PointF top_point = middle_point; 151 gfx::PointF top_point = middle_point;
154 top_point.Offset(0, -y_offset); 152 top_point.Offset(0, -y_offset);
155 153
156 gfx::PointF bottom_point = middle_point; 154 gfx::PointF bottom_point = middle_point;
157 bottom_point.Offset(0, y_offset); 155 bottom_point.Offset(0, y_offset);
158 156
159 middle_dot_.Paint(middle_point, start_color_, severity_color_, canvas, bounds, 157 middle_dot_.Paint(middle_point, start_color_, severity_color_, canvas, bounds,
160 animation_.get()); 158 animation_.get());
161 top_dot_.Paint(top_point, start_color_, severity_color_, canvas, bounds, 159 top_dot_.Paint(top_point, start_color_, severity_color_, canvas, bounds,
162 animation_.get()); 160 animation_.get());
163 bottom_dot_.Paint(bottom_point, start_color_, severity_color_, canvas, bounds, 161 bottom_dot_.Paint(bottom_point, start_color_, severity_color_, canvas, bounds,
164 animation_.get()); 162 animation_.get());
165 } 163 }
166 164
167 void AppMenuAnimation::SetIconColors(SkColor start_color,
168 SkColor severity_color) {
169 start_color_ = start_color;
170 severity_color_ = severity_color;
171 }
172
173 void AppMenuAnimation::StartAnimation() { 165 void AppMenuAnimation::StartAnimation() {
174 if (!animation_->is_animating()) { 166 if (!animation_->is_animating()) {
175 animation_->SetSlideDuration(kOpenDurationMs); 167 animation_->SetSlideDuration(kOpenDurationMs);
176 animation_->Show(); 168 animation_->Show();
177 owner_->AppMenuAnimationStarted(); 169 owner_->AppMenuAnimationStarted();
178 } 170 }
179 } 171 }
180 172
181 void AppMenuAnimation::AnimationEnded(const gfx::Animation* animation) { 173 void AppMenuAnimation::AnimationEnded(const gfx::Animation* animation) {
182 if (animation_->IsShowing() && should_animate_closed_) { 174 if (animation_->IsShowing()) {
183 animation_->SetSlideDuration(kCloseDurationMs); 175 animation_->SetSlideDuration(kCloseDurationMs);
184 animation_->Hide(); 176 animation_->Hide();
185 return; 177 } else {
178 start_color_ = severity_color_;
186 } 179 }
187 180
188 if (!animation_->IsShowing())
189 start_color_ = severity_color_;
190
191 owner_->AppMenuAnimationEnded(); 181 owner_->AppMenuAnimationEnded();
192 } 182 }
193 183
194 void AppMenuAnimation::AnimationProgressed(const gfx::Animation* animation) { 184 void AppMenuAnimation::AnimationProgressed(const gfx::Animation* animation) {
195 owner_->SchedulePaint(); 185 owner_->SchedulePaint();
196 } 186 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698