// // NSView+Additions.m // Perforce // // Created by Adam Czubernat on 28.05.2013. // Copyright (c) 2013 Perforce Software, Inc. All rights reserved. // #import "NSView+Additions.h" @implementation NSView (Additions) + (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations { [self animateWithDuration:duration animations:animations completion:nil]; } + (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^)(void))completion { [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) { context.duration = duration; animations(); } completionHandler:completion]; } - (void)setAutoresizing:(NSViewAutoresizing)mask { mask ^= NSViewAutoresizingLeftEdge | NSViewAutoresizingRightEdge; if (!(mask & (NSViewMinYMargin | NSViewMaxYMargin))) mask |= (NSViewMinYMargin | NSViewMaxYMargin); if (!(mask & (NSViewMinXMargin | NSViewMaxXMargin))) mask |= (NSViewMinXMargin | NSViewMaxXMargin); self.autoresizingMask = mask; } - (void)printSubviews { [self printSubviewsLevel:NSIntegerMax]; } - (void)printSubviewsLevel:(NSInteger)maxLevel { __block void (^__weak block)(NSView *, NSString *, NSInteger); void (^weak)(NSView *, NSString *, NSInteger); block = weak = ^(NSView *view, NSString *indent, NSInteger level) { NSString *string = [NSString stringWithFormat:@"%@(%@) %@%@", indent, NSStringFromClass([view class]), NSStringFromRect([view frame]), view.isHidden ? @" #hidden#" : @""]; NSString *title = nil; if ([view isKindOfClass:[NSTextField class]]) title = [(NSTextField *)view stringValue]; else if ([view isKindOfClass:[NSButton class]]) title = [(NSButton *)view title]; if (title) string = [string stringByAppendingFormat:@" = \"%@\"", title]; printf("%s\n", string.UTF8String); if (level < maxLevel) for (NSView *subview in view.subviews) block(subview, [indent stringByAppendingString:@" |\t"], level+1); else if (view.subviews.count) printf("%s", [[NSString stringWithFormat:@"%@ |\t...\n", indent] UTF8String]); }; block(self, @"", 0); } @end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 16507 | perforce_software | Move to main branch. | ||
//guest/perforce_software/piper/mac/R1.0/Perforce/Classes/Helpers/NSView+Additions.m | |||||
#1 | 11254 | alan_petersen |
Populate //guest/perforce_software/piper/mac/R1.0/... from //guest/perforce_software/piper/mac/main/.... |
||
//guest/perforce_software/piper/mac/main/Perforce/Classes/Helpers/NSView+Additions.m | |||||
#1 | 11252 | alan_petersen | Rename/move file(s) | ||
//guest/perforce_software/piper/mac/Perforce/Classes/Helpers/NSView+Additions.m | |||||
#1 | 10744 | alan_petersen | Rename/move file(s) | ||
//guest/perforce_software/piper/Perforce/Classes/Helpers/NSView+Additions.m | |||||
#1 | 8919 | Matt Attaway | Initial add of Piper, a lightweight Perforce client for artists and designers. |