summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authordmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-02 23:49:28 +0000
committerdmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-02 23:49:28 +0000
commit1d9b0c033ee6b04ac59a6caf96f34424cdf15cd8 (patch)
treea6b49dd7153d75069531ca7d588f4b1ac4f48d3e /remoting
parented800c4f0b3874b219e8901bd954e64b08163c2c (diff)
downloadchromium_src-1d9b0c033ee6b04ac59a6caf96f34424cdf15cd8.zip
chromium_src-1d9b0c033ee6b04ac59a6caf96f34424cdf15cd8.tar.gz
chromium_src-1d9b0c033ee6b04ac59a6caf96f34424cdf15cd8.tar.bz2
Make Mac Chromoting Disconnect Window look good for R2L systems.
BUG=NONE TEST=Try chromoting in arabic. Review URL: http://codereview.chromium.org/8364025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108360 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/host/disconnect_window.h5
-rw-r--r--remoting/host/disconnect_window.xib62
-rw-r--r--remoting/host/disconnect_window_mac.h4
-rw-r--r--remoting/host/disconnect_window_mac.mm96
4 files changed, 132 insertions, 35 deletions
diff --git a/remoting/host/disconnect_window.h b/remoting/host/disconnect_window.h
index 434051f..d7e6aee 100644
--- a/remoting/host/disconnect_window.h
+++ b/remoting/host/disconnect_window.h
@@ -13,6 +13,11 @@ class ChromotingHost;
class DisconnectWindow {
public:
+
+ enum {
+ kMaximumConnectedNameWidthInPixels = 400
+ };
+
virtual ~DisconnectWindow() {}
// Show the disconnect window allowing the user to shut down |host|.
diff --git a/remoting/host/disconnect_window.xib b/remoting/host/disconnect_window.xib
index 5976eab..809ce9c 100644
--- a/remoting/host/disconnect_window.xib
+++ b/remoting/host/disconnect_window.xib
@@ -41,7 +41,7 @@
<object class="NSWindowTemplate" id="327397516">
<int key="NSWindowStyleMask">17</int>
<int key="NSWindowBacking">2</int>
- <string key="NSWindowRect">{{247, 517}, {466, 41}}</string>
+ <string key="NSWindowRect">{{247, 517}, {466, 40}}</string>
<int key="NSWTFlags">611844096</int>
<string key="NSWindowTitle">Remoting</string>
<string key="NSWindowClass">DisconnectWindow</string>
@@ -55,7 +55,7 @@
<object class="NSButton" id="456006926">
<reference key="NSNextResponder" ref="1718335"/>
<int key="NSvFlags">300</int>
- <string key="NSFrame">{{275, 10}, {182, 22}}</string>
+ <string key="NSFrame">{{271, 9}, {182, 22}}</string>
<reference key="NSSuperview" ref="1718335"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="837573888">
@@ -79,7 +79,7 @@
<object class="NSTextField" id="165586339">
<reference key="NSNextResponder" ref="1718335"/>
<int key="NSvFlags">300</int>
- <string key="NSFrame">{{26, 14}, {244, 14}}</string>
+ <string key="NSFrame">{{26, 13}, {240, 14}}</string>
<reference key="NSSuperview" ref="1718335"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="752844448">
@@ -109,7 +109,7 @@
</object>
</object>
</object>
- <string key="NSFrameSize">{466, 41}</string>
+ <string key="NSFrameSize">{466, 40}</string>
<reference key="NSSuperview"/>
<int key="NSViewLayerContentsRedrawPolicy">2</int>
</object>
@@ -248,6 +248,7 @@
<string>13.IBViewBoundsToFrameTransform</string>
<string>14.IBPluginDependency</string>
<string>23.IBPluginDependency</string>
+ <string>23.IBViewBoundsToFrameTransform</string>
<string>24.IBPluginDependency</string>
<string>3.IBEditorWindowLastContentRect</string>
<string>3.IBPluginDependency</string>
@@ -263,14 +264,17 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform">
- <bytes key="NSTransformStruct">P4AAAL+AAABDcAAAwfAAAA</bytes>
+ <bytes key="NSTransformStruct">P4AAAL+AAABDiYAAwegAAA</bytes>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <object class="NSAffineTransform">
+ <bytes key="NSTransformStruct">P4AAAL+AAABB0AAAwcgAAA</bytes>
+ </object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{679, 1013}, {466, 41}}</string>
+ <string>{{200, 1287}, {466, 40}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{679, 1013}, {466, 41}}</string>
+ <string>{{200, 1287}, {466, 40}}</string>
<boolean value="NO"/>
<string>DisconnectView</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -292,7 +296,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">26</int>
+ <int key="maxID">27</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -908,6 +912,48 @@
</object>
</object>
<object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">QTKit.framework/Headers/QTCaptureDecompressedVideoOutput.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">QTKit.framework/Headers/QTCaptureFileOutput.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">QTKit.framework/Headers/QTCaptureVideoPreviewOutput.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">QTKit.framework/Headers/QTCaptureView.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">QTKit.framework/Headers/QTMovie.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">QTKit.framework/Headers/QTMovieView.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 727574f..206d016 100644
--- a/remoting/host/disconnect_window_mac.h
+++ b/remoting/host/disconnect_window_mac.h
@@ -14,16 +14,14 @@ class DisconnectWindowMac;
@interface DisconnectWindowController : NSWindowController {
@private
remoting::ChromotingHost* host_;
- remoting::DisconnectWindowMac* disconnectWindow_;
NSString* username_;
IBOutlet NSTextField* connectedToField_;
IBOutlet NSButton* disconnectButton_;
}
-- (IBAction)stopSharing:(id)sender;
- (id)initWithHost:(remoting::ChromotingHost*)host
- window:(remoting::DisconnectWindowMac*)window
username:(NSString*)username;
+- (IBAction)stopSharing:(id)sender;
@end
// A floating window with a custom border. The custom border and background
diff --git a/remoting/host/disconnect_window_mac.mm b/remoting/host/disconnect_window_mac.mm
index 0f177aa..7c1ab44 100644
--- a/remoting/host/disconnect_window_mac.mm
+++ b/remoting/host/disconnect_window_mac.mm
@@ -43,7 +43,6 @@ void DisconnectWindowMac::Show(remoting::ChromotingHost* host,
NSString* nsUsername = base::SysUTF8ToNSString(username);
window_controller_ =
[[DisconnectWindowController alloc] initWithHost:host
- window:this
username:nsUsername];
[window_controller_ showWindow:nil];
}
@@ -63,28 +62,22 @@ remoting::DisconnectWindow* remoting::DisconnectWindow::Create() {
@interface DisconnectWindowController()
@property (nonatomic, assign) remoting::ChromotingHost* host;
-@property (nonatomic, assign) remoting::DisconnectWindowMac* disconnectWindow;
@property (nonatomic, copy) NSString* username;
+
+- (BOOL)isRToL;
+
@end
@implementation DisconnectWindowController
@synthesize host = host_;
-@synthesize disconnectWindow = disconnectWindow_;
@synthesize username = username_;
-- (void)close {
- self.host = NULL;
- [super close];
-}
-
- (id)initWithHost:(remoting::ChromotingHost*)host
- window:(remoting::DisconnectWindowMac*)disconnectWindow
username:(NSString*)username {
self = [super initWithWindowNibName:@"disconnect_window"];
if (self) {
host_ = host;
- disconnectWindow_ = disconnectWindow;
username_ = [username copy];
}
return self;
@@ -100,7 +93,15 @@ remoting::DisconnectWindow* remoting::DisconnectWindow::Create() {
self.host->Shutdown(NULL);
self.host = NULL;
}
- self.disconnectWindow = NULL;
+}
+
+- (BOOL)isRToL {
+ return host_->ui_strings().direction == remoting::UiStrings::RTL;
+}
+
+- (void)close {
+ self.host = NULL;
+ [super close];
}
- (void)windowDidLoad {
@@ -116,16 +117,26 @@ remoting::DisconnectWindow* remoting::DisconnectWindow::Create() {
// Resize the window dynamically based on the content.
CGFloat oldConnectedWidth = NSWidth([connectedToField_ bounds]);
[connectedToField_ sizeToFit];
- CGFloat newConnectedWidth = NSWidth([connectedToField_ bounds]);
+ NSRect connectedToFrame = [connectedToField_ frame];
+ CGFloat newConnectedWidth = NSWidth(connectedToFrame);
+
+ // Set a max width for the connected to text field.
+ if (newConnectedWidth >
+ remoting::DisconnectWindow::kMaximumConnectedNameWidthInPixels) {
+ newConnectedWidth
+ = remoting::DisconnectWindow::kMaximumConnectedNameWidthInPixels;
+ connectedToFrame.size.width = newConnectedWidth;
+ [connectedToField_ setFrame:connectedToFrame];
+ }
CGFloat oldDisconnectWidth = NSWidth([disconnectButton_ bounds]);
[disconnectButton_ sizeToFit];
- NSRect disconnectBounds = [disconnectButton_ frame];
- CGFloat newDisconnectWidth = NSWidth(disconnectBounds);
+ NSRect disconnectFrame = [disconnectButton_ frame];
+ CGFloat newDisconnectWidth = NSWidth(disconnectFrame);
// Move the disconnect button appropriately.
- disconnectBounds.origin.x += newConnectedWidth - oldConnectedWidth;
- [disconnectButton_ setFrame:disconnectBounds];
+ disconnectFrame.origin.x += newConnectedWidth - oldConnectedWidth;
+ [disconnectButton_ setFrame:disconnectFrame];
// Then resize the window appropriately
NSWindow *window = [self window];
@@ -133,6 +144,17 @@ remoting::DisconnectWindow* remoting::DisconnectWindow::Create() {
windowFrame.size.width += (newConnectedWidth - oldConnectedWidth +
newDisconnectWidth - oldDisconnectWidth);
[window setFrame:windowFrame display:NO];
+
+ if ([self isRToL]) {
+ // Handle right to left case
+ CGFloat buttonInset = NSWidth(windowFrame) - NSMaxX(disconnectFrame);
+ CGFloat buttonTextSpacing
+ = NSMinX(disconnectFrame) - NSMaxX(connectedToFrame);
+ disconnectFrame.origin.x = buttonInset;
+ connectedToFrame.origin.x = NSMaxX(disconnectFrame) + buttonTextSpacing;
+ [connectedToField_ setFrame:connectedToFrame];
+ [disconnectButton_ setFrame:disconnectFrame];
+ }
}
- (void)windowWillClose:(NSNotification*)notification {
@@ -142,6 +164,11 @@ remoting::DisconnectWindow* remoting::DisconnectWindow::Create() {
@end
+
+@interface DisconnectWindow()
+- (BOOL)isRToL;
+@end
+
@implementation DisconnectWindow
- (id)initWithContentRect:(NSRect)contentRect
@@ -166,13 +193,28 @@ remoting::DisconnectWindow* remoting::DisconnectWindow::Create() {
return self;
}
+- (BOOL)isRToL {
+ DCHECK([[self windowController] respondsToSelector:@selector(isRToL)]);
+ return [[self windowController] isRToL];
+}
+
+@end
+
+
+@interface DisconnectView()
+- (BOOL)isRToL;
@end
@implementation DisconnectView
+- (BOOL)isRToL {
+ DCHECK([[self window] isKindOfClass:[DisconnectWindow class]]);
+ return [static_cast<DisconnectWindow*>([self window]) isRToL];
+}
+
- (void)drawRect:(NSRect)rect {
// All magic numbers taken from screen shots provided by UX.
- NSRect bounds = NSInsetRect([self bounds], 1.5, 1.5);
+ NSRect bounds = NSInsetRect([self bounds], 1, 1);
NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:bounds
xRadius:5
@@ -180,7 +222,7 @@ remoting::DisconnectWindow* remoting::DisconnectWindow::Create() {
NSColor *gray = [NSColor colorWithCalibratedWhite:0.91 alpha:1.0];
[gray setFill];
[path fill];
- [path setLineWidth:3];
+ [path setLineWidth:4];
NSColor *green = [NSColor colorWithCalibratedRed:0.13
green:0.69
blue:0.11
@@ -188,9 +230,12 @@ remoting::DisconnectWindow* remoting::DisconnectWindow::Create() {
[green setStroke];
[path stroke];
- // Draw drag handle on left hand side
- const CGFloat height = 21.0;
- const CGFloat inset = 12.0;
+
+ // Draw drag handle on proper side
+ const CGFloat kHeight = 21.0;
+ const CGFloat kBaseInset = 12.0;
+ const CGFloat kDragHandleWidth = 5.0;
+
NSColor *dark = [NSColor colorWithCalibratedWhite:0.70 alpha:1.0];
NSColor *light = [NSColor colorWithCalibratedWhite:0.97 alpha:1.0];
@@ -199,8 +244,12 @@ remoting::DisconnectWindow* remoting::DisconnectWindow::Create() {
BOOL alias = [context shouldAntialias];
[context setShouldAntialias:NO];
- NSPoint top = NSMakePoint(inset, NSMidY(bounds) - height / 2.0);
- NSPoint bottom = NSMakePoint(inset, top.y + height);
+ // Handle bidirectional locales properly.
+ CGFloat inset = [self isRToL] ? NSMaxX(bounds) - kBaseInset - kDragHandleWidth
+ : kBaseInset;
+
+ NSPoint top = NSMakePoint(inset, NSMidY(bounds) - kHeight / 2.0);
+ NSPoint bottom = NSMakePoint(inset, top.y + kHeight);
path = [NSBezierPath bezierPath];
[path moveToPoint:top];
@@ -236,4 +285,3 @@ remoting::DisconnectWindow* remoting::DisconnectWindow::Create() {
}
@end
-