OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/window_cycle_list.h" | 5 #include "ash/common/wm/window_cycle_list.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "ash/common/wm/mru_window_tracker.h" | 10 #include "ash/common/wm/mru_window_tracker.h" |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 }; | 206 }; |
207 | 207 |
208 // A view that shows a collection of windows the user can tab through. | 208 // A view that shows a collection of windows the user can tab through. |
209 class WindowCycleView : public views::WidgetDelegateView { | 209 class WindowCycleView : public views::WidgetDelegateView { |
210 public: | 210 public: |
211 explicit WindowCycleView(const WindowCycleList::WindowList& windows) | 211 explicit WindowCycleView(const WindowCycleList::WindowList& windows) |
212 : mirror_container_(new views::View()), | 212 : mirror_container_(new views::View()), |
213 highlight_view_(new views::View()), | 213 highlight_view_(new views::View()), |
214 target_window_(nullptr) { | 214 target_window_(nullptr) { |
215 DCHECK(!windows.empty()); | 215 DCHECK(!windows.empty()); |
216 SetPaintToLayer(true); | 216 SetPaintToLayer(); |
217 layer()->SetFillsBoundsOpaquely(false); | 217 layer()->SetFillsBoundsOpaquely(false); |
218 layer()->SetMasksToBounds(true); | 218 layer()->SetMasksToBounds(true); |
219 layer()->SetOpacity(0.0); | 219 layer()->SetOpacity(0.0); |
220 { | 220 { |
221 ui::ScopedLayerAnimationSettings animate_fade(layer()->GetAnimator()); | 221 ui::ScopedLayerAnimationSettings animate_fade(layer()->GetAnimator()); |
222 animate_fade.SetTransitionDuration( | 222 animate_fade.SetTransitionDuration( |
223 base::TimeDelta::FromMilliseconds(100)); | 223 base::TimeDelta::FromMilliseconds(100)); |
224 layer()->SetOpacity(1.0); | 224 layer()->SetOpacity(1.0); |
225 } | 225 } |
226 | 226 |
227 const int kInsideBorderPaddingDip = 64; | 227 const int kInsideBorderPaddingDip = 64; |
228 const int kBetweenChildPaddingDip = 10; | 228 const int kBetweenChildPaddingDip = 10; |
229 views::BoxLayout* layout = new views::BoxLayout( | 229 views::BoxLayout* layout = new views::BoxLayout( |
230 views::BoxLayout::kHorizontal, kInsideBorderPaddingDip, | 230 views::BoxLayout::kHorizontal, kInsideBorderPaddingDip, |
231 kInsideBorderPaddingDip, kBetweenChildPaddingDip); | 231 kInsideBorderPaddingDip, kBetweenChildPaddingDip); |
232 layout->set_cross_axis_alignment( | 232 layout->set_cross_axis_alignment( |
233 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START); | 233 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START); |
234 mirror_container_->SetLayoutManager(layout); | 234 mirror_container_->SetLayoutManager(layout); |
235 mirror_container_->SetPaintToLayer(true); | 235 mirror_container_->SetPaintToLayer(); |
236 mirror_container_->layer()->SetFillsBoundsOpaquely(false); | 236 mirror_container_->layer()->SetFillsBoundsOpaquely(false); |
237 | 237 |
238 for (WmWindow* window : windows) { | 238 for (WmWindow* window : windows) { |
239 // |mirror_container_| owns |view|. | 239 // |mirror_container_| owns |view|. |
240 views::View* view = new WindowPreviewView(window); | 240 views::View* view = new WindowPreviewView(window); |
241 window_view_map_[window] = view; | 241 window_view_map_[window] = view; |
242 mirror_container_->AddChildView(view); | 242 mirror_container_->AddChildView(view); |
243 } | 243 } |
244 | 244 |
245 // The background needs to be painted to fill the layer, not the View, | 245 // The background needs to be painted to fill the layer, not the View, |
246 // because the layer animates bounds changes but the View's bounds change | 246 // because the layer animates bounds changes but the View's bounds change |
247 // immediately. | 247 // immediately. |
248 highlight_view_->set_background(new LayerFillBackgroundPainter( | 248 highlight_view_->set_background(new LayerFillBackgroundPainter( |
249 views::Painter::CreateRoundRectWith1PxBorderPainter( | 249 views::Painter::CreateRoundRectWith1PxBorderPainter( |
250 SkColorSetA(SK_ColorWHITE, 0x4D), SkColorSetA(SK_ColorWHITE, 0x33), | 250 SkColorSetA(SK_ColorWHITE, 0x4D), SkColorSetA(SK_ColorWHITE, 0x33), |
251 kBackgroundCornerRadius))); | 251 kBackgroundCornerRadius))); |
252 highlight_view_->SetPaintToLayer(true); | 252 highlight_view_->SetPaintToLayer(); |
| 253 |
253 highlight_view_->layer()->SetFillsBoundsOpaquely(false); | 254 highlight_view_->layer()->SetFillsBoundsOpaquely(false); |
254 | 255 |
255 AddChildView(highlight_view_); | 256 AddChildView(highlight_view_); |
256 AddChildView(mirror_container_); | 257 AddChildView(mirror_container_); |
257 } | 258 } |
258 | 259 |
259 ~WindowCycleView() override {} | 260 ~WindowCycleView() override {} |
260 | 261 |
261 void SetTargetWindow(WmWindow* target) { | 262 void SetTargetWindow(WmWindow* target) { |
262 target_window_ = target; | 263 target_window_ = target; |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 widget->Init(params); | 552 widget->Init(params); |
552 | 553 |
553 screen_observer_.Add(display::Screen::GetScreen()); | 554 screen_observer_.Add(display::Screen::GetScreen()); |
554 widget->Show(); | 555 widget->Show(); |
555 widget->SetCapture(cycle_view_); | 556 widget->SetCapture(cycle_view_); |
556 widget->set_auto_release_capture(false); | 557 widget->set_auto_release_capture(false); |
557 cycle_ui_widget_ = widget; | 558 cycle_ui_widget_ = widget; |
558 } | 559 } |
559 | 560 |
560 } // namespace ash | 561 } // namespace ash |
OLD | NEW |