Commit 4278522e authored by dewittj@chromium.org's avatar dewittj@chromium.org

Enable notification collapse-expand under a flag.

This fixes a layout bug that was dormant since previously notifications
were always expanded.

BUG=NONE

Review URL: https://codereview.chromium.org/68713006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235651 0039d316-1c4b-4281-b951-d872f2087c98
parent 11c2b337
......@@ -105,7 +105,8 @@ const SkColor kProgressBarSliceColor = SkColorSetRGB(120, 120, 120);
// Line limits.
const int kTitleLineLimit = 3;
const int kMessageCollapsedLineLimit = 3;
const int kExperimentalTitleLineLimit = 1;
const int kMessageCollapsedLineLimit = 2;
const int kMessageExpandedLineLimit = 7;
const int kContextMessageLineLimit = 1;
......
......@@ -21,6 +21,7 @@
#include "ui/message_center/message_center.h"
#include "ui/message_center/message_center_style.h"
#include "ui/message_center/message_center_types.h"
#include "ui/message_center/message_center_util.h"
#include "ui/message_center/views/message_center_button_bar.h"
#include "ui/message_center/views/message_view.h"
#include "ui/message_center/views/notification_view.h"
......@@ -925,11 +926,14 @@ void MessageCenterView::OnNotificationUpdated(const std::string& id) {
++iter, ++index) {
DCHECK((*iter)->id() == message_views_[index]->notification_id());
if ((*iter)->id() == id) {
bool expanded = true;
if (IsExperimentalNotificationUIEnabled())
expanded = (*iter)->is_expanded();
MessageView* view =
NotificationView::Create(*(*iter),
message_center_,
tray_,
true, // Create expanded.
expanded,
false); // Not creating a top-level
// notification.
view->set_scroller(scroller_);
......@@ -985,11 +989,14 @@ void MessageCenterView::AddNotificationAt(const Notification& notification,
int index) {
// NotificationViews are expanded by default here until
// http://crbug.com/217902 is fixed. TODO(dharcourt): Fix.
bool expanded = true;
if (IsExperimentalNotificationUIEnabled())
expanded = notification.is_expanded();
MessageView* view =
NotificationView::Create(notification,
message_center_,
tray_,
true, // Create expanded.
expanded,
false); // Not creating a top-level
// notification.
view->set_scroller(scroller_);
......
......@@ -19,6 +19,7 @@
#include "ui/gfx/screen.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/message_center_style.h"
#include "ui/message_center/message_center_util.h"
#include "ui/message_center/notification.h"
#include "ui/message_center/notification_list.h"
#include "ui/message_center/views/notification_view.h"
......@@ -129,11 +130,14 @@ void MessagePopupCollection::UpdateWidgets() {
if (FindToast((*iter)->id()))
continue;
bool expanded = true;
if (IsExperimentalNotificationUIEnabled())
expanded = (*iter)->is_expanded();
MessageView* view =
NotificationView::Create(*(*iter),
message_center_,
tray_,
true, // Create expanded.
expanded,
true); // Create top-level notification.
int view_height = ToastContentsView::GetToastSizeForView(view).height();
int height_available = top_down ? work_area_.bottom() - base : base;
......@@ -412,11 +416,14 @@ void MessagePopupCollection::OnNotificationUpdated(
if ((*iter)->id() != notification_id)
continue;
bool expanded = true;
if (IsExperimentalNotificationUIEnabled())
expanded = (*iter)->is_expanded();
MessageView* view =
NotificationView::Create(*(*iter),
message_center_,
tray_,
true, // Create expanded.
expanded,
true); // Create top-level notification.
(*toast_iter)->SetContents(view);
updated = true;
......
......@@ -491,7 +491,9 @@ NotificationView::NotificationView(const Notification& notification,
gfx::TruncateString(notification.title(), kTitleCharacterLimit),
font_list);
title_view_->SetLineHeight(kTitleLineHeight);
title_view_->SetLineLimit(message_center::kTitleLineLimit);
title_view_->SetLineLimit(IsExperimentalNotificationUIEnabled() ?
message_center::kExperimentalTitleLineLimit :
message_center::kTitleLineLimit);
title_view_->SetColors(message_center::kRegularTextColor,
kRegularTextBackgroundColor);
title_view_->set_border(MakeTextBorder(padding, 3, 0));
......@@ -640,7 +642,6 @@ int NotificationView::GetHeightForWidth(int width) {
int content_width = width - GetInsets().width();
int top_height = top_view_->GetHeightForWidth(content_width);
int bottom_height = bottom_view_->GetHeightForWidth(content_width);
int content_height = std::max(top_height, kIconSize) + bottom_height;
// <http://crbug.com/230448> Fix: Adjust the height when the message_view's
// line limit would be different for the specified width than it currently is.
......@@ -649,11 +650,13 @@ int NotificationView::GetHeightForWidth(int width) {
int used_limit = message_view_->GetLineLimit();
int correct_limit = GetMessageLineLimit(width);
if (used_limit != correct_limit) {
content_height -= GetMessageHeight(content_width, used_limit);
content_height += GetMessageHeight(content_width, correct_limit);
top_height -= GetMessageHeight(content_width, used_limit);
top_height += GetMessageHeight(content_width, correct_limit);
}
}
int content_height = std::max(top_height, kIconSize) + bottom_height;
// Adjust the height to make sure there is at least 16px of space below the
// icon if there is any space there (<http://crbug.com/232966>).
if (content_height > kIconSize)
......@@ -797,14 +800,17 @@ int NotificationView::GetMessageLineLimit(int width) {
if (is_expanded_ && !image_view_)
return message_center::kMessageExpandedLineLimit;
// If there's a title ensure title + message lines <= collapsed line limit.
if (title_view_) {
int title_lines = title_view_->GetLinesForWidthAndLimit(width, -1);
return std::max(message_center::kMessageCollapsedLineLimit - title_lines,
0);
int message_line_limit = message_center::kMessageCollapsedLineLimit;
// Subtract any lines taken by the context message.
if (context_message_view_) {
message_line_limit -= context_message_view_->GetLinesForWidthAndLimit(
width,
message_center::kContextMessageLineLimit);
}
return message_center::kMessageCollapsedLineLimit;
DCHECK_GT(message_line_limit, 0);
return message_line_limit;
}
int NotificationView::GetMessageLines(int width, int limit) {
......
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