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/tray/tray_background_view.h" | 5 #include "ash/common/system/tray/tray_background_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/common/ash_constants.h" | 9 #include "ash/common/ash_constants.h" |
10 #include "ash/common/material_design/material_design_controller.h" | 10 #include "ash/common/material_design/material_design_controller.h" |
11 #include "ash/common/shelf/shelf_constants.h" | 11 #include "ash/common/shelf/shelf_constants.h" |
12 #include "ash/common/shelf/wm_shelf.h" | 12 #include "ash/common/shelf/wm_shelf.h" |
13 #include "ash/common/shelf/wm_shelf_util.h" | 13 #include "ash/common/shelf/wm_shelf_util.h" |
14 #include "ash/common/system/status_area_widget.h" | |
15 #include "ash/common/system/tray/system_tray.h" | 14 #include "ash/common/system/tray/system_tray.h" |
16 #include "ash/common/system/tray/tray_constants.h" | 15 #include "ash/common/system/tray/tray_constants.h" |
17 #include "ash/common/system/tray/tray_event_filter.h" | 16 #include "ash/common/system/tray/tray_event_filter.h" |
18 #include "ash/common/wm_lookup.h" | 17 #include "ash/common/wm_lookup.h" |
19 #include "ash/common/wm_shell.h" | 18 #include "ash/common/wm_shell.h" |
20 #include "ash/common/wm_window.h" | 19 #include "ash/common/wm_window.h" |
21 #include "ash/public/cpp/shell_window_ids.h" | 20 #include "ash/public/cpp/shell_window_ids.h" |
22 #include "grit/ash_resources.h" | 21 #include "grit/ash_resources.h" |
23 #include "ui/accessibility/ax_node_data.h" | 22 #include "ui/accessibility/ax_node_data.h" |
24 #include "ui/base/nine_image_painter_factory.h" | 23 #include "ui/base/nine_image_painter_factory.h" |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 // TrayBackgroundView | 283 // TrayBackgroundView |
285 | 284 |
286 TrayBackgroundView::TrayBackgroundView(WmShelf* wm_shelf) | 285 TrayBackgroundView::TrayBackgroundView(WmShelf* wm_shelf) |
287 // Note the ink drop style is ignored. | 286 // Note the ink drop style is ignored. |
288 : ActionableView(nullptr, TrayPopupInkDropStyle::FILL_BOUNDS), | 287 : ActionableView(nullptr, TrayPopupInkDropStyle::FILL_BOUNDS), |
289 wm_shelf_(wm_shelf), | 288 wm_shelf_(wm_shelf), |
290 tray_container_(NULL), | 289 tray_container_(NULL), |
291 shelf_alignment_(SHELF_ALIGNMENT_BOTTOM), | 290 shelf_alignment_(SHELF_ALIGNMENT_BOTTOM), |
292 background_(NULL), | 291 background_(NULL), |
293 is_active_(false), | 292 is_active_(false), |
294 is_separator_visible_(false), | |
295 widget_observer_(new TrayWidgetObserver(this)) { | 293 widget_observer_(new TrayWidgetObserver(this)) { |
296 DCHECK(wm_shelf_); | 294 DCHECK(wm_shelf_); |
297 set_notify_enter_exit_on_child(true); | 295 set_notify_enter_exit_on_child(true); |
298 set_ink_drop_base_color(kShelfInkDropBaseColor); | 296 set_ink_drop_base_color(kShelfInkDropBaseColor); |
299 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity); | 297 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity); |
300 | 298 |
301 tray_container_ = new TrayContainer(shelf_alignment_); | 299 tray_container_ = new TrayContainer(shelf_alignment_); |
302 SetContents(tray_container_); | 300 SetContents(tray_container_); |
303 tray_event_filter_.reset(new TrayEventFilter); | 301 tray_event_filter_.reset(new TrayEventFilter); |
304 | 302 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 layer()->SetTransform(transform); | 368 layer()->SetTransform(transform); |
371 } else { | 369 } else { |
372 // Listen only to the hide animation. As we cannot turn off visibility | 370 // Listen only to the hide animation. As we cannot turn off visibility |
373 // until the animation is over. | 371 // until the animation is over. |
374 animation.AddObserver(this); | 372 animation.AddObserver(this); |
375 animation.SetTweenType(gfx::Tween::EASE_IN); | 373 animation.SetTweenType(gfx::Tween::EASE_IN); |
376 layer()->SetOpacity(0.0f); | 374 layer()->SetOpacity(0.0f); |
377 layer()->SetVisible(false); | 375 layer()->SetVisible(false); |
378 HideTransformation(); | 376 HideTransformation(); |
379 } | 377 } |
380 wm_shelf_->GetStatusAreaWidget()->OnTrayVisibilityChanged(this); | |
381 } | 378 } |
382 | 379 |
383 const char* TrayBackgroundView::GetClassName() const { | 380 const char* TrayBackgroundView::GetClassName() const { |
384 return kViewClassName; | 381 return kViewClassName; |
385 } | 382 } |
386 | 383 |
387 void TrayBackgroundView::ChildPreferredSizeChanged(views::View* child) { | 384 void TrayBackgroundView::ChildPreferredSizeChanged(views::View* child) { |
388 PreferredSizeChanged(); | 385 PreferredSizeChanged(); |
389 } | 386 } |
390 | 387 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 // Nothing to do here. | 512 // Nothing to do here. |
516 } | 513 } |
517 | 514 |
518 void TrayBackgroundView::UpdateShelfItemBackground(int alpha) { | 515 void TrayBackgroundView::UpdateShelfItemBackground(int alpha) { |
519 if (background_) { | 516 if (background_) { |
520 background_->set_alpha(alpha); | 517 background_->set_alpha(alpha); |
521 SchedulePaint(); | 518 SchedulePaint(); |
522 } | 519 } |
523 } | 520 } |
524 | 521 |
525 void TrayBackgroundView::SetSeparatorVisibility(bool is_shown) { | |
526 is_separator_visible_ = is_shown; | |
527 SchedulePaint(); | |
528 } | |
529 | |
530 views::View* TrayBackgroundView::GetBubbleAnchor() const { | 522 views::View* TrayBackgroundView::GetBubbleAnchor() const { |
531 return tray_container_; | 523 return tray_container_; |
532 } | 524 } |
533 | 525 |
534 gfx::Insets TrayBackgroundView::GetBubbleAnchorInsets() const { | 526 gfx::Insets TrayBackgroundView::GetBubbleAnchorInsets() const { |
535 gfx::Insets anchor_insets = GetBubbleAnchor()->GetInsets(); | 527 gfx::Insets anchor_insets = GetBubbleAnchor()->GetInsets(); |
536 gfx::Insets tray_bg_insets = GetInsets(); | 528 gfx::Insets tray_bg_insets = GetInsets(); |
537 if (GetAnchorAlignment() == TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) { | 529 if (GetAnchorAlignment() == TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) { |
538 return gfx::Insets(-tray_bg_insets.top(), anchor_insets.left(), | 530 return gfx::Insets(-tray_bg_insets.top(), anchor_insets.left(), |
539 -tray_bg_insets.bottom(), anchor_insets.right()); | 531 -tray_bg_insets.bottom(), anchor_insets.right()); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 gfx::RectF paint_bounds(GetFocusBounds()); | 571 gfx::RectF paint_bounds(GetFocusBounds()); |
580 paint_bounds.Inset(gfx::Insets(2, -2)); | 572 paint_bounds.Inset(gfx::Insets(2, -2)); |
581 canvas->DrawSolidFocusRect(paint_bounds, kFocusBorderColor, | 573 canvas->DrawSolidFocusRect(paint_bounds, kFocusBorderColor, |
582 kFocusBorderThickness); | 574 kFocusBorderThickness); |
583 } | 575 } |
584 | 576 |
585 void TrayBackgroundView::OnPaint(gfx::Canvas* canvas) { | 577 void TrayBackgroundView::OnPaint(gfx::Canvas* canvas) { |
586 ActionableView::OnPaint(canvas); | 578 ActionableView::OnPaint(canvas); |
587 if (!MaterialDesignController::IsShelfMaterial() || | 579 if (!MaterialDesignController::IsShelfMaterial() || |
588 shelf()->GetBackgroundType() == | 580 shelf()->GetBackgroundType() == |
589 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT || | 581 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT) { |
590 !is_separator_visible_) { | |
591 return; | 582 return; |
592 } | 583 } |
593 // In the given |canvas|, for a horizontal shelf draw a separator line to the | 584 // In the given |canvas|, for a horizontal shelf draw a separator line to the |
594 // right or left of the TrayBackgroundView when the system is LTR or RTL | 585 // right or left of the TrayBackgroundView when the system is LTR or RTL |
595 // aligned, respectively. For a vertical shelf draw the separator line | 586 // aligned, respectively. For a vertical shelf draw the separator line |
596 // underneath the items instead. | 587 // underneath the items instead. |
597 const bool horizontal_shelf = IsHorizontalAlignment(shelf_alignment_); | 588 const bool horizontal_shelf = IsHorizontalAlignment(shelf_alignment_); |
598 const gfx::Rect local_bounds = GetLocalBounds(); | 589 const gfx::Rect local_bounds = GetLocalBounds(); |
599 const int height = kTrayItemSize; | 590 const int height = kTrayItemSize; |
600 const int x = | 591 const int x = |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 } | 628 } |
638 | 629 |
639 gfx::Rect TrayBackgroundView::GetBackgroundBounds() const { | 630 gfx::Rect TrayBackgroundView::GetBackgroundBounds() const { |
640 gfx::Insets insets = GetBackgroundInsets(); | 631 gfx::Insets insets = GetBackgroundInsets(); |
641 gfx::Rect bounds = GetLocalBounds(); | 632 gfx::Rect bounds = GetLocalBounds(); |
642 bounds.Inset(insets); | 633 bounds.Inset(insets); |
643 return bounds; | 634 return bounds; |
644 } | 635 } |
645 | 636 |
646 } // namespace ash | 637 } // namespace ash |
OLD | NEW |