Commit 2ab7c3e1 authored by Megumi Hattori's avatar Megumi Hattori Committed by Commit Bot

Add animation when the inline reply row is appearing.

When the inline reply row is appering right after a "REPLY" button is clicked, the row is light gray first, and change to blue like ink drop.

Bug=803757

Change-Id: Ie2e482be0de5edae2ff581c84c755545cd3beaf5
Reviewed-on: https://chromium-review.googlesource.com/890979
Commit-Queue: Megumi Hattori <megumihattori@google.com>
Reviewed-by: default avatarTetsui Ohkubo <tetsui@chromium.org>
Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532816}
parent 17728cdd
......@@ -30,6 +30,7 @@
#include "ui/message_center/views/padded_button.h"
#include "ui/message_center/views/proportional_image_view.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/animation/flood_fill_ink_drop_ripple.h"
#include "ui/views/animation/ink_drop_highlight.h"
#include "ui/views/background.h"
#include "ui/views/border.h"
......@@ -456,11 +457,19 @@ void NotificationInputReplyButtonMD::SetPlaceholderImage() {
NotificationInputContainerMD::NotificationInputContainerMD(
NotificationInputDelegate* delegate)
: delegate_(delegate),
ink_drop_container_(new views::InkDropContainerView()),
textfield_(new NotificationInputTextfieldMD(delegate)),
button_(new NotificationInputReplyButtonMD(this)) {
auto* layout = SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::kHorizontal, gfx::Insets(), 0));
SetBackground(views::CreateSolidBackground(kInputContainerBackgroundColor));
SetBackground(views::CreateSolidBackground(kActionsRowBackgroundColor));
SetInkDropMode(InkDropMode::ON);
set_ink_drop_visible_opacity(1);
ink_drop_container_->SetPaintToLayer();
ink_drop_container_->layer()->SetFillsBoundsOpaquely(false);
AddChildView(ink_drop_container_);
AddChildView(textfield_);
layout->SetFlexForView(textfield_, 1);
......@@ -468,6 +477,43 @@ NotificationInputContainerMD::NotificationInputContainerMD(
AddChildView(button_);
}
NotificationInputContainerMD::~NotificationInputContainerMD() = default;
void NotificationInputContainerMD::AnimateBackground(
const ui::LocatedEvent& event) {
if (View::HitTestPoint(event.location()))
AnimateInkDrop(views::InkDropState::ACTION_PENDING,
ui::LocatedEvent::FromIfValid(&event));
}
void NotificationInputContainerMD::AddInkDropLayer(ui::Layer* ink_drop_layer) {
textfield_->SetPaintToLayer();
textfield_->layer()->SetFillsBoundsOpaquely(false);
button_->SetPaintToLayer();
button_->layer()->SetFillsBoundsOpaquely(false);
ink_drop_container_->AddInkDropLayer(ink_drop_layer);
InstallInkDropMask(ink_drop_layer);
}
void NotificationInputContainerMD::RemoveInkDropLayer(
ui::Layer* ink_drop_layer) {
textfield_->DestroyLayer();
button_->DestroyLayer();
ResetInkDropMask();
ink_drop_container_->RemoveInkDropLayer(ink_drop_layer);
}
std::unique_ptr<views::InkDropRipple>
NotificationInputContainerMD::CreateInkDropRipple() const {
return std::make_unique<views::FloodFillInkDropRipple>(
size(), GetInkDropCenterBasedOnLastEvent(), GetInkDropBaseColor(),
ink_drop_visible_opacity());
}
SkColor NotificationInputContainerMD::GetInkDropBaseColor() const {
return kInputContainerBackgroundColor;
}
void NotificationInputContainerMD::ButtonPressed(views::Button* sender,
const ui::Event& event) {
if (sender == button_) {
......@@ -476,8 +522,6 @@ void NotificationInputContainerMD::ButtonPressed(views::Button* sender,
}
}
NotificationInputContainerMD::~NotificationInputContainerMD() = default;
// InlineSettingsRadioButton ///////////////////////////////////////////////////
class InlineSettingsRadioButton : public views::RadioButton {
......@@ -761,6 +805,7 @@ void NotificationViewMD::ButtonPressed(views::Button* sender,
inline_reply_->textfield()->set_placeholder(
action_buttons_[i]->placeholder());
inline_reply_->textfield()->RequestFocus();
inline_reply_->AnimateBackground(*event.AsLocatedEvent());
inline_reply_->SetVisible(true);
action_buttons_row_->SetVisible(false);
Layout();
......
......@@ -189,12 +189,21 @@ class NotificationInputReplyButtonMD : public views::ImageButton {
DISALLOW_COPY_AND_ASSIGN(NotificationInputReplyButtonMD);
};
class NotificationInputContainerMD : public views::View,
class NotificationInputContainerMD : public views::InkDropHostView,
public views::ButtonListener {
public:
NotificationInputContainerMD(NotificationInputDelegate* delegate);
~NotificationInputContainerMD() override;
void AnimateBackground(const ui::LocatedEvent& event);
// Overridden from views::InkDropHostView:
void AddInkDropLayer(ui::Layer* ink_drop_layer) override;
void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override;
std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override;
SkColor GetInkDropBaseColor() const override;
// Overridden from views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
NotificationInputTextfieldMD* textfield() const { return textfield_; };
......@@ -203,6 +212,8 @@ class NotificationInputContainerMD : public views::View,
private:
NotificationInputDelegate* const delegate_;
views::InkDropContainerView* const ink_drop_container_;
NotificationInputTextfieldMD* const textfield_;
NotificationInputReplyButtonMD* const button_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment