OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/common/wm/dock/docked_window_layout_manager.h" | 5 #include "ash/common/wm/dock/docked_window_layout_manager.h" |
6 | 6 |
7 #include "ash/animation/animation_change_type.h" | 7 #include "ash/animation/animation_change_type.h" |
8 #include "ash/common/shelf/shelf_background_animator.h" | 8 #include "ash/common/shelf/shelf_background_animator.h" |
9 #include "ash/common/shelf/shelf_background_animator_observer.h" | 9 #include "ash/common/shelf/shelf_background_animator_observer.h" |
10 #include "ash/common/shelf/shelf_constants.h" | 10 #include "ash/common/shelf/shelf_constants.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 const int kFadeDurationMs = 60; | 49 const int kFadeDurationMs = 60; |
50 const int kMinimizeDurationMs = 720; | 50 const int kMinimizeDurationMs = 720; |
51 | 51 |
52 class DockedBackgroundWidget : public views::Widget, | 52 class DockedBackgroundWidget : public views::Widget, |
53 public WmShelfObserver, | 53 public WmShelfObserver, |
54 public ShelfBackgroundAnimatorObserver { | 54 public ShelfBackgroundAnimatorObserver { |
55 public: | 55 public: |
56 explicit DockedBackgroundWidget(DockedWindowLayoutManager* manager) | 56 explicit DockedBackgroundWidget(DockedWindowLayoutManager* manager) |
57 : manager_(manager), | 57 : manager_(manager), |
58 alignment_(DOCKED_ALIGNMENT_NONE), | 58 alignment_(DOCKED_ALIGNMENT_NONE), |
59 background_animator_(SHELF_BACKGROUND_DEFAULT, nullptr), | 59 background_animator_(SHELF_BACKGROUND_DEFAULT, |
| 60 nullptr, |
| 61 WmShell::Get()->wallpaper_controller()), |
60 opaque_background_(ui::LAYER_SOLID_COLOR), | 62 opaque_background_(ui::LAYER_SOLID_COLOR), |
61 visible_background_type_(manager_->shelf()->GetBackgroundType()), | 63 visible_background_type_(manager_->shelf()->GetBackgroundType()), |
62 visible_background_change_type_(AnimationChangeType::IMMEDIATE) { | 64 visible_background_change_type_(AnimationChangeType::IMMEDIATE) { |
63 manager_->shelf()->AddObserver(this); | 65 manager_->shelf()->AddObserver(this); |
64 InitWidget(manager_->dock_container()); | 66 InitWidget(manager_->dock_container()); |
65 | 67 |
66 background_animator_.AddObserver(this); | 68 background_animator_.AddObserver(this); |
67 } | 69 } |
68 | 70 |
69 ~DockedBackgroundWidget() override { | 71 ~DockedBackgroundWidget() override { |
70 background_animator_.RemoveObserver(this); | 72 background_animator_.RemoveObserver(this); |
71 manager_->shelf()->RemoveObserver(this); | 73 manager_->shelf()->RemoveObserver(this); |
72 } | 74 } |
73 | 75 |
74 // Sets widget bounds and sizes opaque background layer to fill the widget. | 76 // Sets widget bounds and sizes opaque background layer to fill the widget. |
75 void SetBackgroundBounds(const gfx::Rect& bounds, DockedAlignment alignment) { | 77 void SetBackgroundBounds(const gfx::Rect& bounds, DockedAlignment alignment) { |
76 SetBounds(bounds); | 78 SetBounds(bounds); |
77 opaque_background_.SetBounds(gfx::Rect(bounds.size())); | 79 opaque_background_.SetBounds(gfx::Rect(bounds.size())); |
78 alignment_ = alignment; | 80 alignment_ = alignment; |
79 } | 81 } |
80 | 82 |
81 private: | 83 private: |
82 // views::Widget: | 84 // views::Widget: |
83 void OnNativeWidgetVisibilityChanged(bool visible) override { | 85 void OnNativeWidgetVisibilityChanged(bool visible) override { |
84 views::Widget::OnNativeWidgetVisibilityChanged(visible); | 86 views::Widget::OnNativeWidgetVisibilityChanged(visible); |
85 UpdateBackground(); | 87 UpdateBackground(); |
86 } | 88 } |
87 | 89 |
88 // ShelfBackgroundAnimatorObserver: | 90 // ShelfBackgroundAnimatorObserver: |
89 void UpdateShelfBackground(int alpha) override { | 91 void UpdateShelfBackground(SkColor color) override { |
90 const float kMaxAlpha = 255.0f; | 92 opaque_background_.SetColor(color); |
91 opaque_background_.SetOpacity(alpha / kMaxAlpha); | |
92 } | 93 } |
93 | 94 |
94 // WmShelfObserver: | 95 // WmShelfObserver: |
95 void OnBackgroundTypeChanged(ShelfBackgroundType background_type, | 96 void OnBackgroundTypeChanged(ShelfBackgroundType background_type, |
96 AnimationChangeType change_type) override { | 97 AnimationChangeType change_type) override { |
97 // Sets the background type. Starts an animation to transition to | 98 // Sets the background type. Starts an animation to transition to |
98 // |background_type| if the widget is visible. If the widget is not visible, | 99 // |background_type| if the widget is visible. If the widget is not visible, |
99 // the animation is postponed till the widget becomes visible. | 100 // the animation is postponed till the widget becomes visible. |
100 visible_background_type_ = background_type; | 101 visible_background_type_ = background_type; |
101 visible_background_change_type_ = change_type; | 102 visible_background_change_type_ = change_type; |
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1327 const gfx::Rect& keyboard_bounds) { | 1328 const gfx::Rect& keyboard_bounds) { |
1328 // This bounds change will have caused a change to the Shelf which does not | 1329 // This bounds change will have caused a change to the Shelf which does not |
1329 // propagate automatically to this class, so manually recalculate bounds. | 1330 // propagate automatically to this class, so manually recalculate bounds. |
1330 Relayout(); | 1331 Relayout(); |
1331 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); | 1332 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); |
1332 } | 1333 } |
1333 | 1334 |
1334 void DockedWindowLayoutManager::OnKeyboardClosed() {} | 1335 void DockedWindowLayoutManager::OnKeyboardClosed() {} |
1335 | 1336 |
1336 } // namespace ash | 1337 } // namespace ash |
OLD | NEW |