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

Side by Side Diff: chrome/browser/ui/panels/panel_slide_animation.cc

Issue 8826002: Panels: Adding 3-step animation on minimize on Linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more fixes for win Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/panels/panel_slide_animation.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/panels/panel_slide_animation.h"
6
7 #include "chrome/browser/ui/panels/panel.h"
8
9 namespace {
prasadt 2011/12/06 23:21:30 Empty line needed as per coding-style.
Dmitry Titov 2011/12/07 03:46:04 Done.
10 // These values are experimental and subjective.
11 const int kSetBoundsAnimationMs = 180;
12 const int kSetBoundsAnimationMinimizeMs = 1500;
prasadt 2011/12/06 23:21:30 Empty line needed as per coding-style.
Dmitry Titov 2011/12/07 03:46:04 Done.
13 }
14
15 PanelSlideAnimation::PanelSlideAnimation(ui::AnimationDelegate* target,
16 Panel* panel,
17 gfx::Rect initial_bounds,
18 gfx::Rect final_bounds)
19 : ui::SlideAnimation(target),
20 panel_(panel),
21 for_minimize_(false),
22 animation_stop_to_show_titlebar_(0) {
23 // Detect animation that happens when expansion state is set to MINIMIZED
24 // and there is relatively big portion of the panel to hide from view.
25 // Initialize animation differently in this case, using fast-pause-slow
26 // method, see below for more details.
27 int duration = kSetBoundsAnimationMs;
28 if (panel_->expansion_state() == Panel::MINIMIZED) {
29 double hidden_title_height =
30 panel_->TitleOnlyHeight() - final_bounds.height();
31 double distance_y = initial_bounds.height() - final_bounds.height();
32 animation_stop_to_show_titlebar_ = 1.0 - hidden_title_height / distance_y;
33 if (animation_stop_to_show_titlebar_ > 0.7) { // Relatively big movement.
prasadt 2011/12/06 23:21:30 I find it easier to read the other way: distance_
Dmitry Titov 2011/12/07 03:46:04 Hmm. it would add another long-name variable. Why
prasadt 2011/12/07 17:59:31 distance_to_title_height_ratio tells me its a rati
34 for_minimize_ = true;
prasadt 2011/12/06 23:21:30 for_minimize_ is not quite what it is. How about c
Dmitry Titov 2011/12/07 03:46:04 I wanted to capture "we are doing minimize animati
35 duration = kSetBoundsAnimationMinimizeMs;
prasadt 2011/12/06 23:21:30 Same comment - I suggest calling it kSetBoundsAnim
Dmitry Titov 2011/12/07 03:46:04 Ditto. 3 steps is just current impl of it.
36 }
37 }
38 SetSlideDuration(duration);
39 }
40
41 PanelSlideAnimation::~PanelSlideAnimation() { }
42
43 double PanelSlideAnimation::GetCurrentValue() const {
44 double progress = ui::SlideAnimation::GetCurrentValue();
45 if (!for_minimize_) {
46 // Cubic easing out.
47 float value = 1.0 - progress;
48 return 1.0 - value * value * value;
49 }
50
51 // Minimize animation:
prasadt 2011/12/06 23:21:30 Minimize animation: -> Three step animation:
dcheng 2011/12/06 23:49:01 Doesn't the 3-step animation only apply to minimiz
prasadt 2011/12/06 23:58:11 3-step implies minimizing but minimizing does not
dcheng 2011/12/07 00:02:45 I see. I don't think three step is particularly sp
Dmitry Titov 2011/12/07 03:46:04 I changed comment to mention that minimize animati
52 // 1. Quickly (0 -> 0.15) make only titlebar visible.
53 // 2. Stay a little bit (0.15->0.6) in place, just showing titlebar.
54 // 3. Slowly minimize to thin strip (0.6->1.0)
55 const double kAnimationStopAfterQuickDecrease = 0.15;
56 const double kAnimationStopAfterShowingTitlebar = 0.6;
57 double value;
58 if (progress <= kAnimationStopAfterQuickDecrease) {
59 value = progress * animation_stop_to_show_titlebar_ /
60 kAnimationStopAfterQuickDecrease;
prasadt 2011/12/06 23:21:30 I think the intent comes through more clearly if y
Dmitry Titov 2011/12/07 03:46:04 Done.
61 } else if (progress <= kAnimationStopAfterShowingTitlebar) {
prasadt 2011/12/06 23:21:30 Shouldn't the if condition be: if (progress <= (kA
Dmitry Titov 2011/12/07 03:46:04 Discussed offline, changed constants names to be m
62 value = animation_stop_to_show_titlebar_;
63 } else {
64 value = animation_stop_to_show_titlebar_ +
65 (progress - kAnimationStopAfterShowingTitlebar) *
66 (1.0 - animation_stop_to_show_titlebar_) /
67 (1.0 - kAnimationStopAfterShowingTitlebar);
prasadt 2011/12/06 23:21:30 The above equation doesn't seem to add up for some
Dmitry Titov 2011/12/07 03:46:04 Changed from 'physical' (time past * speed) to 'ma
68 }
69 return value;
70 }
71
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel_slide_animation.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698