| 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/tray/tray_background_view.h" | 5 #include "ash/system/tray/tray_background_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/ash_constants.h" | 9 #include "ash/ash_constants.h" |
| 10 #include "ash/shelf/shelf_constants.h" | 10 #include "ash/shelf/shelf_constants.h" |
| 11 #include "ash/shelf/wm_shelf.h" | 11 #include "ash/shelf/wm_shelf.h" |
| 12 #include "ash/shelf/wm_shelf_util.h" | |
| 13 #include "ash/system/tray/tray_constants.h" | 12 #include "ash/system/tray/tray_constants.h" |
| 13 #include "ash/system/tray/tray_container.h" |
| 14 #include "ash/system/tray/tray_event_filter.h" | 14 #include "ash/system/tray/tray_event_filter.h" |
| 15 #include "ash/wm_window.h" | 15 #include "ash/wm_window.h" |
| 16 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
| 17 #include "ui/accessibility/ax_node_data.h" | 17 #include "ui/accessibility/ax_node_data.h" |
| 18 #include "ui/compositor/layer.h" | 18 #include "ui/compositor/layer.h" |
| 19 #include "ui/compositor/layer_animation_element.h" | 19 #include "ui/compositor/layer_animation_element.h" |
| 20 #include "ui/compositor/scoped_layer_animation_settings.h" | 20 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 21 #include "ui/events/event_constants.h" | |
| 22 #include "ui/gfx/animation/tween.h" | 21 #include "ui/gfx/animation/tween.h" |
| 23 #include "ui/gfx/canvas.h" | 22 #include "ui/gfx/canvas.h" |
| 24 #include "ui/gfx/geometry/rect.h" | 23 #include "ui/gfx/geometry/rect.h" |
| 25 #include "ui/gfx/geometry/size.h" | 24 #include "ui/gfx/geometry/size.h" |
| 26 #include "ui/gfx/scoped_canvas.h" | |
| 27 #include "ui/gfx/transform.h" | 25 #include "ui/gfx/transform.h" |
| 28 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" | 26 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" |
| 29 #include "ui/views/animation/ink_drop_highlight.h" | 27 #include "ui/views/animation/ink_drop_highlight.h" |
| 30 #include "ui/views/animation/ink_drop_mask.h" | 28 #include "ui/views/animation/ink_drop_mask.h" |
| 31 #include "ui/views/background.h" | 29 #include "ui/views/background.h" |
| 32 #include "ui/views/layout/box_layout.h" | 30 #include "ui/views/layout/fill_layout.h" |
| 33 | 31 |
| 34 namespace { | 32 namespace { |
| 35 | 33 |
| 36 const int kAnimationDurationForPopupMs = 200; | 34 const int kAnimationDurationForPopupMs = 200; |
| 37 | 35 |
| 38 // Duration of opacity animation for visibility changes. | 36 // Duration of opacity animation for visibility changes. |
| 39 const int kAnimationDurationForVisibilityMs = 250; | 37 const int kAnimationDurationForVisibilityMs = 250; |
| 40 | 38 |
| 41 // When becoming visible delay the animation so that StatusAreaWidgetDelegate | 39 // When becoming visible delay the animation so that StatusAreaWidgetDelegate |
| 42 // can animate sibling views out of the position to be occuped by the | 40 // can animate sibling views out of the position to be occuped by the |
| 43 // TrayBackgroundView. | 41 // TrayBackgroundView. |
| 44 const int kShowAnimationDelayMs = 100; | 42 const int kShowAnimationDelayMs = 100; |
| 45 | 43 |
| 46 // Switches left and right insets if RTL mode is active. | 44 // Switches left and right insets if RTL mode is active. |
| 47 void MirrorInsetsIfNecessary(gfx::Insets* insets) { | 45 void MirrorInsetsIfNecessary(gfx::Insets* insets) { |
| 48 if (base::i18n::IsRTL()) { | 46 if (base::i18n::IsRTL()) { |
| 49 insets->Set(insets->top(), insets->right(), insets->bottom(), | 47 insets->Set(insets->top(), insets->right(), insets->bottom(), |
| 50 insets->left()); | 48 insets->left()); |
| 51 } | 49 } |
| 52 } | 50 } |
| 53 | 51 |
| 54 // Returns background insets relative to the contents bounds of the view and | 52 // Returns background insets relative to the contents bounds of the view and |
| 55 // mirrored if RTL mode is active. | 53 // mirrored if RTL mode is active. |
| 56 gfx::Insets GetMirroredBackgroundInsets(ash::ShelfAlignment shelf_alignment) { | 54 gfx::Insets GetMirroredBackgroundInsets(bool is_shelf_horizontal) { |
| 57 gfx::Insets insets; | 55 gfx::Insets insets; |
| 58 if (IsHorizontalAlignment(shelf_alignment)) { | 56 if (is_shelf_horizontal) { |
| 59 insets.Set(0, ash::kHitRegionPadding, 0, | 57 insets.Set(0, ash::kHitRegionPadding, 0, |
| 60 ash::kHitRegionPadding + ash::kSeparatorWidth); | 58 ash::kHitRegionPadding + ash::kSeparatorWidth); |
| 61 } else { | 59 } else { |
| 62 insets.Set(ash::kHitRegionPadding, 0, | 60 insets.Set(ash::kHitRegionPadding, 0, |
| 63 ash::kHitRegionPadding + ash::kSeparatorWidth, 0); | 61 ash::kHitRegionPadding + ash::kSeparatorWidth, 0); |
| 64 } | 62 } |
| 65 MirrorInsetsIfNecessary(&insets); | 63 MirrorInsetsIfNecessary(&insets); |
| 66 return insets; | 64 return insets; |
| 67 } | 65 } |
| 68 | 66 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 public: | 98 public: |
| 101 explicit TrayBackground(TrayBackgroundView* tray_background_view) | 99 explicit TrayBackground(TrayBackgroundView* tray_background_view) |
| 102 : tray_background_view_(tray_background_view), | 100 : tray_background_view_(tray_background_view), |
| 103 color_(SK_ColorTRANSPARENT) {} | 101 color_(SK_ColorTRANSPARENT) {} |
| 104 | 102 |
| 105 ~TrayBackground() override {} | 103 ~TrayBackground() override {} |
| 106 | 104 |
| 107 void set_color(SkColor color) { color_ = color; } | 105 void set_color(SkColor color) { color_ = color; } |
| 108 | 106 |
| 109 private: | 107 private: |
| 110 WmShelf* GetShelf() const { return tray_background_view_->shelf(); } | |
| 111 | |
| 112 // Overridden from views::Background. | 108 // Overridden from views::Background. |
| 113 void Paint(gfx::Canvas* canvas, views::View* view) const override { | 109 void Paint(gfx::Canvas* canvas, views::View* view) const override { |
| 114 cc::PaintFlags background_flags; | 110 cc::PaintFlags background_flags; |
| 115 background_flags.setAntiAlias(true); | 111 background_flags.setAntiAlias(true); |
| 116 background_flags.setColor(color_); | 112 background_flags.setColor(color_); |
| 117 gfx::Insets insets = | 113 gfx::Insets insets = GetMirroredBackgroundInsets( |
| 118 GetMirroredBackgroundInsets(GetShelf()->GetAlignment()); | 114 tray_background_view_->shelf()->IsHorizontalAlignment()); |
| 119 gfx::Rect bounds = view->GetLocalBounds(); | 115 gfx::Rect bounds = view->GetLocalBounds(); |
| 120 bounds.Inset(insets); | 116 bounds.Inset(insets); |
| 121 canvas->DrawRoundRect(bounds, kTrayRoundedBorderRadius, background_flags); | 117 canvas->DrawRoundRect(bounds, kTrayRoundedBorderRadius, background_flags); |
| 122 } | 118 } |
| 123 | 119 |
| 124 // Reference to the TrayBackgroundView for which this is a background. | 120 // Reference to the TrayBackgroundView for which this is a background. |
| 125 TrayBackgroundView* tray_background_view_; | 121 TrayBackgroundView* tray_background_view_; |
| 126 | 122 |
| 127 SkColor color_; | 123 SkColor color_; |
| 128 | 124 |
| 129 DISALLOW_COPY_AND_ASSIGN(TrayBackground); | 125 DISALLOW_COPY_AND_ASSIGN(TrayBackground); |
| 130 }; | 126 }; |
| 131 | 127 |
| 132 TrayBackgroundView::TrayContainer::TrayContainer(ShelfAlignment alignment) | |
| 133 : alignment_(alignment) { | |
| 134 UpdateLayout(); | |
| 135 } | |
| 136 | |
| 137 void TrayBackgroundView::TrayContainer::SetAlignment(ShelfAlignment alignment) { | |
| 138 if (alignment_ == alignment) | |
| 139 return; | |
| 140 alignment_ = alignment; | |
| 141 UpdateLayout(); | |
| 142 } | |
| 143 | |
| 144 void TrayBackgroundView::TrayContainer::SetMargin(int main_axis_margin, | |
| 145 int cross_axis_margin) { | |
| 146 main_axis_margin_ = main_axis_margin; | |
| 147 cross_axis_margin_ = cross_axis_margin; | |
| 148 UpdateLayout(); | |
| 149 } | |
| 150 | |
| 151 void TrayBackgroundView::TrayContainer::ChildPreferredSizeChanged( | |
| 152 views::View* child) { | |
| 153 PreferredSizeChanged(); | |
| 154 } | |
| 155 | |
| 156 void TrayBackgroundView::TrayContainer::ChildVisibilityChanged(View* child) { | |
| 157 PreferredSizeChanged(); | |
| 158 } | |
| 159 | |
| 160 void TrayBackgroundView::TrayContainer::ViewHierarchyChanged( | |
| 161 const ViewHierarchyChangedDetails& details) { | |
| 162 if (details.parent == this) | |
| 163 PreferredSizeChanged(); | |
| 164 } | |
| 165 | |
| 166 void TrayBackgroundView::TrayContainer::UpdateLayout() { | |
| 167 bool is_horizontal = IsHorizontalAlignment(alignment_); | |
| 168 | |
| 169 // Adjust the size of status tray dark background by adding additional | |
| 170 // empty border. | |
| 171 views::BoxLayout::Orientation orientation = | |
| 172 is_horizontal ? views::BoxLayout::kHorizontal | |
| 173 : views::BoxLayout::kVertical; | |
| 174 | |
| 175 const int hit_region_with_separator = kHitRegionPadding + kSeparatorWidth; | |
| 176 gfx::Insets insets( | |
| 177 is_horizontal | |
| 178 ? gfx::Insets(0, kHitRegionPadding, 0, hit_region_with_separator) | |
| 179 : gfx::Insets(kHitRegionPadding, 0, hit_region_with_separator, 0)); | |
| 180 MirrorInsetsIfNecessary(&insets); | |
| 181 SetBorder(views::CreateEmptyBorder(insets)); | |
| 182 | |
| 183 int horizontal_margin = main_axis_margin_; | |
| 184 int vertical_margin = cross_axis_margin_; | |
| 185 if (!is_horizontal) | |
| 186 std::swap(horizontal_margin, vertical_margin); | |
| 187 views::BoxLayout* layout = | |
| 188 new views::BoxLayout(orientation, horizontal_margin, vertical_margin, 0); | |
| 189 | |
| 190 layout->set_minimum_cross_axis_size(kTrayItemSize); | |
| 191 views::View::SetLayoutManager(layout); | |
| 192 | |
| 193 PreferredSizeChanged(); | |
| 194 } | |
| 195 | |
| 196 //////////////////////////////////////////////////////////////////////////////// | 128 //////////////////////////////////////////////////////////////////////////////// |
| 197 // TrayBackgroundView | 129 // TrayBackgroundView |
| 198 | 130 |
| 199 TrayBackgroundView::TrayBackgroundView(WmShelf* wm_shelf, bool draws_background) | 131 TrayBackgroundView::TrayBackgroundView(WmShelf* wm_shelf) |
| 200 // Note the ink drop style is ignored. | 132 // Note the ink drop style is ignored. |
| 201 : ActionableView(nullptr, TrayPopupInkDropStyle::FILL_BOUNDS), | 133 : ActionableView(nullptr, TrayPopupInkDropStyle::FILL_BOUNDS), |
| 202 wm_shelf_(wm_shelf), | 134 wm_shelf_(wm_shelf), |
| 203 tray_container_(nullptr), | 135 tray_container_(new TrayContainer(wm_shelf)), |
| 204 shelf_alignment_(SHELF_ALIGNMENT_BOTTOM), | 136 background_(new TrayBackground(this)), |
| 205 background_(nullptr), | |
| 206 is_active_(false), | 137 is_active_(false), |
| 207 separator_visible_(true), | 138 separator_visible_(true), |
| 208 widget_observer_(new TrayWidgetObserver(this)) { | 139 widget_observer_(new TrayWidgetObserver(this)) { |
| 209 DCHECK(wm_shelf_); | 140 DCHECK(wm_shelf_); |
| 210 set_notify_enter_exit_on_child(true); | 141 set_notify_enter_exit_on_child(true); |
| 211 set_ink_drop_base_color(kShelfInkDropBaseColor); | 142 set_ink_drop_base_color(kShelfInkDropBaseColor); |
| 212 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity); | 143 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity); |
| 213 | 144 |
| 214 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | 145 SetLayoutManager(new views::FillLayout); |
| 215 | 146 |
| 216 tray_container_ = new TrayContainer(shelf_alignment_); | 147 tray_container_->set_background(background_); |
| 217 if (draws_background) { | |
| 218 background_ = new TrayBackground(this); | |
| 219 tray_container_->set_background(background_); | |
| 220 } | |
| 221 AddChildView(tray_container_); | 148 AddChildView(tray_container_); |
| 222 | 149 |
| 223 tray_event_filter_.reset(new TrayEventFilter); | 150 tray_event_filter_.reset(new TrayEventFilter); |
| 224 | 151 |
| 225 SetPaintToLayer(); | 152 SetPaintToLayer(); |
| 226 layer()->SetFillsBoundsOpaquely(false); | 153 layer()->SetFillsBoundsOpaquely(false); |
| 227 // Start the tray items not visible, because visibility changes are animated. | 154 // Start the tray items not visible, because visibility changes are animated. |
| 228 views::View::SetVisible(false); | 155 views::View::SetVisible(false); |
| 229 } | 156 } |
| 230 | 157 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 bounds.set_width(bounds.width() + 2 * icon_size); | 266 bounds.set_width(bounds.width() + 2 * icon_size); |
| 340 bounds.set_height(bounds.height() + 2 * icon_size); | 267 bounds.set_height(bounds.height() + 2 * icon_size); |
| 341 std::unique_ptr<views::InkDropHighlight> highlight( | 268 std::unique_ptr<views::InkDropHighlight> highlight( |
| 342 new views::InkDropHighlight(bounds.size(), 0, | 269 new views::InkDropHighlight(bounds.size(), 0, |
| 343 gfx::RectF(bounds).CenterPoint(), | 270 gfx::RectF(bounds).CenterPoint(), |
| 344 GetInkDropBaseColor())); | 271 GetInkDropBaseColor())); |
| 345 highlight->set_visible_opacity(kTrayPopupInkDropHighlightOpacity); | 272 highlight->set_visible_opacity(kTrayPopupInkDropHighlightOpacity); |
| 346 return highlight; | 273 return highlight; |
| 347 } | 274 } |
| 348 | 275 |
| 349 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { | 276 void TrayBackgroundView::UpdateAfterShelfAlignmentChange() { |
| 350 shelf_alignment_ = alignment; | 277 tray_container_->UpdateAfterShelfAlignmentChange(); |
| 351 tray_container_->SetAlignment(alignment); | |
| 352 } | 278 } |
| 353 | 279 |
| 354 void TrayBackgroundView::OnImplicitAnimationsCompleted() { | 280 void TrayBackgroundView::OnImplicitAnimationsCompleted() { |
| 355 // If there is another animation in the queue, the reverse animation was | 281 // If there is another animation in the queue, the reverse animation was |
| 356 // triggered before the completion of animating to invisible. Do not turn off | 282 // triggered before the completion of animating to invisible. Do not turn off |
| 357 // the visibility so that the next animation may render. The value of | 283 // the visibility so that the next animation may render. The value of |
| 358 // layer()->GetTargetVisibility() can be incorrect if the hide animation was | 284 // layer()->GetTargetVisibility() can be incorrect if the hide animation was |
| 359 // aborted to schedule an animation to become visible. As the new animation | 285 // aborted to schedule an animation to become visible. As the new animation |
| 360 // is not yet added to the queue. crbug.com/374236 | 286 // is not yet added to the queue. crbug.com/374236 |
| 361 if (layer()->GetAnimator()->is_animating() || layer()->GetTargetVisibility()) | 287 if (layer()->GetAnimator()->is_animating() || layer()->GetTargetVisibility()) |
| 362 return; | 288 return; |
| 363 views::View::SetVisible(false); | 289 views::View::SetVisible(false); |
| 364 } | 290 } |
| 365 | 291 |
| 366 bool TrayBackgroundView::RequiresNotificationWhenAnimatorDestroyed() const { | 292 bool TrayBackgroundView::RequiresNotificationWhenAnimatorDestroyed() const { |
| 367 // This is needed so that OnImplicitAnimationsCompleted() is called even upon | 293 // This is needed so that OnImplicitAnimationsCompleted() is called even upon |
| 368 // destruction of the animator. This can occure when parallel animations | 294 // destruction of the animator. This can occure when parallel animations |
| 369 // caused by ScreenRotationAnimator end before the animations of | 295 // caused by ScreenRotationAnimator end before the animations of |
| 370 // TrayBackgroundView. This allows for a proper update to the visual state of | 296 // TrayBackgroundView. This allows for a proper update to the visual state of |
| 371 // the view. (crbug.com/476667) | 297 // the view. (crbug.com/476667) |
| 372 return true; | 298 return true; |
| 373 } | 299 } |
| 374 | 300 |
| 375 void TrayBackgroundView::HideTransformation() { | 301 void TrayBackgroundView::HideTransformation() { |
| 376 gfx::Transform transform; | 302 gfx::Transform transform; |
| 377 if (IsHorizontalAlignment(shelf_alignment_)) | 303 if (wm_shelf_->IsHorizontalAlignment()) |
| 378 transform.Translate(width(), 0.0f); | 304 transform.Translate(width(), 0.0f); |
| 379 else | 305 else |
| 380 transform.Translate(0.0f, height()); | 306 transform.Translate(0.0f, height()); |
| 381 layer()->SetTransform(transform); | 307 layer()->SetTransform(transform); |
| 382 } | 308 } |
| 383 | 309 |
| 384 TrayBubbleView::AnchorAlignment TrayBackgroundView::GetAnchorAlignment() const { | 310 TrayBubbleView::AnchorAlignment TrayBackgroundView::GetAnchorAlignment() const { |
| 385 if (shelf_alignment_ == SHELF_ALIGNMENT_LEFT) | 311 if (wm_shelf_->alignment() == SHELF_ALIGNMENT_LEFT) |
| 386 return TrayBubbleView::ANCHOR_ALIGNMENT_LEFT; | 312 return TrayBubbleView::ANCHOR_ALIGNMENT_LEFT; |
| 387 if (shelf_alignment_ == SHELF_ALIGNMENT_RIGHT) | 313 if (wm_shelf_->alignment() == SHELF_ALIGNMENT_RIGHT) |
| 388 return TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT; | 314 return TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT; |
| 389 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; | 315 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; |
| 390 } | 316 } |
| 391 | 317 |
| 392 void TrayBackgroundView::SetIsActive(bool is_active) { | 318 void TrayBackgroundView::SetIsActive(bool is_active) { |
| 393 if (is_active_ == is_active) | 319 if (is_active_ == is_active) |
| 394 return; | 320 return; |
| 395 is_active_ = is_active; | 321 is_active_ = is_active; |
| 396 AnimateInkDrop(is_active_ ? views::InkDropState::ACTIVATED | 322 AnimateInkDrop(is_active_ ? views::InkDropState::ACTIVATED |
| 397 : views::InkDropState::DEACTIVATED, | 323 : views::InkDropState::DEACTIVATED, |
| 398 nullptr); | 324 nullptr); |
| 399 } | 325 } |
| 400 | 326 |
| 401 void TrayBackgroundView::UpdateBubbleViewArrow( | 327 void TrayBackgroundView::UpdateBubbleViewArrow( |
| 402 views::TrayBubbleView* bubble_view) { | 328 views::TrayBubbleView* bubble_view) { |
| 403 // Nothing to do here. | 329 // Nothing to do here. |
| 404 } | 330 } |
| 405 | 331 |
| 406 void TrayBackgroundView::UpdateShelfItemBackground(SkColor color) { | 332 void TrayBackgroundView::UpdateShelfItemBackground(SkColor color) { |
| 407 if (background_) { | 333 background_->set_color(color); |
| 408 background_->set_color(color); | 334 SchedulePaint(); |
| 409 SchedulePaint(); | |
| 410 } | |
| 411 } | 335 } |
| 412 | 336 |
| 413 views::View* TrayBackgroundView::GetBubbleAnchor() const { | 337 views::View* TrayBackgroundView::GetBubbleAnchor() const { |
| 414 return tray_container_; | 338 return tray_container_; |
| 415 } | 339 } |
| 416 | 340 |
| 417 gfx::Insets TrayBackgroundView::GetBubbleAnchorInsets() const { | 341 gfx::Insets TrayBackgroundView::GetBubbleAnchorInsets() const { |
| 418 gfx::Insets anchor_insets = GetBubbleAnchor()->GetInsets(); | 342 gfx::Insets anchor_insets = GetBubbleAnchor()->GetInsets(); |
| 419 gfx::Insets tray_bg_insets = GetInsets(); | 343 gfx::Insets tray_bg_insets = GetInsets(); |
| 420 if (GetAnchorAlignment() == TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) { | 344 if (GetAnchorAlignment() == TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 !separator_visible_) { | 392 !separator_visible_) { |
| 469 return; | 393 return; |
| 470 } | 394 } |
| 471 // In the given |canvas|, for a horizontal shelf draw a separator line to the | 395 // In the given |canvas|, for a horizontal shelf draw a separator line to the |
| 472 // right or left of the TrayBackgroundView when the system is LTR or RTL | 396 // right or left of the TrayBackgroundView when the system is LTR or RTL |
| 473 // aligned, respectively. For a vertical shelf draw the separator line | 397 // aligned, respectively. For a vertical shelf draw the separator line |
| 474 // underneath the items instead. | 398 // underneath the items instead. |
| 475 const gfx::Rect local_bounds = GetLocalBounds(); | 399 const gfx::Rect local_bounds = GetLocalBounds(); |
| 476 const SkColor color = SkColorSetA(SK_ColorWHITE, 0x4D); | 400 const SkColor color = SkColorSetA(SK_ColorWHITE, 0x4D); |
| 477 | 401 |
| 478 if (IsHorizontalAlignment(shelf_alignment_)) { | 402 if (wm_shelf_->IsHorizontalAlignment()) { |
| 479 const gfx::PointF point( | 403 const gfx::PointF point( |
| 480 base::i18n::IsRTL() ? 0 : (local_bounds.width() - kSeparatorWidth), | 404 base::i18n::IsRTL() ? 0 : (local_bounds.width() - kSeparatorWidth), |
| 481 (kShelfSize - kTrayItemSize) / 2); | 405 (kShelfSize - kTrayItemSize) / 2); |
| 482 const gfx::Vector2dF vector(0, kTrayItemSize); | 406 const gfx::Vector2dF vector(0, kTrayItemSize); |
| 483 canvas->Draw1pxLine(point, point + vector, color); | 407 canvas->Draw1pxLine(point, point + vector, color); |
| 484 } else { | 408 } else { |
| 485 const gfx::PointF point((kShelfSize - kTrayItemSize) / 2, | 409 const gfx::PointF point((kShelfSize - kTrayItemSize) / 2, |
| 486 local_bounds.height() - kSeparatorWidth); | 410 local_bounds.height() - kSeparatorWidth); |
| 487 const gfx::Vector2dF vector(kTrayItemSize, 0); | 411 const gfx::Vector2dF vector(kTrayItemSize, 0); |
| 488 canvas->Draw1pxLine(point, point + vector, color); | 412 canvas->Draw1pxLine(point, point + vector, color); |
| 489 } | 413 } |
| 490 } | 414 } |
| 491 | 415 |
| 492 gfx::Insets TrayBackgroundView::GetBackgroundInsets() const { | 416 gfx::Insets TrayBackgroundView::GetBackgroundInsets() const { |
| 493 gfx::Insets insets = GetMirroredBackgroundInsets(shelf_alignment_); | 417 gfx::Insets insets = |
| 418 GetMirroredBackgroundInsets(wm_shelf_->IsHorizontalAlignment()); |
| 494 | 419 |
| 495 // |insets| are relative to contents bounds. Change them to be relative to | 420 // |insets| are relative to contents bounds. Change them to be relative to |
| 496 // local bounds. | 421 // local bounds. |
| 497 gfx::Insets local_contents_insets = | 422 gfx::Insets local_contents_insets = |
| 498 GetLocalBounds().InsetsFrom(GetContentsBounds()); | 423 GetLocalBounds().InsetsFrom(GetContentsBounds()); |
| 499 MirrorInsetsIfNecessary(&local_contents_insets); | 424 MirrorInsetsIfNecessary(&local_contents_insets); |
| 500 insets += local_contents_insets; | 425 insets += local_contents_insets; |
| 501 | 426 |
| 502 return insets; | 427 return insets; |
| 503 } | 428 } |
| 504 | 429 |
| 505 gfx::Rect TrayBackgroundView::GetBackgroundBounds() const { | 430 gfx::Rect TrayBackgroundView::GetBackgroundBounds() const { |
| 506 gfx::Insets insets = GetBackgroundInsets(); | 431 gfx::Insets insets = GetBackgroundInsets(); |
| 507 gfx::Rect bounds = GetLocalBounds(); | 432 gfx::Rect bounds = GetLocalBounds(); |
| 508 bounds.Inset(insets); | 433 bounds.Inset(insets); |
| 509 return bounds; | 434 return bounds; |
| 510 } | 435 } |
| 511 | 436 |
| 512 } // namespace ash | 437 } // namespace ash |
| OLD | NEW |