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

Unified Diff: ui/message_center/views/notification_header_view.cc

Issue 2966673002: Add ripple effect to action in expand button. (Closed)
Patch Set: Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: ui/message_center/views/notification_header_view.cc
diff --git a/ui/message_center/views/notification_header_view.cc b/ui/message_center/views/notification_header_view.cc
index 7a4fa5d9d8a4b62f7af2b273010ba832839a332a..9e7b1ecfebf5de3f17f6e631bd23134168793310 100644
--- a/ui/message_center/views/notification_header_view.cc
+++ b/ui/message_center/views/notification_header_view.cc
@@ -43,6 +43,51 @@ constexpr float kInkDropRippleVisibleOpacity = 0.08f;
// Highlight (hover) ink drop opacity of action buttons.
constexpr float kInkDropHighlightVisibleOpacity = 0.08f;
+class ExpandButton : public views::ImageButton, public views::ButtonListener {
yoshiki 2017/07/03 06:26:49 BTW, why is it inheriting a button? Although this
tetsui 2017/07/03 07:10:54 Done.
+ public:
+ ExpandButton(NotificationHeaderView* header);
+ ~ExpandButton() override;
+
+ // ButtonListener override:
+ void ButtonPressed(Button* sender, const ui::Event& event) override;
+
+ protected:
+ // ImageButton override:
+ void OnMouseEvent(ui::MouseEvent* event) override;
+ void OnKeyEvent(ui::KeyEvent* event) override;
+
+ private:
+ NotificationHeaderView* header_;
+};
+
+ExpandButton::ExpandButton(NotificationHeaderView* header)
+ : views::ImageButton(this), header_(header) {
+ SetImage(views::Button::STATE_NORMAL,
+ gfx::CreateVectorIcon(kNotificationExpandMoreIcon, kExpandIconSize,
+ gfx::kChromeIconGrey));
+ SetFocusForPlatform();
+ SetFocusPainter(views::Painter::CreateSolidFocusPainter(
+ kFocusBorderColor, gfx::Insets(1, 2, 2, 2)));
+}
+
+ExpandButton::~ExpandButton() = default;
+
+void ExpandButton::ButtonPressed(Button* sender, const ui::Event& event) {
+ // No need to handle event here because raw OnMouseEvent and OnKeyEvent are
+ // forwarded to NotificationHeaderView.
+}
+
+void ExpandButton::OnMouseEvent(ui::MouseEvent* event) {
+ views::View* source = this;
yoshiki 2017/07/03 06:26:49 Can this method be empty? I think if you don't any
tetsui 2017/07/03 07:10:54 Done.
+ views::View* target = header_;
+ ui::MouseEvent converted_event(*event, source, target);
+ header_->OnMouseEvent(&converted_event);
+}
+
+void ExpandButton::OnKeyEvent(ui::KeyEvent* event) {
+ header_->OnKeyEvent(event);
+}
+
} // namespace
NotificationHeaderView::NotificationHeaderView(views::ButtonListener* listener)
@@ -101,14 +146,7 @@ NotificationHeaderView::NotificationHeaderView(views::ButtonListener* listener)
app_info_container->AddChildView(summary_text_view_);
// Expand button view
- expand_button_ = new views::ImageButton(listener);
- expand_button_->SetImage(
- views::Button::STATE_NORMAL,
- gfx::CreateVectorIcon(kNotificationExpandMoreIcon, kExpandIconSize,
- gfx::kChromeIconGrey));
- expand_button_->SetFocusForPlatform();
- expand_button_->SetFocusPainter(views::Painter::CreateSolidFocusPainter(
- kFocusBorderColor, gfx::Insets(1, 2, 2, 2)));
+ expand_button_ = new ExpandButton(this);
app_info_container->AddChildView(expand_button_);
// Spacer between left-aligned views and right-aligned views
@@ -157,6 +195,11 @@ void NotificationHeaderView::ClearProgress() {
}
void NotificationHeaderView::SetExpandButtonEnabled(bool enabled) {
+ // SetInkDropMode iff. the visibility changed.
+ // Otherwise, the ink drop animation cannot finish.
+ if (expand_button_->visible() != enabled)
+ SetInkDropMode(enabled ? InkDropMode::ON : InkDropMode::OFF);
+
expand_button_->SetVisible(enabled);
}

Powered by Google App Engine
This is Rietveld 408576698