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

Side by Side Diff: ash/common/wm/dock/docked_window_layout_manager.cc

Issue 2679333002: [ash-md] Remove the number of animators used for the Shelf animations. (Closed)
Patch Set: Created 3 years, 10 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) 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/common/shelf/shelf_background_animator.h" 7 #include "ash/common/shelf/shelf_background_animator.h"
8 #include "ash/common/shelf/shelf_background_animator_observer.h" 8 #include "ash/common/shelf/shelf_background_animator_observer.h"
9 #include "ash/common/shelf/shelf_constants.h" 9 #include "ash/common/shelf/shelf_constants.h"
10 #include "ash/common/shelf/wm_shelf.h" 10 #include "ash/common/shelf/wm_shelf.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 class DockedBackgroundWidget : public views::Widget, 49 class DockedBackgroundWidget : public views::Widget,
50 public WmShelfObserver, 50 public WmShelfObserver,
51 public ShelfBackgroundAnimatorObserver { 51 public ShelfBackgroundAnimatorObserver {
52 public: 52 public:
53 explicit DockedBackgroundWidget(DockedWindowLayoutManager* manager) 53 explicit DockedBackgroundWidget(DockedWindowLayoutManager* manager)
54 : manager_(manager), 54 : manager_(manager),
55 alignment_(DOCKED_ALIGNMENT_NONE), 55 alignment_(DOCKED_ALIGNMENT_NONE),
56 background_animator_(SHELF_BACKGROUND_DEFAULT, nullptr), 56 background_animator_(SHELF_BACKGROUND_DEFAULT, nullptr),
57 opaque_background_(ui::LAYER_SOLID_COLOR), 57 opaque_background_(ui::LAYER_SOLID_COLOR),
58 visible_background_type_(manager_->shelf()->GetBackgroundType()), 58 visible_background_type_(manager_->shelf()->GetBackgroundType()),
59 visible_background_change_type_(BACKGROUND_CHANGE_IMMEDIATE) { 59 visible_background_change_type_(gfx::ANIMATION_CHANGE_IMMEDIATE) {
60 manager_->shelf()->AddObserver(this); 60 manager_->shelf()->AddObserver(this);
61 InitWidget(manager_->dock_container()); 61 InitWidget(manager_->dock_container());
62 62
63 background_animator_.AddObserver(this); 63 background_animator_.AddObserver(this);
64 } 64 }
65 65
66 ~DockedBackgroundWidget() override { 66 ~DockedBackgroundWidget() override {
67 background_animator_.RemoveObserver(this); 67 background_animator_.RemoveObserver(this);
68 manager_->shelf()->RemoveObserver(this); 68 manager_->shelf()->RemoveObserver(this);
69 } 69 }
70 70
71 // Sets widget bounds and sizes opaque background layer to fill the widget. 71 // Sets widget bounds and sizes opaque background layer to fill the widget.
72 void SetBackgroundBounds(const gfx::Rect& bounds, DockedAlignment alignment) { 72 void SetBackgroundBounds(const gfx::Rect& bounds, DockedAlignment alignment) {
73 SetBounds(bounds); 73 SetBounds(bounds);
74 opaque_background_.SetBounds(gfx::Rect(bounds.size())); 74 opaque_background_.SetBounds(gfx::Rect(bounds.size()));
75 alignment_ = alignment; 75 alignment_ = alignment;
76 } 76 }
77 77
78 private: 78 private:
79 // views::Widget: 79 // views::Widget:
80 void OnNativeWidgetVisibilityChanged(bool visible) override { 80 void OnNativeWidgetVisibilityChanged(bool visible) override {
81 views::Widget::OnNativeWidgetVisibilityChanged(visible); 81 views::Widget::OnNativeWidgetVisibilityChanged(visible);
82 UpdateBackground(); 82 UpdateBackground();
83 } 83 }
84 84
85 // ShelfBackgroundAnimatorObserver: 85 // ShelfBackgroundAnimatorObserver:
86 void UpdateShelfOpaqueBackground(int alpha) override { 86 void UpdateShelfBackground(int alpha) override {
87 const float kMaxAlpha = 255.0f; 87 const float kMaxAlpha = 255.0f;
88 opaque_background_.SetOpacity(alpha / kMaxAlpha); 88 opaque_background_.SetOpacity(alpha / kMaxAlpha);
89 } 89 }
90 90
91 // WmShelfObserver: 91 // WmShelfObserver:
92 void OnBackgroundTypeChanged( 92 void OnBackgroundTypeChanged(ShelfBackgroundType background_type,
93 ShelfBackgroundType background_type, 93 gfx::AnimationChangeType change_type) override {
94 BackgroundAnimatorChangeType change_type) override {
95 // Sets the background type. Starts an animation to transition to 94 // Sets the background type. Starts an animation to transition to
96 // |background_type| if the widget is visible. If the widget is not visible, 95 // |background_type| if the widget is visible. If the widget is not visible,
97 // the animation is postponed till the widget becomes visible. 96 // the animation is postponed till the widget becomes visible.
98 visible_background_type_ = background_type; 97 visible_background_type_ = background_type;
99 visible_background_change_type_ = change_type; 98 visible_background_change_type_ = change_type;
100 if (IsVisible()) 99 if (IsVisible())
101 UpdateBackground(); 100 UpdateBackground();
102 } 101 }
103 102
104 void InitWidget(WmWindow* parent) { 103 void InitWidget(WmWindow* parent) {
(...skipping 20 matching lines...) Expand all
125 // added to the container, and UpdateStacking only manages user windows, not 124 // added to the container, and UpdateStacking only manages user windows, not
126 // the background widget. 125 // the background widget.
127 parent->StackChildAtBottom(wm_window); 126 parent->StackChildAtBottom(wm_window);
128 } 127 }
129 128
130 // Transitions to |visible_background_type_| if the widget is visible and to 129 // Transitions to |visible_background_type_| if the widget is visible and to
131 // SHELF_BACKGROUND_DEFAULT if it is not. 130 // SHELF_BACKGROUND_DEFAULT if it is not.
132 void UpdateBackground() { 131 void UpdateBackground() {
133 ShelfBackgroundType background_type = 132 ShelfBackgroundType background_type =
134 IsVisible() ? visible_background_type_ : SHELF_BACKGROUND_DEFAULT; 133 IsVisible() ? visible_background_type_ : SHELF_BACKGROUND_DEFAULT;
135 BackgroundAnimatorChangeType change_type = 134 gfx::AnimationChangeType change_type =
136 IsVisible() ? visible_background_change_type_ 135 IsVisible() ? visible_background_change_type_
137 : BACKGROUND_CHANGE_IMMEDIATE; 136 : gfx::ANIMATION_CHANGE_IMMEDIATE;
138 background_animator_.PaintBackground(background_type, change_type); 137 background_animator_.PaintBackground(background_type, change_type);
139 SchedulePaintInRect(gfx::Rect(GetWindowBoundsInScreen().size())); 138 SchedulePaintInRect(gfx::Rect(GetWindowBoundsInScreen().size()));
140 } 139 }
141 140
142 DockedWindowLayoutManager* manager_; 141 DockedWindowLayoutManager* manager_;
143 142
144 DockedAlignment alignment_; 143 DockedAlignment alignment_;
145 144
146 // The animator for the background transitions. 145 // The animator for the background transitions.
147 ShelfBackgroundAnimator background_animator_; 146 ShelfBackgroundAnimator background_animator_;
148 147
149 // Solid black background that can be made fully opaque. 148 // Solid black background that can be made fully opaque.
150 ui::Layer opaque_background_; 149 ui::Layer opaque_background_;
151 150
152 // The background type to use when the widget is visible. When not visible, 151 // The background type to use when the widget is visible. When not visible,
153 // the widget uses SHELF_BACKGROUND_DEFAULT. 152 // the widget uses SHELF_BACKGROUND_DEFAULT.
154 ShelfBackgroundType visible_background_type_; 153 ShelfBackgroundType visible_background_type_;
155 154
156 // Whether the widget should animate to |visible_background_type_|. 155 // Whether the widget should animate to |visible_background_type_|.
157 BackgroundAnimatorChangeType visible_background_change_type_; 156 gfx::AnimationChangeType visible_background_change_type_;
158 157
159 DISALLOW_COPY_AND_ASSIGN(DockedBackgroundWidget); 158 DISALLOW_COPY_AND_ASSIGN(DockedBackgroundWidget);
160 }; 159 };
161 160
162 namespace { 161 namespace {
163 162
164 // Returns true if a window is a popup or a transient child. 163 // Returns true if a window is a popup or a transient child.
165 bool IsPopupOrTransient(const WmWindow* window) { 164 bool IsPopupOrTransient(const WmWindow* window) {
166 return (window->GetType() == ui::wm::WINDOW_TYPE_POPUP || 165 return (window->GetType() == ui::wm::WINDOW_TYPE_POPUP ||
167 window->GetTransientParent()); 166 window->GetTransientParent());
(...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 const gfx::Rect& keyboard_bounds) { 1318 const gfx::Rect& keyboard_bounds) {
1320 // This bounds change will have caused a change to the Shelf which does not 1319 // This bounds change will have caused a change to the Shelf which does not
1321 // propagate automatically to this class, so manually recalculate bounds. 1320 // propagate automatically to this class, so manually recalculate bounds.
1322 Relayout(); 1321 Relayout();
1323 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); 1322 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING);
1324 } 1323 }
1325 1324
1326 void DockedWindowLayoutManager::OnKeyboardClosed() {} 1325 void DockedWindowLayoutManager::OnKeyboardClosed() {}
1327 1326
1328 } // namespace ash 1327 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698