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

Side by Side Diff: ui/views/animation/ink_drop_impl.cc

Issue 2499523003: Add ink drop masking to TrayBackgroundView (Closed)
Patch Set: Rebased Created 4 years, 1 month 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ui/views/animation/ink_drop_impl.h" 5 #include "ui/views/animation/ink_drop_impl.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/timer/timer.h" 8 #include "base/timer/timer.h"
9 #include "ui/compositor/layer.h" 9 #include "ui/compositor/layer.h"
10 #include "ui/views/animation/ink_drop_highlight.h" 10 #include "ui/views/animation/ink_drop_highlight.h"
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 this, animation_duration, explode); 568 this, animation_duration, explode);
569 case InkDropImpl::AutoHighlightMode::SHOW_ON_RIPPLE: 569 case InkDropImpl::AutoHighlightMode::SHOW_ON_RIPPLE:
570 return base::MakeUnique<ShowHighlightOnRippleVisibleState>( 570 return base::MakeUnique<ShowHighlightOnRippleVisibleState>(
571 this, animation_duration, explode); 571 this, animation_duration, explode);
572 } 572 }
573 // Required for some compilers. 573 // Required for some compilers.
574 NOTREACHED(); 574 NOTREACHED();
575 return nullptr; 575 return nullptr;
576 } 576 }
577 577
578 InkDropImpl::InkDropImpl(InkDropHost* ink_drop_host) 578 InkDropImpl::InkDropImpl(InkDropHost* ink_drop_host,
579 const gfx::Size& layer_size)
579 : ink_drop_host_(ink_drop_host), 580 : ink_drop_host_(ink_drop_host),
580 root_layer_(new ui::Layer(ui::LAYER_NOT_DRAWN)), 581 root_layer_(new ui::Layer(ui::LAYER_NOT_DRAWN)),
581 root_layer_added_to_host_(false), 582 root_layer_added_to_host_(false),
582 show_highlight_on_hover_(true), 583 show_highlight_on_hover_(true),
583 show_highlight_on_focus_(false), 584 show_highlight_on_focus_(false),
584 is_hovered_(false), 585 is_hovered_(false),
585 is_focused_(false), 586 is_focused_(false),
586 exiting_highlight_state_(false), 587 exiting_highlight_state_(false),
587 destroying_(false) { 588 destroying_(false) {
589 root_layer_->SetBounds(gfx::Rect(layer_size));
588 SetAutoHighlightMode(AutoHighlightMode::NONE); 590 SetAutoHighlightMode(AutoHighlightMode::NONE);
589 root_layer_->set_name("InkDropImpl:RootLayer"); 591 root_layer_->set_name("InkDropImpl:RootLayer");
590 } 592 }
591 593
592 InkDropImpl::~InkDropImpl() { 594 InkDropImpl::~InkDropImpl() {
593 destroying_ = true; 595 destroying_ = true;
594 // Setting a no-op state prevents animations from being triggered on a null 596 // Setting a no-op state prevents animations from being triggered on a null
595 // |ink_drop_ripple_| as a side effect of the tear down. 597 // |ink_drop_ripple_| as a side effect of the tear down.
596 SetHighlightState(base::MakeUnique<DestroyingHighlightState>()); 598 SetHighlightState(base::MakeUnique<DestroyingHighlightState>());
597 599
(...skipping 15 matching lines...) Expand all
613 615
614 void InkDropImpl::SetAutoHighlightMode(AutoHighlightMode auto_highlight_mode) { 616 void InkDropImpl::SetAutoHighlightMode(AutoHighlightMode auto_highlight_mode) {
615 // Exit the current state completely first in case state tear down accesses 617 // Exit the current state completely first in case state tear down accesses
616 // the current |highlight_state_factory_| instance. 618 // the current |highlight_state_factory_| instance.
617 ExitHighlightState(); 619 ExitHighlightState();
618 highlight_state_factory_ = 620 highlight_state_factory_ =
619 base::MakeUnique<HighlightStateFactory>(auto_highlight_mode, this); 621 base::MakeUnique<HighlightStateFactory>(auto_highlight_mode, this);
620 SetHighlightState(highlight_state_factory_->CreateStartState()); 622 SetHighlightState(highlight_state_factory_->CreateStartState());
621 } 623 }
622 624
625 void InkDropImpl::UpdateLayerSize(const gfx::Size& layer_size) {
626 root_layer_->SetBounds(gfx::Rect(layer_size));
bruthig 2016/11/14 19:09:38 nit: A comment here saying that "we are updating |
mohsen 2016/11/14 20:19:39 Done.
627 }
628
623 InkDropState InkDropImpl::GetTargetInkDropState() const { 629 InkDropState InkDropImpl::GetTargetInkDropState() const {
624 if (!ink_drop_ripple_) 630 if (!ink_drop_ripple_)
625 return InkDropState::HIDDEN; 631 return InkDropState::HIDDEN;
626 return ink_drop_ripple_->target_ink_drop_state(); 632 return ink_drop_ripple_->target_ink_drop_state();
627 } 633 }
628 634
629 void InkDropImpl::AnimateToState(InkDropState ink_drop_state) { 635 void InkDropImpl::AnimateToState(InkDropState ink_drop_state) {
630 // Never animate hidden -> hidden, since that will add layers which may never 636 // Never animate hidden -> hidden, since that will add layers which may never
631 // be needed. Other same-state transitions may restart animations. 637 // be needed. Other same-state transitions may restart animations.
632 if (ink_drop_state == InkDropState::HIDDEN && 638 if (ink_drop_state == InkDropState::HIDDEN &&
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 "within a call to " 809 "within a call to "
804 "HighlightState::Exit()."; 810 "HighlightState::Exit().";
805 if (highlight_state_) { 811 if (highlight_state_) {
806 base::AutoReset<bool> exit_guard(&exiting_highlight_state_, true); 812 base::AutoReset<bool> exit_guard(&exiting_highlight_state_, true);
807 highlight_state_->Exit(); 813 highlight_state_->Exit();
808 } 814 }
809 highlight_state_ = nullptr; 815 highlight_state_ = nullptr;
810 } 816 }
811 817
812 } // namespace views 818 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698