OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "chrome/browser/notifications/balloon.h" | 10 #include "chrome/browser/notifications/balloon.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 PositionBalloons(true); | 130 PositionBalloons(true); |
131 } | 131 } |
132 | 132 |
133 void BalloonCollectionImpl::OnBalloonClosed(Balloon* source) { | 133 void BalloonCollectionImpl::OnBalloonClosed(Balloon* source) { |
134 #if USE_OFFSETS | 134 #if USE_OFFSETS |
135 // We want to free the balloon when finished. | 135 // We want to free the balloon when finished. |
136 const Balloons& balloons = base_.balloons(); | 136 const Balloons& balloons = base_.balloons(); |
137 | 137 |
138 Balloons::const_iterator it = balloons.begin(); | 138 Balloons::const_iterator it = balloons.begin(); |
139 if (layout_.RequiresOffsets()) { | 139 if (layout_.RequiresOffsets()) { |
140 gfx::Point offset; | 140 gfx::Vector2d offset; |
141 bool apply_offset = false; | 141 bool apply_offset = false; |
142 while (it != balloons.end()) { | 142 while (it != balloons.end()) { |
143 if (*it == source) { | 143 if (*it == source) { |
144 ++it; | 144 ++it; |
145 if (it != balloons.end()) { | 145 if (it != balloons.end()) { |
146 apply_offset = true; | 146 apply_offset = true; |
147 offset.set_y((source)->offset().y() - (*it)->offset().y() + | 147 offset.set_y((source)->offset().y() - (*it)->offset().y() + |
148 (*it)->content_size().height() - source->content_size().height()); | 148 (*it)->content_size().height() - source->content_size().height()); |
149 } | 149 } |
150 } else { | 150 } else { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 void BalloonCollectionImpl::CancelOffsets() { | 242 void BalloonCollectionImpl::CancelOffsets() { |
243 reposition_factory_.InvalidateWeakPtrs(); | 243 reposition_factory_.InvalidateWeakPtrs(); |
244 | 244 |
245 // Unhook from listening to all UI events. | 245 // Unhook from listening to all UI events. |
246 RemoveMessageLoopObserver(); | 246 RemoveMessageLoopObserver(); |
247 | 247 |
248 const Balloons& balloons = base_.balloons(); | 248 const Balloons& balloons = base_.balloons(); |
249 for (Balloons::const_iterator it = balloons.begin(); | 249 for (Balloons::const_iterator it = balloons.begin(); |
250 it != balloons.end(); | 250 it != balloons.end(); |
251 ++it) | 251 ++it) |
252 (*it)->set_offset(gfx::Point(0, 0)); | 252 (*it)->set_offset(gfx::Vector2d()); |
253 | 253 |
254 PositionBalloons(true); | 254 PositionBalloons(true); |
255 } | 255 } |
256 | 256 |
257 void BalloonCollectionImpl::HandleMouseMoveEvent() { | 257 void BalloonCollectionImpl::HandleMouseMoveEvent() { |
258 if (!IsCursorInBalloonCollection()) { | 258 if (!IsCursorInBalloonCollection()) { |
259 // Mouse has left the region. Schedule a reposition after | 259 // Mouse has left the region. Schedule a reposition after |
260 // a short delay. | 260 // a short delay. |
261 if (!reposition_factory_.HasWeakPtrs()) { | 261 if (!reposition_factory_.HasWeakPtrs()) { |
262 MessageLoop::current()->PostDelayedTask( | 262 MessageLoop::current()->PostDelayedTask( |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area(); | 470 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area(); |
471 #endif | 471 #endif |
472 if (work_area_ != new_work_area) { | 472 if (work_area_ != new_work_area) { |
473 work_area_.SetRect(new_work_area.x(), new_work_area.y(), | 473 work_area_.SetRect(new_work_area.x(), new_work_area.y(), |
474 new_work_area.width(), new_work_area.height()); | 474 new_work_area.width(), new_work_area.height()); |
475 changed = true; | 475 changed = true; |
476 } | 476 } |
477 | 477 |
478 return changed; | 478 return changed; |
479 } | 479 } |
OLD | NEW |