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

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

Powered by Google App Engine
This is Rietveld 408576698