diff options
author | dmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-19 19:33:03 +0000 |
---|---|---|
committer | dmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-19 19:33:03 +0000 |
commit | 5569de8f27a8e0f8aadba007c30e37d7e0737454 (patch) | |
tree | 1b8181286e0ab01e5efe54b9a7f08094c99d9875 /remoting/host | |
parent | 094e4c0743cf1bee8a0b35fd637ab8b75b4d10a6 (diff) | |
download | chromium_src-5569de8f27a8e0f8aadba007c30e37d7e0737454.zip chromium_src-5569de8f27a8e0f8aadba007c30e37d7e0737454.tar.gz chromium_src-5569de8f27a8e0f8aadba007c30e37d7e0737454.tar.bz2 |
New disconnect window (mac) for Chromoting.
Implements the new and improved disconnect window for Mac for Chromoting.
BUG=NONE
TEST=Show disconnect window on mac.
Review URL: http://codereview.chromium.org/8333003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106347 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host')
-rw-r--r-- | remoting/host/disconnect_window.xib | 74 | ||||
-rw-r--r-- | remoting/host/disconnect_window_mac.h | 13 | ||||
-rw-r--r-- | remoting/host/disconnect_window_mac.mm | 119 |
3 files changed, 169 insertions, 37 deletions
diff --git a/remoting/host/disconnect_window.xib b/remoting/host/disconnect_window.xib index 9b18f3c..5976eab 100644 --- a/remoting/host/disconnect_window.xib +++ b/remoting/host/disconnect_window.xib @@ -3,12 +3,12 @@ <data> <int key="IBDocument.SystemTarget">1050</int> <string key="IBDocument.SystemVersion">10K549</string> - <string key="IBDocument.InterfaceBuilderVersion">851</string> + <string key="IBDocument.InterfaceBuilderVersion">804</string> <string key="IBDocument.AppKitVersion">1038.36</string> <string key="IBDocument.HIToolboxVersion">461.00</string> <object class="NSMutableDictionary" key="IBDocument.PluginVersions"> <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string> - <string key="NS.object.0">851</string> + <string key="NS.object.0">804</string> </object> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -41,35 +41,35 @@ <object class="NSWindowTemplate" id="327397516"> <int key="NSWindowStyleMask">17</int> <int key="NSWindowBacking">2</int> - <string key="NSWindowRect">{{247, 442}, {279, 116}}</string> + <string key="NSWindowRect">{{247, 517}, {466, 41}}</string> <int key="NSWTFlags">611844096</int> <string key="NSWindowTitle">Remoting</string> - <string key="NSWindowClass">NSPanel</string> + <string key="NSWindowClass">DisconnectWindow</string> <nil key="NSViewClass"/> <string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string> <object class="NSView" key="NSWindowView" id="1718335"> <reference key="NSNextResponder"/> - <int key="NSvFlags">293</int> + <int key="NSvFlags">274</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSButton" id="456006926"> <reference key="NSNextResponder" ref="1718335"/> - <int key="NSvFlags">301</int> - <string key="NSFrame">{{31, 12}, {217, 32}}</string> + <int key="NSvFlags">300</int> + <string key="NSFrame">{{275, 10}, {182, 22}}</string> <reference key="NSSuperview" ref="1718335"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="837573888"> <int key="NSCellFlags">67239424</int> - <int key="NSCellFlags2">134217728</int> + <int key="NSCellFlags2">134348800</int> <string key="NSContents"><disconnect></string> - <object class="NSFont" key="NSSupport"> + <object class="NSFont" key="NSSupport" id="26"> <string key="NSName">LucidaGrande</string> - <double key="NSSize">13</double> - <int key="NSfFlags">1044</int> + <double key="NSSize">11</double> + <int key="NSfFlags">3100</int> </object> <reference key="NSControlView" ref="456006926"/> <int key="NSButtonFlags">-2038284033</int> - <int key="NSButtonFlags2">129</int> + <int key="NSButtonFlags2">134</int> <string key="NSAlternateContents"/> <string key="NSKeyEquivalent"/> <int key="NSPeriodicDelay">200</int> @@ -78,19 +78,15 @@ </object> <object class="NSTextField" id="165586339"> <reference key="NSNextResponder" ref="1718335"/> - <int key="NSvFlags">268</int> - <string key="NSFrame">{{17, 48}, {245, 55}}</string> + <int key="NSvFlags">300</int> + <string key="NSFrame">{{26, 14}, {244, 14}}</string> <reference key="NSSuperview" ref="1718335"/> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="752844448"> - <int key="NSCellFlags">67239424</int> - <int key="NSCellFlags2">272629760</int> + <int key="NSCellFlags">604110336</int> + <int key="NSCellFlags2">272761088</int> <string key="NSContents"><connected-to></string> - <object class="NSFont" key="NSSupport"> - <string key="NSName">LucidaGrande</string> - <double key="NSSize">13</double> - <int key="NSfFlags">16</int> - </object> + <reference key="NSSupport" ref="26"/> <reference key="NSControlView" ref="165586339"/> <object class="NSColor" key="NSBackgroundColor"> <int key="NSColorSpace">6</int> @@ -113,7 +109,7 @@ </object> </object> </object> - <string key="NSFrameSize">{279, 116}</string> + <string key="NSFrameSize">{466, 41}</string> <reference key="NSSuperview"/> <int key="NSViewLayerContentsRedrawPolicy">2</int> </object> @@ -257,6 +253,7 @@ <string>3.IBPluginDependency</string> <string>3.IBWindowTemplateEditedContentRect</string> <string>3.NSWindowTemplate.visibleAtLaunch</string> + <string>4.CustomClassName</string> <string>4.IBPluginDependency</string> </object> <object class="NSMutableArray" key="dict.values"> @@ -266,15 +263,16 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <object class="NSAffineTransform"> - <bytes key="NSTransformStruct">P4AAAL+AAABBqAAAwigAAA</bytes> + <bytes key="NSTransformStruct">P4AAAL+AAABDcAAAwfAAAA</bytes> </object> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{1363, 896}, {279, 116}}</string> + <string>{{679, 1013}, {466, 41}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{1363, 896}, {279, 116}}</string> + <string>{{679, 1013}, {466, 41}}</string> <boolean value="NO"/> + <string>DisconnectView</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> </object> </object> @@ -300,6 +298,19 @@ <object class="NSMutableArray" key="referencedPartialClassDescriptions"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="IBPartialClassDescription"> + <string key="className">DisconnectView</string> + <string key="superclassName">NSView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="516174697"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">host/disconnect_window_mac.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">DisconnectWindow</string> + <string key="superclassName">NSWindow</string> + <reference key="sourceIdentifier" ref="516174697"/> + </object> + <object class="IBPartialClassDescription"> <string key="className">DisconnectWindowController</string> <string key="superclassName">NSWindowController</string> <object class="NSMutableDictionary" key="actions"> @@ -345,10 +356,7 @@ </object> </object> </object> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBProjectSource</string> - <string key="minorKey">host/disconnect_window_mac.h</string> - </object> + <reference key="sourceIdentifier" ref="516174697"/> </object> <object class="IBPartialClassDescription"> <string key="className">NSObject</string> @@ -900,14 +908,6 @@ </object> </object> <object class="IBPartialClassDescription"> - <string key="className">NSPanel</string> - <string key="superclassName">NSWindow</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSPanel.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> <string key="className">NSResponder</string> <object class="IBClassDescriptionSource" key="sourceIdentifier"> <string key="majorKey">IBFrameworkSource</string> diff --git a/remoting/host/disconnect_window_mac.h b/remoting/host/disconnect_window_mac.h index 7e1593f..727574f 100644 --- a/remoting/host/disconnect_window_mac.h +++ b/remoting/host/disconnect_window_mac.h @@ -9,6 +9,8 @@ class ChromotingHost; class DisconnectWindowMac; } +// Controller for the disconnect window which allows the host user to +// quickly disconnect a session. @interface DisconnectWindowController : NSWindowController { @private remoting::ChromotingHost* host_; @@ -23,3 +25,14 @@ class DisconnectWindowMac; window:(remoting::DisconnectWindowMac*)window username:(NSString*)username; @end + +// A floating window with a custom border. The custom border and background +// content is defined by DisconnectView. Declared here so that it can be +// instantiated via a xib. +@interface DisconnectWindow : NSWindow +@end + +// The custom background/border for the DisconnectWindow. Declared here so that +// it can be instantiated via a xib. +@interface DisconnectView : NSView +@end diff --git a/remoting/host/disconnect_window_mac.mm b/remoting/host/disconnect_window_mac.mm index 0743c1b..0f177aa 100644 --- a/remoting/host/disconnect_window_mac.mm +++ b/remoting/host/disconnect_window_mac.mm @@ -13,6 +13,7 @@ #include "remoting/host/disconnect_window.h" namespace remoting { + class DisconnectWindowMac : public remoting::DisconnectWindow { public: DisconnectWindowMac(); @@ -57,6 +58,7 @@ void DisconnectWindowMac::Hide() { remoting::DisconnectWindow* remoting::DisconnectWindow::Create() { return new DisconnectWindowMac; } + } // namespace remoting @interface DisconnectWindowController() @@ -110,6 +112,27 @@ remoting::DisconnectWindow* remoting::DisconnectWindow::Create() { [disconnectButton_ setTitle:base::SysUTF16ToNSString( host_->ui_strings().disconnect_button_text_plus_shortcut)]; + + // Resize the window dynamically based on the content. + CGFloat oldConnectedWidth = NSWidth([connectedToField_ bounds]); + [connectedToField_ sizeToFit]; + CGFloat newConnectedWidth = NSWidth([connectedToField_ bounds]); + + CGFloat oldDisconnectWidth = NSWidth([disconnectButton_ bounds]); + [disconnectButton_ sizeToFit]; + NSRect disconnectBounds = [disconnectButton_ frame]; + CGFloat newDisconnectWidth = NSWidth(disconnectBounds); + + // Move the disconnect button appropriately. + disconnectBounds.origin.x += newConnectedWidth - oldConnectedWidth; + [disconnectButton_ setFrame:disconnectBounds]; + + // Then resize the window appropriately + NSWindow *window = [self window]; + NSRect windowFrame = [window frame]; + windowFrame.size.width += (newConnectedWidth - oldConnectedWidth + + newDisconnectWidth - oldDisconnectWidth); + [window setFrame:windowFrame display:NO]; } - (void)windowWillClose:(NSNotification*)notification { @@ -118,3 +141,99 @@ remoting::DisconnectWindow* remoting::DisconnectWindow::Create() { } @end + +@implementation DisconnectWindow + +- (id)initWithContentRect:(NSRect)contentRect + styleMask:(unsigned int)aStyle + backing:(NSBackingStoreType)bufferingType + defer:(BOOL)flag { + // Pass NSBorderlessWindowMask for the styleMask to remove the title bar. + self = [super initWithContentRect:contentRect + styleMask:NSBorderlessWindowMask + backing:bufferingType + defer:flag]; + + if (self) { + // Set window to be clear and non-opaque so we can see through it. + [self setBackgroundColor:[NSColor clearColor]]; + [self setOpaque:NO]; + [self setMovableByWindowBackground:YES]; + + // Pull the window up to Status Level so that it always displays. + [self setLevel:NSStatusWindowLevel]; + } + return self; +} + +@end + +@implementation DisconnectView + +- (void)drawRect:(NSRect)rect { + // All magic numbers taken from screen shots provided by UX. + NSRect bounds = NSInsetRect([self bounds], 1.5, 1.5); + + NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:bounds + xRadius:5 + yRadius:5]; + NSColor *gray = [NSColor colorWithCalibratedWhite:0.91 alpha:1.0]; + [gray setFill]; + [path fill]; + [path setLineWidth:3]; + NSColor *green = [NSColor colorWithCalibratedRed:0.13 + green:0.69 + blue:0.11 + alpha:1.0]; + [green setStroke]; + [path stroke]; + + // Draw drag handle on left hand side + const CGFloat height = 21.0; + const CGFloat inset = 12.0; + NSColor *dark = [NSColor colorWithCalibratedWhite:0.70 alpha:1.0]; + NSColor *light = [NSColor colorWithCalibratedWhite:0.97 alpha:1.0]; + + // Turn off aliasing so it's nice and crisp. + NSGraphicsContext *context = [NSGraphicsContext currentContext]; + BOOL alias = [context shouldAntialias]; + [context setShouldAntialias:NO]; + + NSPoint top = NSMakePoint(inset, NSMidY(bounds) - height / 2.0); + NSPoint bottom = NSMakePoint(inset, top.y + height); + + path = [NSBezierPath bezierPath]; + [path moveToPoint:top]; + [path lineToPoint:bottom]; + [dark setStroke]; + [path stroke]; + + top.x += 1; + bottom.x += 1; + path = [NSBezierPath bezierPath]; + [path moveToPoint:top]; + [path lineToPoint:bottom]; + [light setStroke]; + [path stroke]; + + top.x += 2; + bottom.x += 2; + path = [NSBezierPath bezierPath]; + [path moveToPoint:top]; + [path lineToPoint:bottom]; + [dark setStroke]; + [path stroke]; + + top.x += 1; + bottom.x += 1; + path = [NSBezierPath bezierPath]; + [path moveToPoint:top]; + [path lineToPoint:bottom]; + [light setStroke]; + [path stroke]; + + [context setShouldAntialias:alias]; +} + +@end + |