diff options
author | Sven Weidauer <sven@5sw.de> | 2017-06-05 12:43:11 +0200 |
---|---|---|
committer | Sven Weidauer <sven@5sw.de> | 2017-06-05 12:43:11 +0200 |
commit | e51c739bfc8e0c50161172952c99b8796703c6fe (patch) | |
tree | 1b3a47b5123aad511bc91a2b589a2dd2949549e3 /frontends/cocoa/ScrollableView.m | |
parent | 2ba97ae0dbd01a4f46c543ae025249e5349e0585 (diff) | |
download | netsurf-e51c739bfc8e0c50161172952c99b8796703c6fe.tar.gz netsurf-e51c739bfc8e0c50161172952c99b8796703c6fe.tar.bz2 |
Start modernising ObjC
Diffstat (limited to 'frontends/cocoa/ScrollableView.m')
-rw-r--r-- | frontends/cocoa/ScrollableView.m | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/frontends/cocoa/ScrollableView.m b/frontends/cocoa/ScrollableView.m index e31d90ade..b2210d059 100644 --- a/frontends/cocoa/ScrollableView.m +++ b/frontends/cocoa/ScrollableView.m @@ -20,24 +20,25 @@ @interface ScrollableView () +@property (weak, nonatomic) NSView *observedSuperview; + - (void)frameChangeNotification:(NSNotification *)note; @end @implementation ScrollableView -@synthesize minimumSize; - (void)setMinimumSize:(NSSize)newSize { - minimumSize = newSize; + _minimumSize = newSize; [self adjustFrame]; } - (void)adjustFrame { NSSize frameSize = [[self superview] frame].size; - [self setFrameSize:NSMakeSize(MAX(minimumSize.width, frameSize.width), - MAX(minimumSize.height, frameSize.height))]; + [self setFrameSize:NSMakeSize(MAX(self.minimumSize.width, frameSize.width), + MAX(self.minimumSize.height, frameSize.height))]; } - (void)frameChangeNotification:(NSNotification *)note @@ -47,24 +48,25 @@ - (void)viewDidMoveToSuperview { - if (observedSuperview) { + NSView *oldSuperview = _observedSuperview; + _observedSuperview = nil; + if (oldSuperview) { [[NSNotificationCenter defaultCenter] removeObserver:self name:NSViewFrameDidChangeNotification - object:observedSuperview]; - observedSuperview = nil; + object:oldSuperview]; } NSView *newSuperView = [self superview]; if (nil != newSuperView) { - observedSuperview = newSuperView; + _observedSuperview = newSuperView; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(frameChangeNotification:) name:NSViewFrameDidChangeNotification - object:observedSuperview]; - [observedSuperview setPostsFrameChangedNotifications:YES]; + object:newSuperView]; + newSuperView.postsFrameChangedNotifications = YES; } } |