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

Side by Side Diff: ui/aura/window.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 | « ui/aura/window.h ('k') | ui/aura/window_unittest.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 "ui/aura/window.h" 5 #include "ui/aura/window.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "ui/aura/desktop.h" 10 #include "ui/aura/desktop.h"
11 #include "ui/aura/event.h" 11 #include "ui/aura/event.h"
12 #include "ui/aura/event_filter.h" 12 #include "ui/aura/event_filter.h"
13 #include "ui/aura/focus_manager.h" 13 #include "ui/aura/focus_manager.h"
14 #include "ui/aura/layout_manager.h" 14 #include "ui/aura/layout_manager.h"
15 #include "ui/aura/window_delegate.h" 15 #include "ui/aura/window_delegate.h"
16 #include "ui/base/animation/multi_animation.h"
16 #include "ui/gfx/canvas_skia.h" 17 #include "ui/gfx/canvas_skia.h"
17 #include "ui/gfx/compositor/compositor.h" 18 #include "ui/gfx/compositor/compositor.h"
18 #include "ui/gfx/compositor/layer.h" 19 #include "ui/gfx/compositor/layer.h"
19 20
20 namespace aura { 21 namespace aura {
21 22
22 using internal::RootWindow; 23 using internal::RootWindow;
23 24
24 Window::Window(WindowDelegate* delegate) 25 Window::Window(WindowDelegate* delegate)
25 : delegate_(delegate), 26 : delegate_(delegate),
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 (visibility_ == VISIBILITY_HIDDEN && 78 (visibility_ == VISIBILITY_HIDDEN &&
78 !Desktop::GetInstance()->active_window())) { 79 !Desktop::GetInstance()->active_window())) {
79 Desktop::GetInstance()->ActivateTopmostWindow(); 80 Desktop::GetInstance()->ActivateTopmostWindow();
80 } 81 }
81 } 82 }
82 83
83 void Window::SetLayoutManager(LayoutManager* layout_manager) { 84 void Window::SetLayoutManager(LayoutManager* layout_manager) {
84 layout_manager_.reset(layout_manager); 85 layout_manager_.reset(layout_manager);
85 } 86 }
86 87
87 void Window::SetBounds(const gfx::Rect& bounds, int anim_ms) { 88 void Window::SetBounds(const gfx::Rect& new_bounds) {
88 // TODO: support anim_ms
89 // TODO: funnel this through the Desktop. 89 // TODO: funnel this through the Desktop.
90 bool was_move = bounds_.size() == bounds.size(); 90 gfx::Rect old_bounds = bounds();
91 gfx::Rect old_bounds = bounds_; 91 bool was_move = old_bounds.size() == new_bounds.size();
92 bounds_ = bounds; 92 layer_->SetBounds(new_bounds);
93 layer_->SetBounds(bounds); 93
94 if (layout_manager_.get()) 94 if (layout_manager_.get())
95 layout_manager_->OnWindowResized(); 95 layout_manager_->OnWindowResized();
96 if (delegate_) 96 if (delegate_)
97 delegate_->OnBoundsChanged(old_bounds, bounds_); 97 delegate_->OnBoundsChanged(old_bounds, new_bounds);
98 if (was_move) 98 if (was_move)
99 SchedulePaintInRect(gfx::Rect()); 99 SchedulePaintInRect(gfx::Rect());
100 else 100 else
101 SchedulePaint(); 101 SchedulePaint();
102 } 102 }
103 103
104 const gfx::Rect& Window::bounds() const {
105 return layer_->bounds();
106 }
107
104 void Window::SchedulePaintInRect(const gfx::Rect& rect) { 108 void Window::SchedulePaintInRect(const gfx::Rect& rect) {
105 layer_->SchedulePaint(rect); 109 layer_->SchedulePaint(rect);
106 } 110 }
107 111
108 void Window::SetCanvas(const SkCanvas& canvas, const gfx::Point& origin) { 112 void Window::SetCanvas(const SkCanvas& canvas, const gfx::Point& origin) {
109 // TODO: figure out how this is going to work when animating the layer. In 113 // TODO: figure out how this is going to work when animating the layer. In
110 // particular if we're animating the size then the underlying Texture is going 114 // particular if we're animating the size then the underlying Texture is going
111 // to be unhappy if we try to set a texture on a size bigger than the size of 115 // to be unhappy if we try to set a texture on a size bigger than the size of
112 // the texture. 116 // the texture.
113 layer_->SetCanvas(canvas, origin); 117 layer_->SetCanvas(canvas, origin);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 return; 228 return;
225 229
226 root->ReleaseCapture(this); 230 root->ReleaseCapture(this);
227 } 231 }
228 232
229 bool Window::HasCapture() { 233 bool Window::HasCapture() {
230 RootWindow* root = GetRoot(); 234 RootWindow* root = GetRoot();
231 return root && root->capture_window() == this; 235 return root && root->capture_window() == this;
232 } 236 }
233 237
238 // static
239 ui::Animation* Window::CreateDefaultAnimation() {
240 std::vector<ui::MultiAnimation::Part> parts;
241 parts.push_back(ui::MultiAnimation::Part(200, ui::Tween::LINEAR));
242 ui::MultiAnimation* multi_animation = new ui::MultiAnimation(parts);
243 multi_animation->set_continuous(false);
244 return multi_animation;
245 }
246
234 internal::RootWindow* Window::GetRoot() { 247 internal::RootWindow* Window::GetRoot() {
235 return parent_ ? parent_->GetRoot() : NULL; 248 return parent_ ? parent_->GetRoot() : NULL;
236 } 249 }
237 250
238 void Window::SchedulePaint() { 251 void Window::SchedulePaint() {
239 SchedulePaintInRect(gfx::Rect(0, 0, bounds_.width(), bounds_.height())); 252 SchedulePaintInRect(gfx::Rect(0, 0, bounds().width(), bounds().height()));
240 } 253 }
241 254
242 void Window::OnPaintLayer(gfx::Canvas* canvas) { 255 void Window::OnPaintLayer(gfx::Canvas* canvas) {
243 delegate_->OnPaint(canvas); 256 delegate_->OnPaint(canvas);
244 } 257 }
245 258
246 } // namespace aura 259 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/window.h ('k') | ui/aura/window_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698