Commit 1fd1483e authored by Megumi Hattori's avatar Megumi Hattori Committed by Commit Bot

Change reply icon color when the textfield is empty in the inline reply.

Before this CL, the reply icon color was opaque white regardless of whether the textfield is empty or not.
This CL Changes the icon color to transparent white (opacity: 38%) when textfield is empty.

BUG=803759

Change-Id: Id7824e62fd44b0700ea5608b222cdda4de03048c
Reviewed-on: https://chromium-review.googlesource.com/886204Reviewed-by: default avatarTetsui Ohkubo <tetsui@chromium.org>
Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Commit-Queue: Megumi Hattori <megumihattori@google.com>
Cr-Commit-Position: refs/heads/master@{#532312}
parent 657576bc
......@@ -95,6 +95,8 @@ const SkColor kInputPlaceholderColor = SkColorSetARGB(0x8A, 0xFF, 0xFF, 0xFF);
// The icon color of inline reply input field.
const SkColor kInputReplyButtonColor = SkColorSetRGB(0xFF, 0xFF, 0xFF);
const SkColor kInputReplyButtonPlaceholderColor =
SkColorSetARGB(0x60, 0xFF, 0xFF, 0xFF);
// The icon size of inline reply input field.
constexpr int kInputReplyButtonSize = 20;
......@@ -155,20 +157,6 @@ class ClickActivator : public ui::EventHandler {
DISALLOW_COPY_AND_ASSIGN(ClickActivator);
};
class NotificationInputReplyButtonMD : public views::ImageView {
public:
NotificationInputReplyButtonMD() {
SetImage(gfx::CreateVectorIcon(kNotificationInlineReplyIcon,
kInputReplyButtonSize,
kInputReplyButtonColor));
SetBorder(views::CreateEmptyBorder(kInputReplyButtonPadding));
}
~NotificationInputReplyButtonMD() override = default;
private:
DISALLOW_COPY_AND_ASSIGN(NotificationInputReplyButtonMD);
};
} // anonymous namespace
// ItemView ////////////////////////////////////////////////////////////////////
......@@ -393,8 +381,19 @@ NotificationInputTextfieldMD::NotificationInputTextfieldMD(
NotificationInputTextfieldMD::~NotificationInputTextfieldMD() = default;
void NotificationInputTextfieldMD::CheckUpdateImage() {
if (is_empty_ && !text().empty()) {
is_empty_ = false;
delegate_->SetNormalImageToReplyButton();
} else if (!is_empty_ && text().empty()) {
is_empty_ = true;
delegate_->SetPlaceholderImageToReplyButton();
}
}
bool NotificationInputTextfieldMD::HandleKeyEvent(views::Textfield* sender,
const ui::KeyEvent& event) {
CheckUpdateImage();
if (event.type() == ui::ET_KEY_PRESSED &&
event.key_code() == ui::VKEY_RETURN) {
delegate_->OnNotificationInputSubmit(index_, text());
......@@ -403,6 +402,20 @@ bool NotificationInputTextfieldMD::HandleKeyEvent(views::Textfield* sender,
return event.type() == ui::ET_KEY_RELEASED;
}
bool NotificationInputTextfieldMD::HandleMouseEvent(
views::Textfield* sender,
const ui::MouseEvent& event) {
CheckUpdateImage();
return event.type() == ui::ET_MOUSE_RELEASED;
}
bool NotificationInputTextfieldMD::HandleGestureEvent(
views::Textfield* sender,
const ui::GestureEvent& event) {
CheckUpdateImage();
return false;
}
void NotificationInputTextfieldMD::set_placeholder(
const base::string16& placeholder) {
if (placeholder.empty()) {
......@@ -413,6 +426,27 @@ void NotificationInputTextfieldMD::set_placeholder(
}
}
// NotificationInputReplyButtonMD //////////////////////////////////////////////
NotificationInputReplyButtonMD::NotificationInputReplyButtonMD() {
SetPlaceholderImage();
SetBorder(views::CreateEmptyBorder(kInputReplyButtonPadding));
}
NotificationInputReplyButtonMD::~NotificationInputReplyButtonMD() = default;
void NotificationInputReplyButtonMD::SetNormalImage() {
SetImage(gfx::CreateVectorIcon(kNotificationInlineReplyIcon,
kInputReplyButtonSize,
kInputReplyButtonColor));
}
void NotificationInputReplyButtonMD::SetPlaceholderImage() {
SetImage(gfx::CreateVectorIcon(kNotificationInlineReplyIcon,
kInputReplyButtonSize,
kInputReplyButtonPlaceholderColor));
}
// NotificationInputContainerMD ////////////////////////////////////////////////
NotificationInputContainerMD::NotificationInputContainerMD(
......@@ -731,6 +765,14 @@ void NotificationViewMD::ButtonPressed(views::Button* sender,
}
}
void NotificationViewMD::SetNormalImageToReplyButton() {
inline_reply_->button()->SetNormalImage();
}
void NotificationViewMD::SetPlaceholderImageToReplyButton() {
inline_reply_->button()->SetPlaceholderImage();
}
void NotificationViewMD::OnNotificationInputSubmit(size_t index,
const base::string16& text) {
MessageCenter::Get()->ClickOnNotificationButtonWithReply(notification_id(),
......
......@@ -137,6 +137,8 @@ class NotificationButtonMD : public views::LabelButton {
class NotificationInputDelegate {
public:
virtual void SetNormalImageToReplyButton() = 0;
virtual void SetPlaceholderImageToReplyButton() = 0;
virtual void OnNotificationInputSubmit(size_t index,
const base::string16& text) = 0;
virtual ~NotificationInputDelegate() = default;
......@@ -148,8 +150,13 @@ class NotificationInputTextfieldMD : public views::Textfield,
NotificationInputTextfieldMD(NotificationInputDelegate* delegate);
~NotificationInputTextfieldMD() override;
void CheckUpdateImage();
bool HandleKeyEvent(views::Textfield* sender,
const ui::KeyEvent& key_event) override;
bool HandleMouseEvent(views::Textfield* sender,
const ui::MouseEvent& mouse_event) override;
bool HandleGestureEvent(views::Textfield* sender,
const ui::GestureEvent& gesture_event) override;
void set_index(size_t index) { index_ = index; }
void set_placeholder(const base::string16& placeholder);
......@@ -157,6 +164,8 @@ class NotificationInputTextfieldMD : public views::Textfield,
private:
NotificationInputDelegate* const delegate_;
bool is_empty_ = true;
// |index_| is the notification action index that should be passed as the
// argument of ClickOnNotificationButtonWithReply.
size_t index_ = 0;
......@@ -164,16 +173,29 @@ class NotificationInputTextfieldMD : public views::Textfield,
DISALLOW_COPY_AND_ASSIGN(NotificationInputTextfieldMD);
};
class NotificationInputReplyButtonMD : public views::ImageView {
public:
NotificationInputReplyButtonMD();
~NotificationInputReplyButtonMD() override;
void SetNormalImage();
void SetPlaceholderImage();
private:
DISALLOW_COPY_AND_ASSIGN(NotificationInputReplyButtonMD);
};
class NotificationInputContainerMD : public views::View {
public:
NotificationInputContainerMD(NotificationInputDelegate* delegate);
~NotificationInputContainerMD() override;
NotificationInputTextfieldMD* textfield() const { return textfield_; };
NotificationInputReplyButtonMD* button() const { return button_; };
private:
NotificationInputTextfieldMD* const textfield_;
views::ImageView* const button_;
NotificationInputReplyButtonMD* const button_;
DISALLOW_COPY_AND_ASSIGN(NotificationInputContainerMD);
};
......@@ -214,6 +236,8 @@ class MESSAGE_CENTER_EXPORT NotificationViewMD
void OnSettingsButtonPressed() override;
// Overridden from NotificationInputDelegate:
void SetNormalImageToReplyButton() override;
void SetPlaceholderImageToReplyButton() override;
void OnNotificationInputSubmit(size_t index,
const base::string16& text) override;
......
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