| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/shelf/shelf_widget.h" | 5 #include "ash/common/shelf/shelf_widget.h" |
| 6 | 6 |
| 7 #include "ash/animation/animation_change_type.h" | 7 #include "ash/animation/animation_change_type.h" |
| 8 #include "ash/common/focus_cycler.h" | 8 #include "ash/common/focus_cycler.h" |
| 9 #include "ash/common/session/session_state_delegate.h" | 9 #include "ash/common/session/session_state_delegate.h" |
| 10 #include "ash/common/shelf/app_list_button.h" | 10 #include "ash/common/shelf/app_list_button.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 // views::WidgetDelegateView overrides: | 55 // views::WidgetDelegateView overrides: |
| 56 views::Widget* GetWidget() override { return View::GetWidget(); } | 56 views::Widget* GetWidget() override { return View::GetWidget(); } |
| 57 const views::Widget* GetWidget() const override { return View::GetWidget(); } | 57 const views::Widget* GetWidget() const override { return View::GetWidget(); } |
| 58 | 58 |
| 59 bool CanActivate() const override; | 59 bool CanActivate() const override; |
| 60 void ReorderChildLayers(ui::Layer* parent_layer) override; | 60 void ReorderChildLayers(ui::Layer* parent_layer) override; |
| 61 // This will be called when the parent local bounds change. | 61 // This will be called when the parent local bounds change. |
| 62 void OnBoundsChanged(const gfx::Rect& old_bounds) override; | 62 void OnBoundsChanged(const gfx::Rect& old_bounds) override; |
| 63 | 63 |
| 64 // ShelfBackgroundAnimatorObserver: | 64 // ShelfBackgroundAnimatorObserver: |
| 65 void UpdateShelfBackground(int alpha) override; | 65 void UpdateShelfBackground(SkColor color) override; |
| 66 | 66 |
| 67 private: | 67 private: |
| 68 ShelfWidget* shelf_widget_; | 68 ShelfWidget* shelf_widget_; |
| 69 FocusCycler* focus_cycler_; | 69 FocusCycler* focus_cycler_; |
| 70 // A black background layer that may be visible depending on a | 70 // A black background layer that may be visible depending on a |
| 71 // ShelfBackgroundAnimator. | 71 // ShelfBackgroundAnimator. |
| 72 // TODO(bruthig): Remove opaque_background_ (see https://crbug.com/621551). | 72 // TODO(bruthig): Remove opaque_background_ (see https://crbug.com/621551). |
| 73 ui::Layer opaque_background_; | 73 ui::Layer opaque_background_; |
| 74 // A black foreground layer which is shown while transitioning between users. | 74 // A black foreground layer which is shown while transitioning between users. |
| 75 // Note: Since the back- and foreground layers have different functions they | 75 // Note: Since the back- and foreground layers have different functions they |
| 76 // can be used simultaneously - so no repurposing possible. | 76 // can be used simultaneously - so no repurposing possible. |
| 77 ui::Layer opaque_foreground_; | 77 ui::Layer opaque_foreground_; |
| 78 | 78 |
| 79 DISALLOW_COPY_AND_ASSIGN(DelegateView); | 79 DISALLOW_COPY_AND_ASSIGN(DelegateView); |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 ShelfWidget::DelegateView::DelegateView(ShelfWidget* shelf_widget) | 82 ShelfWidget::DelegateView::DelegateView(ShelfWidget* shelf_widget) |
| 83 : shelf_widget_(shelf_widget), | 83 : shelf_widget_(shelf_widget), |
| 84 focus_cycler_(nullptr), | 84 focus_cycler_(nullptr), |
| 85 opaque_background_(ui::LAYER_SOLID_COLOR), | 85 opaque_background_(ui::LAYER_SOLID_COLOR), |
| 86 opaque_foreground_(ui::LAYER_SOLID_COLOR) { | 86 opaque_foreground_(ui::LAYER_SOLID_COLOR) { |
| 87 DCHECK(shelf_widget_); | 87 DCHECK(shelf_widget_); |
| 88 SetLayoutManager(new views::FillLayout()); | 88 SetLayoutManager(new views::FillLayout()); |
| 89 set_allow_deactivate_on_esc(true); | 89 set_allow_deactivate_on_esc(true); |
| 90 opaque_background_.SetColor(SK_ColorBLACK); | 90 opaque_background_.SetColor(SK_ColorBLACK); |
| 91 opaque_background_.SetBounds(GetLocalBounds()); | 91 opaque_background_.SetBounds(GetLocalBounds()); |
| 92 opaque_background_.SetOpacity(0.0f); | |
| 93 opaque_foreground_.SetColor(SK_ColorBLACK); | 92 opaque_foreground_.SetColor(SK_ColorBLACK); |
| 94 opaque_foreground_.SetBounds(GetLocalBounds()); | 93 opaque_foreground_.SetBounds(GetLocalBounds()); |
| 95 opaque_foreground_.SetOpacity(0.0f); | 94 opaque_foreground_.SetOpacity(0.0f); |
| 96 } | 95 } |
| 97 | 96 |
| 98 ShelfWidget::DelegateView::~DelegateView() {} | 97 ShelfWidget::DelegateView::~DelegateView() {} |
| 99 | 98 |
| 100 void ShelfWidget::DelegateView::SetParentLayer(ui::Layer* layer) { | 99 void ShelfWidget::DelegateView::SetParentLayer(ui::Layer* layer) { |
| 101 layer->Add(&opaque_background_); | 100 layer->Add(&opaque_background_); |
| 102 layer->Add(&opaque_foreground_); | 101 layer->Add(&opaque_foreground_); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 118 views::View::ReorderChildLayers(parent_layer); | 117 views::View::ReorderChildLayers(parent_layer); |
| 119 parent_layer->StackAtBottom(&opaque_background_); | 118 parent_layer->StackAtBottom(&opaque_background_); |
| 120 parent_layer->StackAtTop(&opaque_foreground_); | 119 parent_layer->StackAtTop(&opaque_foreground_); |
| 121 } | 120 } |
| 122 | 121 |
| 123 void ShelfWidget::DelegateView::OnBoundsChanged(const gfx::Rect& old_bounds) { | 122 void ShelfWidget::DelegateView::OnBoundsChanged(const gfx::Rect& old_bounds) { |
| 124 opaque_background_.SetBounds(GetLocalBounds()); | 123 opaque_background_.SetBounds(GetLocalBounds()); |
| 125 opaque_foreground_.SetBounds(GetLocalBounds()); | 124 opaque_foreground_.SetBounds(GetLocalBounds()); |
| 126 } | 125 } |
| 127 | 126 |
| 128 void ShelfWidget::DelegateView::UpdateShelfBackground(int alpha) { | 127 void ShelfWidget::DelegateView::UpdateShelfBackground(SkColor color) { |
| 129 const float kMaxAlpha = 255.0f; | 128 opaque_background_.SetColor(color); |
| 130 opaque_background_.SetOpacity(alpha / kMaxAlpha); | |
| 131 } | 129 } |
| 132 | 130 |
| 133 ShelfWidget::ShelfWidget(WmWindow* shelf_container, WmShelf* wm_shelf) | 131 ShelfWidget::ShelfWidget(WmWindow* shelf_container, WmShelf* wm_shelf) |
| 134 : wm_shelf_(wm_shelf), | 132 : wm_shelf_(wm_shelf), |
| 135 status_area_widget_(nullptr), | 133 status_area_widget_(nullptr), |
| 136 delegate_view_(new DelegateView(this)), | 134 delegate_view_(new DelegateView(this)), |
| 137 shelf_view_(nullptr), | 135 shelf_view_(nullptr), |
| 138 background_animator_(SHELF_BACKGROUND_DEFAULT, wm_shelf_), | 136 background_animator_(SHELF_BACKGROUND_DEFAULT, |
| 137 wm_shelf_, |
| 138 WmShell::Get()->wallpaper_controller()), |
| 139 activating_as_fallback_(false) { | 139 activating_as_fallback_(false) { |
| 140 DCHECK(wm_shelf_); | 140 DCHECK(wm_shelf_); |
| 141 background_animator_.AddObserver(this); | 141 background_animator_.AddObserver(this); |
| 142 background_animator_.AddObserver(delegate_view_); | 142 background_animator_.AddObserver(delegate_view_); |
| 143 | 143 |
| 144 views::Widget::InitParams params( | 144 views::Widget::InitParams params( |
| 145 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 145 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| 146 params.name = "ShelfWidget"; | 146 params.name = "ShelfWidget"; |
| 147 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 147 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 148 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 148 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 | 339 |
| 340 void ShelfWidget::OnWidgetActivationChanged(views::Widget* widget, | 340 void ShelfWidget::OnWidgetActivationChanged(views::Widget* widget, |
| 341 bool active) { | 341 bool active) { |
| 342 activating_as_fallback_ = false; | 342 activating_as_fallback_ = false; |
| 343 if (active) | 343 if (active) |
| 344 delegate_view_->SetPaneFocusAndFocusDefault(); | 344 delegate_view_->SetPaneFocusAndFocusDefault(); |
| 345 else | 345 else |
| 346 delegate_view_->GetFocusManager()->ClearFocus(); | 346 delegate_view_->GetFocusManager()->ClearFocus(); |
| 347 } | 347 } |
| 348 | 348 |
| 349 void ShelfWidget::UpdateShelfItemBackground(int alpha) { | 349 void ShelfWidget::UpdateShelfItemBackground(SkColor color) { |
| 350 if (shelf_view_) | 350 if (shelf_view_) |
| 351 shelf_view_->UpdateShelfItemBackground(alpha); | 351 shelf_view_->UpdateShelfItemBackground(color); |
| 352 } | 352 } |
| 353 | 353 |
| 354 void ShelfWidget::WillDeleteShelfLayoutManager() { | 354 void ShelfWidget::WillDeleteShelfLayoutManager() { |
| 355 shelf_layout_manager_->RemoveObserver(this); | 355 shelf_layout_manager_->RemoveObserver(this); |
| 356 shelf_layout_manager_ = nullptr; | 356 shelf_layout_manager_ = nullptr; |
| 357 } | 357 } |
| 358 | 358 |
| 359 } // namespace ash | 359 } // namespace ash |
| OLD | NEW |