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

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

Issue 2103113003: Fix shelf layout when switching from left-aligned shelf to right-aligned shelf (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge Created 4 years, 5 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 "ash/common/material_design/material_design_controller.h" 7 #include "ash/common/material_design/material_design_controller.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"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // Start the tray items not visible, because visibility changes are animated. 244 // Start the tray items not visible, because visibility changes are animated.
245 views::View::SetVisible(false); 245 views::View::SetVisible(false);
246 } 246 }
247 247
248 TrayBackgroundView::~TrayBackgroundView() { 248 TrayBackgroundView::~TrayBackgroundView() {
249 if (GetWidget()) 249 if (GetWidget())
250 GetWidget()->RemoveObserver(widget_observer_.get()); 250 GetWidget()->RemoveObserver(widget_observer_.get());
251 StopObservingImplicitAnimations(); 251 StopObservingImplicitAnimations();
252 } 252 }
253 253
254 void TrayBackgroundView::Initialize() { 254 void TrayBackgroundView::Initialize(const gfx::Insets& insets) {
255 GetWidget()->AddObserver(widget_observer_.get()); 255 GetWidget()->AddObserver(widget_observer_.get());
256 SetTrayBorder(insets);
256 } 257 }
257 258
258 // static 259 // static
259 void TrayBackgroundView::InitializeBubbleAnimations( 260 void TrayBackgroundView::InitializeBubbleAnimations(
260 views::Widget* bubble_widget) { 261 views::Widget* bubble_widget) {
261 WmWindow* window = WmLookup::Get()->GetWindowForWidget(bubble_widget); 262 WmWindow* window = WmLookup::Get()->GetWindowForWidget(bubble_widget);
262 window->SetVisibilityAnimationType( 263 window->SetVisibilityAnimationType(
263 ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); 264 ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE);
264 window->SetVisibilityAnimationTransition(::wm::ANIMATE_HIDE); 265 window->SetVisibilityAnimationTransition(::wm::ANIMATE_HIDE);
265 window->SetVisibilityAnimationDuration( 266 window->SetVisibilityAnimationDuration(
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 369
369 void TrayBackgroundView::SetContents(views::View* contents) { 370 void TrayBackgroundView::SetContents(views::View* contents) {
370 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 371 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
371 AddChildView(contents); 372 AddChildView(contents);
372 } 373 }
373 void TrayBackgroundView::SetContentsBackground() { 374 void TrayBackgroundView::SetContentsBackground() {
374 background_ = new TrayBackground(this); 375 background_ = new TrayBackground(this);
375 tray_container_->set_background(background_); 376 tray_container_->set_background(background_);
376 } 377 }
377 378
378 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { 379 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment,
380 const gfx::Insets& insets) {
379 shelf_alignment_ = alignment; 381 shelf_alignment_ = alignment;
382 SetTrayBorder(insets);
James Cook 2016/06/29 19:34:14 This should pull the insets from somewhere, rather
380 tray_container_->SetAlignment(alignment); 383 tray_container_->SetAlignment(alignment);
381 } 384 }
382 385
386 void TrayBackgroundView::SetTrayBorder(const gfx::Insets& insets) {
387 SetBorder(views::Border::CreateEmptyBorder(insets.top(), insets.left(),
388 insets.bottom(), insets.right()));
389 }
390
383 void TrayBackgroundView::OnImplicitAnimationsCompleted() { 391 void TrayBackgroundView::OnImplicitAnimationsCompleted() {
384 // If there is another animation in the queue, the reverse animation was 392 // If there is another animation in the queue, the reverse animation was
385 // triggered before the completion of animating to invisible. Do not turn off 393 // triggered before the completion of animating to invisible. Do not turn off
386 // the visibility so that the next animation may render. The value of 394 // the visibility so that the next animation may render. The value of
387 // layer()->GetTargetVisibility() can be incorrect if the hide animation was 395 // layer()->GetTargetVisibility() can be incorrect if the hide animation was
388 // aborted to schedule an animation to become visible. As the new animation 396 // aborted to schedule an animation to become visible. As the new animation
389 // is not yet added to the queue. crbug.com/374236 397 // is not yet added to the queue. crbug.com/374236
390 if (layer()->GetAnimator()->is_animating() || layer()->GetTargetVisibility()) 398 if (layer()->GetAnimator()->is_animating() || layer()->GetTargetVisibility())
391 return; 399 return;
392 views::View::SetVisible(false); 400 views::View::SetVisible(false);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 return; 512 return;
505 SchedulePaint(); 513 SchedulePaint();
506 } 514 }
507 515
508 void TrayBackgroundView::UpdateBubbleViewArrow( 516 void TrayBackgroundView::UpdateBubbleViewArrow(
509 views::TrayBubbleView* bubble_view) { 517 views::TrayBubbleView* bubble_view) {
510 // Nothing to do here. 518 // Nothing to do here.
511 } 519 }
512 520
513 } // namespace ash 521 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698