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

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

Issue 1907363004: (Merge to M-51) Revise the shelf alignment locking mechanism. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 8 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
« no previous file with comments | « ash/system/tray/system_tray_unittest.cc ('k') | ash/system/tray/tray_image_item.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/system/tray/tray_background_view.h" 5 #include "ash/system/tray/tray_background_view.h"
6 6
7 #include "ash/root_window_controller.h" 7 #include "ash/root_window_controller.h"
8 #include "ash/screen_util.h" 8 #include "ash/screen_util.h"
9 #include "ash/shelf/shelf_layout_manager.h" 9 #include "ash/shelf/shelf_layout_manager.h"
10 #include "ash/shelf/shelf_util.h"
10 #include "ash/shelf/shelf_widget.h" 11 #include "ash/shelf/shelf_widget.h"
11 #include "ash/shell.h" 12 #include "ash/shell.h"
12 #include "ash/shell_window_ids.h" 13 #include "ash/shell_window_ids.h"
13 #include "ash/system/status_area_widget.h" 14 #include "ash/system/status_area_widget.h"
14 #include "ash/system/status_area_widget_delegate.h" 15 #include "ash/system/status_area_widget_delegate.h"
15 #include "ash/system/tray/system_tray.h" 16 #include "ash/system/tray/system_tray.h"
16 #include "ash/system/tray/tray_constants.h" 17 #include "ash/system/tray/tray_constants.h"
17 #include "ash/system/tray/tray_event_filter.h" 18 #include "ash/system/tray/tray_event_filter.h"
18 #include "ash/wm/window_animations.h" 19 #include "ash/wm/window_animations.h"
19 #include "base/command_line.h" 20 #include "base/command_line.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 185
185 void TrayBackgroundView::TrayContainer::ViewHierarchyChanged( 186 void TrayBackgroundView::TrayContainer::ViewHierarchyChanged(
186 const ViewHierarchyChangedDetails& details) { 187 const ViewHierarchyChangedDetails& details) {
187 if (details.parent == this) 188 if (details.parent == this)
188 PreferredSizeChanged(); 189 PreferredSizeChanged();
189 } 190 }
190 191
191 void TrayBackgroundView::TrayContainer::UpdateLayout() { 192 void TrayBackgroundView::TrayContainer::UpdateLayout() {
192 // Adjust the size of status tray dark background by adding additional 193 // Adjust the size of status tray dark background by adding additional
193 // empty border. 194 // empty border.
194 if (alignment_ == SHELF_ALIGNMENT_BOTTOM) { 195 if (IsHorizontalAlignment(alignment_)) {
195 SetBorder(views::Border::CreateEmptyBorder( 196 SetBorder(views::Border::CreateEmptyBorder(
196 kPaddingFromEdgeOfShelf, 197 kPaddingFromEdgeOfShelf,
197 kPaddingFromEdgeOfShelf, 198 kPaddingFromEdgeOfShelf,
198 kPaddingFromEdgeOfShelf, 199 kPaddingFromEdgeOfShelf,
199 kPaddingFromEdgeOfShelf)); 200 kPaddingFromEdgeOfShelf));
200 201
201 views::BoxLayout* layout = 202 views::BoxLayout* layout =
202 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); 203 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0);
203 layout->SetDefaultFlex(1); 204 layout->SetDefaultFlex(1);
204 views::View::SetLayoutManager(layout); 205 views::View::SetLayoutManager(layout);
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 shelf_alignment_ = alignment; 396 shelf_alignment_ = alignment;
396 SetTrayBorder(); 397 SetTrayBorder();
397 tray_container_->SetAlignment(alignment); 398 tray_container_->SetAlignment(alignment);
398 } 399 }
399 400
400 void TrayBackgroundView::SetTrayBorder() { 401 void TrayBackgroundView::SetTrayBorder() {
401 views::View* parent = status_area_widget_->status_area_widget_delegate(); 402 views::View* parent = status_area_widget_->status_area_widget_delegate();
402 // Tray views are laid out right-to-left or bottom-to-top 403 // Tray views are laid out right-to-left or bottom-to-top
403 bool on_edge = (this == parent->child_at(0)); 404 bool on_edge = (this == parent->child_at(0));
404 int left_edge, top_edge, right_edge, bottom_edge; 405 int left_edge, top_edge, right_edge, bottom_edge;
405 if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { 406 if (IsHorizontalAlignment(shelf_alignment())) {
406 top_edge = ShelfLayoutManager::kShelfItemInset; 407 top_edge = ShelfLayoutManager::kShelfItemInset;
407 left_edge = 0; 408 left_edge = 0;
408 bottom_edge = kShelfSize - 409 bottom_edge = kShelfSize -
409 ShelfLayoutManager::kShelfItemInset - kShelfItemHeight; 410 ShelfLayoutManager::kShelfItemInset - kShelfItemHeight;
410 right_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; 411 right_edge = on_edge ? kPaddingFromEdgeOfShelf : 0;
411 } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) { 412 } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) {
412 top_edge = 0; 413 top_edge = 0;
413 left_edge = kShelfSize - 414 left_edge = kShelfSize -
414 ShelfLayoutManager::kShelfItemInset - kShelfItemHeight; 415 ShelfLayoutManager::kShelfItemInset - kShelfItemHeight;
415 bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; 416 bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0;
(...skipping 26 matching lines...) Expand all
442 // This is needed so that OnImplicitAnimationsCompleted() is called even upon 443 // This is needed so that OnImplicitAnimationsCompleted() is called even upon
443 // destruction of the animator. This can occure when parallel animations 444 // destruction of the animator. This can occure when parallel animations
444 // caused by ScreenRotationAnimator end before the animations of 445 // caused by ScreenRotationAnimator end before the animations of
445 // TrayBackgroundView. This allows for a proper update to the visual state of 446 // TrayBackgroundView. This allows for a proper update to the visual state of
446 // the view. (crbug.com/476667) 447 // the view. (crbug.com/476667)
447 return true; 448 return true;
448 } 449 }
449 450
450 void TrayBackgroundView::HideTransformation() { 451 void TrayBackgroundView::HideTransformation() {
451 gfx::Transform transform; 452 gfx::Transform transform;
452 if (shelf_alignment_ == SHELF_ALIGNMENT_BOTTOM) 453 if (IsHorizontalAlignment(shelf_alignment_))
453 transform.Translate(width(), 0.0f); 454 transform.Translate(width(), 0.0f);
454 else 455 else
455 transform.Translate(0.0f, height()); 456 transform.Translate(0.0f, height());
456 layer()->SetTransform(transform); 457 layer()->SetTransform(transform);
457 } 458 }
458 459
459 void TrayBackgroundView::InitializeBubbleAnimations( 460 void TrayBackgroundView::InitializeBubbleAnimations(
460 views::Widget* bubble_widget) { 461 views::Widget* bubble_widget) {
461 wm::SetWindowVisibilityAnimationType( 462 wm::SetWindowVisibilityAnimationType(
462 bubble_widget->GetNativeWindow(), 463 bubble_widget->GetNativeWindow(),
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 kPaddingFromRightEdgeOfScreenBottomAlignment : 552 kPaddingFromRightEdgeOfScreenBottomAlignment :
552 rect.width() - kPaddingFromRightEdgeOfScreenBottomAlignment, 553 rect.width() - kPaddingFromRightEdgeOfScreenBottomAlignment,
553 rect.height() - kPaddingFromBottomOfScreenBottomAlignment, 554 rect.height() - kPaddingFromBottomOfScreenBottomAlignment,
554 0, 0); 555 0, 0);
555 } 556 }
556 } 557 }
557 return rect; 558 return rect;
558 } 559 }
559 560
560 TrayBubbleView::AnchorAlignment TrayBackgroundView::GetAnchorAlignment() const { 561 TrayBubbleView::AnchorAlignment TrayBackgroundView::GetAnchorAlignment() const {
561 switch (shelf_alignment_) { 562 if (shelf_alignment_ == SHELF_ALIGNMENT_LEFT)
562 case SHELF_ALIGNMENT_BOTTOM: 563 return TrayBubbleView::ANCHOR_ALIGNMENT_LEFT;
563 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; 564 if (shelf_alignment_ == SHELF_ALIGNMENT_RIGHT)
564 case SHELF_ALIGNMENT_LEFT: 565 return TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT;
565 return TrayBubbleView::ANCHOR_ALIGNMENT_LEFT;
566 case SHELF_ALIGNMENT_RIGHT:
567 return TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT;
568 }
569 NOTREACHED();
570 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; 566 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM;
571 } 567 }
572 568
573 void TrayBackgroundView::SetDrawBackgroundAsActive(bool visible) { 569 void TrayBackgroundView::SetDrawBackgroundAsActive(bool visible) {
574 if (draw_background_as_active_ == visible) 570 if (draw_background_as_active_ == visible)
575 return; 571 return;
576 draw_background_as_active_ = visible; 572 draw_background_as_active_ = visible;
577 if (!background_) 573 if (!background_)
578 return; 574 return;
579 575
580 // Do not change gradually, changing color between grey and blue is weird. 576 // Do not change gradually, changing color between grey and blue is weird.
581 if (draw_background_as_active_) 577 if (draw_background_as_active_)
582 background_->set_color(kTrayBackgroundPressedColor); 578 background_->set_color(kTrayBackgroundPressedColor);
583 else if (hovered_) 579 else if (hovered_)
584 background_->set_alpha(kTrayBackgroundHoverAlpha); 580 background_->set_alpha(kTrayBackgroundHoverAlpha);
585 else 581 else
586 background_->set_alpha(kTrayBackgroundAlpha); 582 background_->set_alpha(kTrayBackgroundAlpha);
587 SchedulePaint(); 583 SchedulePaint();
588 } 584 }
589 585
590 void TrayBackgroundView::UpdateBubbleViewArrow( 586 void TrayBackgroundView::UpdateBubbleViewArrow(
591 views::TrayBubbleView* bubble_view) { 587 views::TrayBubbleView* bubble_view) {
592 // Nothing to do here. 588 // Nothing to do here.
593 } 589 }
594 590
595 } // namespace ash 591 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/system_tray_unittest.cc ('k') | ash/system/tray/tray_image_item.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698