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

Side by Side Diff: ash/wm/overview/window_selector_item.cc

Issue 2012343002: Converts overview to use common ash types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: feedback Created 4 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
« no previous file with comments | « ash/wm/overview/window_selector_item.h ('k') | ash/wm/overview/window_selector_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/wm/overview/window_selector_item.h" 5 #include "ash/wm/overview/window_selector_item.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/material_design/material_design_controller.h" 10 #include "ash/material_design/material_design_controller.h"
11 #include "ash/screen_util.h"
12 #include "ash/shell.h"
13 #include "ash/shell_window_ids.h"
14 #include "ash/wm/common/window_state.h" 11 #include "ash/wm/common/window_state.h"
12 #include "ash/wm/common/wm_lookup.h"
13 #include "ash/wm/common/wm_root_window_controller.h"
14 #include "ash/wm/common/wm_shell_window_ids.h"
15 #include "ash/wm/common/wm_shell_window_ids.h"
16 #include "ash/wm/common/wm_window.h"
17 #include "ash/wm/common/wm_window_property.h"
15 #include "ash/wm/overview/overview_animation_type.h" 18 #include "ash/wm/overview/overview_animation_type.h"
16 #include "ash/wm/overview/scoped_overview_animation_settings.h" 19 #include "ash/wm/overview/scoped_overview_animation_settings.h"
20 #include "ash/wm/overview/scoped_overview_animation_settings_factory.h"
17 #include "ash/wm/overview/scoped_transform_overview_window.h" 21 #include "ash/wm/overview/scoped_transform_overview_window.h"
18 #include "ash/wm/overview/window_selector.h" 22 #include "ash/wm/overview/window_selector.h"
19 #include "ash/wm/overview/window_selector_controller.h" 23 #include "ash/wm/overview/window_selector_controller.h"
20 #include "base/auto_reset.h" 24 #include "base/auto_reset.h"
21 #include "base/strings/string_util.h" 25 #include "base/strings/string_util.h"
22 #include "base/strings/utf_string_conversions.h" 26 #include "base/strings/utf_string_conversions.h"
23 #include "base/time/time.h" 27 #include "base/time/time.h"
24 #include "grit/ash_resources.h" 28 #include "grit/ash_resources.h"
25 #include "grit/ash_strings.h" 29 #include "grit/ash_strings.h"
26 #include "ui/aura/client/aura_constants.h"
27 #include "ui/aura/window.h"
28 #include "ui/base/l10n/l10n_util.h" 30 #include "ui/base/l10n/l10n_util.h"
29 #include "ui/base/resource/resource_bundle.h" 31 #include "ui/base/resource/resource_bundle.h"
30 #include "ui/gfx/geometry/safe_integer_conversions.h" 32 #include "ui/gfx/geometry/safe_integer_conversions.h"
31 #include "ui/gfx/geometry/vector2d.h" 33 #include "ui/gfx/geometry/vector2d.h"
32 #include "ui/gfx/transform_util.h" 34 #include "ui/gfx/transform_util.h"
33 #include "ui/strings/grit/ui_strings.h" 35 #include "ui/strings/grit/ui_strings.h"
34 #include "ui/views/border.h" 36 #include "ui/views/border.h"
35 #include "ui/views/controls/button/image_button.h" 37 #include "ui/views/controls/button/image_button.h"
36 #include "ui/views/layout/box_layout.h" 38 #include "ui/views/layout/box_layout.h"
37 #include "ui/views/widget/widget.h"
38 #include "ui/views/window/non_client_view.h" 39 #include "ui/views/window/non_client_view.h"
39 #include "ui/wm/core/window_util.h" 40 #include "ui/wm/core/window_util.h"
40 41
41 namespace ash { 42 namespace ash {
42 43
43 namespace { 44 namespace {
44 45
45 // In the conceptual overview table, the window margin is the space reserved 46 // In the conceptual overview table, the window margin is the space reserved
46 // around the window within the cell. This margin does not overlap so the 47 // around the window within the cell. This margin does not overlap so the
47 // closest distance between adjacent windows will be twice this amount. 48 // closest distance between adjacent windows will be twice this amount.
(...skipping 17 matching lines...) Expand all
65 66
66 // Amount of blur applied to the label shadow 67 // Amount of blur applied to the label shadow
67 static const int kShadowBlur = 10; 68 static const int kShadowBlur = 10;
68 69
69 // Opacity for dimmed items. 70 // Opacity for dimmed items.
70 static const float kDimmedItemOpacity = 0.5f; 71 static const float kDimmedItemOpacity = 0.5f;
71 72
72 // Calculates the |window| bounds after being transformed to the selector's 73 // Calculates the |window| bounds after being transformed to the selector's
73 // space. With Material Design at most |title_height| is reserved above the 74 // space. With Material Design at most |title_height| is reserved above the
74 // |window|. The returned Rect is in virtual screen coordinates. 75 // |window|. The returned Rect is in virtual screen coordinates.
75 gfx::Rect GetTransformedBounds(aura::Window* window, int title_height) { 76 gfx::Rect GetTransformedBounds(wm::WmWindow* window, int title_height) {
76 gfx::RectF bounds(ScreenUtil::ConvertRectToScreen(window->GetRootWindow(), 77 gfx::RectF bounds(
77 window->GetTargetBounds())); 78 window->GetRootWindow()->ConvertRectToScreen(window->GetTargetBounds()));
78 gfx::Transform new_transform = TransformAboutPivot( 79 gfx::Transform new_transform = TransformAboutPivot(
79 gfx::Point(bounds.x(), bounds.y()), 80 gfx::Point(bounds.x(), bounds.y()), window->GetTargetTransform());
80 window->layer()->GetTargetTransform());
81 new_transform.TransformRect(&bounds); 81 new_transform.TransformRect(&bounds);
82 82
83 // With Material Design the preview title is shown above the preview window. 83 // With Material Design the preview title is shown above the preview window.
84 // Hide the window header for apps or browser windows with no tabs (web apps) 84 // Hide the window header for apps or browser windows with no tabs (web apps)
85 // to avoid showing both the window header and the preview title. 85 // to avoid showing both the window header and the preview title.
86 if (ash::MaterialDesignController::IsOverviewMaterial()) { 86 if (ash::MaterialDesignController::IsOverviewMaterial()) {
87 gfx::RectF header_bounds(bounds); 87 gfx::RectF header_bounds(bounds);
88 header_bounds.set_height(std::min( 88 header_bounds.set_height(
89 window->GetProperty(aura::client::kTopViewInset), title_height)); 89 std::min(window->GetIntProperty(wm::WmWindowProperty::TOP_VIEW_INSET),
90 title_height));
90 new_transform.TransformRect(&header_bounds); 91 new_transform.TransformRect(&header_bounds);
91 bounds.Inset(0, header_bounds.height(), 0, 0); 92 bounds.Inset(0, header_bounds.height(), 0, 0);
92 } 93 }
93 return ToEnclosingRect(bounds); 94 return ToEnclosingRect(bounds);
94 } 95 }
95 96
96 // Convenience method to fade in a Window with predefined animation settings. 97 // Convenience method to fade in a Window with predefined animation settings.
97 // Note: The fade in animation will occur after a delay where the delay is how 98 // Note: The fade in animation will occur after a delay where the delay is how
98 // long the lay out animations take. 99 // long the lay out animations take.
99 void SetupFadeInAfterLayout(aura::Window* window) { 100 void SetupFadeInAfterLayout(views::Widget* widget) {
100 ui::Layer* layer = window->layer(); 101 wm::WmWindow* window = wm::WmLookup::Get()->GetWindowForWidget(widget);
101 layer->SetOpacity(0.0f); 102 window->SetOpacity(0.0f);
102 ScopedOverviewAnimationSettings animation_settings( 103 std::unique_ptr<ScopedOverviewAnimationSettings>
103 OverviewAnimationType::OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN, 104 scoped_overview_animation_settings =
104 window); 105 ScopedOverviewAnimationSettingsFactory::Get()
105 layer->SetOpacity(1.0f); 106 ->CreateOverviewAnimationSettings(
107 OverviewAnimationType::
108 OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN,
109 window);
110 window->SetOpacity(1.0f);
106 } 111 }
107 112
108 // An image button with a close window icon. 113 // An image button with a close window icon.
109 class OverviewCloseButton : public views::ImageButton { 114 class OverviewCloseButton : public views::ImageButton {
110 public: 115 public:
111 explicit OverviewCloseButton(views::ButtonListener* listener); 116 explicit OverviewCloseButton(views::ButtonListener* listener);
112 ~OverviewCloseButton() override; 117 ~OverviewCloseButton() override;
113 118
114 private: 119 private:
115 DISALLOW_COPY_AND_ASSIGN(OverviewCloseButton); 120 DISALLOW_COPY_AND_ASSIGN(OverviewCloseButton);
(...skipping 27 matching lines...) Expand all
143 148
144 gfx::Rect WindowSelectorItem::OverviewLabelButton::GetChildAreaBounds() { 149 gfx::Rect WindowSelectorItem::OverviewLabelButton::GetChildAreaBounds() {
145 gfx::Rect bounds = GetLocalBounds(); 150 gfx::Rect bounds = GetLocalBounds();
146 if (ash::MaterialDesignController::IsOverviewMaterial()) 151 if (ash::MaterialDesignController::IsOverviewMaterial())
147 bounds.Inset(kHorizontalLabelPaddingMD, 0, kHorizontalLabelPaddingMD, 0); 152 bounds.Inset(kHorizontalLabelPaddingMD, 0, kHorizontalLabelPaddingMD, 0);
148 else 153 else
149 bounds.Inset(0, top_padding_, 0, 0); 154 bounds.Inset(0, top_padding_, 0, 0);
150 return bounds; 155 return bounds;
151 } 156 }
152 157
153 WindowSelectorItem::WindowSelectorItem(aura::Window* window, 158 WindowSelectorItem::WindowSelectorItem(wm::WmWindow* window,
154 WindowSelector* window_selector) 159 WindowSelector* window_selector)
155 : dimmed_(false), 160 : dimmed_(false),
156 root_window_(window->GetRootWindow()), 161 root_window_(window->GetRootWindow()),
157 transform_window_(window), 162 transform_window_(window),
158 in_bounds_update_(false), 163 in_bounds_update_(false),
159 window_label_button_view_(nullptr), 164 window_label_button_view_(nullptr),
160 close_button_(new OverviewCloseButton(this)), 165 close_button_(new OverviewCloseButton(this)),
161 window_selector_(window_selector) { 166 window_selector_(window_selector) {
162 const bool material = ash::MaterialDesignController::IsOverviewMaterial(); 167 const bool material = ash::MaterialDesignController::IsOverviewMaterial();
163 CreateWindowLabel(window->title()); 168 CreateWindowLabel(window->GetTitle());
164 views::Widget::InitParams params; 169 views::Widget::InitParams params;
165 params.type = views::Widget::InitParams::TYPE_POPUP; 170 params.type = views::Widget::InitParams::TYPE_POPUP;
166 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 171 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
167 params.opacity = material ? views::Widget::InitParams::OPAQUE_WINDOW 172 params.opacity = material ? views::Widget::InitParams::OPAQUE_WINDOW
168 : views::Widget::InitParams::TRANSLUCENT_WINDOW; 173 : views::Widget::InitParams::TRANSLUCENT_WINDOW;
169 params.parent = Shell::GetContainer(root_window_,
170 kShellWindowId_OverlayContainer);
171 close_button_widget_.set_focus_on_creation(false); 174 close_button_widget_.set_focus_on_creation(false);
175 window->GetRootWindowController()->ConfigureWidgetInitParamsForContainer(
176 &close_button_widget_, kShellWindowId_OverlayContainer, &params);
172 close_button_widget_.Init(params); 177 close_button_widget_.Init(params);
173 close_button_->SetVisible(false); 178 close_button_->SetVisible(false);
174 close_button_widget_.SetContentsView(close_button_); 179 close_button_widget_.SetContentsView(close_button_);
175 close_button_widget_.SetSize(close_button_->GetPreferredSize()); 180 close_button_widget_.SetSize(close_button_->GetPreferredSize());
176 close_button_widget_.Show(); 181 close_button_widget_.Show();
177 182
178 gfx::Rect close_button_rect(close_button_widget_.GetNativeWindow()->bounds()); 183 gfx::Rect close_button_rect(close_button_->GetPreferredSize());
179 // Align the center of the button with position (0, 0) so that the 184 // Align the center of the button with position (0, 0) so that the
180 // translate transform does not need to take the button dimensions into 185 // translate transform does not need to take the button dimensions into
181 // account. 186 // account.
182 if (material) { 187 if (material) {
183 close_button_rect.set_x(-close_button_rect.width()); 188 close_button_rect.set_x(-close_button_rect.width());
184 close_button_rect.set_y(-close_button_rect.height()); 189 close_button_rect.set_y(-close_button_rect.height());
185 } else { 190 } else {
186 close_button_rect.set_x(-close_button_rect.width() / 2); 191 close_button_rect.set_x(-close_button_rect.width() / 2);
187 close_button_rect.set_y(-close_button_rect.height() / 2); 192 close_button_rect.set_y(-close_button_rect.height() / 2);
188 } 193 }
189 close_button_widget_.GetNativeWindow()->SetBounds(close_button_rect); 194 wm::WmLookup::Get()
195 ->GetWindowForWidget(&close_button_widget_)
196 ->SetBounds(close_button_rect);
190 197
191 GetWindow()->AddObserver(this); 198 GetWindow()->AddObserver(this);
192 } 199 }
193 200
194 WindowSelectorItem::~WindowSelectorItem() { 201 WindowSelectorItem::~WindowSelectorItem() {
195 GetWindow()->RemoveObserver(this); 202 GetWindow()->RemoveObserver(this);
196 } 203 }
197 204
198 aura::Window* WindowSelectorItem::GetWindow() { 205 wm::WmWindow* WindowSelectorItem::GetWindow() {
199 return transform_window_.window(); 206 return transform_window_.window();
200 } 207 }
201 208
202 void WindowSelectorItem::RestoreWindow() { 209 void WindowSelectorItem::RestoreWindow() {
203 transform_window_.RestoreWindow(); 210 transform_window_.RestoreWindow();
204 } 211 }
205 212
206 void WindowSelectorItem::ShowWindowOnExit() { 213 void WindowSelectorItem::ShowWindowOnExit() {
207 transform_window_.ShowWindowOnExit(); 214 transform_window_.ShowWindowOnExit();
208 } 215 }
209 216
210 void WindowSelectorItem::PrepareForOverview() { 217 void WindowSelectorItem::PrepareForOverview() {
211 transform_window_.PrepareForOverview(); 218 transform_window_.PrepareForOverview();
212 } 219 }
213 220
214 bool WindowSelectorItem::Contains(const aura::Window* target) const { 221 bool WindowSelectorItem::Contains(const wm::WmWindow* target) const {
215 return transform_window_.Contains(target); 222 return transform_window_.Contains(target);
216 } 223 }
217 224
218 void WindowSelectorItem::SetBounds(const gfx::Rect& target_bounds, 225 void WindowSelectorItem::SetBounds(const gfx::Rect& target_bounds,
219 OverviewAnimationType animation_type) { 226 OverviewAnimationType animation_type) {
220 if (in_bounds_update_) 227 if (in_bounds_update_)
221 return; 228 return;
222 base::AutoReset<bool> auto_reset_in_bounds_update(&in_bounds_update_, true); 229 base::AutoReset<bool> auto_reset_in_bounds_update(&in_bounds_update_, true);
223 target_bounds_ = target_bounds; 230 target_bounds_ = target_bounds;
224 231
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 void WindowSelectorItem::ButtonPressed(views::Button* sender, 269 void WindowSelectorItem::ButtonPressed(views::Button* sender,
263 const ui::Event& event) { 270 const ui::Event& event) {
264 if (sender == close_button_) { 271 if (sender == close_button_) {
265 transform_window_.Close(); 272 transform_window_.Close();
266 return; 273 return;
267 } 274 }
268 CHECK(sender == window_label_button_view_); 275 CHECK(sender == window_label_button_view_);
269 window_selector_->SelectWindow(transform_window_.window()); 276 window_selector_->SelectWindow(transform_window_.window());
270 } 277 }
271 278
272 void WindowSelectorItem::OnWindowDestroying(aura::Window* window) { 279 void WindowSelectorItem::OnWindowDestroying(wm::WmWindow* window) {
273 window->RemoveObserver(this); 280 window->RemoveObserver(this);
274 transform_window_.OnWindowDestroyed(); 281 transform_window_.OnWindowDestroyed();
275 } 282 }
276 283
277 void WindowSelectorItem::OnWindowTitleChanged(aura::Window* window) { 284 void WindowSelectorItem::OnWindowTitleChanged(wm::WmWindow* window) {
278 // TODO(flackr): Maybe add the new title to a vector of titles so that we can 285 // TODO(flackr): Maybe add the new title to a vector of titles so that we can
279 // filter any of the titles the window had while in the overview session. 286 // filter any of the titles the window had while in the overview session.
280 window_label_button_view_->SetText(window->title()); 287 window_label_button_view_->SetText(window->GetTitle());
281 UpdateCloseButtonAccessibilityName(); 288 UpdateCloseButtonAccessibilityName();
282 } 289 }
283 290
284 void WindowSelectorItem::SetItemBounds(const gfx::Rect& target_bounds, 291 void WindowSelectorItem::SetItemBounds(const gfx::Rect& target_bounds,
285 OverviewAnimationType animation_type) { 292 OverviewAnimationType animation_type) {
286 DCHECK(root_window_ == GetWindow()->GetRootWindow()); 293 DCHECK(root_window_ == GetWindow()->GetRootWindow());
287 gfx::Rect screen_rect = transform_window_.GetTargetBoundsInScreen(); 294 gfx::Rect screen_rect = transform_window_.GetTargetBoundsInScreen();
288 295
289 // Avoid division by zero by ensuring screen bounds is not empty. 296 // Avoid division by zero by ensuring screen bounds is not empty.
290 gfx::Size screen_size(screen_rect.size()); 297 gfx::Size screen_size(screen_rect.size());
291 screen_size.SetToMax(gfx::Size(1, 1)); 298 screen_size.SetToMax(gfx::Size(1, 1));
292 screen_rect.set_size(screen_size); 299 screen_rect.set_size(screen_size);
293 300
294 int top_view_inset = 0; 301 int top_view_inset = 0;
295 int title_height = 0; 302 int title_height = 0;
296 if (ash::MaterialDesignController::IsOverviewMaterial()) { 303 if (ash::MaterialDesignController::IsOverviewMaterial()) {
297 top_view_inset = GetWindow()->GetProperty(aura::client::kTopViewInset); 304 top_view_inset =
305 GetWindow()->GetIntProperty(wm::WmWindowProperty::TOP_VIEW_INSET);
298 title_height = close_button_->GetPreferredSize().height(); 306 title_height = close_button_->GetPreferredSize().height();
299 } 307 }
300 gfx::Rect selector_item_bounds = 308 gfx::Rect selector_item_bounds =
301 ScopedTransformOverviewWindow::ShrinkRectToFitPreservingAspectRatio( 309 ScopedTransformOverviewWindow::ShrinkRectToFitPreservingAspectRatio(
302 screen_rect, target_bounds, top_view_inset, title_height); 310 screen_rect, target_bounds, top_view_inset, title_height);
303 gfx::Transform transform = ScopedTransformOverviewWindow::GetTransformForRect( 311 gfx::Transform transform = ScopedTransformOverviewWindow::GetTransformForRect(
304 screen_rect, selector_item_bounds); 312 screen_rect, selector_item_bounds);
305 ScopedTransformOverviewWindow::ScopedAnimationSettings animation_settings; 313 ScopedTransformOverviewWindow::ScopedAnimationSettings animation_settings;
306 transform_window_.BeginScopedAnimation(animation_type, &animation_settings); 314 transform_window_.BeginScopedAnimation(animation_type, &animation_settings);
307 transform_window_.SetTransform(root_window_, transform); 315 transform_window_.SetTransform(root_window_, transform);
308 transform_window_.set_overview_transform(transform); 316 transform_window_.set_overview_transform(transform);
309 } 317 }
310 318
311 void WindowSelectorItem::SetOpacity(float opacity) { 319 void WindowSelectorItem::SetOpacity(float opacity) {
312 window_label_->GetNativeWindow()->layer()->SetOpacity(opacity); 320 window_label_->SetOpacity(opacity);
313 close_button_widget_.GetNativeWindow()->layer()->SetOpacity(opacity); 321 close_button_widget_.SetOpacity(opacity);
314 322
315 transform_window_.SetOpacity(opacity); 323 transform_window_.SetOpacity(opacity);
316 } 324 }
317 325
318 void WindowSelectorItem::UpdateWindowLabel( 326 void WindowSelectorItem::UpdateWindowLabel(
319 const gfx::Rect& window_bounds, 327 const gfx::Rect& window_bounds,
320 OverviewAnimationType animation_type) { 328 OverviewAnimationType animation_type) {
321 // If the root window has changed, force the window label to be recreated
322 // and faded in on the new root window.
323 DCHECK(!window_label_ ||
324 window_label_->GetNativeWindow()->GetRootWindow() == root_window_);
325
326 if (!window_label_->IsVisible()) { 329 if (!window_label_->IsVisible()) {
327 window_label_->Show(); 330 window_label_->Show();
328 SetupFadeInAfterLayout(window_label_->GetNativeWindow()); 331 SetupFadeInAfterLayout(window_label_.get());
329 } 332 }
330 333
331 gfx::Rect converted_bounds = 334 gfx::Rect label_bounds = root_window_->ConvertRectFromScreen(window_bounds);
332 ScreenUtil::ConvertRectFromScreen(root_window_, window_bounds);
333 gfx::Rect label_bounds(converted_bounds.x(), converted_bounds.y(),
334 converted_bounds.width(), converted_bounds.height());
335 window_label_button_view_->set_top_padding(label_bounds.height() - 335 window_label_button_view_->set_top_padding(label_bounds.height() -
336 kVerticalLabelPadding); 336 kVerticalLabelPadding);
337 ScopedOverviewAnimationSettings animation_settings( 337 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings =
338 animation_type, window_label_->GetNativeWindow()); 338 ScopedOverviewAnimationSettingsFactory::Get()
339 ->CreateOverviewAnimationSettings(
340 animation_type,
341 wm::WmLookup::Get()->GetWindowForWidget(window_label_.get()));
339 342
340 window_label_->GetNativeWindow()->SetBounds(label_bounds); 343 window_label_->SetBounds(label_bounds);
341 } 344 }
342 345
343 void WindowSelectorItem::CreateWindowLabel(const base::string16& title) { 346 void WindowSelectorItem::CreateWindowLabel(const base::string16& title) {
344 const bool material = ash::MaterialDesignController::IsOverviewMaterial(); 347 const bool material = ash::MaterialDesignController::IsOverviewMaterial();
345 window_label_.reset(new views::Widget); 348 window_label_.reset(new views::Widget);
346 views::Widget::InitParams params; 349 views::Widget::InitParams params;
347 params.type = views::Widget::InitParams::TYPE_POPUP; 350 params.type = views::Widget::InitParams::TYPE_POPUP;
348 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 351 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
349 params.opacity = material ? views::Widget::InitParams::OPAQUE_WINDOW 352 params.opacity = material ? views::Widget::InitParams::OPAQUE_WINDOW
350 : views::Widget::InitParams::TRANSLUCENT_WINDOW; 353 : views::Widget::InitParams::TRANSLUCENT_WINDOW;
351 params.parent =
352 Shell::GetContainer(root_window_, kShellWindowId_OverlayContainer);
353 params.visible_on_all_workspaces = true; 354 params.visible_on_all_workspaces = true;
354 window_label_->set_focus_on_creation(false); 355 window_label_->set_focus_on_creation(false);
356 root_window_->GetRootWindowController()
357 ->ConfigureWidgetInitParamsForContainer(
358 window_label_.get(), kShellWindowId_OverlayContainer, &params);
355 window_label_->Init(params); 359 window_label_->Init(params);
356 window_label_button_view_ = new OverviewLabelButton(this, title); 360 window_label_button_view_ = new OverviewLabelButton(this, title);
357 window_label_button_view_->SetBorder(views::Border::NullBorder()); 361 window_label_button_view_->SetBorder(views::Border::NullBorder());
358 window_label_button_view_->SetEnabledTextColors(kLabelColor); 362 window_label_button_view_->SetEnabledTextColors(kLabelColor);
359 window_label_button_view_->set_animate_on_state_change(false); 363 window_label_button_view_->set_animate_on_state_change(false);
360 if (material) { 364 if (material) {
361 window_label_button_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 365 window_label_button_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
362 } else { 366 } else {
363 window_label_button_view_->SetHorizontalAlignment(gfx::ALIGN_CENTER); 367 window_label_button_view_->SetHorizontalAlignment(gfx::ALIGN_CENTER);
364 window_label_button_view_->SetTextShadows(gfx::ShadowValues( 368 window_label_button_view_->SetTextShadows(gfx::ShadowValues(
365 1, gfx::ShadowValue(gfx::Vector2d(0, kVerticalShadowOffset), 369 1, gfx::ShadowValue(gfx::Vector2d(0, kVerticalShadowOffset),
366 kShadowBlur, kLabelShadow))); 370 kShadowBlur, kLabelShadow)));
367 } 371 }
368 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 372 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
369 window_label_button_view_->SetFontList( 373 window_label_button_view_->SetFontList(
370 bundle.GetFontList(ui::ResourceBundle::BoldFont)); 374 bundle.GetFontList(ui::ResourceBundle::BoldFont));
371 window_label_->SetContentsView(window_label_button_view_); 375 window_label_->SetContentsView(window_label_button_view_);
372 if (material) { 376 if (material) {
373 window_label_button_view_->SetVisible(false); 377 window_label_button_view_->SetVisible(false);
374 window_label_->Show(); 378 window_label_->Show();
375 } 379 }
376 } 380 }
377 381
378 void WindowSelectorItem::UpdateHeaderLayout( 382 void WindowSelectorItem::UpdateHeaderLayout(
379 OverviewAnimationType animation_type) { 383 OverviewAnimationType animation_type) {
380 gfx::Rect transformed_window_bounds = ScreenUtil::ConvertRectFromScreen( 384 gfx::Rect transformed_window_bounds =
381 close_button_widget_.GetNativeWindow()->GetRootWindow(), 385 root_window_->ConvertRectFromScreen(GetTransformedBounds(
382 GetTransformedBounds(GetWindow(), 386 GetWindow(), close_button_->GetPreferredSize().height()));
383 close_button_->GetPreferredSize().height()));
384 387
385 { 388 {
386 if (!close_button_->visible()) { 389 if (!close_button_->visible()) {
387 close_button_->SetVisible(true); 390 close_button_->SetVisible(true);
388 SetupFadeInAfterLayout(close_button_widget_.GetNativeWindow()); 391 SetupFadeInAfterLayout(&close_button_widget_);
389 } 392 }
390 ScopedOverviewAnimationSettings animation_settings( 393 wm::WmWindow* close_button_widget_window =
391 animation_type, close_button_widget_.GetNativeWindow()); 394 wm::WmLookup::Get()->GetWindowForWidget(&close_button_widget_);
395 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings =
396 ScopedOverviewAnimationSettingsFactory::Get()
397 ->CreateOverviewAnimationSettings(animation_type,
398 close_button_widget_window);
392 399
393 gfx::Transform close_button_transform; 400 gfx::Transform close_button_transform;
394 close_button_transform.Translate(transformed_window_bounds.right(), 401 close_button_transform.Translate(transformed_window_bounds.right(),
395 transformed_window_bounds.y()); 402 transformed_window_bounds.y());
396 close_button_widget_.GetNativeWindow()->SetTransform( 403 close_button_widget_window->SetTransform(close_button_transform);
397 close_button_transform);
398 } 404 }
399 405
400 // TODO(varkha): Figure out how to draw |window_label_| opaquely over the 406 // TODO(varkha): Figure out how to draw |window_label_| opaquely over the
401 // occluded header or truly hide the headers in overview mode. 407 // occluded header or truly hide the headers in overview mode.
402 if (ash::MaterialDesignController::IsOverviewMaterial()) { 408 if (ash::MaterialDesignController::IsOverviewMaterial()) {
403 gfx::Rect label_rect(close_button_->GetPreferredSize()); 409 gfx::Rect label_rect(close_button_->GetPreferredSize());
404 label_rect.set_y(-label_rect.height()); 410 label_rect.set_y(-label_rect.height());
405 label_rect.set_width(transformed_window_bounds.width() - 411 label_rect.set_width(transformed_window_bounds.width() -
406 label_rect.width()); 412 label_rect.width());
407 window_label_->GetNativeWindow()->SetBounds(label_rect); 413 window_label_->SetBounds(label_rect);
408 414
409 if (!window_label_button_view_->visible()) { 415 if (!window_label_button_view_->visible()) {
410 window_label_button_view_->SetVisible(true); 416 window_label_button_view_->SetVisible(true);
411 SetupFadeInAfterLayout(window_label_->GetNativeWindow()); 417 SetupFadeInAfterLayout(window_label_.get());
412 } 418 }
413 ScopedOverviewAnimationSettings animation_settings( 419 wm::WmWindow* window_label_window =
414 animation_type, window_label_->GetNativeWindow()); 420 wm::WmLookup::Get()->GetWindowForWidget(window_label_.get());
421 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings =
422 ScopedOverviewAnimationSettingsFactory::Get()
423 ->CreateOverviewAnimationSettings(animation_type,
424 window_label_window);
415 gfx::Transform label_transform; 425 gfx::Transform label_transform;
416 label_transform.Translate(transformed_window_bounds.x(), 426 label_transform.Translate(transformed_window_bounds.x(),
417 transformed_window_bounds.y()); 427 transformed_window_bounds.y());
418 window_label_->GetNativeWindow()->SetTransform(label_transform); 428 window_label_window->SetTransform(label_transform);
419 } 429 }
420 } 430 }
421 431
422 void WindowSelectorItem::UpdateCloseButtonAccessibilityName() { 432 void WindowSelectorItem::UpdateCloseButtonAccessibilityName() {
423 close_button_->SetAccessibleName(l10n_util::GetStringFUTF16( 433 close_button_->SetAccessibleName(l10n_util::GetStringFUTF16(
424 IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME, 434 IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME,
425 GetWindow()->title())); 435 GetWindow()->GetTitle()));
426 } 436 }
427 437
428 } // namespace ash 438 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/overview/window_selector_item.h ('k') | ash/wm/overview/window_selector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698