Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1286)

Side by Side Diff: ash/common/system/tray/tray_background_view.cc

Issue 2618383003: Remove the extra separator appears on the right side of the shelf (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 // TrayBackgroundView 284 // TrayBackgroundView
285 285
286 TrayBackgroundView::TrayBackgroundView(WmShelf* wm_shelf) 286 TrayBackgroundView::TrayBackgroundView(WmShelf* wm_shelf)
287 // Note the ink drop style is ignored. 287 // Note the ink drop style is ignored.
288 : ActionableView(nullptr, TrayPopupInkDropStyle::FILL_BOUNDS), 288 : ActionableView(nullptr, TrayPopupInkDropStyle::FILL_BOUNDS),
289 wm_shelf_(wm_shelf), 289 wm_shelf_(wm_shelf),
290 tray_container_(NULL), 290 tray_container_(NULL),
291 shelf_alignment_(SHELF_ALIGNMENT_BOTTOM), 291 shelf_alignment_(SHELF_ALIGNMENT_BOTTOM),
292 background_(NULL), 292 background_(NULL),
293 is_active_(false), 293 is_active_(false),
294 is_separator_visible_(true),
294 widget_observer_(new TrayWidgetObserver(this)) { 295 widget_observer_(new TrayWidgetObserver(this)) {
295 DCHECK(wm_shelf_); 296 DCHECK(wm_shelf_);
296 set_notify_enter_exit_on_child(true); 297 set_notify_enter_exit_on_child(true);
297 set_ink_drop_base_color(kShelfInkDropBaseColor); 298 set_ink_drop_base_color(kShelfInkDropBaseColor);
298 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity); 299 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity);
299 300
300 tray_container_ = new TrayContainer(shelf_alignment_); 301 tray_container_ = new TrayContainer(shelf_alignment_);
301 SetContents(tray_container_); 302 SetContents(tray_container_);
302 tray_event_filter_.reset(new TrayEventFilter); 303 tray_event_filter_.reset(new TrayEventFilter);
303 304
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 // Nothing to do here. 514 // Nothing to do here.
514 } 515 }
515 516
516 void TrayBackgroundView::UpdateShelfItemBackground(int alpha) { 517 void TrayBackgroundView::UpdateShelfItemBackground(int alpha) {
517 if (background_) { 518 if (background_) {
518 background_->set_alpha(alpha); 519 background_->set_alpha(alpha);
519 SchedulePaint(); 520 SchedulePaint();
520 } 521 }
521 } 522 }
522 523
524 void TrayBackgroundView::SetSeparatorVisibility(bool is_shown) {
James Cook 2017/01/09 23:50:53 nit: whatever you choose in the header, make sure
yiyix 2017/01/10 01:02:53 Done.
525 if (is_separator_visible_ == is_shown)
526 return;
527 is_separator_visible_ = is_shown;
528 SchedulePaint();
James Cook 2017/01/09 23:50:53 Is this needed? The two places you call SetSeparat
yiyix 2017/01/10 01:02:53 I don't need SchedulePaint() now. I was thinking h
529 }
530
523 views::View* TrayBackgroundView::GetBubbleAnchor() const { 531 views::View* TrayBackgroundView::GetBubbleAnchor() const {
524 return tray_container_; 532 return tray_container_;
525 } 533 }
526 534
527 gfx::Insets TrayBackgroundView::GetBubbleAnchorInsets() const { 535 gfx::Insets TrayBackgroundView::GetBubbleAnchorInsets() const {
528 gfx::Insets anchor_insets = GetBubbleAnchor()->GetInsets(); 536 gfx::Insets anchor_insets = GetBubbleAnchor()->GetInsets();
529 gfx::Insets tray_bg_insets = GetInsets(); 537 gfx::Insets tray_bg_insets = GetInsets();
530 if (GetAnchorAlignment() == TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) { 538 if (GetAnchorAlignment() == TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) {
531 return gfx::Insets(-tray_bg_insets.top(), anchor_insets.left(), 539 return gfx::Insets(-tray_bg_insets.top(), anchor_insets.left(),
532 -tray_bg_insets.bottom(), anchor_insets.right()); 540 -tray_bg_insets.bottom(), anchor_insets.right());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 paint_bounds.Inset(gfx::Insets(1)); 582 paint_bounds.Inset(gfx::Insets(1));
575 } 583 }
576 canvas->DrawSolidFocusRect(paint_bounds, kFocusBorderColor, 584 canvas->DrawSolidFocusRect(paint_bounds, kFocusBorderColor,
577 kFocusBorderThickness); 585 kFocusBorderThickness);
578 } 586 }
579 587
580 void TrayBackgroundView::OnPaint(gfx::Canvas* canvas) { 588 void TrayBackgroundView::OnPaint(gfx::Canvas* canvas) {
581 ActionableView::OnPaint(canvas); 589 ActionableView::OnPaint(canvas);
582 if (!MaterialDesignController::IsShelfMaterial() || 590 if (!MaterialDesignController::IsShelfMaterial() ||
583 shelf()->GetBackgroundType() == 591 shelf()->GetBackgroundType() ==
584 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT) { 592 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT ||
593 !is_separator_visible_) {
585 return; 594 return;
586 } 595 }
587 // In the given |canvas|, for a horizontal shelf draw a separator line to the 596 // In the given |canvas|, for a horizontal shelf draw a separator line to the
588 // right or left of the TrayBackgroundView when the system is LTR or RTL 597 // right or left of the TrayBackgroundView when the system is LTR or RTL
589 // aligned, respectively. For a vertical shelf draw the separator line 598 // aligned, respectively. For a vertical shelf draw the separator line
590 // underneath the items instead. 599 // underneath the items instead.
591 const bool horizontal_shelf = IsHorizontalAlignment(shelf_alignment_); 600 const bool horizontal_shelf = IsHorizontalAlignment(shelf_alignment_);
592 const gfx::Rect local_bounds = GetLocalBounds(); 601 const gfx::Rect local_bounds = GetLocalBounds();
593 const int height = kTrayItemSize; 602 const int height = kTrayItemSize;
594 const int x = 603 const int x =
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 } 640 }
632 641
633 gfx::Rect TrayBackgroundView::GetBackgroundBounds() const { 642 gfx::Rect TrayBackgroundView::GetBackgroundBounds() const {
634 gfx::Insets insets = GetBackgroundInsets(); 643 gfx::Insets insets = GetBackgroundInsets();
635 gfx::Rect bounds = GetLocalBounds(); 644 gfx::Rect bounds = GetLocalBounds();
636 bounds.Inset(insets); 645 bounds.Inset(insets);
637 return bounds; 646 return bounds;
638 } 647 }
639 648
640 } // namespace ash 649 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698