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

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

Issue 2729533002: Adjust behavior of control buttons of notifications. (Closed)
Patch Set: Add unimplemented method to TestContentViewDelegate Created 3 years, 10 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
« no previous file with comments | « ui/message_center/views/notification_view.h ('k') | ui/message_center/views/padded_button.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/message_center/views/notification_view.cc
diff --git a/ui/message_center/views/notification_view.cc b/ui/message_center/views/notification_view.cc
index 966fe19f86c68c0db88b1ae5bba6ac19b11c65f1..da750d916c7b5ceeacb44af979ed7e7f554a544f 100644
--- a/ui/message_center/views/notification_view.cc
+++ b/ui/message_center/views/notification_view.cc
@@ -345,6 +345,16 @@ gfx::NativeCursor NotificationView::GetCursor(const ui::MouseEvent& event) {
return views::GetNativeHandCursor();
}
+void NotificationView::OnMouseEntered(const ui::MouseEvent& event) {
+ MessageView::OnMouseEntered(event);
+ UpdateControlButtonsVisibility();
+}
+
+void NotificationView::OnMouseExited(const ui::MouseEvent& event) {
+ MessageView::OnMouseExited(event);
+ UpdateControlButtonsVisibility();
+}
+
void NotificationView::UpdateWithNotification(
const Notification& notification) {
MessageView::UpdateWithNotification(notification);
@@ -525,6 +535,7 @@ void NotificationView::CreateOrUpdateSettingsButtonView(
settings_button_view_ = settings;
AddChildView(settings_button_view_);
}
+ UpdateControlButtonsVisibility();
}
void NotificationView::CreateOrUpdateProgressBarView(
@@ -689,11 +700,29 @@ void NotificationView::CreateOrUpdateCloseButtonView(
IDS_MESSAGE_CENTER_CLOSE_NOTIFICATION_BUTTON_TOOLTIP));
close_button_->set_owned_by_client();
AddChildView(close_button_.get());
+ UpdateControlButtonsVisibility();
} else if (notification.pinned() && close_button_) {
close_button_.reset();
}
}
+void NotificationView::UpdateControlButtonsVisibility() {
+ const bool target_visibility =
+ IsMouseHovered() || HasFocus() ||
+ (close_button_ && close_button_->HasFocus()) ||
+ (settings_button_view_ && settings_button_view_->HasFocus());
+
+ if (close_button_) {
+ if (target_visibility != close_button_->visible())
+ close_button_->SetVisible(target_visibility);
+ }
+
+ if (settings_button_view_) {
+ if (target_visibility != settings_button_view_->visible())
+ settings_button_view_->SetVisible(target_visibility);
+ }
+}
+
int NotificationView::GetMessageLineLimit(int title_lines, int width) const {
// Image notifications require that the image must be kept flush against
// their icons, but we can allow more text if no image.
« no previous file with comments | « ui/message_center/views/notification_view.h ('k') | ui/message_center/views/padded_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698