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

Side by Side Diff: views/layer_property_setter.cc

Issue 7972023: Implicit animations through Layer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More tweaks Created 9 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « views/layer_property_setter.h ('k') | views/widget/native_widget_aura.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 "views/layer_property_setter.h" 5 #include "views/layer_property_setter.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "ui/gfx/compositor/compositor.h" 8 #include "ui/gfx/compositor/compositor.h"
9 #include "ui/gfx/compositor/layer.h" 9 #include "ui/gfx/compositor/layer.h"
10 #include "ui/gfx/compositor/layer_animator.h"
11 10
12 namespace views { 11 namespace views {
13 12
14 namespace { 13 namespace {
15 14
16 // DefaultSetter --------------------------------------------------------------- 15 // DefaultSetter ---------------------------------------------------------------
17 16
18 class DefaultSetter : public LayerPropertySetter { 17 class DefaultSetter : public LayerPropertySetter {
19 public: 18 public:
20 DefaultSetter(); 19 DefaultSetter();
(...skipping 20 matching lines...) Expand all
41 40
42 void DefaultSetter::SetTransform(ui::Layer* layer, 41 void DefaultSetter::SetTransform(ui::Layer* layer,
43 const ui::Transform& transform) { 42 const ui::Transform& transform) {
44 layer->SetTransform(transform); 43 layer->SetTransform(transform);
45 } 44 }
46 45
47 void DefaultSetter::SetBounds(ui::Layer* layer, const gfx::Rect& bounds) { 46 void DefaultSetter::SetBounds(ui::Layer* layer, const gfx::Rect& bounds) {
48 layer->SetBounds(bounds); 47 layer->SetBounds(bounds);
49 } 48 }
50 49
51 // AnimatingSetter -------------------------------------------------------------
52
53 class AnimatingSetter : public LayerPropertySetter {
54 public:
55 AnimatingSetter();
56
57 // LayerPropertySetter:
58 virtual void Installed(ui::Layer* layer) OVERRIDE;
59 virtual void Uninstalled(ui::Layer* layer) OVERRIDE;
60 virtual void SetTransform(ui::Layer* layer,
61 const ui::Transform& transform) OVERRIDE;
62 virtual void SetBounds(ui::Layer* layer, const gfx::Rect& bounds) OVERRIDE;
63
64 private:
65 scoped_ptr<ui::LayerAnimator> animator_;
66
67 DISALLOW_COPY_AND_ASSIGN(AnimatingSetter);
68 };
69
70 AnimatingSetter::AnimatingSetter() {
71 }
72
73 void AnimatingSetter::Installed(ui::Layer* layer) {
74 animator_.reset(new ui::LayerAnimator(layer));
75 }
76
77 void AnimatingSetter::Uninstalled(ui::Layer* layer) {
78 animator_.reset();
79 }
80
81 void AnimatingSetter::SetTransform(ui::Layer* layer,
82 const ui::Transform& transform) {
83 animator_->AnimateTransform(transform);
84 }
85
86 void AnimatingSetter::SetBounds(ui::Layer* layer, const gfx::Rect& bounds) {
87 if (bounds.size() == animator_->layer()->bounds().size())
88 animator_->AnimateToPoint(bounds.origin());
89 else
90 animator_->StopAnimatingToPoint();
91 }
92
93 } // namespace 50 } // namespace
94 51
95 // LayerPropertySetter --------------------------------------------------------- 52 // LayerPropertySetter ---------------------------------------------------------
96 53
97 // static 54 // static
98 LayerPropertySetter* LayerPropertySetter::CreateDefaultSetter() { 55 LayerPropertySetter* LayerPropertySetter::CreateDefaultSetter() {
99 return new DefaultSetter; 56 return new DefaultSetter;
100 } 57 }
101 58
102 // static
103 LayerPropertySetter* LayerPropertySetter::CreateAnimatingSetter() {
104 return new AnimatingSetter();
105 }
106
107 } // namespace views 59 } // namespace views
OLDNEW
« no previous file with comments | « views/layer_property_setter.h ('k') | views/widget/native_widget_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698