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

Side by Side Diff: athena/wm/window_overview_mode.cc

Issue 335673003: athena: Add shadows to the windows in overview mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge Created 6 years, 6 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "athena/wm/window_overview_mode.h" 5 #include "athena/wm/window_overview_mode.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "ui/aura/scoped_window_targeter.h" 12 #include "ui/aura/scoped_window_targeter.h"
13 #include "ui/aura/window.h" 13 #include "ui/aura/window.h"
14 #include "ui/aura/window_delegate.h" 14 #include "ui/aura/window_delegate.h"
15 #include "ui/aura/window_property.h" 15 #include "ui/aura/window_property.h"
16 #include "ui/aura/window_targeter.h" 16 #include "ui/aura/window_targeter.h"
17 #include "ui/compositor/scoped_layer_animation_settings.h" 17 #include "ui/compositor/scoped_layer_animation_settings.h"
18 #include "ui/events/event_handler.h" 18 #include "ui/events/event_handler.h"
19 #include "ui/gfx/transform.h" 19 #include "ui/gfx/transform.h"
20 #include "ui/wm/core/shadow.h"
20 21
21 namespace { 22 namespace {
22 23
23 struct WindowOverviewState { 24 struct WindowOverviewState {
24 // The transform for when the window is at the topmost position. 25 // The transform for when the window is at the topmost position.
25 gfx::Transform top; 26 gfx::Transform top;
26 27
27 // The transform for when the window is at the bottom-most position. 28 // The transform for when the window is at the bottom-most position.
28 gfx::Transform bottom; 29 gfx::Transform bottom;
29 30
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 scoped_targeter_(new aura::ScopedWindowTargeter( 96 scoped_targeter_(new aura::ScopedWindowTargeter(
96 container, 97 container,
97 scoped_ptr<ui::EventTargeter>( 98 scoped_ptr<ui::EventTargeter>(
98 new StaticWindowTargeter(container)))) { 99 new StaticWindowTargeter(container)))) {
99 container_->set_target_handler(this); 100 container_->set_target_handler(this);
100 101
101 // Prepare the desired transforms for all the windows, and set the initial 102 // Prepare the desired transforms for all the windows, and set the initial
102 // state on the windows. 103 // state on the windows.
103 ComputeTerminalStatesForAllWindows(); 104 ComputeTerminalStatesForAllWindows();
104 SetInitialWindowStates(); 105 SetInitialWindowStates();
106 AddShadowsForWindows();
105 } 107 }
106 108
107 virtual ~WindowOverviewModeImpl() { 109 virtual ~WindowOverviewModeImpl() {
108 container_->set_target_handler(container_->delegate()); 110 container_->set_target_handler(container_->delegate());
109 111
110 aura::Window::Windows windows = container_->children(); 112 aura::Window::Windows windows = container_->children();
111 if (windows.empty()) 113 if (windows.empty())
112 return; 114 return;
113 std::for_each(windows.begin(), windows.end(), &RestoreWindowState); 115 std::for_each(windows.begin(), windows.end(), &RestoreWindowState);
114 } 116 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 { 182 {
181 ui::ScopedLayerAnimationSettings settings(animator); 183 ui::ScopedLayerAnimationSettings settings(animator);
182 settings.SetPreemptionStrategy( 184 settings.SetPreemptionStrategy(
183 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 185 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
184 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(250)); 186 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(250));
185 SetWindowProgress(window, progress); 187 SetWindowProgress(window, progress);
186 } 188 }
187 } 189 }
188 } 190 }
189 191
192 void AddShadowsForWindows() {
193 aura::Window::Windows windows = container_->children();
194 if (windows.empty())
195 return;
196 std::for_each(
197 windows.begin(),
198 windows.end(),
199 std::bind1st(std::mem_fun(&WindowOverviewModeImpl::AddShadowForWindow),
200 this));
201 }
202
203 void AddShadowForWindow(aura::Window* window) {
204 wm::Shadow* shadow = new wm::Shadow();
205 shadows_.push_back(shadow);
206 shadow->Init(wm::Shadow::STYLE_ACTIVE);
207 shadow->SetContentBounds(gfx::Rect(window->bounds().size()));
208 shadow->layer()->SetVisible(true);
209 window->layer()->Add(shadow->layer());
210 }
211
190 aura::Window* SelectWindowAt(ui::LocatedEvent* event) { 212 aura::Window* SelectWindowAt(ui::LocatedEvent* event) {
191 CHECK_EQ(container_, event->target()); 213 CHECK_EQ(container_, event->target());
192 // Find the old targeter to find the target of the event. 214 // Find the old targeter to find the target of the event.
193 ui::EventTarget* window = container_; 215 ui::EventTarget* window = container_;
194 ui::EventTargeter* targeter = scoped_targeter_->old_targeter(); 216 ui::EventTargeter* targeter = scoped_targeter_->old_targeter();
195 while (!targeter && window->GetParentTarget()) { 217 while (!targeter && window->GetParentTarget()) {
196 window = window->GetParentTarget(); 218 window = window->GetParentTarget();
197 targeter = window->GetEventTargeter(); 219 targeter = window->GetEventTargeter();
198 } 220 }
199 if (!targeter) 221 if (!targeter)
(...skipping 22 matching lines...) Expand all
222 aura::Window* select = SelectWindowAt(gesture); 244 aura::Window* select = SelectWindowAt(gesture);
223 if (select) { 245 if (select) {
224 gesture->SetHandled(); 246 gesture->SetHandled();
225 delegate_->OnSelectWindow(select); 247 delegate_->OnSelectWindow(select);
226 } 248 }
227 } 249 }
228 250
229 aura::Window* container_; 251 aura::Window* container_;
230 WindowOverviewModeDelegate* delegate_; 252 WindowOverviewModeDelegate* delegate_;
231 scoped_ptr<aura::ScopedWindowTargeter> scoped_targeter_; 253 scoped_ptr<aura::ScopedWindowTargeter> scoped_targeter_;
254 ScopedVector<wm::Shadow> shadows_;
oshima 2014/06/12 19:15:24 can't you store the shadow in the state object?
sadrul 2014/06/12 19:37:51 Good idea! done.
232 255
233 DISALLOW_COPY_AND_ASSIGN(WindowOverviewModeImpl); 256 DISALLOW_COPY_AND_ASSIGN(WindowOverviewModeImpl);
234 }; 257 };
235 258
236 } // namespace 259 } // namespace
237 260
238 scoped_ptr<WindowOverviewMode> WindowOverviewMode::Create( 261 scoped_ptr<WindowOverviewMode> WindowOverviewMode::Create(
239 aura::Window* window, 262 aura::Window* window,
240 WindowOverviewModeDelegate* delegate) { 263 WindowOverviewModeDelegate* delegate) {
241 return scoped_ptr<WindowOverviewMode>( 264 return scoped_ptr<WindowOverviewMode>(
242 new WindowOverviewModeImpl(window, delegate)); 265 new WindowOverviewModeImpl(window, delegate));
243 } 266 }
244 267
245 } // namespace athena 268 } // namespace athena
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698