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 "ui/gfx/size.h" | 8 #include "ui/gfx/size.h" |
9 | 9 |
10 #if defined(TOOLKIT_VIEWS) | 10 #if defined(TOOLKIT_VIEWS) |
(...skipping 17 matching lines...) Expand all Loading... |
28 } | 28 } |
29 | 29 |
30 int BalloonCollectionImpl::Layout::HorizontalEdgeMargin() const { | 30 int BalloonCollectionImpl::Layout::HorizontalEdgeMargin() const { |
31 return 5; | 31 return 5; |
32 } | 32 } |
33 | 33 |
34 int BalloonCollectionImpl::Layout::VerticalEdgeMargin() const { | 34 int BalloonCollectionImpl::Layout::VerticalEdgeMargin() const { |
35 return 5; | 35 return 5; |
36 } | 36 } |
37 | 37 |
| 38 gfx::Point BalloonCollectionImpl::Layout::GetLayoutOrigin() const { |
| 39 int x = 0; |
| 40 int y = 0; |
| 41 switch (placement_) { |
| 42 case VERTICALLY_FROM_TOP_LEFT: |
| 43 x = work_area_.x() + HorizontalEdgeMargin(); |
| 44 y = work_area_.y() + VerticalEdgeMargin(); |
| 45 break; |
| 46 case VERTICALLY_FROM_TOP_RIGHT: |
| 47 x = work_area_.right() - HorizontalEdgeMargin(); |
| 48 y = work_area_.y() + VerticalEdgeMargin(); |
| 49 break; |
| 50 case VERTICALLY_FROM_BOTTOM_LEFT: |
| 51 x = work_area_.x() + HorizontalEdgeMargin(); |
| 52 // For this placement, balloon needs to stay on top of left-most panels |
| 53 // to avoid overlapping. |
| 54 y = work_area_.bottom() - VerticalEdgeMargin() - |
| 55 bottom_left_offset_to_move_above_panels_; |
| 56 break; |
| 57 case VERTICALLY_FROM_BOTTOM_RIGHT: |
| 58 x = work_area_.right() - HorizontalEdgeMargin(); |
| 59 // For this placement, balloon needs to stay on top of right-most panels |
| 60 // to avoid overlapping. |
| 61 y = work_area_.bottom() - VerticalEdgeMargin() - |
| 62 bottom_right_offset_to_move_above_panels_; |
| 63 break; |
| 64 default: |
| 65 NOTREACHED(); |
| 66 break; |
| 67 } |
| 68 return gfx::Point(x, y); |
| 69 } |
| 70 |
38 void BalloonCollectionImpl::PositionBalloons(bool reposition) { | 71 void BalloonCollectionImpl::PositionBalloons(bool reposition) { |
39 PositionBalloonsInternal(reposition); | 72 PositionBalloonsInternal(reposition); |
40 } | 73 } |
41 | 74 |
42 #if defined(TOUCH_UI) | 75 #if defined(TOUCH_UI) |
43 base::EventStatus BalloonCollectionImpl::WillProcessEvent( | 76 base::EventStatus BalloonCollectionImpl::WillProcessEvent( |
44 const base::NativeEvent& event) { | 77 const base::NativeEvent& event) { |
45 return base::EVENT_CONTINUE; | 78 return base::EVENT_CONTINUE; |
46 } | 79 } |
47 | 80 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 else | 125 else |
93 NOTREACHED(); | 126 NOTREACHED(); |
94 | 127 |
95 PositionBalloons(true); | 128 PositionBalloons(true); |
96 } | 129 } |
97 | 130 |
98 // static | 131 // static |
99 BalloonCollection* BalloonCollection::Create() { | 132 BalloonCollection* BalloonCollection::Create() { |
100 return new BalloonCollectionImpl(); | 133 return new BalloonCollectionImpl(); |
101 } | 134 } |
OLD | NEW |