| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/system/status_area_widget_delegate.h" | 5 #include "ash/system/status_area_widget_delegate.h" |
| 6 | 6 |
| 7 #include "ash/ash_export.h" | 7 #include "ash/ash_export.h" |
| 8 #include "ash/common/ash_switches.h" | 8 #include "ash/common/ash_switches.h" |
| 9 #include "ash/common/focus_cycler.h" | 9 #include "ash/common/focus_cycler.h" |
| 10 #include "ash/common/material_design/material_design_controller.h" | 10 #include "ash/common/material_design/material_design_controller.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 const int kAnimationDurationMs = 250; | 29 const int kAnimationDurationMs = 250; |
| 30 | 30 |
| 31 class StatusAreaWidgetDelegateAnimationSettings | 31 class StatusAreaWidgetDelegateAnimationSettings |
| 32 : public ui::ScopedLayerAnimationSettings { | 32 : public ui::ScopedLayerAnimationSettings { |
| 33 public: | 33 public: |
| 34 explicit StatusAreaWidgetDelegateAnimationSettings(ui::Layer* layer) | 34 explicit StatusAreaWidgetDelegateAnimationSettings(ui::Layer* layer) |
| 35 : ui::ScopedLayerAnimationSettings(layer->GetAnimator()) { | 35 : ui::ScopedLayerAnimationSettings(layer->GetAnimator()) { |
| 36 SetTransitionDuration( | 36 SetTransitionDuration( |
| 37 base::TimeDelta::FromMilliseconds(kAnimationDurationMs)); | 37 base::TimeDelta::FromMilliseconds(kAnimationDurationMs)); |
| 38 SetPreemptionStrategy( | 38 SetPreemptionStrategy(ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 39 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | |
| 40 SetTweenType(gfx::Tween::EASE_IN_OUT); | 39 SetTweenType(gfx::Tween::EASE_IN_OUT); |
| 41 } | 40 } |
| 42 | 41 |
| 43 ~StatusAreaWidgetDelegateAnimationSettings() override {} | 42 ~StatusAreaWidgetDelegateAnimationSettings() override {} |
| 44 | 43 |
| 45 private: | 44 private: |
| 46 DISALLOW_COPY_AND_ASSIGN(StatusAreaWidgetDelegateAnimationSettings); | 45 DISALLOW_COPY_AND_ASSIGN(StatusAreaWidgetDelegateAnimationSettings); |
| 47 }; | 46 }; |
| 48 | 47 |
| 49 } // namespace | 48 } // namespace |
| 50 | 49 |
| 51 namespace ash { | 50 namespace ash { |
| 52 | 51 |
| 53 StatusAreaWidgetDelegate::StatusAreaWidgetDelegate() | 52 StatusAreaWidgetDelegate::StatusAreaWidgetDelegate() |
| 54 : focus_cycler_for_testing_(nullptr), alignment_(SHELF_ALIGNMENT_BOTTOM) { | 53 : focus_cycler_for_testing_(nullptr), alignment_(SHELF_ALIGNMENT_BOTTOM) { |
| 55 // Allow the launcher to surrender the focus to another window upon | 54 // Allow the launcher to surrender the focus to another window upon |
| 56 // navigation completion by the user. | 55 // navigation completion by the user. |
| 57 set_allow_deactivate_on_esc(true); | 56 set_allow_deactivate_on_esc(true); |
| 58 SetPaintToLayer(true); | 57 SetPaintToLayer(true); |
| 59 layer()->SetFillsBoundsOpaquely(false); | 58 layer()->SetFillsBoundsOpaquely(false); |
| 60 } | 59 } |
| 61 | 60 |
| 62 StatusAreaWidgetDelegate::~StatusAreaWidgetDelegate() { | 61 StatusAreaWidgetDelegate::~StatusAreaWidgetDelegate() {} |
| 63 } | |
| 64 | 62 |
| 65 void StatusAreaWidgetDelegate::SetFocusCyclerForTesting( | 63 void StatusAreaWidgetDelegate::SetFocusCyclerForTesting( |
| 66 const FocusCycler* focus_cycler) { | 64 const FocusCycler* focus_cycler) { |
| 67 focus_cycler_for_testing_ = focus_cycler; | 65 focus_cycler_for_testing_ = focus_cycler; |
| 68 } | 66 } |
| 69 | 67 |
| 70 views::View* StatusAreaWidgetDelegate::GetDefaultFocusableChild() { | 68 views::View* StatusAreaWidgetDelegate::GetDefaultFocusableChild() { |
| 71 return child_at(0); | 69 return child_at(0); |
| 72 } | 70 } |
| 73 | 71 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 91 | 89 |
| 92 bool StatusAreaWidgetDelegate::CanActivate() const { | 90 bool StatusAreaWidgetDelegate::CanActivate() const { |
| 93 // We don't want mouse clicks to activate us, but we need to allow | 91 // We don't want mouse clicks to activate us, but we need to allow |
| 94 // activation when the user is using the keyboard (FocusCycler). | 92 // activation when the user is using the keyboard (FocusCycler). |
| 95 const FocusCycler* focus_cycler = focus_cycler_for_testing_ | 93 const FocusCycler* focus_cycler = focus_cycler_for_testing_ |
| 96 ? focus_cycler_for_testing_ | 94 ? focus_cycler_for_testing_ |
| 97 : WmShell::Get()->focus_cycler(); | 95 : WmShell::Get()->focus_cycler(); |
| 98 return focus_cycler->widget_activating() == GetWidget(); | 96 return focus_cycler->widget_activating() == GetWidget(); |
| 99 } | 97 } |
| 100 | 98 |
| 101 void StatusAreaWidgetDelegate::DeleteDelegate() { | 99 void StatusAreaWidgetDelegate::DeleteDelegate() {} |
| 102 } | |
| 103 | 100 |
| 104 void StatusAreaWidgetDelegate::AddTray(views::View* tray) { | 101 void StatusAreaWidgetDelegate::AddTray(views::View* tray) { |
| 105 SetLayoutManager(NULL); // Reset layout manager before adding a child. | 102 SetLayoutManager(NULL); // Reset layout manager before adding a child. |
| 106 AddChildView(tray); | 103 AddChildView(tray); |
| 107 // Set the layout manager with the new list of children. | 104 // Set the layout manager with the new list of children. |
| 108 UpdateLayout(); | 105 UpdateLayout(); |
| 109 } | 106 } |
| 110 | 107 |
| 111 void StatusAreaWidgetDelegate::UpdateLayout() { | 108 void StatusAreaWidgetDelegate::UpdateLayout() { |
| 112 // Use a grid layout so that the trays can be centered in each cell, and | 109 // Use a grid layout so that the trays can be centered in each cell, and |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 on_edge ? GetTrayConstant(TRAY_PADDING_FROM_EDGE_OF_SHELF) : 0; | 234 on_edge ? GetTrayConstant(TRAY_PADDING_FROM_EDGE_OF_SHELF) : 0; |
| 238 right_edge = | 235 right_edge = |
| 239 GetShelfConstant(SHELF_SIZE) - kShelfItemInset - kShelfItemHeight; | 236 GetShelfConstant(SHELF_SIZE) - kShelfItemInset - kShelfItemHeight; |
| 240 } | 237 } |
| 241 } | 238 } |
| 242 child->SetBorder(views::Border::CreateEmptyBorder(top_edge, left_edge, | 239 child->SetBorder(views::Border::CreateEmptyBorder(top_edge, left_edge, |
| 243 bottom_edge, right_edge)); | 240 bottom_edge, right_edge)); |
| 244 } | 241 } |
| 245 | 242 |
| 246 } // namespace ash | 243 } // namespace ash |
| OLD | NEW |