Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(625)

Side by Side Diff: chrome/browser/ui/cocoa/notifications/balloon_collection_cocoa.mm

Issue 23361031: [Mac] Delete old balloon and Notification Center notification implementations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix DCHECK Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/notifications/balloon_collection_impl.h"
6
7 #import <Cocoa/Cocoa.h>
8
9 #include "chrome/browser/ui/cocoa/notifications/balloon_view_bridge.h"
10
11 Balloon* BalloonCollectionImpl::MakeBalloon(const Notification& notification,
12 Profile* profile) {
13 Balloon* balloon = new Balloon(notification, profile, this);
14 balloon->set_view(new BalloonViewBridge());
15 gfx::Size size(layout_.min_balloon_width(), layout_.min_balloon_height());
16 balloon->set_content_size(size);
17 return balloon;
18 }
19
20 // static
21 gfx::Rect BalloonCollectionImpl::GetMacWorkArea() {
22 NSScreen* primary = [[NSScreen screens] objectAtIndex:0];
23 return gfx::Rect(NSRectToCGRect([primary visibleFrame]));
24 }
25
26 int BalloonCollectionImpl::Layout::InterBalloonMargin() const {
27 return 5;
28 }
29
30 int BalloonCollectionImpl::Layout::HorizontalEdgeMargin() const {
31 return 5;
32 }
33
34 int BalloonCollectionImpl::Layout::VerticalEdgeMargin() const {
35 return 0;
36 }
37
38 bool BalloonCollectionImpl::Layout::NeedToMoveAboveLeftSidePanels() const {
39 return placement_ == VERTICALLY_FROM_TOP_LEFT;
40 }
41
42 bool BalloonCollectionImpl::Layout::NeedToMoveAboveRightSidePanels() const {
43 return placement_ == VERTICALLY_FROM_TOP_RIGHT;
44 }
45
46 void BalloonCollectionImpl::PositionBalloons(bool reposition) {
47 // Use an animation context so that all the balloons animate together.
48 [NSAnimationContext beginGrouping];
49 [[NSAnimationContext currentContext] setDuration:0.1f];
50 PositionBalloonsInternal(reposition);
51 [NSAnimationContext endGrouping];
52 }
53
54 void BalloonCollectionImpl::SetPositionPreference(
55 PositionPreference position) {
56 if (position == DEFAULT_POSITION)
57 position = UPPER_RIGHT;
58
59 // All positioning schemes are vertical, but mac
60 // uses a vertically reversed screen orientation.
61 if (position == UPPER_RIGHT)
62 layout_.set_placement(Layout::VERTICALLY_FROM_BOTTOM_RIGHT);
63 else if (position == UPPER_LEFT)
64 layout_.set_placement(Layout::VERTICALLY_FROM_BOTTOM_LEFT);
65 else if (position == LOWER_LEFT)
66 layout_.set_placement(Layout::VERTICALLY_FROM_TOP_LEFT);
67 else if (position == LOWER_RIGHT)
68 layout_.set_placement(Layout::VERTICALLY_FROM_TOP_RIGHT);
69 else
70 NOTREACHED();
71
72 layout_.ComputeOffsetToMoveAbovePanels();
73 PositionBalloons(true);
74 }
75
76 // static
77 BalloonCollection* BalloonCollection::Create() {
78 return new BalloonCollectionImpl();
79 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698