-
Notifications
You must be signed in to change notification settings - Fork 39
First try at version 2. #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
c1f57cd
5446dbd
e7f963d
b3383ff
93257a8
8bda0e4
c72ce75
248e116
47887d5
273f55e
710959c
6b34e97
44c0e58
eec885a
7a3eadf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - Nam Kennic wrote the initial implementation for -setBackgroundColor:, on what was then the LFGlassView. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // | ||
| // Copyright (c) 2014 Evadne Wu and Nicholas Levin | ||
| // | ||
| // Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| // of this software and associated documentation files (the "Software"), to deal | ||
| // in the Software without restriction, including without limitation the rights | ||
| // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| // copies of the Software, and to permit persons to whom the Software is | ||
| // furnished to do so, subject to the following conditions: | ||
| // | ||
| // The above copyright notice and this permission notice shall be included in | ||
| // all copies or substantial portions of the Software. | ||
| // | ||
| // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| // THE SOFTWARE. | ||
| // | ||
|
|
||
| #include "LFDefines.h" | ||
| #include <math.h> | ||
|
|
||
| const CGPoint LFPointNull = (CGPoint){INFINITY, INFINITY}; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| // | ||
| // Copyright (c) 2014 Evadne Wu and Nicholas Levin | ||
| // | ||
| // Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| // of this software and associated documentation files (the "Software"), to deal | ||
| // in the Software without restriction, including without limitation the rights | ||
| // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| // copies of the Software, and to permit persons to whom the Software is | ||
| // furnished to do so, subject to the following conditions: | ||
| // | ||
| // The above copyright notice and this permission notice shall be included in | ||
| // all copies or substantial portions of the Software. | ||
| // | ||
| // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| // THE SOFTWARE. | ||
| // | ||
|
|
||
| #ifndef LiveFrost_LFDefines_h | ||
| #define LiveFrost_LFDefines_h | ||
|
|
||
| #include <CoreGraphics/CGGeometry.h> | ||
|
|
||
| extern const CGPoint LFPointNull; | ||
|
|
||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,24 +22,24 @@ | |
|
|
||
| #import "LFDisplayBridge.h" | ||
|
|
||
| void LF_refreshAllSubscribedViewsApplierFunction(const void *value, void *context); | ||
| void LF_refreshAllSubscribedObjectsApplierFunction(const void *value, void *context); | ||
|
|
||
| @interface LFDisplayBridge () | ||
|
|
||
| @property (nonatomic, readwrite, assign) CFMutableSetRef subscribedViews; | ||
| @property (nonatomic, readwrite, assign) CFMutableSetRef subscribedObjects; | ||
| @property (nonatomic, readonly, strong) CADisplayLink *displayLink; | ||
|
|
||
| @end | ||
|
|
||
| void LF_refreshAllSubscribedViewsApplierFunction(const void *value, void *context) { | ||
| [(__bridge UIView<LFDisplayBridgeTriggering> *)value refresh]; | ||
| void LF_refreshAllSubscribedObjectsApplierFunction(const void *value, void *context) { | ||
| [(__bridge id<LFDisplayBridgeTriggering>)value refresh]; | ||
| } | ||
|
|
||
| #if !__has_feature(objc_arc) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure with keeping ARC detection intact. We distribute thru CocoaPods which will ensure that the library has ARC enabled during compilation. We might want to move this into some kind of shared header if it appears more than once, or we might choose to simply omit this if that is fine.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was written for users that aren't using CocoaPods. (Which do exist.) (Cough, cough.) Git submodules, for instance.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔥 🔥 🔥 🔥 I think this belongs to a shared header.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, it can't be a header, as the ARC check needs to happen in the implementation files. When adding exceptions to an ARC or not ARC aware codebase, the files that you need to pick out are specifically the implementation files. ARC doesn't care much for headers, as that's just an API.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess then the only solution is to ensure that this check is applied to each file. |
||
| #error This implementation file must be compiled with Objective-C ARC. | ||
| #error This implementation file must be compiled with Objective-C ARC. | ||
|
|
||
| #error Compile this file with the -fobjc-arc flag under your target's Build Phases, | ||
| #error or convert your project to Objective-C ARC. | ||
| #error Compile this file with the -fobjc-arc flag under your target's Build Phases, | ||
| #error or convert your project to Objective-C ARC. | ||
| #endif | ||
|
|
||
| @implementation LFDisplayBridge | ||
|
|
@@ -55,32 +55,32 @@ + (instancetype) sharedInstance { | |
|
|
||
| - (id) init { | ||
| if (self = [super init]) { | ||
| _subscribedViews = CFSetCreateMutable(kCFAllocatorDefault, 0, NULL); | ||
| _subscribedObjects = CFSetCreateMutable(kCFAllocatorDefault, 0, NULL); | ||
| _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(handleDisplayLink:)]; | ||
| [_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes]; | ||
| } | ||
| return self; | ||
| } | ||
|
|
||
| - (void) addSubscribedViewsObject:(UIView<LFDisplayBridgeTriggering> *)object { | ||
| CFSetAddValue(_subscribedViews, (__bridge const void*)object); | ||
| - (void) dealloc { | ||
| [_displayLink invalidate]; | ||
| CFRelease(_subscribedObjects); | ||
| } | ||
|
|
||
| - (void) removeSubscribedViewsObject:(UIView<LFDisplayBridgeTriggering> *)object { | ||
| CFSetRemoveValue(_subscribedViews, (__bridge const void*)object); | ||
| - (void) addSubscribedObject:(id<LFDisplayBridgeTriggering>)object { | ||
| CFSetAddValue(_subscribedObjects, (__bridge const void*)object); | ||
| } | ||
|
|
||
| - (void) handleDisplayLink:(CADisplayLink *)displayLink { | ||
| [self refresh]; | ||
| - (void) removeSubscribedObject:(id<LFDisplayBridgeTriggering>)object { | ||
| CFSetRemoveValue(_subscribedObjects, (__bridge const void*)object); | ||
| } | ||
|
|
||
| - (void) dealloc { | ||
| [_displayLink invalidate]; | ||
| CFRelease(_subscribedViews); | ||
| - (void) handleDisplayLink:(CADisplayLink *)displayLink { | ||
| [self refresh]; | ||
| } | ||
|
|
||
| - (void) refresh { | ||
| CFSetApplyFunction(_subscribedViews, LF_refreshAllSubscribedViewsApplierFunction, NULL); | ||
| CFSetApplyFunction(_subscribedObjects, LF_refreshAllSubscribedObjectsApplierFunction, NULL); | ||
| } | ||
|
|
||
| @end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // | ||
| // Copyright (c) 2013-2014 Evadne Wu and Nicholas Levin | ||
| // | ||
| // Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| // of this software and associated documentation files (the "Software"), to deal | ||
| // in the Software without restriction, including without limitation the rights | ||
| // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| // copies of the Software, and to permit persons to whom the Software is | ||
| // furnished to do so, subject to the following conditions: | ||
| // | ||
| // The above copyright notice and this permission notice shall be included in | ||
| // all copies or substantial portions of the Software. | ||
| // | ||
| // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| // THE SOFTWARE. | ||
| // | ||
|
|
||
| @protocol LFDisplayBridgeTriggering <NSObject> | ||
| - (void) refresh; | ||
| @end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| // | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Headers are not included in this project by default, so we need to either add this to all files or remove ones introduced.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not quite sure what you mean. LFGlassView.h inherits from LFGlassLayer.h, though that could be moved to the implementation file and the header could see only a class definition for the LFGlassLayer instance.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, the “Copyright” declaration block.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe that's already been covered, as far as applying that copyright header to every interface and implementation file. Unless there are some additional files that I've missed. |
||
| // Copyright (c) 2013-2014 Evadne Wu and Nicholas Levin | ||
| // | ||
| // Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| // of this software and associated documentation files (the "Software"), to deal | ||
| // in the Software without restriction, including without limitation the rights | ||
| // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| // copies of the Software, and to permit persons to whom the Software is | ||
| // furnished to do so, subject to the following conditions: | ||
| // | ||
| // The above copyright notice and this permission notice shall be included in | ||
| // all copies or substantial portions of the Software. | ||
| // | ||
| // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| // THE SOFTWARE. | ||
| // | ||
|
|
||
| @import Accelerate.vImage; | ||
| @import QuartzCore.CALayer; | ||
| #import "LFDisplayBridgeTriggering.h" | ||
|
|
||
| @interface LFGlassLayer : CALayer <LFDisplayBridgeTriggering> | ||
|
|
||
| @property (nonatomic, assign) CGFloat blurRadius; | ||
| @property (nonatomic, assign) CGFloat scaleFactor; | ||
|
|
||
| @property (nonatomic, assign) NSUInteger frameInterval; | ||
|
|
||
| - (BOOL) blurOnceIfPossible; | ||
|
|
||
| // optional properties for greater customization | ||
| @property (nonatomic, weak) CALayer *customBlurTargetLayer; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure about this part.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the extra layer of abstraction help? This doesn't seem like a place where an extra object helps out. A better question may be, does this really clarify any logic, or add a greater degree of flexibility than what we have right now?
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No but the API gets cleaner.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, okay, took me a little extra time to realize that you were thinking of moving out the bounds/position/anchorPoint/frame bits from the layer. I don't know, it still seems a bit more limiting than what we have now. I did consider that custom parameters + just the bog standard superview would be a possible, even likely scenario, judging from issue #15.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will do this then |
||
| @property (nonatomic, assign) CGRect customBlurBounds; | ||
| @property (nonatomic, assign) CGPoint customBlurPosition; | ||
| @property (nonatomic, assign) CGPoint customBlurAnchorPoint; | ||
| @property (nonatomic, assign) CGRect customBlurFrame; | ||
|
|
||
| - (void) resetCustomPositioning; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I disagree here, it's not a universal reset, it's strictly for custom bounds/position/anchorPoint/frame. |
||
|
|
||
| @end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question, KVO methods. 👍 ? 👎 ?