summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjohnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-24 19:45:56 +0000
committerjohnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-24 19:45:56 +0000
commitc4043d950bf0316f5a7eacdc6fc51605442c8d97 (patch)
treea77a8b9714d64e0149fe0a36ab862416efb1d667
parent5826f3ea7caadda2945b5061b3d757fba9a9e359 (diff)
downloadchromium_src-c4043d950bf0316f5a7eacdc6fc51605442c8d97.zip
chromium_src-c4043d950bf0316f5a7eacdc6fc51605442c8d97.tar.gz
chromium_src-c4043d950bf0316f5a7eacdc6fc51605442c8d97.tar.bz2
Convert notification UI on Mac to a NIB rather than hand-coded. Also update the UI to reflect the latest mocks. Also improve the animation onto the screen.
BUG=34627 TEST=none Review URL: http://codereview.chromium.org/2822019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50757 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/nibs/Notification.xib537
-rw-r--r--chrome/browser/cocoa/notifications/balloon_controller.h20
-rw-r--r--chrome/browser/cocoa/notifications/balloon_controller.mm273
-rw-r--r--chrome/browser/cocoa/notifications/balloon_view.h13
-rw-r--r--chrome/browser/cocoa/notifications/balloon_view.mm74
-rw-r--r--chrome/browser/cocoa/notifications/balloon_view_bridge.mm1
-rw-r--r--chrome/browser/notifications/balloon_collection.cc65
-rw-r--r--chrome/browser/notifications/balloon_collection_impl.h7
-rw-r--r--chrome/chrome_dll.gypi1
9 files changed, 691 insertions, 300 deletions
diff --git a/chrome/app/nibs/Notification.xib b/chrome/app/nibs/Notification.xib
new file mode 100644
index 0000000..849ddbe7
--- /dev/null
+++ b/chrome/app/nibs/Notification.xib
@@ -0,0 +1,537 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03">
+ <data>
+ <int key="IBDocument.SystemTarget">1050</int>
+ <string key="IBDocument.SystemVersion">9L31a</string>
+ <string key="IBDocument.InterfaceBuilderVersion">677</string>
+ <string key="IBDocument.AppKitVersion">949.54</string>
+ <string key="IBDocument.HIToolboxVersion">353.00</string>
+ <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <integer value="54"/>
+ </object>
+ <object class="NSArray" key="IBDocument.PluginDependencies">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ </object>
+ <object class="NSMutableDictionary" key="IBDocument.Metadata">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ </object>
+ <object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSCustomObject" id="1001">
+ <string key="NSClassName">BalloonController</string>
+ </object>
+ <object class="NSCustomObject" id="1003">
+ <string key="NSClassName">FirstResponder</string>
+ </object>
+ <object class="NSCustomObject" id="1004">
+ <string key="NSClassName">NSApplication</string>
+ </object>
+ <object class="NSWindowTemplate" id="644637438">
+ <int key="NSWindowStyleMask">1</int>
+ <int key="NSWindowBacking">2</int>
+ <string key="NSWindowRect">{{1140, 794}, {300, 84}}</string>
+ <int key="NSWTFlags">603980800</int>
+ <string key="NSWindowTitle">Window</string>
+ <string key="NSWindowClass">BalloonWindow</string>
+ <nil key="NSViewClass"/>
+ <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string>
+ <string key="NSWindowContentMinSize">{300, 25}</string>
+ <object class="NSView" key="NSWindowView" id="433977361">
+ <reference key="NSNextResponder"/>
+ <int key="NSvFlags">256</int>
+ <object class="NSMutableArray" key="NSSubviews">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSCustomView" id="662796088">
+ <reference key="NSNextResponder" ref="433977361"/>
+ <int key="NSvFlags">4378</int>
+ <string key="NSFrameSize">{300, 60}</string>
+ <reference key="NSSuperview" ref="433977361"/>
+ <string key="NSClassName">BalloonContentViewCocoa</string>
+ </object>
+ <object class="NSCustomView" id="667965148">
+ <reference key="NSNextResponder" ref="433977361"/>
+ <int key="NSvFlags">266</int>
+ <object class="NSMutableArray" key="NSSubviews">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSTextField" id="293244832">
+ <reference key="NSNextResponder" ref="667965148"/>
+ <int key="NSvFlags">271</int>
+ <string key="NSFrame">{{24, 5}, {248, 14}}</string>
+ <reference key="NSSuperview" ref="667965148"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="963811960">
+ <int key="NSCellFlags">67239488</int>
+ <int key="NSCellFlags2">138414080</int>
+ <string key="NSContents">source origin</string>
+ <object class="NSFont" key="NSSupport">
+ <string key="NSName">LucidaGrande</string>
+ <double key="NSSize">1.100000e+01</double>
+ <int key="NSfFlags">16</int>
+ </object>
+ <reference key="NSControlView" ref="293244832"/>
+ <object class="NSColor" key="NSBackgroundColor">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">controlColor</string>
+ <object class="NSColor" key="NSColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MC42NjY2NjY2OQA</bytes>
+ </object>
+ </object>
+ <object class="NSColor" key="NSTextColor">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">controlTextColor</string>
+ <object class="NSColor" key="NSColor" id="56913">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MAA</bytes>
+ </object>
+ </object>
+ </object>
+ </object>
+ <object class="NSButton" id="690499602">
+ <reference key="NSNextResponder" ref="667965148"/>
+ <int key="NSvFlags">268</int>
+ <string key="NSFrame">{{4, 3}, {16, 16}}</string>
+ <reference key="NSSuperview" ref="667965148"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="485798191">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">134479872</int>
+ <string key="NSContents">Button</string>
+ <object class="NSFont" key="NSSupport">
+ <string key="NSName">LucidaGrande</string>
+ <double key="NSSize">9.000000e+00</double>
+ <int key="NSfFlags">3614</int>
+ </object>
+ <reference key="NSControlView" ref="690499602"/>
+ <int key="NSButtonFlags">-2038284033</int>
+ <int key="NSButtonFlags2">129</int>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSButton" id="439315238">
+ <reference key="NSNextResponder" ref="667965148"/>
+ <int key="NSvFlags">265</int>
+ <string key="NSFrame">{{279.5, 4}, {14, 14}}</string>
+ <reference key="NSSuperview" ref="667965148"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="34148179">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">134217728</int>
+ <string key="NSContents">Button</string>
+ <object class="NSFont" key="NSSupport">
+ <string key="NSName">LucidaGrande</string>
+ <double key="NSSize">1.300000e+01</double>
+ <int key="NSfFlags">1044</int>
+ </object>
+ <reference key="NSControlView" ref="439315238"/>
+ <int key="NSButtonFlags">-2042347265</int>
+ <int key="NSButtonFlags2">135</int>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ </object>
+ <string key="NSFrame">{{0, 59}, {300, 24}}</string>
+ <reference key="NSSuperview" ref="433977361"/>
+ <string key="NSClassName">BalloonShelfViewCocoa</string>
+ </object>
+ </object>
+ <string key="NSFrameSize">{300, 84}</string>
+ <reference key="NSSuperview"/>
+ </object>
+ <string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
+ <string key="NSMinSize">{300, 47}</string>
+ <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
+ </object>
+ </object>
+ <object class="IBObjectContainer" key="IBDocument.Objects">
+ <object class="NSMutableArray" key="connectionRecords">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">originLabel_</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="293244832"/>
+ </object>
+ <int key="connectionID">60</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">htmlContainer_</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="662796088"/>
+ </object>
+ <int key="connectionID">61</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">optionsButtonPressed:</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="439315238"/>
+ </object>
+ <int key="connectionID">66</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">optionsButton_</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="439315238"/>
+ </object>
+ <int key="connectionID">67</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">window</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="644637438"/>
+ </object>
+ <int key="connectionID">68</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">closeButton_</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="690499602"/>
+ </object>
+ <int key="connectionID">77</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">closeButtonPressed:</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="690499602"/>
+ </object>
+ <int key="connectionID">78</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">shelf_</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="667965148"/>
+ </object>
+ <int key="connectionID">86</int>
+ </object>
+ </object>
+ <object class="IBMutableOrderedSet" key="objectRecords">
+ <object class="NSArray" key="orderedObjects">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBObjectRecord">
+ <int key="objectID">0</int>
+ <object class="NSArray" key="object" id="930852779">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <reference key="children" ref="1000"/>
+ <nil key="parent"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-2</int>
+ <reference key="object" ref="1001"/>
+ <reference key="parent" ref="930852779"/>
+ <string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-1</int>
+ <reference key="object" ref="1003"/>
+ <reference key="parent" ref="930852779"/>
+ <string key="objectName">First Responder</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-3</int>
+ <reference key="object" ref="1004"/>
+ <reference key="parent" ref="930852779"/>
+ <string key="objectName">Application</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">54</int>
+ <reference key="object" ref="644637438"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="433977361"/>
+ </object>
+ <reference key="parent" ref="930852779"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">55</int>
+ <reference key="object" ref="433977361"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="662796088"/>
+ <reference ref="667965148"/>
+ </object>
+ <reference key="parent" ref="644637438"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">56</int>
+ <reference key="object" ref="662796088"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <reference key="parent" ref="433977361"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">85</int>
+ <reference key="object" ref="667965148"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="293244832"/>
+ <reference ref="690499602"/>
+ <reference ref="439315238"/>
+ </object>
+ <reference key="parent" ref="433977361"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">2</int>
+ <reference key="object" ref="293244832"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="963811960"/>
+ </object>
+ <reference key="parent" ref="667965148"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">3</int>
+ <reference key="object" ref="963811960"/>
+ <reference key="parent" ref="293244832"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">71</int>
+ <reference key="object" ref="690499602"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="485798191"/>
+ </object>
+ <reference key="parent" ref="667965148"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">72</int>
+ <reference key="object" ref="485798191"/>
+ <reference key="parent" ref="690499602"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">64</int>
+ <reference key="object" ref="439315238"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="34148179"/>
+ </object>
+ <reference key="parent" ref="667965148"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">65</int>
+ <reference key="object" ref="34148179"/>
+ <reference key="parent" ref="439315238"/>
+ </object>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="flattenedProperties">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSMutableArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>-1.IBPluginDependency</string>
+ <string>-2.IBPluginDependency</string>
+ <string>-3.IBPluginDependency</string>
+ <string>2.IBPluginDependency</string>
+ <string>3.IBPluginDependency</string>
+ <string>54.IBEditorWindowLastContentRect</string>
+ <string>54.IBPluginDependency</string>
+ <string>54.IBWindowTemplateEditedContentRect</string>
+ <string>54.NSWindowTemplate.visibleAtLaunch</string>
+ <string>54.windowTemplate.hasMinSize</string>
+ <string>54.windowTemplate.minSize</string>
+ <string>55.IBPluginDependency</string>
+ <string>56.IBPluginDependency</string>
+ <string>56.IBViewIntegration.shadowBlurRadius</string>
+ <string>56.IBViewIntegration.shadowColor</string>
+ <string>56.IBViewIntegration.shadowOffsetHeight</string>
+ <string>56.IBViewIntegration.shadowOffsetWidth</string>
+ <string>64.IBPluginDependency</string>
+ <string>65.IBPluginDependency</string>
+ <string>71.CustomClassName</string>
+ <string>71.IBPluginDependency</string>
+ <string>72.IBPluginDependency</string>
+ <string>85.IBPluginDependency</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>{{642, 507}, {300, 84}}</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>{{642, 507}, {300, 84}}</string>
+ <boolean value="NO"/>
+ <boolean value="YES"/>
+ <string>{300, 25}</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <real value="0.000000e+00"/>
+ <reference ref="56913"/>
+ <real value="0.000000e+00"/>
+ <real value="0.000000e+00"/>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>HoverCloseButton</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="unlocalizedProperties">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ </object>
+ <nil key="activeLocalization"/>
+ <object class="NSMutableDictionary" key="localizations">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ </object>
+ <nil key="sourceID"/>
+ <int key="maxID">86</int>
+ </object>
+ <object class="IBClassDescriber" key="IBDocument.Classes">
+ <object class="NSMutableArray" key="referencedPartialClassDescriptions">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBPartialClassDescription">
+ <string key="className">BalloonContentViewCocoa</string>
+ <string key="superclassName">NSView</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier" id="513011931">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">browser/cocoa/notifications/balloon_view.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">BalloonController</string>
+ <string key="superclassName">NSWindowController</string>
+ <object class="NSMutableDictionary" key="actions">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSMutableArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>closeButtonPressed:</string>
+ <string>optionsButtonPressed:</string>
+ <string>permissionRevoked:</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="outlets">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSMutableArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>closeButton_</string>
+ <string>htmlContainer_</string>
+ <string>optionsButton_</string>
+ <string>originLabel_</string>
+ <string>shelf_</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>HoverCloseButton</string>
+ <string>BalloonContentViewCocoa</string>
+ <string>NSButton</string>
+ <string>NSTextField</string>
+ <string>BalloonShelfViewCocoa</string>
+ </object>
+ </object>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">browser/cocoa/notifications/balloon_controller.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">BalloonShelfViewCocoa</string>
+ <string key="superclassName">NSView</string>
+ <reference key="sourceIdentifier" ref="513011931"/>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">BalloonWindow</string>
+ <string key="superclassName">NSWindow</string>
+ <reference key="sourceIdentifier" ref="513011931"/>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">HoverCloseButton</string>
+ <string key="superclassName">NSButton</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">browser/cocoa/hover_close_button.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">../third_party/GTM/Foundation/GTMNSObject+KeyValueObserving.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">browser/cocoa/objc_zombie.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">browser/cocoa/status_bubble_mac.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">browser/cocoa/tab_strip_model_observer_bridge.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSWindow</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">browser/cocoa/chrome_browser_window.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSWindow</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">browser/cocoa/themed_window.h</string>
+ </object>
+ </object>
+ </object>
+ </object>
+ <int key="IBDocument.localizationMode">0</int>
+ <string key="IBDocument.LastKnownRelativeProjectPath">../../chrome.xcodeproj</string>
+ <int key="IBDocument.defaultPropertyAccessControl">3</int>
+ </data>
+</archive>
diff --git a/chrome/browser/cocoa/notifications/balloon_controller.h b/chrome/browser/cocoa/notifications/balloon_controller.h
index 3cff471..bacf3af 100644
--- a/chrome/browser/cocoa/notifications/balloon_controller.h
+++ b/chrome/browser/cocoa/notifications/balloon_controller.h
@@ -9,6 +9,7 @@
#include "base/scoped_nsobject.h"
#include "base/cocoa_protocols_mac.h"
+#import "chrome/browser/cocoa/hover_close_button.h"
#import "chrome/browser/cocoa/notifications/balloon_view.h"
#import "chrome/browser/cocoa/notifications/balloon_view_host_mac.h"
#include "chrome/browser/notifications/balloon.h"
@@ -23,21 +24,22 @@
// owned by the browser's NotificationUIManager.
Balloon* balloon_;
- // The window that contains the frame of the notification.
- scoped_nsobject<NSWindow> frameContainer_;
-
// The view that contains the contents of the notification
- scoped_nsobject<NSView> htmlContainer_;
+ IBOutlet BalloonContentViewCocoa* htmlContainer_;
+
+ // The view that contains the controls of the notification
+ IBOutlet BalloonShelfViewCocoa* shelf_;
- // The view that contains the frame around the contents.
- scoped_nsobject<NSView> frameView_;
+ // The close button.
+ IBOutlet HoverCloseButton* closeButton_;
+
+ // The origin label.
+ IBOutlet NSTextField* originLabel_;
// The options menu that appears when "options" is pressed.
+ IBOutlet NSButton* optionsButton_;
scoped_nsobject<NSMenu> optionsMenu_;
- // An animation for moving the balloon smoothly.
- scoped_nsobject<NSViewAnimation> animation_;
-
// The host for the renderer of the HTML contents.
scoped_ptr<BalloonViewHost> htmlContents_;
}
diff --git a/chrome/browser/cocoa/notifications/balloon_controller.mm b/chrome/browser/cocoa/notifications/balloon_controller.mm
index d8a42ca..01a753c 100644
--- a/chrome/browser/cocoa/notifications/balloon_controller.mm
+++ b/chrome/browser/cocoa/notifications/balloon_controller.mm
@@ -5,181 +5,71 @@
#include "chrome/browser/cocoa/notifications/balloon_controller.h"
#include "app/l10n_util.h"
+#include "app/resource_bundle.h"
#import "base/cocoa_protocols_mac.h"
#import "base/scoped_nsobject.h"
-#include "base/string_util.h"
-#include "chrome/browser/browser_list.h"
-#include "chrome/browser/browser_window.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/cocoa/notifications/balloon_view_host_mac.h"
#include "chrome/browser/notifications/balloon.h"
#include "chrome/browser/notifications/desktop_notification_service.h"
#include "chrome/browser/profile.h"
#include "grit/generated_resources.h"
+#include "grit/theme_resources.h"
namespace {
// Margin, in pixels, between the notification frame and the contents
// of the notification.
-const int kTopMargin = 2;
-const int kBottomMargin = 2;
-const int kLeftMargin = 2;
-const int kRightMargin = 2;
-
-// How many pixels of overlap there is between the shelf top and the
-// balloon bottom.
-const int kShelfBorderTopOverlap = 6;
-
-// Properties of the dismiss button.
-const int kDismissButtonWidth = 52;
-const int kDismissButtonHeight = 18;
-
-// Properties of the options menu.
-const int kOptionsMenuWidth = 52;
-const int kOptionsMenuHeight = 18;
-
-// Properties of the origin label.
-const int kLeftLabelMargin = 4;
-const int kLabelHeight = 16;
-
-// TODO(johnnyg): http://crbug.com/34826 Add a shadow for the frame.
-const int kLeftShadowWidth = 0;
-const int kRightShadowWidth = 0;
-const int kTopShadowWidth = 0;
-const int kBottomShadowWidth = 0;
-
-// The shelf height for the system default font size. It is scaled
-// with changes in the default font size.
-const int kDefaultShelfHeight = 22;
+const int kTopMargin = 1;
+const int kBottomMargin = 1;
+const int kLeftMargin = 1;
+const int kRightMargin = 1;
} // namespace
-@interface BalloonController (InternalLayout)
-// The following are all internal methods to calculate the dimensions of
-// subviews.
-- (NSPoint)contentsOffset;
-- (int)shelfHeight;
-- (int)balloonFrameHeight;
-- (NSRect)contentsRectangle;
-- (NSRect)closeButtonBounds;
-- (NSRect)optionsMenuBounds;
-- (NSRect)labelBounds;
-@end
-
@implementation BalloonController
- (id)initWithBalloon:(Balloon*)balloon {
- NSString* sourceLabelText = l10n_util::GetNSStringF(
- IDS_NOTIFICATION_BALLOON_SOURCE_LABEL,
- WideToUTF16(balloon->notification().display_source()));
- NSString* optionsText =
- l10n_util::GetNSString(IDS_NOTIFICATION_OPTIONS_MENU_LABEL);
- NSString* dismissText =
- l10n_util::GetNSString(IDS_NOTIFICATION_BALLOON_DISMISS_LABEL);
- NSString* revokeText =
- l10n_util::GetNSStringF(IDS_NOTIFICATION_BALLOON_REVOKE_MESSAGE,
- WideToUTF16(balloon->notification().display_source()));
-
- balloon_ = balloon;
-
- frameContainer_.reset([[NSWindow alloc]
- initWithContentRect:NSZeroRect
- styleMask:NSBorderlessWindowMask
- backing:NSBackingStoreBuffered
- defer:YES]);
- [frameContainer_ setAlphaValue:1.0];
- [frameContainer_ setOpaque:NO];
- [frameContainer_ setLevel:NSFloatingWindowLevel];
-
- if ((self = [self initWithWindow:frameContainer_.get()])) {
- // Position of the balloon.
- int x = balloon_->position().x();
- int y = balloon_->position().y();
- int w = [self desiredTotalWidth];
- int h = [self desiredTotalHeight];
-
- NSView* contentView = [frameContainer_ contentView];
-
- frameView_.reset([[BalloonViewCocoa alloc]
- initWithFrame:NSMakeRect(0,
- [self shelfHeight],
- w,
- [self balloonFrameHeight])]);
- [contentView addSubview:frameView_.get()];
-
- htmlContainer_.reset(
- [[NSView alloc] initWithFrame:[self contentsRectangle]]);
- [htmlContainer_ setNeedsDisplay:YES];
- [htmlContainer_ setFrame:[self contentsRectangle]];
- [frameView_ addSubview:htmlContainer_.get()];
-
- htmlContents_.reset(new BalloonViewHost(balloon));
+ if ((self = [super initWithWindowNibName:@"Notification"])) {
+ balloon_ = balloon;
[self initializeHost];
+ }
+ return self;
+}
- scoped_nsobject<NSView> shelfView([[BalloonShelfViewCocoa alloc]
- initWithFrame:NSMakeRect(0,
- 0,
- w,
- [self shelfHeight]+kShelfBorderTopOverlap)]);
- [contentView addSubview:shelfView.get()
- positioned:NSWindowBelow
- relativeTo:htmlContainer_.get()];
-
- optionsMenu_.reset([[NSMenu alloc] init]);
- [optionsMenu_ addItemWithTitle:revokeText
- action:@selector(permissionRevoked:)
- keyEquivalent:@""];
-
-
- // Creating UI elements by hand for easier parity with other platforms.
- // TODO(johnnyg): http://crbug.com/34627
- // Investigate converting this to a nib.
- scoped_nsobject<BalloonButtonCell> closeButtonCell(
- [[BalloonButtonCell alloc] initTextCell:dismissText]);
- scoped_nsobject<NSButton> closeButton(
- [[NSButton alloc] initWithFrame:[self closeButtonBounds]]);
- [shelfView addSubview:closeButton.get()];
- [closeButton setCell:closeButtonCell.get()];
- [closeButton setTarget:self];
- [closeButton setAction:@selector(closeButtonPressed:)];
- [closeButtonCell setTextColor:[NSColor whiteColor]];
+- (void)awakeFromNib {
+ DCHECK([self window]);
+ DCHECK_EQ(self, [[self window] delegate]);
- scoped_nsobject<BalloonButtonCell> optionsButtonCell(
- [[BalloonButtonCell alloc] initTextCell:optionsText]);
- scoped_nsobject<NSButton> optionsButton(
- [[NSButton alloc] initWithFrame:[self optionsMenuBounds]]);
- [shelfView addSubview:optionsButton.get()];
- [optionsButton setCell:optionsButtonCell.get()];
- [optionsButton setTarget:self];
- [optionsButton setAction:@selector(optionsButtonPressed:)];
- [optionsButtonCell setTextColor:[NSColor whiteColor]];
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ NSImage* image = rb.GetNSImageNamed(IDR_BALLOON_WRENCH);
+ DCHECK(image);
+ [optionsButton_ setImage:image];
- scoped_nsobject<NSTextField> originLabel([[NSTextField alloc] init]);
- [shelfView addSubview:originLabel.get()];
- [originLabel setEditable:NO];
- [originLabel setBezeled:NO];
- [originLabel setSelectable:NO];
- [originLabel setDrawsBackground:NO];
- [[originLabel cell] setLineBreakMode:NSLineBreakByTruncatingTail];
- [[originLabel cell] setTextColor:[NSColor whiteColor]];
- [originLabel setStringValue:sourceLabelText];
- [originLabel setFrame:[self labelBounds]];
- [originLabel setFont:
- [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
+ optionsMenu_.reset([[NSMenu alloc] init]);
+ NSString* revokeText = l10n_util::GetNSStringF(
+ IDS_NOTIFICATION_BALLOON_REVOKE_MESSAGE,
+ WideToUTF16(balloon_->notification().display_source()));
+ [optionsMenu_ addItemWithTitle:revokeText
+ action:@selector(permissionRevoked:)
+ keyEquivalent:@""];
- [frameContainer_ setFrame:NSMakeRect(x, y, w, h) display:YES];
- [frameContainer_ setDelegate:self];
- }
- return self;
-}
+ NSString* sourceLabelText = l10n_util::GetNSStringF(
+ IDS_NOTIFICATION_BALLOON_SOURCE_LABEL,
+ WideToUTF16(balloon_->notification().display_source()));
+ [originLabel_ setStringValue:sourceLabelText];
-- (IBAction)closeButtonPressed:(id)sender {
- [self closeBalloon:YES];
+ gfx::NativeView contents = htmlContents_->native_view();
+ [contents setFrame:NSMakeRect(kLeftMargin, kTopMargin, 0, 0)];
+ [[htmlContainer_ superview] addSubview:contents
+ positioned:NSWindowBelow
+ relativeTo:nil];
}
- (IBAction)optionsButtonPressed:(id)sender {
[NSMenu popUpContextMenu:optionsMenu_
withEvent:[NSApp currentEvent]
- forView:frameView_];
+ forView:optionsButton_];
}
- (IBAction)permissionRevoked:(id)sender {
@@ -188,10 +78,16 @@ const int kDefaultShelfHeight = 22;
service->DenyPermission(balloon_->notification().origin_url());
}
+- (IBAction)closeButtonPressed:(id)sender {
+ [self closeBalloon:YES];
+ [self close];
+}
+
- (void)closeBalloon:(bool)byUser {
DCHECK(balloon_);
[self close];
- htmlContents_->Shutdown();
+ if (htmlContents_.get())
+ htmlContents_->Shutdown();
balloon_->OnClose(byUser);
balloon_ = NULL;
}
@@ -203,38 +99,22 @@ const int kDefaultShelfHeight = 22;
int w = [self desiredTotalWidth];
int h = [self desiredTotalHeight];
- NSRect frame = NSMakeRect(x, y, w, h);
-
htmlContents_->UpdateActualSize(balloon_->content_size());
- [htmlContainer_ setFrame:[self contentsRectangle]];
- [frameView_ setFrame:NSMakeRect(0,
- [self shelfHeight],
- w,
- [self balloonFrameHeight])];
-
- [animation_ stopAnimation];
-
- NSDictionary* dict =
- [NSDictionary dictionaryWithObjectsAndKeys:
- frameContainer_.get(), NSViewAnimationTargetKey,
- [NSValue valueWithRect:frame], NSViewAnimationEndFrameKey, nil];
-
- animation_.reset([[NSViewAnimation alloc]
- initWithViewAnimations:[NSArray arrayWithObjects:dict, nil]]);
- [animation_ startAnimation];
+ [[self window] setFrame:NSMakeRect(x, y, w, h)
+ display:YES
+ animate:YES];
}
// Returns the total width the view should be to accommodate the balloon.
- (int)desiredTotalWidth {
return (balloon_ ? balloon_->content_size().width() : 0) +
- kLeftMargin + kRightMargin + kLeftShadowWidth + kRightShadowWidth;
+ kLeftMargin + kRightMargin;
}
// Returns the total height the view should be to accommodate the balloon.
- (int)desiredTotalHeight {
return (balloon_ ? balloon_->content_size().height() : 0) +
- kTopMargin + kBottomMargin + kTopShadowWidth + kBottomShadowWidth +
- [self shelfHeight];
+ kTopMargin + kBottomMargin + [shelf_ frame].size.height;
}
// Returns the BalloonHost {
@@ -242,65 +122,10 @@ const int kDefaultShelfHeight = 22;
return htmlContents_.get();
}
-// Relative to the lower left of the frame, above the shelf.
-- (NSPoint)contentsOffset {
- return NSMakePoint(kLeftShadowWidth + kLeftMargin,
- kBottomShadowWidth + kBottomMargin);
-}
-
-// Returns the height of the shelf in pixels.
-- (int)shelfHeight {
- // TODO(johnnyg): add scaling here.
- return kDefaultShelfHeight;
-}
-
-// Returns the height of the balloon contents frame in pixels.
-- (int)balloonFrameHeight {
- return [self desiredTotalHeight] - [self shelfHeight];
-}
-
-// Relative to the lower-left of the frame.
-- (NSRect)contentsRectangle {
- gfx::Size contentSize = balloon_->content_size();
- NSPoint offset = [self contentsOffset];
- return NSMakeRect(offset.x, offset.y,
- contentSize.width(), contentSize.height());
-}
-
-// Returns the bounds of the close button.
-- (NSRect)closeButtonBounds {
- return NSMakeRect(
- [self desiredTotalWidth] - kDismissButtonWidth - kRightMargin,
- kBottomMargin,
- kDismissButtonWidth,
- kDismissButtonHeight);
-}
-
-// Returns the bounds of the button which opens the options menu.
-- (NSRect)optionsMenuBounds {
- return NSMakeRect(
- [self desiredTotalWidth] -
- kDismissButtonWidth - kOptionsMenuWidth - kRightMargin,
- kBottomMargin,
- kOptionsMenuWidth,
- kOptionsMenuHeight);
-}
-
-// Returns the bounds of the label showing the origin of the notification.
-- (NSRect)labelBounds {
- return NSMakeRect(
- kLeftLabelMargin,
- kBottomMargin,
- [self desiredTotalWidth] -
- kDismissButtonWidth - kOptionsMenuWidth - kRightMargin,
- kLabelHeight);
-}
-
// Initializes the renderer host showing the HTML contents.
- (void)initializeHost {
+ htmlContents_.reset(new BalloonViewHost(balloon_));
htmlContents_->Init();
- gfx::NativeView contents = htmlContents_->native_view();
- [htmlContainer_ addSubview:contents];
}
// NSWindowDelegate notification.
diff --git a/chrome/browser/cocoa/notifications/balloon_view.h b/chrome/browser/cocoa/notifications/balloon_view.h
index 8720d94..95d3e69 100644
--- a/chrome/browser/cocoa/notifications/balloon_view.h
+++ b/chrome/browser/cocoa/notifications/balloon_view.h
@@ -7,9 +7,15 @@
#import <Cocoa/Cocoa.h>
+#include "base/scoped_nsobject.h"
+
+@interface BalloonWindow : NSWindow {
+}
+@end
+
// This view class draws a frame around the HTML contents of a
// notification balloon.
-@interface BalloonViewCocoa : NSView {
+@interface BalloonContentViewCocoa : NSView {
}
@end
@@ -19,10 +25,5 @@
}
@end
-// This view draws a button with the shelf of the balloon.
-@interface BalloonButtonCell : NSButtonCell {
-}
-- (void)setTextColor:(NSColor*)color;
-@end
#endif // CHROME_BROWSER_COCOA_NOTIFICATIONS_BALLOON_VIEW_H_
diff --git a/chrome/browser/cocoa/notifications/balloon_view.mm b/chrome/browser/cocoa/notifications/balloon_view.mm
index 1186975e..3797f9c 100644
--- a/chrome/browser/cocoa/notifications/balloon_view.mm
+++ b/chrome/browser/cocoa/notifications/balloon_view.mm
@@ -8,65 +8,57 @@
#include "base/logging.h"
#include "base/scoped_nsobject.h"
+#import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h"
namespace {
-const int kRoundedCornerSize = 4;
+const int kRoundedCornerSize = 6.5;
} // namespace
+@implementation BalloonWindow
+- (id)initWithContentRect:(NSRect)contentRect
+ styleMask:(unsigned int)aStyle
+ backing:(NSBackingStoreType)bufferingType
+ defer:(BOOL)flag {
+ self = [super initWithContentRect:contentRect
+ styleMask:NSBorderlessWindowMask
+ backing:NSBackingStoreBuffered
+ defer:NO];
+ if (self) {
+ [self setLevel:NSStatusWindowLevel];
+ [self setOpaque:NO];
+ [self setBackgroundColor:[NSColor clearColor]];
+ }
+ return self;
+}
+@end
-@implementation BalloonViewCocoa
+@implementation BalloonShelfViewCocoa
- (void)drawRect:(NSRect)rect {
- NSRect bounds = [self bounds];
NSBezierPath* path =
- [NSBezierPath bezierPathWithRoundedRect:bounds
- xRadius:kRoundedCornerSize
- yRadius:kRoundedCornerSize];
- [[NSColor lightGrayColor] set];
+ [NSBezierPath gtm_bezierPathWithRoundRect:[self bounds]
+ topLeftCornerRadius:kRoundedCornerSize
+ topRightCornerRadius:kRoundedCornerSize
+ bottomLeftCornerRadius:0.0
+ bottomRightCornerRadius:0.0];
+
+ [[NSColor colorWithCalibratedWhite:0.957 alpha:1.0] set];
[path fill];
[[NSColor blackColor] set];
[path stroke];
}
@end
-@implementation BalloonShelfViewCocoa
+@implementation BalloonContentViewCocoa
- (void)drawRect:(NSRect)rect {
- NSRect bounds = [self bounds];
NSBezierPath* path =
- [NSBezierPath bezierPathWithRoundedRect:bounds
- xRadius:kRoundedCornerSize
- yRadius:kRoundedCornerSize];
- [[NSColor colorWithCalibratedRed:0.304 green:0.549 blue:0.85 alpha:1.0] set];
- [path fill];
+ [NSBezierPath gtm_bezierPathWithRoundRect:[self bounds]
+ topLeftCornerRadius:0.0
+ topRightCornerRadius:0.0
+ bottomLeftCornerRadius:kRoundedCornerSize
+ bottomRightCornerRadius:kRoundedCornerSize];
[[NSColor blackColor] set];
[path stroke];
}
@end
-
-@implementation BalloonButtonCell
-
-- (id)initTextCell:(NSString*)string {
- if ((self = [super initTextCell:string])) {
- [self setButtonType:NSMomentaryPushInButton];
- [self setShowsBorderOnlyWhileMouseInside:YES];
- [self setBezelStyle:NSShadowlessSquareBezelStyle];
- [self setControlSize:NSSmallControlSize];
- [self setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
- }
-
- return self;
-}
-
-- (void)setTextColor:(NSColor*)color {
- NSDictionary* dict = [NSDictionary dictionaryWithObjectsAndKeys:
- color, NSForegroundColorAttributeName,
- [self font], NSFontAttributeName, nil];
- scoped_nsobject<NSAttributedString> title(
- [[NSAttributedString alloc] initWithString:[self title] attributes:dict]);
-
- NSButton* button = static_cast<NSButton*>([self controlView]);
- DCHECK([button isKindOfClass:[NSButton class]]);
- [button setAttributedTitle:title.get()];
-}
-@end
diff --git a/chrome/browser/cocoa/notifications/balloon_view_bridge.mm b/chrome/browser/cocoa/notifications/balloon_view_bridge.mm
index 9edf952..121846e 100644
--- a/chrome/browser/cocoa/notifications/balloon_view_bridge.mm
+++ b/chrome/browser/cocoa/notifications/balloon_view_bridge.mm
@@ -31,6 +31,7 @@ void BalloonViewBridge::RepositionToBalloon() {
void BalloonViewBridge::Show(Balloon* balloon) {
controller_ = [[BalloonController alloc] initWithBalloon:balloon];
+ [controller_ repositionToBalloon];
[controller_ showWindow:nil];
}
diff --git a/chrome/browser/notifications/balloon_collection.cc b/chrome/browser/notifications/balloon_collection.cc
index 52b25fc..d5b92be 100644
--- a/chrome/browser/notifications/balloon_collection.cc
+++ b/chrome/browser/notifications/balloon_collection.cc
@@ -41,9 +41,11 @@ BalloonCollectionImpl::~BalloonCollectionImpl() {
void BalloonCollectionImpl::Add(const Notification& notification,
Profile* profile) {
Balloon* new_balloon = MakeBalloon(notification, profile);
+
+ new_balloon->SetPosition(layout_.OffScreenLocation(), true);
+ new_balloon->Show();
balloons_.push_back(new_balloon);
PositionBalloons(false);
- new_balloon->Show();
// There may be no listener in a unit test.
if (space_change_listener_)
@@ -79,24 +81,8 @@ bool BalloonCollectionImpl::HasSpace() const {
void BalloonCollectionImpl::ResizeBalloon(Balloon* balloon,
const gfx::Size& size) {
- // restrict to the min & max sizes
- gfx::Size real_size(
- std::max(Layout::min_balloon_width(),
- std::min(Layout::max_balloon_width(), size.width())),
- std::max(Layout::min_balloon_height(),
- std::min(Layout::max_balloon_height(), size.height())));
-
- // Don't allow balloons to shrink. This avoids flickering
- // on Mac OS which sometimes rapidly reports alternating sizes. Special
- // case for setting the minimum value.
- gfx::Size old_size = balloon->content_size();
- if (real_size.width() > old_size.width() ||
- real_size.height() > old_size.height() ||
- real_size == gfx::Size(Layout::min_balloon_width(),
- Layout::min_balloon_height())) {
- balloon->set_content_size(real_size);
- PositionBalloons(true);
- }
+ balloon->set_content_size(Layout::ConstrainToSizeLimits(size));
+ PositionBalloons(true);
}
void BalloonCollectionImpl::DisplayChanged() {
@@ -123,7 +109,8 @@ void BalloonCollectionImpl::OnBalloonClosed(Balloon* source) {
void BalloonCollectionImpl::PositionBalloons(bool reposition) {
gfx::Point origin = layout_.GetLayoutOrigin();
for (Balloons::iterator it = balloons_.begin(); it != balloons_.end(); ++it) {
- gfx::Point upper_left = layout_.NextPosition((*it)->GetViewSize(), &origin);
+ gfx::Point upper_left = layout_.NextPosition(
+ Layout::ConstrainToSizeLimits((*it)->GetViewSize()), &origin);
(*it)->SetPosition(upper_left, reposition);
}
}
@@ -219,6 +206,44 @@ gfx::Point BalloonCollectionImpl::Layout::NextPosition(
return gfx::Point(x, y);
}
+gfx::Point BalloonCollectionImpl::Layout::OffScreenLocation() const {
+ int x = 0;
+ int y = 0;
+ switch (placement_) {
+ case HORIZONTALLY_FROM_BOTTOM_LEFT:
+ x = work_area_.x() - kBalloonMaxWidth - HorizontalEdgeMargin();
+ y = work_area_.bottom() - kBalloonMaxHeight - VerticalEdgeMargin();
+ break;
+ case HORIZONTALLY_FROM_BOTTOM_RIGHT:
+ x = work_area_.right() + HorizontalEdgeMargin();
+ y = work_area_.bottom() - kBalloonMaxHeight - VerticalEdgeMargin();
+ break;
+ case VERTICALLY_FROM_TOP_RIGHT:
+ x = work_area_.right() - kBalloonMaxWidth - HorizontalEdgeMargin();
+ y = work_area_.y() + kBalloonMaxHeight + VerticalEdgeMargin();
+ break;
+ case VERTICALLY_FROM_BOTTOM_RIGHT:
+ x = work_area_.right() - kBalloonMaxWidth - HorizontalEdgeMargin();
+ y = work_area_.bottom() + kBalloonMaxHeight + VerticalEdgeMargin();
+ break;
+ default:
+ NOTREACHED();
+ break;
+ }
+ return gfx::Point(x, y);
+}
+
+// static
+gfx::Size BalloonCollectionImpl::Layout::ConstrainToSizeLimits(
+ const gfx::Size& size) {
+ // restrict to the min & max sizes
+ return gfx::Size(
+ std::max(min_balloon_width(),
+ std::min(max_balloon_width(), size.width())),
+ std::max(min_balloon_height(),
+ std::min(max_balloon_height(), size.height())));
+}
+
bool BalloonCollectionImpl::Layout::RefreshSystemMetrics() {
bool changed = false;
diff --git a/chrome/browser/notifications/balloon_collection_impl.h b/chrome/browser/notifications/balloon_collection_impl.h
index 1f3403a..262df06 100644
--- a/chrome/browser/notifications/balloon_collection_impl.h
+++ b/chrome/browser/notifications/balloon_collection_impl.h
@@ -51,6 +51,9 @@ class BalloonCollectionImpl : public BalloonCollection {
static int min_balloon_height() { return kBalloonMinHeight; }
static int max_balloon_height() { return kBalloonMaxHeight; }
+ // Utility function constrains the input rectangle to the min and max sizes.
+ static gfx::Size ConstrainToSizeLimits(const gfx::Size& rect);
+
// Returns both the total space available and the maximum
// allowed per balloon.
//
@@ -75,6 +78,10 @@ class BalloonCollectionImpl : public BalloonCollection {
gfx::Point NextPosition(const gfx::Size& balloon_size,
gfx::Point* position_iterator) const;
+ // Return a offscreen location which is offscreen for this layout,
+ // to be used as the initial position for an animation into view.
+ gfx::Point OffScreenLocation() const;
+
private:
enum Placement {
HORIZONTALLY_FROM_BOTTOM_LEFT,
diff --git a/chrome/chrome_dll.gypi b/chrome/chrome_dll.gypi
index 96ba2fa..622971c0 100644
--- a/chrome/chrome_dll.gypi
+++ b/chrome/chrome_dll.gypi
@@ -233,6 +233,7 @@
'app/nibs/ImportProgressDialog.xib',
'app/nibs/KeywordEditor.xib',
'app/nibs/MainMenu.xib',
+ 'app/nibs/Notification.xib',
'app/nibs/Preferences.xib',
'app/nibs/ReportBug.xib',
'app/nibs/SaveAccessoryView.xib',