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

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: . 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
30 // The current overview state of the window. 0.f means the window is at the 31 // The current overview state of the window. 0.f means the window is at the
31 // topmost position. 1.f means the window is at the bottom-most position. 32 // topmost position. 1.f means the window is at the bottom-most position.
32 float progress; 33 float progress;
34
35 scoped_ptr<wm::Shadow> shadow;
33 }; 36 };
34 37
35 } // namespace 38 } // namespace
36 39
37 DECLARE_WINDOW_PROPERTY_TYPE(WindowOverviewState*) 40 DECLARE_WINDOW_PROPERTY_TYPE(WindowOverviewState*)
38 DEFINE_OWNED_WINDOW_PROPERTY_KEY(WindowOverviewState, 41 DEFINE_OWNED_WINDOW_PROPERTY_KEY(WindowOverviewState,
39 kWindowOverviewState, 42 kWindowOverviewState,
40 NULL) 43 NULL)
41 namespace athena { 44 namespace athena {
42 45
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 gfx::Transform bottom_transform; 145 gfx::Transform bottom_transform;
143 int bottom = container_size.height() - (index * kGapBetweenWindowsBottom); 146 int bottom = container_size.height() - (index * kGapBetweenWindowsBottom);
144 x_translate = container_size.width() * (1 - kMaxScale) / 2.; 147 x_translate = container_size.width() * (1 - kMaxScale) / 2.;
145 bottom_transform.Translate(x_translate, bottom - window->bounds().y()); 148 bottom_transform.Translate(x_translate, bottom - window->bounds().y());
146 bottom_transform.Scale(kMaxScale, kMaxScale); 149 bottom_transform.Scale(kMaxScale, kMaxScale);
147 150
148 WindowOverviewState* state = new WindowOverviewState; 151 WindowOverviewState* state = new WindowOverviewState;
149 state->top = top_transform; 152 state->top = top_transform;
150 state->bottom = bottom_transform; 153 state->bottom = bottom_transform;
151 state->progress = 0.f; 154 state->progress = 0.f;
155 state->shadow = CreateShadowForWindow(window);
152 window->SetProperty(kWindowOverviewState, state); 156 window->SetProperty(kWindowOverviewState, state);
153 } 157 }
154 } 158 }
155 159
156 // Sets the initial position for the windows for the overview mode. 160 // Sets the initial position for the windows for the overview mode.
157 void SetInitialWindowStates() { 161 void SetInitialWindowStates() {
158 aura::Window::Windows windows = container_->children(); 162 aura::Window::Windows windows = container_->children();
159 size_t window_count = windows.size(); 163 size_t window_count = windows.size();
160 // The initial overview state of the topmost three windows. 164 // The initial overview state of the topmost three windows.
161 const float kInitialProgress[] = { 0.5f, 0.05f, 0.01f }; 165 const float kInitialProgress[] = { 0.5f, 0.05f, 0.01f };
(...skipping 18 matching lines...) Expand all
180 { 184 {
181 ui::ScopedLayerAnimationSettings settings(animator); 185 ui::ScopedLayerAnimationSettings settings(animator);
182 settings.SetPreemptionStrategy( 186 settings.SetPreemptionStrategy(
183 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 187 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
184 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(250)); 188 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(250));
185 SetWindowProgress(window, progress); 189 SetWindowProgress(window, progress);
186 } 190 }
187 } 191 }
188 } 192 }
189 193
194 scoped_ptr<wm::Shadow> CreateShadowForWindow(aura::Window* window) {
195 scoped_ptr<wm::Shadow> shadow(new wm::Shadow());
196 shadow->Init(wm::Shadow::STYLE_ACTIVE);
197 shadow->SetContentBounds(gfx::Rect(window->bounds().size()));
198 shadow->layer()->SetVisible(true);
199 window->layer()->Add(shadow->layer());
200 return shadow.Pass();
201 }
202
190 aura::Window* SelectWindowAt(ui::LocatedEvent* event) { 203 aura::Window* SelectWindowAt(ui::LocatedEvent* event) {
191 CHECK_EQ(container_, event->target()); 204 CHECK_EQ(container_, event->target());
192 // Find the old targeter to find the target of the event. 205 // Find the old targeter to find the target of the event.
193 ui::EventTarget* window = container_; 206 ui::EventTarget* window = container_;
194 ui::EventTargeter* targeter = scoped_targeter_->old_targeter(); 207 ui::EventTargeter* targeter = scoped_targeter_->old_targeter();
195 while (!targeter && window->GetParentTarget()) { 208 while (!targeter && window->GetParentTarget()) {
196 window = window->GetParentTarget(); 209 window = window->GetParentTarget();
197 targeter = window->GetEventTargeter(); 210 targeter = window->GetEventTargeter();
198 } 211 }
199 if (!targeter) 212 if (!targeter)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } // namespace 249 } // namespace
237 250
238 scoped_ptr<WindowOverviewMode> WindowOverviewMode::Create( 251 scoped_ptr<WindowOverviewMode> WindowOverviewMode::Create(
239 aura::Window* window, 252 aura::Window* window,
240 WindowOverviewModeDelegate* delegate) { 253 WindowOverviewModeDelegate* delegate) {
241 return scoped_ptr<WindowOverviewMode>( 254 return scoped_ptr<WindowOverviewMode>(
242 new WindowOverviewModeImpl(window, delegate)); 255 new WindowOverviewModeImpl(window, delegate));
243 } 256 }
244 257
245 } // namespace athena 258 } // 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