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/common/system/status_area_widget_delegate.h" | 5 #include "ash/common/system/status_area_widget_delegate.h" |
6 | 6 |
7 #include "ash/common/focus_cycler.h" | 7 #include "ash/common/focus_cycler.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_util.h" | 10 #include "ash/common/shelf/wm_shelf_util.h" |
11 #include "ash/common/system/tray/tray_constants.h" | 11 #include "ash/common/system/tray/tray_constants.h" |
12 #include "ash/common/wm_lookup.h" | 12 #include "ash/common/wm_lookup.h" |
13 #include "ash/common/wm_shell.h" | 13 #include "ash/common/wm_shell.h" |
14 #include "ash/common/wm_window.h" | 14 #include "ash/common/wm_window.h" |
15 #include "ash/root_window_controller.h" | 15 #include "ash/root_window_controller.h" |
16 #include "ui/compositor/layer.h" | 16 #include "ui/compositor/layer.h" |
17 #include "ui/compositor/scoped_layer_animation_settings.h" | 17 #include "ui/compositor/scoped_layer_animation_settings.h" |
18 #include "ui/gfx/animation/tween.h" | 18 #include "ui/gfx/animation/tween.h" |
19 #include "ui/views/accessible_pane_view.h" | 19 #include "ui/views/accessible_pane_view.h" |
20 #include "ui/views/border.h" | 20 #include "ui/views/border.h" |
21 #include "ui/views/layout/grid_layout.h" | 21 #include "ui/views/layout/grid_layout.h" |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 const int kAnimationDurationMs = 250; | 25 constexpr int kAnimationDurationMs = 250; |
| 26 |
| 27 constexpr int kPaddingFromEdgeOfShelf = 3; |
26 | 28 |
27 class StatusAreaWidgetDelegateAnimationSettings | 29 class StatusAreaWidgetDelegateAnimationSettings |
28 : public ui::ScopedLayerAnimationSettings { | 30 : public ui::ScopedLayerAnimationSettings { |
29 public: | 31 public: |
30 explicit StatusAreaWidgetDelegateAnimationSettings(ui::Layer* layer) | 32 explicit StatusAreaWidgetDelegateAnimationSettings(ui::Layer* layer) |
31 : ui::ScopedLayerAnimationSettings(layer->GetAnimator()) { | 33 : ui::ScopedLayerAnimationSettings(layer->GetAnimator()) { |
32 SetTransitionDuration( | 34 SetTransitionDuration( |
33 base::TimeDelta::FromMilliseconds(kAnimationDurationMs)); | 35 base::TimeDelta::FromMilliseconds(kAnimationDurationMs)); |
34 SetPreemptionStrategy(ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 36 SetPreemptionStrategy(ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
35 SetTweenType(gfx::Tween::EASE_IN_OUT); | 37 SetTweenType(gfx::Tween::EASE_IN_OUT); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 bool extend_border_to_edge) { | 176 bool extend_border_to_edge) { |
175 // Tray views are laid out right-to-left or bottom-to-top. | 177 // Tray views are laid out right-to-left or bottom-to-top. |
176 const bool horizontal_alignment = IsHorizontalAlignment(alignment_); | 178 const bool horizontal_alignment = IsHorizontalAlignment(alignment_); |
177 const int padding = (GetShelfConstant(SHELF_SIZE) - kTrayItemSize) / 2; | 179 const int padding = (GetShelfConstant(SHELF_SIZE) - kTrayItemSize) / 2; |
178 | 180 |
179 const int top_edge = horizontal_alignment ? padding : 0; | 181 const int top_edge = horizontal_alignment ? padding : 0; |
180 const int left_edge = horizontal_alignment ? 0 : padding; | 182 const int left_edge = horizontal_alignment ? 0 : padding; |
181 const int bottom_edge = | 183 const int bottom_edge = |
182 horizontal_alignment | 184 horizontal_alignment |
183 ? padding | 185 ? padding |
184 : (extend_border_to_edge ? kTrayPaddingFromEdgeOfShelf : 0); | 186 : (extend_border_to_edge ? kPaddingFromEdgeOfShelf : 0); |
185 const int right_edge = | 187 const int right_edge = |
186 horizontal_alignment | 188 horizontal_alignment |
187 ? (extend_border_to_edge ? kTrayPaddingFromEdgeOfShelf : 0) | 189 ? (extend_border_to_edge ? kPaddingFromEdgeOfShelf : 0) |
188 : padding; | 190 : padding; |
189 child->SetBorder( | 191 child->SetBorder( |
190 views::CreateEmptyBorder(top_edge, left_edge, bottom_edge, right_edge)); | 192 views::CreateEmptyBorder(top_edge, left_edge, bottom_edge, right_edge)); |
191 | 193 |
192 // Layout on |child| needs to be updated based on new border value before | 194 // Layout on |child| needs to be updated based on new border value before |
193 // displaying; otherwise |child| will be showing with old border size. | 195 // displaying; otherwise |child| will be showing with old border size. |
194 // Fix for crbug.com/623438. | 196 // Fix for crbug.com/623438. |
195 child->Layout(); | 197 child->Layout(); |
196 } | 198 } |
197 | 199 |
198 } // namespace ash | 200 } // namespace ash |
OLD | NEW |