OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/notifications/balloon_collection_impl.h" | 5 #include "chrome/browser/notifications/balloon_collection_impl.h" |
6 | 6 |
7 #include "chrome/browser/notifications/balloon.h" | 7 #include "chrome/browser/notifications/balloon.h" |
8 #include "chrome/browser/ui/views/notifications/balloon_view.h" | 8 #include "chrome/browser/ui/views/notifications/balloon_view.h" |
9 #include "ui/base/events.h" | 9 #include "ui/base/events.h" |
10 #include "ui/gfx/rect.h" | 10 #include "ui/gfx/rect.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 } | 24 } |
25 | 25 |
26 int BalloonCollectionImpl::Layout::HorizontalEdgeMargin() const { | 26 int BalloonCollectionImpl::Layout::HorizontalEdgeMargin() const { |
27 return 2; | 27 return 2; |
28 } | 28 } |
29 | 29 |
30 int BalloonCollectionImpl::Layout::VerticalEdgeMargin() const { | 30 int BalloonCollectionImpl::Layout::VerticalEdgeMargin() const { |
31 return 0; | 31 return 0; |
32 } | 32 } |
33 | 33 |
| 34 gfx::Point BalloonCollectionImpl::Layout::GetLayoutOrigin() const { |
| 35 int x = 0; |
| 36 int y = 0; |
| 37 switch (placement_) { |
| 38 case VERTICALLY_FROM_TOP_LEFT: |
| 39 x = work_area_.x() + HorizontalEdgeMargin(); |
| 40 y = work_area_.y() + VerticalEdgeMargin(); |
| 41 break; |
| 42 case VERTICALLY_FROM_TOP_RIGHT: |
| 43 x = work_area_.right() - HorizontalEdgeMargin(); |
| 44 y = work_area_.y() + VerticalEdgeMargin(); |
| 45 break; |
| 46 case VERTICALLY_FROM_BOTTOM_LEFT: |
| 47 x = work_area_.x() + HorizontalEdgeMargin(); |
| 48 // For this placement, balloon needs to stay on top of left-most panels |
| 49 // to avoid overlapping. |
| 50 y = work_area_.bottom() - VerticalEdgeMargin() - |
| 51 bottom_left_offset_to_move_above_panels_; |
| 52 break; |
| 53 case VERTICALLY_FROM_BOTTOM_RIGHT: |
| 54 x = work_area_.right() - HorizontalEdgeMargin(); |
| 55 // For this placement, balloon needs to stay on top of right-most panels |
| 56 // to avoid overlapping. |
| 57 y = work_area_.bottom() - VerticalEdgeMargin() - |
| 58 bottom_right_offset_to_move_above_panels_; |
| 59 break; |
| 60 default: |
| 61 NOTREACHED(); |
| 62 break; |
| 63 } |
| 64 return gfx::Point(x, y); |
| 65 } |
| 66 |
34 void BalloonCollectionImpl::PositionBalloons(bool reposition) { | 67 void BalloonCollectionImpl::PositionBalloons(bool reposition) { |
35 PositionBalloonsInternal(reposition); | 68 PositionBalloonsInternal(reposition); |
36 } | 69 } |
37 | 70 |
38 base::EventStatus BalloonCollectionImpl::WillProcessEvent( | 71 base::EventStatus BalloonCollectionImpl::WillProcessEvent( |
39 const base::NativeEvent& event) { | 72 const base::NativeEvent& event) { |
40 return base::EVENT_CONTINUE; | 73 return base::EVENT_CONTINUE; |
41 } | 74 } |
42 | 75 |
43 void BalloonCollectionImpl::DidProcessEvent(const base::NativeEvent& event) { | 76 void BalloonCollectionImpl::DidProcessEvent(const base::NativeEvent& event) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 else | 129 else |
97 NOTREACHED(); | 130 NOTREACHED(); |
98 | 131 |
99 PositionBalloons(true); | 132 PositionBalloons(true); |
100 } | 133 } |
101 | 134 |
102 // static | 135 // static |
103 BalloonCollection* BalloonCollection::Create() { | 136 BalloonCollection* BalloonCollection::Create() { |
104 return new BalloonCollectionImpl(); | 137 return new BalloonCollectionImpl(); |
105 } | 138 } |
OLD | NEW |