Changeset 13997


Ignore:
Timestamp:
Feb 9, 2013, 7:13:26 PM (8 years ago)
Author:
livings124
Message:

resize the rename dialogue buttons for different localizations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/FileRenameSheetController.m

    r13989 r13997  
    9494    [self.renameButton setEnabled: NO];
    9595   
    96     #warning size these
     96    //resize the buttons so that they're long enough and the same width
     97    const NSRect oldRenameFrame = [self.renameButton frame];
     98    const NSRect oldCancelFrame = [self.cancelButton frame];
     99   
     100    //get the extra width of the rename button from the English xib - the width from sizeToFit is too squished
     101    [self.renameButton sizeToFit];
     102    const CGFloat extra = NSWidth(oldRenameFrame) - NSWidth([self.renameButton frame]);
     103   
    97104    [self.renameButton setStringValue: NSLocalizedString(@"Rename", "rename sheet button")];
    98105    [self.cancelButton setStringValue: NSLocalizedString(@"Cancel", "rename sheet button")];
     106   
     107    [self.renameButton sizeToFit];
     108    [self.cancelButton sizeToFit];
     109    NSRect newRenameFrame = [self.renameButton frame];
     110    NSRect newCancelFrame = [self.cancelButton frame];
     111    newRenameFrame.size.width = MAX(NSWidth(newRenameFrame), NSWidth(newCancelFrame)) + extra;
     112    newCancelFrame.size.width = MAX(NSWidth(newRenameFrame), NSWidth(newCancelFrame)) + extra;
     113   
     114    const CGFloat renameWidthIncrease = NSWidth(newRenameFrame) - NSWidth(oldRenameFrame);
     115    newRenameFrame.origin.x -= renameWidthIncrease;
     116    [self.renameButton setFrame:newRenameFrame];
     117   
     118    const CGFloat cancelWidthIncrease = NSWidth(newCancelFrame) - NSWidth(oldCancelFrame);
     119    newCancelFrame.origin.x -= renameWidthIncrease + cancelWidthIncrease;
     120    [self.cancelButton setFrame:newCancelFrame];
    99121}
    100122
Note: See TracChangeset for help on using the changeset viewer.