Skip to content

Commit

Permalink
Support for autolayout views, which don't have autolayout masks
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge Peixoto Vasquez committed Nov 7, 2012
1 parent 5f49680 commit d1c9356
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions MASPreferencesViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
- (void)viewDidDisappear;
- (NSView*)initialKeyView;

@property (nonatomic, readonly) BOOL resizableWidth;
@property (nonatomic, readonly) BOOL resizableHeight;

@required

@property (nonatomic, readonly) NSString *identifier;
Expand Down
16 changes: 14 additions & 2 deletions MASPreferencesWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,20 @@ - (void)setSelectedViewController:(NSViewController <MASPreferencesViewControlle
NSString *minViewRectString = [_minimumViewRects objectForKey:controller.identifier];
if (!minViewRectString)
[_minimumViewRects setObject:NSStringFromRect(controllerView.bounds) forKey:controller.identifier];
BOOL sizableWidth = [controllerView autoresizingMask] & NSViewWidthSizable;
BOOL sizableHeight = [controllerView autoresizingMask] & NSViewHeightSizable;

BOOL sizableWidth;
BOOL sizableHeight;

if([controller respondsToSelector:@selector(resizableWidth)])
sizableWidth = controller.resizableWidth;
else
sizableWidth = [controllerView autoresizingMask] & NSViewWidthSizable;

if([controller respondsToSelector:@selector(resizableHeight)])
sizableHeight = controller.resizableHeight;
else
sizableHeight = [controllerView autoresizingMask] & NSViewHeightSizable;

NSRect oldViewRect = oldViewRectString ? NSRectFromString(oldViewRectString) : controllerView.bounds;
NSRect minViewRect = minViewRectString ? NSRectFromString(minViewRectString) : controllerView.bounds;
oldViewRect.size.width = NSWidth(oldViewRect) < NSWidth(minViewRect) || !sizableWidth ? NSWidth(minViewRect) : NSWidth(oldViewRect);
Expand Down

0 comments on commit d1c9356

Please sign in to comment.