Index: ash/system/tray/system_tray_bubble.cc |
diff --git a/ash/system/tray/system_tray_bubble.cc b/ash/system/tray/system_tray_bubble.cc |
index 26a28b41ca23b7ef6e3321914a75dfecdba3dd1a..f7c08f933d0078e7ee8aed4c376a32bb782eb0e1 100644 |
--- a/ash/system/tray/system_tray_bubble.cc |
+++ b/ash/system/tray/system_tray_bubble.cc |
@@ -47,6 +47,11 @@ const int kMinArrowOffset = 12; |
const int kAnimationDurationForPopupMS = 200; |
+// When showing a detailed view directly (e.g. from a notification), we may not |
+// know the height of the default view, or the default view may be too small, |
+// so pick a reasonable max height. |
+const int kDetailedBubbleMaxHeight = kTrayPopupItemHeight * 5; |
sadrul
2012/05/22 19:05:17
Let's call this kNotificationBubbleMaxHeight. I do
stevenjb
2012/05/22 22:39:00
This has nothing to do with notifications, it only
|
+ |
const SkColor kShadowColor = SkColorSetARGB(0xff, 0, 0, 0); |
void DrawBlurredShadowAroundView(gfx::Canvas* canvas, |
@@ -262,13 +267,15 @@ namespace internal { |
// SystemTrayBubbleView |
-SystemTrayBubbleView::SystemTrayBubbleView(views::View* anchor, |
+SystemTrayBubbleView::SystemTrayBubbleView( |
+ views::View* anchor, |
views::BubbleBorder::ArrowLocation arrow_location, |
SystemTrayBubble* host, |
bool can_activate) |
: views::BubbleDelegateView(anchor, arrow_location), |
host_(host), |
- can_activate_(can_activate) { |
+ can_activate_(can_activate), |
+ max_height_(0) { |
set_margin(0); |
set_parent_window(ash::Shell::GetInstance()->GetContainer( |
ash::internal::kShellWindowId_SettingBubbleContainer)); |
@@ -335,7 +342,10 @@ bool SystemTrayBubbleView::CanActivate() const { |
gfx::Size SystemTrayBubbleView::GetPreferredSize() { |
gfx::Size size = views::BubbleDelegateView::GetPreferredSize(); |
- return gfx::Size(kTrayPopupWidth, size.height()); |
+ int height = size.height(); |
+ if (max_height_ != 0 && height > max_height_) |
+ height = max_height_; |
+ return gfx::Size(kTrayPopupWidth, height); |
} |
void SystemTrayBubbleView::OnMouseEntered(const views::MouseEvent& event) { |
@@ -355,7 +365,8 @@ SystemTrayBubble::InitParams::InitParams( |
anchor_type(anchor_type), |
can_activate(false), |
login_status(ash::user::LOGGED_IN_NONE), |
- arrow_offset(kArrowPaddingFromRight + kArrowWidth / 2) { |
+ arrow_offset(kArrowPaddingFromRight + kArrowWidth / 2), |
+ max_height(0) { |
} |
// SystemTrayBubble |
@@ -400,8 +411,10 @@ void SystemTrayBubble::UpdateView( |
CreateItemViews(Shell::GetInstance()->tray_delegate()->GetUserLoginStatus()); |
bubble_widget_->GetContentsView()->Layout(); |
// Make sure that the bubble is large enough for the default view. |
- if (bubble_type_ == BUBBLE_TYPE_DEFAULT) |
+ if (bubble_type_ == BUBBLE_TYPE_DEFAULT) { |
+ bubble_view_->set_max_height(0); // Clear max height limit. |
bubble_view_->SizeToContents(); |
+ } |
} |
void SystemTrayBubble::InitView(const InitParams& init_params) { |
@@ -423,6 +436,11 @@ void SystemTrayBubble::InitView(const InitParams& init_params) { |
init_params.anchor, arrow_location, this, init_params.can_activate); |
if (bubble_type_ == BUBBLE_TYPE_NOTIFICATION) |
bubble_view_->set_close_on_deactivate(false); |
+ int max_height = init_params.max_height; |
+ if (bubble_type_ == BUBBLE_TYPE_DETAILED && |
+ max_height < kDetailedBubbleMaxHeight) |
+ max_height = kDetailedBubbleMaxHeight; |
+ bubble_view_->set_max_height(max_height); |
CreateItemViews(init_params.login_status); |