Chromium Code Reviews| 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 4dce878af878442b8863c82456a82bd20f3502f9..b3db458094b6b42656735efe56064aca778c5295 100644 |
| --- a/ash/system/tray/system_tray_bubble.cc |
| +++ b/ash/system/tray/system_tray_bubble.cc |
| @@ -176,11 +176,14 @@ class SystemTrayBubbleBorder : public views::BubbleBorder { |
| ARROW_TYPE_BOTTOM, |
| }; |
| - SystemTrayBubbleBorder(views::View* owner, ArrowType arrow_type) |
| + SystemTrayBubbleBorder(views::View* owner, |
| + ArrowType arrow_type, |
| + int arrow_offset) |
| : views::BubbleBorder(views::BubbleBorder::BOTTOM_RIGHT, |
| views::BubbleBorder::NO_SHADOW), |
| owner_(owner), |
| - arrow_type_(arrow_type) { |
| + arrow_type_(arrow_type), |
| + arrow_offset_(arrow_offset) { |
| set_alignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); |
| } |
| @@ -210,6 +213,13 @@ class SystemTrayBubbleBorder : public views::BubbleBorder { |
| int left_base_y = y; |
| int tip_x = left_base_x + kArrowWidth / 2; |
| int tip_y = left_base_y + kArrowHeight; |
| + if (arrow_offset_ >= kArrowWidth / 2 && |
| + arrow_offset_ < owner_->width() - kArrowWidth / 2) { |
| + tip_x = base::i18n::IsRTL() ? |
| + arrow_offset_ : owner_->width() - arrow_offset_; |
| + left_base_x = tip_x - kArrowWidth / 2; |
| + } |
|
sadrul
2012/05/15 02:18:15
I am not sure I understand this. What does this do
Jun Mukai
2012/05/15 02:43:05
Done.
|
| + |
| SkPath path; |
| path.incReserve(4); |
| path.moveTo(SkIntToScalar(left_base_x), SkIntToScalar(left_base_y)); |
| @@ -231,6 +241,7 @@ class SystemTrayBubbleBorder : public views::BubbleBorder { |
| views::View* owner_; |
| ArrowType arrow_type_; |
| + const int arrow_offset_; |
| DISALLOW_COPY_AND_ASSIGN(SystemTrayBubbleBorder); |
| }; |
| @@ -318,6 +329,16 @@ void SystemTrayBubbleView::OnMouseExited(const views::MouseEvent& event) { |
| host_->RestartAutoCloseTimer(); |
| } |
| +// SystemTrayBubble::InitParams |
| +SystemTrayBubble::InitParams::InitParams( |
| + SystemTrayBubble::AnchorType anchor_type) |
| + : anchor(NULL), |
| + anchor_type(anchor_type), |
| + can_activate(false), |
| + login_status(ash::user::LOGGED_IN_NONE), |
| + arrow_offset(-1) { |
|
sadrul
2012/05/15 02:18:15
Initialize offset to kArrowPaddingFromRight
Jun Mukai
2012/05/15 02:43:05
Done.
|
| +} |
| + |
| // SystemTrayBubble |
| SystemTrayBubble::SystemTrayBubble( |
| @@ -349,13 +370,11 @@ SystemTrayBubble::~SystemTrayBubble() { |
| } |
| } |
| -void SystemTrayBubble::InitView(views::View* anchor, |
| - AnchorType anchor_type, |
| - bool can_activate, |
| - ash::user::LoginStatus login_status) { |
| +void SystemTrayBubble::InitView(const InitParams& init_params) { |
| DCHECK(bubble_view_ == NULL); |
| - anchor_type_ = anchor_type; |
| - bubble_view_ = new SystemTrayBubbleView(anchor, this, can_activate); |
| + anchor_type_ = init_params.anchor_type; |
| + bubble_view_ = new SystemTrayBubbleView( |
| + init_params.anchor, this, init_params.can_activate); |
| for (std::vector<ash::SystemTrayItem*>::iterator it = items_.begin(); |
| it != items_.end(); |
| @@ -363,13 +382,13 @@ void SystemTrayBubble::InitView(views::View* anchor, |
| views::View* view = NULL; |
| switch (bubble_type_) { |
| case BUBBLE_TYPE_DEFAULT: |
| - view = (*it)->CreateDefaultView(login_status); |
| + view = (*it)->CreateDefaultView(init_params.login_status); |
| break; |
| case BUBBLE_TYPE_DETAILED: |
| - view = (*it)->CreateDetailedView(login_status); |
| + view = (*it)->CreateDetailedView(init_params.login_status); |
| break; |
| case BUBBLE_TYPE_NOTIFICATION: |
| - view = (*it)->CreateNotificationView(login_status); |
| + view = (*it)->CreateNotificationView(init_params.login_status); |
| break; |
| } |
| if (view) |
| @@ -387,8 +406,10 @@ void SystemTrayBubble::InitView(views::View* anchor, |
| arrow_type = SystemTrayBubbleBorder::ARROW_TYPE_BOTTOM; |
| else |
| arrow_type = SystemTrayBubbleBorder::ARROW_TYPE_NONE; |
| - bubble_view_->SetBubbleBorder( |
| - new SystemTrayBubbleBorder(bubble_view_, arrow_type)); |
| + |
| + SystemTrayBubbleBorder* bubble_border = new SystemTrayBubbleBorder( |
| + bubble_view_, arrow_type, init_params.arrow_offset); |
| + bubble_view_->SetBubbleBorder(bubble_border); |
| bubble_widget_->AddObserver(this); |