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

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

Issue 2053113002: Replaced BackgroundAnimator with ShelfBackgroundAnimator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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/material_design/material_design_controller.h" 7 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/shelf/shelf_constants.h" 8 #include "ash/common/shelf/shelf_constants.h"
9 #include "ash/common/shelf/wm_shelf.h" 9 #include "ash/common/shelf/wm_shelf.h"
10 #include "ash/common/shelf/wm_shelf_observer.h" 10 #include "ash/common/shelf/wm_shelf_observer.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 class DockedBackgroundWidget : public views::Widget, 49 class DockedBackgroundWidget : public views::Widget,
50 public BackgroundAnimatorDelegate, 50 public BackgroundAnimatorDelegate,
51 public WmShelfObserver { 51 public WmShelfObserver {
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_(this, 0, GetShelfConstant(SHELF_BACKGROUND_ALPHA)), 56 background_animator_(this, 0, GetShelfConstant(SHELF_BACKGROUND_ALPHA)),
57 alpha_(0), 57 alpha_(0),
58 // TODO(bruthig): Remove opaque_background_.
58 opaque_background_(ui::LAYER_SOLID_COLOR), 59 opaque_background_(ui::LAYER_SOLID_COLOR),
59 visible_background_type_(manager_->shelf()->GetBackgroundType()), 60 visible_background_type_(manager_->shelf()->GetBackgroundType()),
60 visible_background_change_type_(BACKGROUND_CHANGE_IMMEDIATE) { 61 visible_background_change_type_(BACKGROUND_CHANGE_IMMEDIATE) {
61 manager_->shelf()->AddObserver(this); 62 manager_->shelf()->AddObserver(this);
62 InitWidget(manager_->dock_container()); 63 InitWidget(manager_->dock_container());
63 } 64 }
64 65
65 ~DockedBackgroundWidget() override { 66 ~DockedBackgroundWidget() override {
66 manager_->shelf()->RemoveObserver(this); 67 manager_->shelf()->RemoveObserver(this);
67 } 68 }
68 69
69 // Sets widget bounds and sizes opaque background layer to fill the widget. 70 // Sets widget bounds and sizes opaque background layer to fill the widget.
70 void SetBackgroundBounds(const gfx::Rect& bounds, DockedAlignment alignment) { 71 void SetBackgroundBounds(const gfx::Rect& bounds, DockedAlignment alignment) {
71 SetBounds(bounds); 72 SetBounds(bounds);
73 // TODO(bruthig): Remove opaque_background_.
72 opaque_background_.SetBounds(gfx::Rect(bounds.size())); 74 opaque_background_.SetBounds(gfx::Rect(bounds.size()));
73 alignment_ = alignment; 75 alignment_ = alignment;
74 } 76 }
75 77
76 private: 78 private:
77 // views::Widget: 79 // views::Widget:
78 void OnNativeWidgetVisibilityChanged(bool visible) override { 80 void OnNativeWidgetVisibilityChanged(bool visible) override {
79 views::Widget::OnNativeWidgetVisibilityChanged(visible); 81 views::Widget::OnNativeWidgetVisibilityChanged(visible);
80 UpdateBackground(); 82 UpdateBackground();
81 } 83 }
(...skipping 25 matching lines...) Expand all
107 ? 0 109 ? 0
108 : shelf_background.width() - 1, 110 : shelf_background.width() - 1,
109 0, 1, shelf_background.height(), 111 0, 1, shelf_background.height(),
110 alignment_ == DOCKED_ALIGNMENT_LEFT ? 0 : shelf_background.width(), 0, 112 alignment_ == DOCKED_ALIGNMENT_LEFT ? 0 : shelf_background.width(), 0,
111 local_window_bounds.width() - shelf_background.width(), 113 local_window_bounds.width() - shelf_background.width(),
112 local_window_bounds.height(), false, paint); 114 local_window_bounds.height(), false, paint);
113 } 115 }
114 } 116 }
115 117
116 // BackgroundAnimatorDelegate: 118 // BackgroundAnimatorDelegate:
117 void UpdateBackground(int alpha) override { 119 void UpdateBackground(BackgroundAnimator* animator, int alpha) override {
118 alpha_ = alpha; 120 alpha_ = alpha;
119 SchedulePaintInRect(gfx::Rect(GetWindowBoundsInScreen().size())); 121 SchedulePaintInRect(gfx::Rect(GetWindowBoundsInScreen().size()));
120 } 122 }
121 123
122 // ShelfLayoutManagerObserver: 124 // ShelfLayoutManagerObserver:
123 void OnBackgroundUpdated(ShelfBackgroundType background_type, 125 void OnBackgroundUpdated(ShelfBackgroundType background_type,
124 BackgroundAnimatorChangeType change_type) override { 126 BackgroundAnimatorChangeType change_type) override {
125 // Sets the background type. Starts an animation to transition to 127 // Sets the background type. Starts an animation to transition to
126 // |background_type| if the widget is visible. If the widget is not visible, 128 // |background_type| if the widget is visible. If the widget is not visible,
127 // the animation is postponed till the widget becomes visible. 129 // the animation is postponed till the widget becomes visible.
(...skipping 10 matching lines...) Expand all
138 params.keep_on_top = false; 140 params.keep_on_top = false;
139 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 141 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
140 params.accept_events = false; 142 params.accept_events = false;
141 set_focus_on_creation(false); 143 set_focus_on_creation(false);
142 parent->GetRootWindowController()->ConfigureWidgetInitParamsForContainer( 144 parent->GetRootWindowController()->ConfigureWidgetInitParamsForContainer(
143 this, parent->GetShellWindowId(), &params); 145 this, parent->GetShellWindowId(), &params);
144 Init(params); 146 Init(params);
145 SetVisibilityChangedAnimationsEnabled(false); 147 SetVisibilityChangedAnimationsEnabled(false);
146 WmWindow* wm_window = WmLookup::Get()->GetWindowForWidget(this); 148 WmWindow* wm_window = WmLookup::Get()->GetWindowForWidget(this);
147 wm_window->SetLockedToRoot(true); 149 wm_window->SetLockedToRoot(true);
150 // TODO(bruthig): Remove opaque_background_.
148 opaque_background_.SetColor(SK_ColorBLACK); 151 opaque_background_.SetColor(SK_ColorBLACK);
149 opaque_background_.SetBounds(gfx::Rect(GetWindowBoundsInScreen().size())); 152 opaque_background_.SetBounds(gfx::Rect(GetWindowBoundsInScreen().size()));
150 opaque_background_.SetOpacity(0.0f); 153 opaque_background_.SetOpacity(0.0f);
151 wm_window->GetLayer()->Add(&opaque_background_); 154 wm_window->GetLayer()->Add(&opaque_background_);
152 155
153 if (!MaterialDesignController::IsShelfMaterial()) { 156 if (!MaterialDesignController::IsShelfMaterial()) {
154 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 157 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
155 gfx::ImageSkia shelf_background = 158 gfx::ImageSkia shelf_background =
156 *rb.GetImageSkiaNamed(IDR_ASH_SHELF_BACKGROUND); 159 *rb.GetImageSkiaNamed(IDR_ASH_SHELF_BACKGROUND);
157 shelf_background_left_ = gfx::ImageSkiaOperations::CreateRotatedImage( 160 shelf_background_left_ = gfx::ImageSkiaOperations::CreateRotatedImage(
158 shelf_background, SkBitmapOperations::ROTATION_90_CW); 161 shelf_background, SkBitmapOperations::ROTATION_90_CW);
159 shelf_background_right_ = gfx::ImageSkiaOperations::CreateRotatedImage( 162 shelf_background_right_ = gfx::ImageSkiaOperations::CreateRotatedImage(
160 shelf_background, SkBitmapOperations::ROTATION_270_CW); 163 shelf_background, SkBitmapOperations::ROTATION_270_CW);
161 } 164 }
162 165
163 // This background should be explicitly stacked below any windows already in 166 // This background should be explicitly stacked below any windows already in
164 // the dock, otherwise the z-order is set by the order in which windows were 167 // the dock, otherwise the z-order is set by the order in which windows were
165 // added to the container, and UpdateStacking only manages user windows, not 168 // added to the container, and UpdateStacking only manages user windows, not
166 // the background widget. 169 // the background widget.
167 parent->StackChildAtBottom(wm_window); 170 parent->StackChildAtBottom(wm_window);
168 } 171 }
169 172
173 // TODO(bruthig): Remove opaque_background_ => and this entire method.
170 // Transitions to |visible_background_type_| if the widget is visible and to 174 // Transitions to |visible_background_type_| if the widget is visible and to
171 // SHELF_BACKGROUND_DEFAULT if it is not. 175 // SHELF_BACKGROUND_DEFAULT if it is not.
172 void UpdateBackground() { 176 void UpdateBackground() {
173 ShelfBackgroundType background_type = 177 ShelfBackgroundType background_type =
174 IsVisible() ? visible_background_type_ : SHELF_BACKGROUND_DEFAULT; 178 IsVisible() ? visible_background_type_ : SHELF_BACKGROUND_DEFAULT;
175 BackgroundAnimatorChangeType change_type = 179 BackgroundAnimatorChangeType change_type =
176 IsVisible() ? visible_background_change_type_ 180 IsVisible() ? visible_background_change_type_
177 : BACKGROUND_CHANGE_IMMEDIATE; 181 : BACKGROUND_CHANGE_IMMEDIATE;
178 182
179 float target_opacity = 183 float target_opacity =
(...skipping 13 matching lines...) Expand all
193 // See also ShelfWidget::SetPaintsBackground. 197 // See also ShelfWidget::SetPaintsBackground.
194 background_animator_.SetPaintsBackground( 198 background_animator_.SetPaintsBackground(
195 background_type != SHELF_BACKGROUND_DEFAULT, change_type); 199 background_type != SHELF_BACKGROUND_DEFAULT, change_type);
196 SchedulePaintInRect(gfx::Rect(GetWindowBoundsInScreen().size())); 200 SchedulePaintInRect(gfx::Rect(GetWindowBoundsInScreen().size()));
197 } 201 }
198 202
199 DockedWindowLayoutManager* manager_; 203 DockedWindowLayoutManager* manager_;
200 204
201 DockedAlignment alignment_; 205 DockedAlignment alignment_;
202 206
207 // TODO(bruthig): Replace BackgroundAnimator with ShelfBackgroundAnimator.
203 // The animator for the background transitions. 208 // The animator for the background transitions.
204 BackgroundAnimator background_animator_; 209 BackgroundAnimator background_animator_;
205 210
206 // The alpha to use for drawing image assets covering the docked background. 211 // The alpha to use for drawing image assets covering the docked background.
207 int alpha_; 212 int alpha_;
208 213
214 // TODO(bruthig): Remove opaque_background_.
209 // Solid black background that can be made fully opaque. 215 // Solid black background that can be made fully opaque.
210 ui::Layer opaque_background_; 216 ui::Layer opaque_background_;
211 217
212 // Backgrounds created from shelf background by 90 or 270 degree rotation. 218 // Backgrounds created from shelf background by 90 or 270 degree rotation.
213 // TODO(tdanderson): These members can be removed once the material design 219 // TODO(tdanderson): These members can be removed once the material design
214 // shelf is enabled by default. See crbug.com/614453. 220 // shelf is enabled by default. See crbug.com/614453.
215 gfx::ImageSkia shelf_background_left_; 221 gfx::ImageSkia shelf_background_left_;
216 gfx::ImageSkia shelf_background_right_; 222 gfx::ImageSkia shelf_background_right_;
217 223
218 // The background type to use when the widget is visible. When not visible, 224 // The background type to use when the widget is visible. When not visible,
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1326 1332
1327 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( 1333 void DockedWindowLayoutManager::OnKeyboardBoundsChanging(
1328 const gfx::Rect& keyboard_bounds) { 1334 const gfx::Rect& keyboard_bounds) {
1329 // This bounds change will have caused a change to the Shelf which does not 1335 // This bounds change will have caused a change to the Shelf which does not
1330 // propagate automatically to this class, so manually recalculate bounds. 1336 // propagate automatically to this class, so manually recalculate bounds.
1331 Relayout(); 1337 Relayout();
1332 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); 1338 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING);
1333 } 1339 }
1334 1340
1335 } // namespace ash 1341 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698