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

Side by Side Diff: ash/wm/shelf_layout_manager.cc

Issue 10221028: Move DIP translation from ui/aura to ui/compositor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 7 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
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/wm/shelf_layout_manager.h" 5 #include "ash/wm/shelf_layout_manager.h"
6 6
7 #include "ash/launcher/launcher.h" 7 #include "ash/launcher/launcher.h"
8 #include "ash/screen_ash.h" 8 #include "ash/screen_ash.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_delegate.h" 10 #include "ash/shell_delegate.h"
11 #include "ash/shell_window_ids.h" 11 #include "ash/shell_window_ids.h"
12 #include "ash/system/tray/system_tray.h" 12 #include "ash/system/tray/system_tray.h"
13 #include "ash/wm/workspace/workspace_manager.h" 13 #include "ash/wm/workspace/workspace_manager.h"
14 #include "base/auto_reset.h" 14 #include "base/auto_reset.h"
15 #include "base/i18n/rtl.h" 15 #include "base/i18n/rtl.h"
16 #include "ui/aura/client/activation_client.h" 16 #include "ui/aura/client/activation_client.h"
17 #include "ui/aura/dip_util.h"
18 #include "ui/aura/event.h" 17 #include "ui/aura/event.h"
19 #include "ui/aura/event_filter.h" 18 #include "ui/aura/event_filter.h"
20 #include "ui/aura/root_window.h" 19 #include "ui/aura/root_window.h"
21 #include "ui/gfx/compositor/layer.h" 20 #include "ui/gfx/compositor/layer.h"
22 #include "ui/gfx/compositor/layer_animation_observer.h" 21 #include "ui/gfx/compositor/layer_animation_observer.h"
23 #include "ui/gfx/compositor/layer_animator.h" 22 #include "ui/gfx/compositor/layer_animator.h"
24 #include "ui/gfx/compositor/scoped_layer_animation_settings.h" 23 #include "ui/gfx/compositor/scoped_layer_animation_settings.h"
25 #include "ui/gfx/screen.h" 24 #include "ui/gfx/screen.h"
26 #include "ui/views/widget/widget.h" 25 #include "ui/views/widget/widget.h"
27 26
28 namespace ash { 27 namespace ash {
29 namespace internal { 28 namespace internal {
30 29
31 namespace { 30 namespace {
32 31
33 // Delay before showing the launcher. This is after the mouse stops moving. 32 // Delay before showing the launcher. This is after the mouse stops moving.
34 const int kAutoHideDelayMS = 200; 33 const int kAutoHideDelayMS = 200;
35 34
36 ui::Layer* GetLayer(views::Widget* widget) { 35 ui::Layer* GetLayer(views::Widget* widget) {
37 return widget->GetNativeView()->layer(); 36 return widget->GetNativeView()->layer();
38 } 37 }
39 38
40 void SetLayerBounds(views::Widget* widget, const gfx::Rect& bounds) {
41 aura::Window* window = widget->GetNativeView();
42 window->layer()->SetBounds(aura::ConvertRectToPixel(window, bounds));
43 }
44
45 } // namespace 39 } // namespace
46 40
47 // static 41 // static
48 const int ShelfLayoutManager::kWorkspaceAreaBottomInset = 2; 42 const int ShelfLayoutManager::kWorkspaceAreaBottomInset = 2;
49 43
50 // static 44 // static
51 const int ShelfLayoutManager::kAutoHideHeight = 2; 45 const int ShelfLayoutManager::kAutoHideHeight = 2;
52 46
53 // Notifies ShelfLayoutManager any time the mouse moves. 47 // Notifies ShelfLayoutManager any time the mouse moves.
54 class ShelfLayoutManager::AutoHideEventFilter : public aura::EventFilter { 48 class ShelfLayoutManager::AutoHideEventFilter : public aura::EventFilter {
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 StopAnimating(); 321 StopAnimating();
328 state_ = state; 322 state_ = state;
329 TargetBounds target_bounds; 323 TargetBounds target_bounds;
330 CalculateTargetBounds(state_, &target_bounds); 324 CalculateTargetBounds(state_, &target_bounds);
331 if (launcher_widget()) { 325 if (launcher_widget()) {
332 ui::ScopedLayerAnimationSettings launcher_animation_setter( 326 ui::ScopedLayerAnimationSettings launcher_animation_setter(
333 GetLayer(launcher_widget())->GetAnimator()); 327 GetLayer(launcher_widget())->GetAnimator());
334 launcher_animation_setter.SetTransitionDuration( 328 launcher_animation_setter.SetTransitionDuration(
335 base::TimeDelta::FromMilliseconds(130)); 329 base::TimeDelta::FromMilliseconds(130));
336 launcher_animation_setter.SetTweenType(ui::Tween::EASE_OUT); 330 launcher_animation_setter.SetTweenType(ui::Tween::EASE_OUT);
337 SetLayerBounds(launcher_widget(), target_bounds.launcher_bounds); 331 GetLayer(launcher_widget())->SetBounds(target_bounds.launcher_bounds);
338 GetLayer(launcher_widget())->SetOpacity(target_bounds.opacity); 332 GetLayer(launcher_widget())->SetOpacity(target_bounds.opacity);
339 } 333 }
340 ui::ScopedLayerAnimationSettings status_animation_setter( 334 ui::ScopedLayerAnimationSettings status_animation_setter(
341 GetLayer(status_)->GetAnimator()); 335 GetLayer(status_)->GetAnimator());
342 status_animation_setter.SetTransitionDuration( 336 status_animation_setter.SetTransitionDuration(
343 base::TimeDelta::FromMilliseconds(130)); 337 base::TimeDelta::FromMilliseconds(130));
344 status_animation_setter.SetTweenType(ui::Tween::EASE_OUT); 338 status_animation_setter.SetTweenType(ui::Tween::EASE_OUT);
345 SetLayerBounds(status_, target_bounds.status_bounds); 339 GetLayer(status_)->SetBounds(target_bounds.status_bounds);
346 GetLayer(status_)->SetOpacity(target_bounds.opacity); 340 GetLayer(status_)->SetOpacity(target_bounds.opacity);
347 Shell::GetInstance()->SetMonitorWorkAreaInsets( 341 Shell::GetInstance()->SetMonitorWorkAreaInsets(
348 Shell::GetRootWindow(), 342 Shell::GetRootWindow(),
349 target_bounds.work_area_insets); 343 target_bounds.work_area_insets);
350 UpdateHitTestBounds(); 344 UpdateHitTestBounds();
351 UpdateShelfBackground(change_type); 345 UpdateShelfBackground(change_type);
352 } 346 }
353 347
354 void ShelfLayoutManager::StopAnimating() { 348 void ShelfLayoutManager::StopAnimating() {
355 if (launcher_widget()) 349 if (launcher_widget())
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 bool ShelfLayoutManager::IsShelfWindow(aura::Window* window) { 461 bool ShelfLayoutManager::IsShelfWindow(aura::Window* window) {
468 if (!window) 462 if (!window)
469 return false; 463 return false;
470 return (launcher_widget() && 464 return (launcher_widget() &&
471 launcher_widget()->GetNativeWindow()->Contains(window)) || 465 launcher_widget()->GetNativeWindow()->Contains(window)) ||
472 (status_ && status_->GetNativeWindow()->Contains(window)); 466 (status_ && status_->GetNativeWindow()->Contains(window));
473 } 467 }
474 468
475 } // namespace internal 469 } // namespace internal
476 } // namespace ash 470 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698