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

Side by Side Diff: ash/common/wm/workspace/phantom_window_controller.cc

Issue 2726823003: Remove WmLookup. (Closed)
Patch Set: Clean up include and modify comment. Created 3 years, 9 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/common/wm/workspace/phantom_window_controller.h" 5 #include "ash/common/wm/workspace/phantom_window_controller.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "ash/common/wm/root_window_finder.h" 9 #include "ash/common/wm/root_window_finder.h"
10 #include "ash/common/wm_lookup.h"
11 #include "ash/common/wm_window.h" 10 #include "ash/common/wm_window.h"
12 #include "ash/public/cpp/shell_window_ids.h" 11 #include "ash/public/cpp/shell_window_ids.h"
13 #include "ash/resources/grit/ash_resources.h" 12 #include "ash/resources/grit/ash_resources.h"
14 #include "ash/root_window_controller.h" 13 #include "ash/root_window_controller.h"
15 #include "ui/compositor/layer.h" 14 #include "ui/compositor/layer.h"
16 #include "ui/compositor/scoped_layer_animation_settings.h" 15 #include "ui/compositor/scoped_layer_animation_settings.h"
17 #include "ui/views/background.h" 16 #include "ui/views/background.h"
18 #include "ui/views/painter.h" 17 #include "ui/views/painter.h"
19 #include "ui/views/view.h" 18 #include "ui/views/view.h"
20 #include "ui/views/widget/widget.h" 19 #include "ui/views/widget/widget.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 } 53 }
55 54
56 // Starts an animation of |widget| to |new_bounds_in_screen|. No-op if |widget| 55 // Starts an animation of |widget| to |new_bounds_in_screen|. No-op if |widget|
57 // is NULL. 56 // is NULL.
58 void AnimateToBounds(views::Widget* widget, 57 void AnimateToBounds(views::Widget* widget,
59 const gfx::Rect& new_bounds_in_screen) { 58 const gfx::Rect& new_bounds_in_screen) {
60 if (!widget) 59 if (!widget)
61 return; 60 return;
62 61
63 ui::ScopedLayerAnimationSettings scoped_setter( 62 ui::ScopedLayerAnimationSettings scoped_setter(
64 WmLookup::Get()->GetWindowForWidget(widget)->GetLayer()->GetAnimator()); 63 WmWindow::Get(widget->GetNativeWindow())->GetLayer()->GetAnimator());
65 scoped_setter.SetTweenType(gfx::Tween::EASE_IN); 64 scoped_setter.SetTweenType(gfx::Tween::EASE_IN);
66 scoped_setter.SetPreemptionStrategy( 65 scoped_setter.SetPreemptionStrategy(
67 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 66 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
68 scoped_setter.SetTransitionDuration( 67 scoped_setter.SetTransitionDuration(
69 base::TimeDelta::FromMilliseconds(kAnimationDurationMs)); 68 base::TimeDelta::FromMilliseconds(kAnimationDurationMs));
70 widget->SetBounds(new_bounds_in_screen); 69 widget->SetBounds(new_bounds_in_screen);
71 } 70 }
72 71
73 } // namespace 72 } // namespace
74 73
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 // the phantom is visible. 112 // the phantom is visible.
114 params.keep_on_top = true; 113 params.keep_on_top = true;
115 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 114 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
116 params.name = "PhantomWindow"; 115 params.name = "PhantomWindow";
117 root_window->GetRootWindowController()->ConfigureWidgetInitParamsForContainer( 116 root_window->GetRootWindowController()->ConfigureWidgetInitParamsForContainer(
118 phantom_widget.get(), kShellWindowId_ShelfContainer, &params); 117 phantom_widget.get(), kShellWindowId_ShelfContainer, &params);
119 phantom_widget->set_focus_on_creation(false); 118 phantom_widget->set_focus_on_creation(false);
120 phantom_widget->Init(params); 119 phantom_widget->Init(params);
121 phantom_widget->SetVisibilityChangedAnimationsEnabled(false); 120 phantom_widget->SetVisibilityChangedAnimationsEnabled(false);
122 WmWindow* phantom_widget_window = 121 WmWindow* phantom_widget_window =
123 WmLookup::Get()->GetWindowForWidget(phantom_widget.get()); 122 WmWindow::Get(phantom_widget->GetNativeWindow());
124 phantom_widget_window->SetShellWindowId(kShellWindowId_PhantomWindow); 123 phantom_widget_window->SetShellWindowId(kShellWindowId_PhantomWindow);
125 phantom_widget->SetBounds(bounds_in_screen); 124 phantom_widget->SetBounds(bounds_in_screen);
126 // TODO(sky): I suspect this is never true, verify that. 125 // TODO(sky): I suspect this is never true, verify that.
127 if (phantom_widget_window->GetParent() == window_->GetParent()) { 126 if (phantom_widget_window->GetParent() == window_->GetParent()) {
128 phantom_widget_window->GetParent()->StackChildAbove(phantom_widget_window, 127 phantom_widget_window->GetParent()->StackChildAbove(phantom_widget_window,
129 window_); 128 window_);
130 } 129 }
131 130
132 const int kImages[] = IMAGE_GRID(IDR_AURA_PHANTOM_WINDOW); 131 const int kImages[] = IMAGE_GRID(IDR_AURA_PHANTOM_WINDOW);
133 views::View* content_view = new views::View; 132 views::View* content_view = new views::View;
134 content_view->set_background(views::Background::CreateBackgroundPainter( 133 content_view->set_background(views::Background::CreateBackgroundPainter(
135 views::Painter::CreateImageGridPainter(kImages))); 134 views::Painter::CreateImageGridPainter(kImages)));
136 phantom_widget->SetContentsView(content_view); 135 phantom_widget->SetContentsView(content_view);
137 136
138 // Show the widget after all the setups. 137 // Show the widget after all the setups.
139 phantom_widget->Show(); 138 phantom_widget->Show();
140 139
141 // Fade the window in. 140 // Fade the window in.
142 ui::Layer* widget_layer = phantom_widget_window->GetLayer(); 141 ui::Layer* widget_layer = phantom_widget_window->GetLayer();
143 widget_layer->SetOpacity(0); 142 widget_layer->SetOpacity(0);
144 ui::ScopedLayerAnimationSettings scoped_setter(widget_layer->GetAnimator()); 143 ui::ScopedLayerAnimationSettings scoped_setter(widget_layer->GetAnimator());
145 scoped_setter.SetTransitionDuration( 144 scoped_setter.SetTransitionDuration(
146 base::TimeDelta::FromMilliseconds(kAnimationDurationMs)); 145 base::TimeDelta::FromMilliseconds(kAnimationDurationMs));
147 widget_layer->SetOpacity(1); 146 widget_layer->SetOpacity(1);
148 147
149 return phantom_widget; 148 return phantom_widget;
150 } 149 }
151 150
152 } // namespace ash 151 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698