diff --git a/docs/ios.md b/docs/ios.md new file mode 100644 index 00000000..fe9f1e2f --- /dev/null +++ b/docs/ios.md @@ -0,0 +1,50 @@ +###Implement Exemple: + +RoboVm needs the native libs/frameworks for create a build! +Copy this files from vtm-ios-0.6.0-SNAPSHOT-natives.jar into a temp folder! + +Create a copy task into your build.gradle + +```java +task copyFrameWorks(type: Copy) { + from(zipTree("./libs/vtm-ios-0.6.0-SNAPSHOT-natives.jar")) + into("${buildDir}/native") +} + + +tasks.withType(org.gradle.api.tasks.compile.JavaCompile) { + compileTask -> compileTask.dependsOn copyFrameWorks +} +``` + +Now you can configure your robovm.xml to implement the vtm-natives and the SVG-Framework + +``` + + z + build/native/libvtm-jni.a + + + build/native + + + SVGgh + UIKit + OpenGLES + QuartzCore + CoreGraphics + OpenAL + AudioToolbox + AVFoundation + +``` + +Remember, the implementation of a iOS- framework is possible since iOS 8! +So we must set the min iOS-Version at Info.plist.xml! + +``` + + MinimumOSVersion + 8.0 + ... +``` \ No newline at end of file diff --git a/vtm-ios/Info.plist.xml b/vtm-ios/Info.plist.xml index c2d27626..6a225346 100644 --- a/vtm-ios/Info.plist.xml +++ b/vtm-ios/Info.plist.xml @@ -2,6 +2,8 @@ "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> + MinimumOSVersion + 8.0 CFBundleDevelopmentRegion en CFBundleDisplayName diff --git a/vtm-ios/natives/SVGgh.framework.dSYM/Contents/Info.plist b/vtm-ios/natives/SVGgh.framework.dSYM/Contents/Info.plist new file mode 100644 index 00000000..fce044f0 --- /dev/null +++ b/vtm-ios/natives/SVGgh.framework.dSYM/Contents/Info.plist @@ -0,0 +1,20 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.apple.xcode.dsym.com.genhelp.SVGgh + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + dSYM + CFBundleSignature + ???? + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/vtm-ios/natives/SVGgh.framework.dSYM/Contents/Resources/DWARF/SVGgh b/vtm-ios/natives/SVGgh.framework.dSYM/Contents/Resources/DWARF/SVGgh new file mode 100755 index 00000000..c6a4e257 Binary files /dev/null and b/vtm-ios/natives/SVGgh.framework.dSYM/Contents/Resources/DWARF/SVGgh differ diff --git a/vtm-ios/natives/SVGgh.framework/Headers/GHButton.h b/vtm-ios/natives/SVGgh.framework/Headers/GHButton.h new file mode 100644 index 00000000..cb1b78e8 --- /dev/null +++ b/vtm-ios/natives/SVGgh.framework/Headers/GHButton.h @@ -0,0 +1,81 @@ +// +// GHButton.h +// SVGgh +// The MIT License (MIT) + +// Copyright (c) 2011-2014 Glenn R. Howes + +// 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. +// + +// Created by Glenn Howes on 1/26/14. +// + +/* + * Note you can instantiate a GHButton in a storyboard or a XIB by dragging a UIView into your view and giving it a class of GHButton. + * You can configure the style of the button by adding "User Defined Runtime Attributes" in XCode's "Identity Inspector" + *********************************** + ** Key Path *** Type *** Value ** + ---------------------------------------------------------------- + schemeNumber Number 3 + artworkPath String Artwork/MenuButton + ----------------------------------------------------------------- + Will make a lightly chromed button with the contents of a file in your app's bundle with the path /Artwork/MenuButton.svg +*/ + +#import "GHControl.h" + +NS_ASSUME_NONNULL_BEGIN + +/*! @brief a button widget that can take on various themed appearances and host vectored svg content +* @attention not a UIButton (too hard to subclass) +* @attention wire any UIAction up to the up inside event not the value changed event +*/ +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000 +IB_DESIGNABLE // Cocapods users should add the use_frameworks! directive if this causes an error +#endif +@interface GHButton : GHControl +/*! @property title +* @brief this text (if any) will be displayed embedded in the button +*/ +@property(nonatomic, strong) IBInspectable NSString* __nullable title; +/*! @property artworkPath + * @brief optional subpath to an svg file inside the resources folder, svg is displayed inside the button at appropriate size + * @attention do not append '.svg' + */ +@property(nonatomic, strong) IBInspectable NSString* __nullable artworkPath; +/*! @property selectedArtworkPath + * @brief optional subpath to an svg file inside the resources folder, svg is displayed inside the button at appropriate size. When button is in selected state. + * @attention do not append '.svg' + */ +@property(nonatomic, strong) IBInspectable NSString* __nullable selectedArtworkPath; +/*! @property pressedArtworkPath + * @brief optional subpath to an svg file inside the resources folder, svg is displayed inside the button at appropriate size. When button is in pressed state. + * @attention do not append '.svg' + */ +@property(nonatomic, strong) IBInspectable NSString* __nullable pressedArtworkPath; +/*! @property artworkView + * @brief optional view to embed inside this button to display artwork. Usually used from storyboard or nib + */ +@property(nonatomic, weak) IBOutlet UIView* __nullable artworkView; + ++(void)makeSureLoaded; +@end + +NS_ASSUME_NONNULL_END diff --git a/vtm-ios/natives/SVGgh.framework/Headers/GHCSSStyle.h b/vtm-ios/natives/SVGgh.framework/Headers/GHCSSStyle.h new file mode 100644 index 00000000..b1c39c1e --- /dev/null +++ b/vtm-ios/natives/SVGgh.framework/Headers/GHCSSStyle.h @@ -0,0 +1,59 @@ +// +// GHCSSStyle.h +// SVGgh +// +// The MIT License (MIT) + +// Copyright (c) 2016 Glenn R. Howes + +// 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. +// +// +// Created by Glenn Howes on 3/19/16. + +#import + +NS_ASSUME_NONNULL_BEGIN + +typedef enum StyleElementType +{ + kStyleTypeUnsupported, + kStyleTypeCSS // text/css +}StyleElementType; + +typedef NS_OPTIONS(NSUInteger, CSSPseudoClassFlags) { + kPseudoClassNone = 0, + kPseudoClassActive = (1 << 0), + kPseudoClassFocused = (1 << 1), + kPseudoClassHovering = (1 << 2) +}; + +@interface GHCSSStyle : NSObject +@property(nonatomic, readonly) NSString* cssClass; +@property(nonatomic, readonly) CSSPseudoClassFlags pseudoClassFlags; +@property(nonatomic, readonly) NSDictionary* __nullable attributes; +@property(nonatomic, readonly) NSDictionary* __nullable subClasses; + + ++(NSDictionary*) stylesForString:(NSString*)css; ++( NSString* _Nullable ) attributeNamed:(NSString*)attributeName classes:(nullable NSArray*)listOfClasses entityName:(nullable NSString*)entityName pseudoClass:(CSSPseudoClassFlags)pseudoClassFlags forStyles:(NSDictionary*) cssStyles; + +@end + +NS_ASSUME_NONNULL_END diff --git a/vtm-ios/natives/SVGgh.framework/Headers/GHControl.h b/vtm-ios/natives/SVGgh.framework/Headers/GHControl.h new file mode 100644 index 00000000..447496da --- /dev/null +++ b/vtm-ios/natives/SVGgh.framework/Headers/GHControl.h @@ -0,0 +1,94 @@ +// +// GHControl.h +// SVGgh +// The MIT License (MIT) + +// Copyright (c) 2011-2015 Glenn R. Howes + +// 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. +// + + +#if defined(__has_feature) && __has_feature(modules) +@import Foundation; +@import UIKit; +#else +#import +#import +#endif + + + +#ifndef IBInspectable +#define IBInspectable +#endif + +#ifndef IB_DESIGNABLE +#define IB_DESIGNABLE +#endif + +#ifndef DEFINED_COLOR_SCHEME +#define DEFINED_COLOR_SCHEME + +typedef NSUInteger ColorScheme; +#endif + +NS_ASSUME_NONNULL_BEGIN + +@interface GHControl : UIControl +@property(nonatomic, assign) ColorScheme scheme; +/*! @property schemeNumber + * @brief this is equivalent to the scheme property, just the one expected to be set via Storyboard or Nib + */ +@property(nonatomic, assign) IBInspectable NSInteger schemeNumber; + + +/*! @property artInsetFraction + * @brief this is a value to inset the artwork from the edges, as a fraction of the widget's height. So if a button is 50 points high and its artInsetFraction is .1 it will be inset 5 points. Should be much less than 0.5 + */ +@property(nonatomic, assign) IBInspectable CGFloat artInsetFraction; + +// these are all related to how the button draws itself as part of a scheme +@property(nonatomic, assign) CGGradientRef __nullable faceGradient; +@property(nonatomic, assign) CGGradientRef __nullable faceGradientPressed; +@property(nonatomic, assign) CGGradientRef __nullable faceGradientSelected; +@property(nonatomic, strong) IBInspectable UIColor* textColor; +@property(nonatomic, strong) IBInspectable UIColor* textColorPressed; +@property(nonatomic, strong) IBInspectable UIColor* textColorSelected; +@property(nonatomic, strong) IBInspectable UIColor* textColorDisabled; +@property(nonatomic, assign) BOOL drawsChrome; +@property(nonatomic, assign) BOOL drawsBackground; +@property(nonatomic, strong) UIColor* __nullable ringColor; +@property(nonatomic, strong) UIColor* __nullable textShadowColor; +@property(nonatomic, assign) BOOL useRadialGradient; +@property (nonatomic, assign) CGFloat textFontSize; +@property(nonatomic, assign) BOOL useBoldText; +@property(nonatomic, assign) BOOL showShadow; + + + +-(void) setupForScheme:(NSUInteger)aScheme; + +@end + +extern const CGFloat kRingThickness; +extern const CGFloat kRoundButtonRadius; +extern const CGFloat kShadowInset; + +NS_ASSUME_NONNULL_END diff --git a/vtm-ios/natives/SVGgh.framework/Headers/GHControlFactory.h b/vtm-ios/natives/SVGgh.framework/Headers/GHControlFactory.h new file mode 100644 index 00000000..c375b8eb --- /dev/null +++ b/vtm-ios/natives/SVGgh.framework/Headers/GHControlFactory.h @@ -0,0 +1,220 @@ +// +// GHControlFactory.h +// SVGgh +// The MIT License (MIT) + +// Copyright (c) 2011-2014 Glenn R. Howes + +// 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. +// +// Created by Glenn Howes on 3/25/12. + +/******* + The basis of a theme engine. This one only creates a GHButton control which is a color appropriate replacement (not a subclass) + of the UIButton that Apple provides. +******/ + + +#if defined(__has_feature) && __has_feature(modules) +@import Foundation; +@import UIKit; +#else +#import +#import +#endif + +@class GHButton; + +NS_ASSUME_NONNULL_BEGIN + +enum { + // do not change the order of these as they are hard coded into storyboards + kColorSchemeiOS, + kColorSchemeMachine, + kColorSchemeKeyboard, + kColorSchemeClear, + kColorSchemeEmpty, // most like iOS 7 or 8 with minimal chrome + kColorSchemeHomeTheatre, + kColorSchemeiOSVersionAppropriate, + kColorSchemeFlatAndBoxy, + + kColorSchemeTVOS, + kLastColorScheme = kColorSchemeTVOS, + + kColorSchemeNone, +}; + +#ifndef DEFINED_COLOR_SCHEME +#define DEFINED_COLOR_SCHEME + +typedef NSUInteger ColorScheme; +#endif + + +/*! @brief a singleton class devoted to storing configurations for themes and returning useful theme objects like gradients and buttons + * @attention right now only returns a button + */ +@interface GHControlFactory : NSObject + +/*! @brief set a standard controlScheme for your app. Call it early in the app creation process. Like in your app delegate's initialize method +@param defaultScheme one of an enumerated list. kColorSchemeEmpty or kColorSchemeClear is nice for iOS 7 +*/ ++(void) setDefaultScheme:(ColorScheme)defaultScheme; + +/*! @brief the ColorScheme that was set by an earlier call to setDefaultScheme + @return one of the enumerated list in the typedef ColorScheme + @see setDefaultScheme: + */ ++(ColorScheme) defaultScheme; + + + +/*! @brief utility routine to validate parameters to make sure the enumerated color scheme is known (in the list) + @param scheme one of the enumerated list in the typedef ColorScheme + @return YES if the scheme is known + */ ++(BOOL)isValidColorScheme:(ColorScheme)scheme; + +/*! @brief set the color of text and the 'currentColor' of embedded SVGs for GHControls + @param defaultTextColor to use + */ ++(void) setDefaultTextColor:(nullable UIColor*)defaultTextColor; ++(void) setDefaultPressedTextColor:(nullable UIColor*)defaultPressedTextColor; + ++(nullable UIColor*)textColor; ++(nullable UIColor*)pressedTextColor; + + +/*! @brief part of what you do to make iOS programs unique is to give controls a color specific to your app +*/ ++(void) setDefaultButtonTint:(nullable UIColor*)buttonTint; + +/*! @brief default tinting color for GHButtons +@return aColor appropriate for tinting a button. +*/ ++(nullable UIColor*)buttonTint; + +/*! @brief Appropriate color for light backgrounded widgets given the scheme +@param scheme one of the enumerated list in the typedef ColorScheme +@return a light color +*/ ++(nullable UIColor*) newLightBackgroundColorForScheme:(ColorScheme)scheme; + +/*! @brief a gradient appropriate for coloring a button background +* @param scheme one of the enumerated list in the typedef ColorScheme +* @return a CGGradientRef +* @attention caller responsible for disposal +*/ ++(nullable CGGradientRef) newButtonBackgroundGradientForScheme:(ColorScheme)scheme CF_RETURNS_RETAINED; + +/*! @brief a gradient appropriate for coloring a pressed button's background + * @param scheme one of the enumerated list in the typedef ColorScheme + * @return a CGGradientRef + * @attention caller responsible for disposal + */ ++(nullable CGGradientRef) newButtonBackgroundGradientPressedForScheme:(ColorScheme)scheme CF_RETURNS_RETAINED; + +/*! @brief a gradient appropriate for coloring a selected button's background + * @param scheme one of the enumerated list in the typedef ColorScheme + * @return a CGGradientRef + * @attention caller responsible for disposal + */ ++(nullable CGGradientRef) newButtonBackgroundGradientSelectedForScheme:(ColorScheme)scheme CF_RETURNS_RETAINED; + +/*! @brief Does the given scheme prefer Radial gradients? + * @param scheme one of the enumerated list in the typedef ColorScheme + * @return YES if radial gradients are preferred + */ ++(BOOL) preferRadialGradientForScheme:(ColorScheme)scheme; + +/*! @brief makes a color appropriate for button text + * @param scheme one of the enumerated list in the typedef ColorScheme + * @return a color which willbe dark if backgrounds are light, and light if backgrounds are dark + */ ++(UIColor*) newTextColorForScheme:(ColorScheme)scheme; + +/*! @brief makes a color appropriate for button text on a pressed button + * @param scheme one of the enumerated list in the typedef ColorScheme + * @return a color which willbe dark if backgrounds are light, and light if backgrounds are dark + */ ++(UIColor*) newTextColorPressedForScheme:(ColorScheme)scheme; + +/*! @brief makes a color appropriate for drop shadow on text + * @param scheme one of the enumerated list in the typedef ColorScheme + * @return a color (if any) to use as the drop shadow color of text + */ ++(nullable UIColor*) newTextShadowColorForScheme:(ColorScheme)scheme; + +/*! @brief makes a color appropriate for the ring chrome around a button + * @param scheme one of the enumerated list in the typedef ColorScheme + * @return a color (if any) for use in a ring's outline + */ ++(nullable UIColor*) newRingColorForScheme:(ColorScheme)scheme; + +/*! @brief makes a color appropriate for background of a button when pressed + * @param scheme one of the enumerated list in the typedef ColorScheme + * @return a color (if any) for use in a ring's outline + */ ++(UIColor*) newPressedColorForColor:(UIColor*)originalColor forScheme:(ColorScheme)scheme; + +/*! @brief generates a button appropriate for the given scheme + * @param scheme one of the enumerated list in the typedef ColorScheme + * @return a GHButton (you can instantiate these without the factory too, like in a storyboard) + */ ++(GHButton*) newButtonForScheme:(ColorScheme)scheme; // not a subclass of UIButton as that's too hard to subclass + +/*! @brief clone a color with a change in brightness + * @param originalColor the starting Color + * @param brightnessDelta number between -1,1 to ramp up or diminish the brightness (0.1 typical) + * @return the cloned color + */ ++(UIColor*) newColor:(UIColor*)originalColor withBrightnessDelta:(CGFloat)brightnessDelta; + + +/*! @brief create a round rect path where the provided rect is given round corners + * @param aRect a rectangle + * @param radius ideally less than half the width or height of the rect + * @return a path user responsible for disposal + */ ++(CGPathRef) newRoundRectPathForRect:(CGRect)aRect withRadius:(CGFloat) radius CF_RETURNS_RETAINED; + +/*! @brief utility routine to find the location of an SVG document relative to a provided bundle + * @param an optional bundle containing the artwork + * @param theArtworkPath subpath within a bundle does not include the .svg extension which is assumed. + */ ++(nullable NSURL*) locateArtworkForBundle:(nullable NSBundle*)mayBeNil atSubpath:(NSString*)theArtworkPath; + +/*! @brief utility routine to find the location of an SVG document relative to either the main bundle or the bundle in which the object is located + * @param anObject for instance a GHButton + * @param theArtworkPath subpath within a bundle does not include the .svg extension which is assumed. + */ ++(nullable NSURL*) locateArtworkForObject:(id)anObject atSubpath:(NSString*)theArtworkPath; // for compatibility + +/*! @brief utility routine to locate a URL inside your project when using Interface Builder's IB_DESIGNABLE service + * @param anObject for instance a GHButton + * @param theArtworkPath subpath within a bundle does not include the .svg extension which is assumed. + */ ++(nullable NSURL*) findInterfaceBuilderArtwork:(NSString*)artworkSubPath; + +@end + +extern UIColor* __nullable UIColorFromSVGColorString (NSString * stringToConvert); +extern __nullable CGPathRef CreatePathFromSVGPathString(NSString* dAttribute, CGAffineTransform transformToApply) CF_RETURNS_RETAINED; + +NS_ASSUME_NONNULL_END diff --git a/vtm-ios/natives/SVGgh.framework/Headers/GHImageCache.h b/vtm-ios/natives/SVGgh.framework/Headers/GHImageCache.h new file mode 100644 index 00000000..10438c34 --- /dev/null +++ b/vtm-ios/natives/SVGgh.framework/Headers/GHImageCache.h @@ -0,0 +1,139 @@ +// +// SVGgh.h +// GHImageCache.h +// The MIT License (MIT) + +// Copyright (c) 2011-2014 Glenn R. Howes + +// 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. +// +// Created by Glenn Howes on 10/5/13. + + +#if defined(__has_feature) && __has_feature(modules) +@import Foundation; +@import CoreGraphics; +@import UIKit; +#else +#import +#import +#import +#endif + +NS_ASSUME_NONNULL_BEGIN + +/*! @brief definition of a block callback to handle the retrieval of an object +* @param anImage resulting image +* @param location where image was located +*/ +typedef void (^handleRetrievedImage_t)(UIImage* __nullable anImage, NSURL* __nullable location); + +/*! @brief definition of a block callback after a list of faces (and locations) were extracted from a parent image + * @param error if failed this will be non-nil + * @param images resulting images each with a face + * @param locations where images are now located + + */ +typedef void (^handleExtractedFaces_t)( NSError* __nullable error, NSArray* __nullable images, NSArray* __nullable locations); + +/*! @brief instance-less class which caches images +* @note uses NSCache to handle low memory warnings. + * @see NSCache +*/ +@interface GHImageCache : NSObject + +/*! @brief method to store an image which can savely thrown away under low memory + * @param anImage image to cache + * @param aName unique name to associate with this image + +*/ ++(void) cacheImage:(UIImage*)anImage forName:(NSString*)aName; + +/*! @brief method to remove an image from the cache + * @param aName unique name of the image to be removed +*/ + ++(void) invalidateImageWithName:(NSString*)aName; + +/*! @brief retrieve the image of the given name +* @warning May return nil if there was a low memory situation +* @param uniqueName the unique name of the image to retrieve +* @return retrieved UIImage + +*/ ++(nullable UIImage*) uncacheImageForName:(NSString*)uniqueName; + +/*! @brief if you have an image in an NSData this will create an image, store it and return it +* @param imageData data in some standard format like PNG or JPEG +* @param preferredName what you want to call it. +* @param callback block to get called to when the operation is completed + +*/ ++(void) saveImageData:(NSData*)imageData withName:(NSString*)preferredName withCallback:(handleRetrievedImage_t)callback; + +/*! @brief store an image with a URL +* @param anImage to be stored, maybe be nil +* @param aFileURL to allow reload, cannot be nil +*/ ++(void) setCachedImage:(nullable UIImage*)anImage forURL:(NSURL*) aFileURL; + +/*! @brief makes a filename that is unigue (via a GUID) with a given extension +* @param extension extension like "jpg" +* @return fileName +*/ ++(NSString*) uniqueFilenameWithExtension:(NSString*)extension; + +/*! @brief return an image either from the memory cache, or from the provided URL +* @attention synchronous even though it takes a callback +* @param aURL file based URL which references an image +* @param retrievalCallback callback to accept the resulting image +*/ ++(void) retrieveCachedImageFromURL:(NSURL*)aURL intoCallback:(handleRetrievedImage_t)retrievalCallback; + +/*! @brief using a separate operation queue to grab the image either from the cache or the url +* @param aURL file URL to grab the image from if need be and to use as cache key +* @param retrievalCallback to accetp the resulting image +*/ ++(void) aSyncRetrieveCachedImageFromURL:(NSURL*)aURL intoCallback:(handleRetrievedImage_t)retrievalCallback; + +/*! @brief this will take an image, and extract faces from it, put them in the cache and store them to disk +* @param anImage image which may have human faces in it. +* @param callback returns a possible error or the faces and their locations +*/ ++(void) extractFaceImageFromPickedImage:(UIImage*) anImage withCallback:(handleExtractedFaces_t)callback; +@end + +/*! @brief If you want to be notified when an image is added to the cache use NSNotificationCenter to register this string + @memberof GHImageCache + */ +extern NSString* const kImageAddedToCacheNotificationName; // does not include faces being added via the picker. + extern NSString* const kImageAddedKey; + extern NSString* const kImageURLAddedKey; + +/*! @brief If you want to be notified when faces (plural) is added to the cache use NSNotificationCenter to register this string + @memberof GHImageCache + */ +extern NSString* const kFacesAddedToCacheNotificationName; + extern NSString* const kFacesAddedKey; + extern NSString* const kFacesURLsAddedKey; + + +extern const CGColorRenderingIntent kColoringRenderingIntent; + +NS_ASSUME_NONNULL_END diff --git a/vtm-ios/natives/SVGgh.framework/Headers/GHRenderable.h b/vtm-ios/natives/SVGgh.framework/Headers/GHRenderable.h new file mode 100644 index 00000000..4c028bd0 --- /dev/null +++ b/vtm-ios/natives/SVGgh.framework/Headers/GHRenderable.h @@ -0,0 +1,114 @@ +// +// GHRenderable.h +// SVGgh +// The MIT License (MIT) + +// Copyright (c) 2011-2014 Glenn R. Howes + +// 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. +// +// Created by Glenn Howes on 1/12/11. + +#if defined(__has_feature) && __has_feature(modules) +@import Foundation; +@import CoreGraphics; +#else +#import +#import +#endif + +@protocol SVGContext; + + +/* + ClippingType + When at all possible, try to use a vectored based mechanism for clipping. It seems so much cleaner and + less memory intensive than having to mask to an image. + */ +enum +{ + kNoClippingType = 0, + kPathClippingType, + kEvenOddPathClippingType, + kFontGlyphClippingType, + kImageClipplingType, + kMixedClippingType +}; + +typedef uint32_t ClippingType; + +NS_ASSUME_NONNULL_BEGIN + +/*! @brief a protocol adoptable by an object design to be rendered to the screen or to add to the clipping +* @see GHRenderableObject +*/ +@protocol GHRenderable +/*! @property transform +* @brief How this object is located in its parent's drawing context +*/ +@property (nonatomic, readonly) CGAffineTransform transform; +/*! @property hidden +* @brief if YES, the object will not be rendered +*/ +@property (nonatomic, readonly) BOOL hidden; + +/*! @property attributes +* @brief presumably this object will be an GHAttributedObject +*/ +@property(nonatomic, readonly) NSDictionary* __nullable attributes; + +/*! @brief draw the object into a Core Graphics context +* @param quartzContext the Core Graphics context into which to render +* @param svgContext state information about the document environment in which this object is being rendered (currentColor, etc.) +*/ +-(void) renderIntoContext:(CGContextRef)quartzContext withSVGContext:(id)svgContext; + +/*! @brief routine to retrieve this object or a sub-object during hit testing +* @param testPoint a Core Graphic point in the coordinate system of this object's parent +* @param svgContext state information about the document environment in which this object is being visited +*/ +-(nullable id) findRenderableObject:(CGPoint)testPoint withSVGContext:(id)svgContext; + +/*! @brief clip the appropriate region for this region +* @param quartzContext the Core Graphics context needing clipping +* @param svgContext state information about the document environment (parent attributes, etc.) +* @param objectBox rectangle of the object being clipped in the coordinate system of this object +*/ +-(void) addToClipForContext:(CGContextRef)quartzContext withSVGContext:(id)svgContext objectBoundingBox:(CGRect) objectBox; + +/*! @brief if possible add to the clipping path (as opposed to using a bitmap mask for clipping) +* @param quartzContext the Core Graphics context needing clipping +* @param svgContext state information about the document environment (parent attributes, etc.) +* @param objectBox rectangle of the object being clipped in the coordinate system of this object +*/ +-(void) addToClipPathForContext:(CGContextRef)quartzContext withSVGContext:(id)svgContext objectBoundingBox:(CGRect) objectBox; + +/*! @briefmethod to communicate the preferred clipping type that this object can provide (path clipping preferred) +@param svgContext state information about the document environment +*/ +-(ClippingType) getClippingTypeWithSVGContext:(id)svgContext; + +/*! @brief return a tight bounding box for the object's content +* @param svgContext state information about the document environment +*/ +-(CGRect) getBoundingBoxWithSVGContext:(id)svgContext; + +@end + +NS_ASSUME_NONNULL_END diff --git a/vtm-ios/natives/SVGgh.framework/Headers/GHSegmentedControl.h b/vtm-ios/natives/SVGgh.framework/Headers/GHSegmentedControl.h new file mode 100644 index 00000000..34258d5f --- /dev/null +++ b/vtm-ios/natives/SVGgh.framework/Headers/GHSegmentedControl.h @@ -0,0 +1,95 @@ +// +// GHSegmentedControl.h +// SVGgh +// The MIT License (MIT) + +// Copyright (c) 2015 Glenn R. Howes + +// 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. +// +// Created by Glenn Howes on 2015-03-26. +// Copyright (c) 2015 Generally Helpful Software. All rights reserved. +// +// Interface deliberately similar to UISegmentedControl + +#import "GHControl.h" + +@class SVGRenderer; + +NS_ASSUME_NONNULL_BEGIN + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000 +IB_DESIGNABLE // Cocapods users should add the use_frameworks! directive if this causes an error +#endif +@interface GHSegmentedControl : GHControl + +/*! @property momentary + * @brief if set, then don't keep showing selected state after tracking ends. Default is NO + */ +@property(nonatomic,getter=isMomentary) BOOL momentary; + +/*! @property numberOfSegments + + * @brief The number of tappable segments in this control + */ +@property(nonatomic,readonly) NSUInteger numberOfSegments; + +/*! @property numberOfSegments + + * @brief Scale the segments that aren't explicitly set + */ +@property(nonatomic) BOOL apportionsSegmentWidthsByContent; + +/*! @property selectedSegmentIndex +* @brief Ignored in momentary mode. returns last segment pressed. default is UISegmentedControlNoSegment until a segment + is pressed. The UIControlEventValueChanged action is invoked when the segment changes via a user event. set + to UISegmentedControlNoSegment to turn off selection + */ +@property(nonatomic) NSInteger selectedSegmentIndex; + +- (instancetype)initWithItems:(NSArray *)items; + +- (void)insertSegmentWithTitle:(NSString *)title atIndex:(NSUInteger)segment animated:(BOOL)animated; +- (void)insertSegmentWithRenderer:(SVGRenderer *)renderer atIndex:(NSUInteger)segment animated:(BOOL)animated; +- (void)insertSegmentWithRenderer:(SVGRenderer *)renderer accessibilityLabel:(nullable NSString*)accessibilityLabel atIndex:(NSUInteger)segment animated:(BOOL)animated; +- (void)removeSegmentAtIndex:(NSUInteger)segment animated:(BOOL)animated; +- (void)removeAllSegments; + +- (void)setTitle:(nullable NSString *)title forSegmentAtIndex:(NSUInteger)segment; +- (nullable NSString *)titleForSegmentAtIndex:(NSUInteger)segment; + +-(void) setRenderer:(nullable SVGRenderer *)renderer forSegmentedIndex:(NSUInteger)segment; +-(nullable SVGRenderer*) rendererForSegmentedIndex:(NSUInteger)segment; + +-(void) setAccessibilityLabel:(NSString *)accessibilityLabel forSegmentIndex:(NSUInteger)segment; +-(nullable NSString*)accessibilityLabelForSegmentedIndex:(NSUInteger)segment; + +- (void)setWidth:(CGFloat)width forSegmentAtIndex:(NSUInteger)segment; +- (CGFloat)widthForSegmentAtIndex:(NSUInteger)segment; + + +- (void)setEnabled:(BOOL)enabled forSegmentAtIndex:(NSUInteger)segment; // default is YES +- (BOOL)isEnabledForSegmentAtIndex:(NSUInteger)segment; + + + ++(void)makeSureLoaded; +@end + +NS_ASSUME_NONNULL_END diff --git a/vtm-ios/natives/SVGgh.framework/Headers/SVGContext.h b/vtm-ios/natives/SVGgh.framework/Headers/SVGContext.h new file mode 100644 index 00000000..fefa0d26 --- /dev/null +++ b/vtm-ios/natives/SVGgh.framework/Headers/SVGContext.h @@ -0,0 +1,99 @@ +// +// SVGContext.h +// SVGgh +// The MIT License (MIT) + +// Copyright (c) 2011-2014 Glenn R. Howes + +// 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. +// +// Created by Glenn Howes on 1/28/14. +// + +#if defined(__has_feature) && __has_feature(modules) +@import Foundation; +@import UIKit; +#else +#import +#import +#endif + +NS_ASSUME_NONNULL_BEGIN + +/*! @brief a protocol followed to communicate state when walking through a tree of SVG objects, passed into nodes/leaves in that tree + */ +@protocol SVGContext +/*! @brief makes a color for a given string found in such SVG attributes as fill, stroke, etc.. + * @param svgColorString a string such as 'blue', '#AAA', '#A7A2F9' or 'rgb(122, 255, 0)' which can be mapped to an RGB color + * @return a UIColor from the RGB color space + * @see UIColorFromSVGColorString + */ +-(nullable UIColor*) colorForSVGColorString:(NSString*)svgColorString; +/*! @brief make a URL relative to the document being parsed + * @param subPath a location inside the app's resource bundle + * @return an NSURL to some resource (hopefully) + */ +-(nullable NSURL*) relativeURL:(NSString*)subPath; + +/*! @brief make a URL + * @param absolutePath a file path + * @return an NSURL to some resource (hopefully) + */ +-(nullable NSURL*) absoluteURL:(NSString*)absolutePath; // sort of... + +/*! @brief find an object whose 'id' or maybe 'xml:id' property have the given name + * @param objectName the name key to look for + * @return some object (usually an id but not always + */ +-(nullable id) objectNamed:(NSString*)objectName; + +/*! @brief sometimes objects in SVG are referenced in the form 'URL(#aRef)'. This returns them. + * @param aLocation some object in this document probably + * @return some object (usually an id but not always + */ +-(nullable id) objectAtURL:(NSString*)aLocation; +/*! @brief sometimes SVG colors are specified as 'currentColor'. This sets the starting currentColor before the tree is visited. Good for colorizing artwork. + * @param startingCurrentColor a UIColor to start with + */ +-(void) setCurrentColor:(nullable UIColor*)startingCurrentColor; +/*! @brief the value for 'currentColor' at this moment in the process of visiting a document + */ +-(nullable UIColor*) currentColor; +/*! @brief the active language expected by the user like 'en' or 'sp' or 'zh' + */ +-(nullable NSString*) isoLanguage; + +/*! @brief if the SVG document specifies a 'non-scaling-stroke' this could be used to scale that. Rarely used. + */ +-(CGFloat) explicitLineScaling; + +/*! @brief Does this SVGDocument/renderer have Cascading Style Sheet based attributes. Rarely true. + */ +-(BOOL) hasCSSAttributes; + +/*! @brief Look through the CSS attributes for a given styling attribute. + * @param attributeName the name of the attribute like 'line-width' + * @param className the name of the CSS class like 'background' or some other arbitrary item + * @param entityName the name of the entity like 'rect' or 'polyline' + */ +-(nullable NSString*) attributeNamed:(NSString*)attributeName classes:(nullable NSArray*)listOfClasses entityName:(nullable NSString*)entityName; + +@end + +NS_ASSUME_NONNULL_END diff --git a/vtm-ios/natives/SVGgh.framework/Headers/SVGDocumentView.h b/vtm-ios/natives/SVGgh.framework/Headers/SVGDocumentView.h new file mode 100644 index 00000000..525fc8b5 --- /dev/null +++ b/vtm-ios/natives/SVGgh.framework/Headers/SVGDocumentView.h @@ -0,0 +1,98 @@ +// +// SVGDocumentView.h +// SVGgh +// The MIT License (MIT) + +// Copyright (c) 2011-2014 Glenn R. Howes + +// 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. +// +// Created by Glenn Howes on 1/15/11. + + +#if defined(__has_feature) && __has_feature(modules) +@import Foundation; +@import UIKit; +#else +#import +#import +#endif + +#import "GHRenderable.h" + +#ifndef IBInspectable +#define IBInspectable +#endif + +#ifndef IB_DESIGNABLE +#define IB_DESIGNABLE +#endif + +NS_ASSUME_NONNULL_BEGIN + +/* + * Note you can instantiate a SVGDocumentView in a storyboard or a XIB by dragging a UIView into your view and giving it a class of SVGDocumentView. + * You can configure the contents of the view by adding "User Defined Runtime Attributes" in XCode's "Identity Inspector" + *********************************** + ** Key Path *** Type *** Value ** + ---------------------------------------------------------------- + schemeNumber Number 3 + artworkPath String Artwork/Background + ----------------------------------------------------------------- + Will draw the contents of a file in your app's bundle with the path /Artwork/Background.svg + You may also want to set the "Mode" in the "Attributes Inspector" panel to "Scale to Fill" + */ + +@class SVGRenderer; +/*! @brief a view capable of hosting an SVGRenderer or rendering a chunk of SVG +*/ +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000 +IB_DESIGNABLE // Cocapods users should add the use_frameworks! directive if this causes an error +#endif +@interface SVGDocumentView : UIView + +/*! @property artworkPath +* @brief the text contents of an SVG document can be accessed via 'User Defined RuntimeAttributes' +*/ +@property(nonatomic, strong) IBInspectable NSString* __nullable artworkPath; + +/*! @property defaultColor + * @brief the color that 'currentColor' in SVG documents will be set to +*/ +@property(nonatomic, strong) IBInspectable UIColor* __nullable defaultColor; + +/*! @property renderer +* @brief a pre-configured SVGRenderer object which will be called to draw the content +*/ +@property(nonatomic, strong) SVGRenderer* __nullable renderer; + +/*! @property beTransparent + * @brief ignore the document's 'viewport-fill' property + */ +@property(nonatomic, assign) IBInspectable BOOL beTransparent; + +/*! @brief method that tries to locate an object located at the given point inside the coordinate system of the view +* @param testPoint a point in the coordinate system of the view +* @return an object hit by the point +*/ +-(nullable id) findRenderableObject:(CGPoint)testPoint; ++(void)makeSureLoaded; +@end + +NS_ASSUME_NONNULL_END diff --git a/vtm-ios/natives/SVGgh.framework/Headers/SVGParser.h b/vtm-ios/natives/SVGgh.framework/Headers/SVGParser.h new file mode 100644 index 00000000..19bcbe01 --- /dev/null +++ b/vtm-ios/natives/SVGgh.framework/Headers/SVGParser.h @@ -0,0 +1,82 @@ +// +// SVGParser.h +// SVGgh +// The MIT License (MIT) + +// Copyright (c) 2011-2014 Glenn R. Howes + +// 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. +// +// Created by Glenn Howes on 2/2/11. +// + +#if defined(__has_feature) && __has_feature(modules) +@import Foundation; +#else +#import +#endif + +NS_ASSUME_NONNULL_BEGIN + +/*! @brief object capable of reading in an SVG document in XML form +*/ +@interface SVGParser : NSObject +@property(nonatomic, readonly) NSError* __nullable parserError; +@property(nonatomic, readonly) NSDictionary* __nullable root; +@property(strong, nonatomic, readonly) NSURL* __nullable svgURL; + +/*! @brief init method which takes a URL reference to a .svg file +* @param url a reference to a standard .svg file +*/ +-(instancetype)initWithContentsOfURL:(NSURL *)url; + +/*! @brief init method which the name of a resource based SVG + * @param a string giving the name of the resource + * @commment might be from XCAsset data + */ +-(nullable instancetype) initWithResourceName:(NSString*)resourceName inBundle:(nullable NSBundle*)bundle; + +/*! @brief init method which takes an SVG document which already exists as a string +* @param utf8String string containing the SVG document +*/ +-(instancetype)initWithString:(NSString*)utf8String; + +/*! @brief init method which takes an SVG document which already exists as a string + * @param assetName string which will be based to constructor of NSDataAsset + * @param bundle optional bundle, if nil, the main bundle will be used. + */ +-(nullable instancetype) initWithDataAssetNamed:(NSString*)assetName withBundle:(nullable NSBundle*)bundle NS_AVAILABLE_IOS(9_0); + + +/*! @brief not allowing a standard init method + */ +-(nullable instancetype) init __attribute__((unavailable("init not available"))); + +/*! @brief method to create a URL relative to the URL used to create this object (assuming use of a URL to create it) +* @param subPath relative path to this parser's svgURL +*/ +-(nullable NSURL*) relativeURL:(NSString*)subPath; + +/*! @brief a routine to return an absolute URL +* @param aPath the file path to the resource +*/ +-(nullable NSURL*) absoluteURL:(NSString*)aPath; +@end + +NS_ASSUME_NONNULL_END diff --git a/vtm-ios/natives/SVGgh.framework/Headers/SVGPathGenerator.h b/vtm-ios/natives/SVGgh.framework/Headers/SVGPathGenerator.h new file mode 100644 index 00000000..bf21bd3e --- /dev/null +++ b/vtm-ios/natives/SVGgh.framework/Headers/SVGPathGenerator.h @@ -0,0 +1,116 @@ +// +// SVGPathGenerator.h +// SVGgh +// The MIT License (MIT) + +// Copyright (c) 2012-2014 Glenn R. Howes + +// 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. +// +// Created by Glenn Howes on 12/31/12. + + +#if defined(__has_feature) && __has_feature(modules) +@import Foundation; +@import CoreGraphics; +#else +#import +#import +#endif + +typedef enum SVGPathValidationError +{ + kPathParsingErrorNone = 0, + kPathParsingErrorMissingNumber, + kPathParsingErrorExpectedBoolean, + kPathParsingErrorExpectedDegrees, + kPathParsingErrorUnknownOperand, + kPathParsingErrorMissingStart, + kPathParsingErrorMissingVirtualControlPoint +}SVGPathValidationError; + +NS_ASSUME_NONNULL_BEGIN + +/*! @brief an object which encapsulates the results of trying to verify an SVG paths 'd' attribute +*/ +@interface PathValidationResult : NSObject + +/*! @property rangeOfError where in the path string was an error found +*/ +@property(nonatomic, readonly) NSRange rangeOfError; + +/*! @property error which of the enumerated SVGPathValidationError codes were found +*/ +@property(nonatomic, readonly) SVGPathValidationError errorCode; + +/*! @property operatorAtError which SVG path operation was the point at which an invalid string was reached +*/ +@property(nonatomic, readonly) unsigned char operatorAtError; + +/*! @property errorInLastOperation was the error (if any) found while parsing the last operation +*/ +@property(nonatomic, readonly) BOOL errorInLastOperation; + +/*! @property unexpectedCharacters a string of characters that should never be in an SVG path entity's 'd' attribute but were +*/ +@property(nonatomic, readonly) NSString* __nullable unexpectedCharacters; + +@end + +/*! @brief a bundle of mehtods that deal with the interaction between CGPaths and the text strings to build them +*/ +@interface SVGPathGenerator : NSObject +/*! @brief given a CGPathRef, convert it to an SVG Path +* @param aPath a path to be serialized +* @return a string appropriate for a 'd' attribute of an SVG path entity +*/ ++(nullable NSString*) svgPathFromCGPath:(CGPathRef)aPath; + +/*! @brief given a 'd' attribute from an SVG path entity, create a Core Graphics Path +* @param anSVGPath something like 'M33 11 H22 L 100 100 a 20 40 0 1 1 12 14 Z' +* @param aTransform an affine transform to apply to the result at the time of creation +*/ ++(nullable CGPathRef) newCGPathFromSVGPath:(NSString*)anSVGPath whileApplyingTransform:(CGAffineTransform)aTransform CF_RETURNS_RETAINED; + +/*! @brief given a SVG path in text form, return a bounding box (includes control points) +* @param anSVGPath a string from a path entity's 'd' attribute +* @return a rectangle which encapulates all the points on the path and any control points +*/ ++(CGRect) maxBoundingBoxForSVGPath:(NSString*)anSVGPath; + +/*! @brief validate the provided SVG path string +* @param anSVGPath a string from a path entity's 'd' attribute +* @return an object which should be checked for errors in parsing the path +*/ ++(nullable PathValidationResult*) findFailure:(NSString*)anSVGPath; + +/*! @brief given an SVG operator e.g. 'm', 'z', 'l', 'H', etc., give the number of expected parameters +* @param svgOperator one of the expected operators for an SVG path +* @return number of parameters needed for given operator, e.g. 'z' would return 0 +*/ ++(NSInteger) parametersNeededForOperator:(unsigned char)svgOperator; + +/*! @brief set of characters that should never appear in a 'd' attribute of an SVG path entity +* @return a set of characters like 'b' or '!' or whatever that never appear +*/ ++(NSCharacterSet*)invalidPathCharacters; + +@end +NS_ASSUME_NONNULL_END + diff --git a/vtm-ios/natives/SVGgh.framework/Headers/SVGPrinter.h b/vtm-ios/natives/SVGgh.framework/Headers/SVGPrinter.h new file mode 100644 index 00000000..a949ea51 --- /dev/null +++ b/vtm-ios/natives/SVGgh.framework/Headers/SVGPrinter.h @@ -0,0 +1,59 @@ +// +// SVGRenderer+Printing.h +// SVGgh +// The MIT License (MIT) + +// Copyright (c) 2011-2014 Glenn R. Howes + +// 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. +// Created by Glenn Howes on 2/4/14. +// + + + +#if defined(__has_feature) && __has_feature(modules) +@import Foundation; +@import UIKit; +#else +#import +#import +#endif + +@class SVGRenderer; + +typedef enum PrintingResults +{ + kSuccessfulPrintingResult = 0, + kCouldntCreatePrintingDataResult, + kCouldntInterfaceWithPrinterResult, + kPrintingErrorResult +}PrintingResults; + +typedef void(^printingCallback_t)(NSError* __nullable error, PrintingResults printingResult); + +NS_ASSUME_NONNULL_BEGIN + +@interface SVGPrinter :NSObject ++(void) printRenderer:(SVGRenderer*)renderer withJobName:(NSString*)jobName withCallback:(printingCallback_t)callback; + ++(void) printRenderer:(SVGRenderer*)renderer withJobName:(NSString*)jobName fromAnchorView:(nullable UIView*)anchorView withCallback:(printingCallback_t)callback; + +@end + +NS_ASSUME_NONNULL_END diff --git a/vtm-ios/natives/SVGgh.framework/Headers/SVGRenderer.h b/vtm-ios/natives/SVGgh.framework/Headers/SVGRenderer.h new file mode 100644 index 00000000..977c8e4e --- /dev/null +++ b/vtm-ios/natives/SVGgh.framework/Headers/SVGRenderer.h @@ -0,0 +1,82 @@ +// +// SVGRenderer.h +// SVGgh +// The MIT License (MIT) + +// Copyright (c) 2011-2014 Glenn R. Howes + +// 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. +// +// Created by Glenn Howes on 1/12/11. + +#if defined(__has_feature) && __has_feature(modules) +@import Foundation; +#else +#import +#endif + +#import "SVGParser.h" +#import "GHRenderable.h" +#import "SVGContext.h" +#import "GHCSSStyle.h" + +NS_ASSUME_NONNULL_BEGIN + +/*! @brief a class capable of rendering itself into a core graphics context +*/ +@interface SVGRenderer : SVGParser + +/*! @property viewRect + * @brief a set of flags that allow the dynamic manipulation of rendering styles (for instance, a focused tvOS image could use kPseudoClassFocused) + */ +@property (assign, nonatomic) CSSPseudoClassFlags cssPseudoClass; + +/*! @property viewRect +* @brief the intrinsic rect declared in the SVG document being rendered +*/ +@property (nonatomic, readonly) CGRect viewRect; + +/*! @brief a queue where it is convenient to renders when the main queue is not necessary +* @return a shared operation queue +*/ ++(NSOperationQueue*) rendererQueue; + +/*! @brief draw the SVG +* @param quartzContext context into which to draw, could be a CALayer, a PDF, an offscreen bitmap, whatever +*/ +-(void)renderIntoContext:(CGContextRef)quartzContext; + +/*! @brief try to locate an object that's been tapped +* @param testPoint a point in the coordinate system of this renderer +* @return an object which implements the GHRenderable protocol +*/ +-(nullable id) findRenderableObject:(CGPoint)testPoint; + +/*! @brief make a scaled image from the renderer + * @param maximumSize the maximum dimension in points to render into. + * @param scale same as a UIWindow's scale + * @return a UIImage + */ +-(UIImage*)asImageWithSize:(CGSize)maximumSize andScale:(CGFloat)scale; + +@end + +NS_ASSUME_NONNULL_END + + diff --git a/vtm-ios/natives/SVGgh.framework/Headers/SVGRendererLayer.h b/vtm-ios/natives/SVGgh.framework/Headers/SVGRendererLayer.h new file mode 100644 index 00000000..23ebc690 --- /dev/null +++ b/vtm-ios/natives/SVGgh.framework/Headers/SVGRendererLayer.h @@ -0,0 +1,72 @@ +// +// SVGRendererLayer.h +// SVGgh +// The MIT License (MIT) + +// Copyright (c) 2011-2014 Glenn R. Howes + +// 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. +// +// Created by Glenn Howes on 1/15/11. + +#if defined(__has_feature) && __has_feature(modules) +@import Foundation; +@import QuartzCore; +#else +#import +#import +#endif + + +#import "SVGRenderer.h" + +NS_ASSUME_NONNULL_BEGIN + +@protocol FillColorProtocol +-(nullable UIColor*) copyFillColor; +@end + +/*! @brief a layer which takes an SVGRenderer and uses it to draw itself +* @see SVGDocumentView +* @see SVGRenderer +*/ +@interface SVGRendererLayer : CALayer +/*! @property renderer +* @brief the object that does the actual drawing. +*/ +@property(nonatomic, strong) SVGRenderer* __nullable renderer; + +/*! @property defaultColor + * @brief the value for 'currentColor' when the SVG is rendered from the root element + */ +@property(nonatomic, strong) UIColor* __nullable defaultColor; + +/*! @property beTransparent + * @brief ignore the document's 'viewport-fill' property + */ +@property(nonatomic, assign) BOOL beTransparent; + +/*! @brief method that tries to locate an object located at the given point inside the coordinate system of the layer + * @param testPoint point in the coordinate system of the layer + * @return an object hit by the point + */ +-(nullable id) findRenderableObject:(CGPoint)testPoint; +@end + +NS_ASSUME_NONNULL_END diff --git a/vtm-ios/natives/SVGgh.framework/Headers/SVGTabBarItem.h b/vtm-ios/natives/SVGgh.framework/Headers/SVGTabBarItem.h new file mode 100644 index 00000000..73bc0bc2 --- /dev/null +++ b/vtm-ios/natives/SVGgh.framework/Headers/SVGTabBarItem.h @@ -0,0 +1,45 @@ +// +// SVGTabBarItem.h +// SVGgh +// +// Created by Glenn Howes on 7/9/15. +// Copyright © 2015 Generally Helpful. All rights reserved. +// + +#if defined(__has_feature) && __has_feature(modules) +@import Foundation; +@import UIKit; +#else +#import +#import +#endif + + +NS_ASSUME_NONNULL_BEGIN + +@interface SVGTabBarItem : UITabBarItem +/*! @property artworkPath + * @brief optional subpath to an svg file inside the resources folder, svg is displayed inside the button at appropriate size + * @attention do not append '.svg' + */ +@property(nonatomic, strong) IBInspectable NSString* artworkPath; +/*! @property selectedArtworkPath + * @brief optional subpath to an svg file inside the resources folder, svg is displayed inside the button at appropriate size. When button is in selected state. + * @attention do not append '.svg' + */ +@property(nonatomic, strong) IBInspectable NSString* __nullable selectedArtworkPath; +/*! @property baseColor + * @brief currentColor used when the tab is not selected + */ +@property(nonatomic, strong) IBInspectable UIColor* __nullable baseColor; +/*! @property baseColor + * @brief currentColor used when the tab is selected + */ +@property(nonatomic, strong) IBInspectable UIColor* __nullable selectedColor; + + ++(void)makeSureLoaded; +@end + + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/vtm-ios/natives/SVGgh.framework/Headers/SVGgh.h b/vtm-ios/natives/SVGgh.framework/Headers/SVGgh.h new file mode 100644 index 00000000..98482f16 --- /dev/null +++ b/vtm-ios/natives/SVGgh.framework/Headers/SVGgh.h @@ -0,0 +1,52 @@ +// +// SVGgh.h +// SVGgh +// The MIT License (MIT) + +// Copyright (c) 2011-2014 Glenn R. Howes + +// 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. + + +#if defined(__has_feature) && __has_feature(modules) +@import Foundation; +#else +#import +#endif + +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import // not yet implemented, somebody want to implement a CSS parser? + +/*! \brief Because views and buttons are dynamically instantiated from Storyboards and Nibs, code for their classes might not link in from a static library. Thus this method to make sure the class gets called at least once from code. +*/ +void MakeSureSVGghLinks(); \ No newline at end of file diff --git a/vtm-ios/natives/SVGgh.framework/Headers/SVGghLoader.h b/vtm-ios/natives/SVGgh.framework/Headers/SVGghLoader.h new file mode 100644 index 00000000..7050bb15 --- /dev/null +++ b/vtm-ios/natives/SVGgh.framework/Headers/SVGghLoader.h @@ -0,0 +1,47 @@ +// +// SVGghLoader.h +// SVGgh +// +// Created by Glenn Howes on 4/27/16. +// Copyright © 2016 Generally Helpful. All rights reserved. +// + +#import +NS_ASSUME_NONNULL_BEGIN +@class SVGRenderer; + +@protocol SVGghLoader +/*! @brief method to retrieve an SVGRenderer + * @param identifier (a subPath or an XCAsset name for instance + * @param bundle usually nil + * @return an SVGRender if one can be found + */ +-(nullable SVGRenderer*) loadRenderForSVGIdentifier:(NSString*)identifier inBundle:(nullable NSBundle*)bundle; +@end + +typedef NS_ENUM(NSInteger, SVGghLoaderType) +{ + SVGghLoaderTypeDefault, + SVGghLoaderTypePath, + SVGghLoaderTypeDataXCAsset // only available on iOS 9 or above +}; + + +@interface SVGghLoaderManager: NSObject +/*! @brief method to retrieve the loader used by the UI elements + * @return the loader + */ ++(id) loader; + + +/*! @brief method to retrieve an SVGRenderer + * @param loader the loader to use by the widget classes. + */ ++(void) setLoader:(nullable id)loader; // call only once, passing null will return to th + ++(void) setLoaderToType:(SVGghLoaderType)type; + +@end + + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/vtm-ios/natives/SVGgh.framework/Headers/SVGtoPDFConverter.h b/vtm-ios/natives/SVGgh.framework/Headers/SVGtoPDFConverter.h new file mode 100644 index 00000000..0067f279 --- /dev/null +++ b/vtm-ios/natives/SVGgh.framework/Headers/SVGtoPDFConverter.h @@ -0,0 +1,59 @@ +// +// SVGRenderer+PDF.h +// SVGgh +// The MIT License (MIT) + +// Copyright (c) 2011-2014 Glenn R. Howes + +// 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. +// Created by Glenn Howes on 2/4/14. +// +#if defined(__has_feature) && __has_feature(modules) +@import Foundation; +@import CoreGraphics; +#else +#import +#import +#endif + +@class SVGRenderer; + +NS_ASSUME_NONNULL_BEGIN + +typedef void(^renderPDFCallback_t)(NSData* __nullable pdfData); + + + +@interface SVGtoPDFConverter : NSObject +/*! @brief call to create a PDF, does so on another queue +* @param aRenderer a configured renderer +* @param callback the block to get called when done +* @attention will callback on another queue may return nil pdfData +*/ ++(void) createPDFFromRenderer:(SVGRenderer*)aRenderer intoCallback:(renderPDFCallback_t)callback; +@end + +/*! \brief utility method to create a PDF context +* \param mediaRect the resulting PDFs boundary (zero origin preferred) +* \param theData an allocated but empty block of data which will be filled with the PDF +* \return a Core Graphics context. Caller responsible for disposal. +*/ +__nullable CGContextRef CreatePDFContext(const CGRect mediaRect, CFMutableDataRef theData); + +NS_ASSUME_NONNULL_END diff --git a/vtm-ios/natives/SVGgh.framework/Info.plist b/vtm-ios/natives/SVGgh.framework/Info.plist new file mode 100644 index 00000000..e6c48faa Binary files /dev/null and b/vtm-ios/natives/SVGgh.framework/Info.plist differ diff --git a/vtm-ios/natives/SVGgh.framework/Modules/module.modulemap b/vtm-ios/natives/SVGgh.framework/Modules/module.modulemap new file mode 100644 index 00000000..6b28c5f7 --- /dev/null +++ b/vtm-ios/natives/SVGgh.framework/Modules/module.modulemap @@ -0,0 +1,6 @@ +framework module SVGgh { + umbrella header "SVGgh.h" + + export * + module * { export * } +} diff --git a/vtm-ios/natives/SVGgh.framework/SVGgh b/vtm-ios/natives/SVGgh.framework/SVGgh new file mode 100755 index 00000000..c6a4e257 Binary files /dev/null and b/vtm-ios/natives/SVGgh.framework/SVGgh differ diff --git a/vtm-ios/robovm.xml b/vtm-ios/robovm.xml index 5f502da2..3b964802 100644 --- a/vtm-ios/robovm.xml +++ b/vtm-ios/robovm.xml @@ -36,7 +36,11 @@ natives/libvtm-jni.a + + natives + + SVGgh UIKit OpenGLES QuartzCore diff --git a/vtm-ios/src/org/oscim/ios/backend/IosBitmap.java b/vtm-ios/src/org/oscim/ios/backend/IosBitmap.java index 065dd9ac..b77e1777 100644 --- a/vtm-ios/src/org/oscim/ios/backend/IosBitmap.java +++ b/vtm-ios/src/org/oscim/ios/backend/IosBitmap.java @@ -122,6 +122,25 @@ public class IosBitmap implements Bitmap { image.dispose(); } + /** + * protected constructor for create IosBitmap from IosSvgBitmap + * @param image + */ + protected IosBitmap(UIImage image){ + CGImage cgiIimage = image.getCGImage(); + this.width = (int) cgiIimage.getWidth(); + this.height = (int) cgiIimage.getHeight(); + this.cgBitmapContext = CGBitmapContext.create(width, height, 8, 4 * width, + CGColorSpace.createDeviceRGB(), CGImageAlphaInfo.PremultipliedLast); + + this.cgBitmapContext.drawImage(new CGRect(0, 0, width, height), cgiIimage); + + // can dispose helper images for release memory + image.dispose(); + cgiIimage.dispose(); + + } + @Override public int getWidth() { diff --git a/vtm-ios/src/org/oscim/ios/backend/IosGraphics.java b/vtm-ios/src/org/oscim/ios/backend/IosGraphics.java index d547357f..f7365229 100644 --- a/vtm-ios/src/org/oscim/ios/backend/IosGraphics.java +++ b/vtm-ios/src/org/oscim/ios/backend/IosGraphics.java @@ -63,8 +63,12 @@ public class IosGraphics extends CanvasAdapter { @Override protected Bitmap decodeSvgBitmapImpl(InputStream inputStream) { - // TODO - return null; + try { + return new IosSvgBitmap(inputStream); + } catch (IOException e) { + log.error("decodeSvgImpl", e); + return null; + } } @Override diff --git a/vtm-ios/src/org/oscim/ios/backend/IosPaint.java b/vtm-ios/src/org/oscim/ios/backend/IosPaint.java index 7b0b24e0..8f4f437b 100644 --- a/vtm-ios/src/org/oscim/ios/backend/IosPaint.java +++ b/vtm-ios/src/org/oscim/ios/backend/IosPaint.java @@ -269,7 +269,6 @@ public class IosPaint implements Paint { fontHeight = (float) ctFont.getBoundingBox().getHeight(); font = ctFont.as(UIFont.class); - log.debug("Put Font to buffer :" + key); fontHashMap.put(key, font); } diff --git a/vtm-ios/src/org/oscim/ios/backend/IosSvgBitmap.java b/vtm-ios/src/org/oscim/ios/backend/IosSvgBitmap.java new file mode 100644 index 00000000..870aa96b --- /dev/null +++ b/vtm-ios/src/org/oscim/ios/backend/IosSvgBitmap.java @@ -0,0 +1,87 @@ +/* + * Copyright 2016 Longri + * + * This program is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with + * this program. If not, see . + */ +package org.oscim.ios.backend; + + +import org.oscim.backend.CanvasAdapter; +import org.robovm.apple.coregraphics.CGRect; +import org.robovm.apple.coregraphics.CGSize; +import org.robovm.apple.uikit.UIImage; +import svg.SVGRenderer; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; + +/** + * Created by Longri on 17.07.16. + */ +public class IosSvgBitmap extends IosBitmap { + private static final float DEFAULT_SIZE = 400f; + + /** + * Constructor
+ * @param inputStream + * @throws IOException + */ + public IosSvgBitmap(InputStream inputStream) throws IOException { + super(getUIImage(inputStream)); + } + + //get UIImage from SVG file + private static UIImage getUIImage(InputStream inputStream) { + String svg = getStringFromInputStream(inputStream); + SVGRenderer renderer = new SVGRenderer(svg); + CGRect viewRect = renderer.getViewRect(); + + float scaleFactor = CanvasAdapter.dpi / 240; + double scale = scaleFactor / Math.sqrt((viewRect.getHeight() * viewRect.getWidth()) / DEFAULT_SIZE); + + float bitmapWidth = (float) (viewRect.getWidth() * scale); + float bitmapHeight = (float) (viewRect.getHeight() * scale); + + return renderer.asImageWithSize(new CGSize(bitmapWidth, bitmapHeight), 1); + } + + + // convert InputStream to String + private static String getStringFromInputStream(InputStream is) { + + BufferedReader br = null; + StringBuilder sb = new StringBuilder(); + + String line; + try { + + br = new BufferedReader(new InputStreamReader(is)); + while ((line = br.readLine()) != null) { + sb.append(line); + } + + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (br != null) { + try { + br.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return sb.toString(); + } +} diff --git a/vtm-ios/src/svg/GHRenderable.java b/vtm-ios/src/svg/GHRenderable.java new file mode 100644 index 00000000..d01e90fa --- /dev/null +++ b/vtm-ios/src/svg/GHRenderable.java @@ -0,0 +1,15 @@ +package svg; + +import org.robovm.apple.coregraphics.CGAffineTransform; +import org.robovm.apple.foundation.NSObjectProtocol; +import org.robovm.objc.annotation.Property; + +public interface GHRenderable extends NSObjectProtocol{ + @Property(selector = "transform") + public CGAffineTransform getTransform(); + + @Property(selector = "hidden") + public boolean isHidden(); + + +} diff --git a/vtm-ios/src/svg/SVGContext.java b/vtm-ios/src/svg/SVGContext.java new file mode 100644 index 00000000..0dbe2b7b --- /dev/null +++ b/vtm-ios/src/svg/SVGContext.java @@ -0,0 +1,14 @@ +package svg; + +import org.robovm.apple.foundation.NSObject; +import org.robovm.apple.uikit.UIColor; +import org.robovm.objc.annotation.Method; + +public interface SVGContext { + @Method(selector = "colorForSVGColorString:") + public UIColor colorForSVGColorString(String svgColorString); + + @Method(selector = "objectAtURL:") + public NSObject objectAtURL(String aLocation); + +} diff --git a/vtm-ios/src/svg/SVGParser.java b/vtm-ios/src/svg/SVGParser.java new file mode 100644 index 00000000..fe46bcf4 --- /dev/null +++ b/vtm-ios/src/svg/SVGParser.java @@ -0,0 +1,31 @@ +package svg; + +import org.robovm.apple.foundation.NSError; +import org.robovm.apple.foundation.NSObject; +import org.robovm.objc.ObjCRuntime; +import org.robovm.objc.annotation.Method; +import org.robovm.objc.annotation.NativeClass; +import org.robovm.objc.annotation.Property; +import org.robovm.rt.bro.annotation.Library; +import org.robovm.rt.bro.annotation.Pointer; +import org.robovm.rt.bro.ptr.Ptr; + +@Library(Library.INTERNAL) +@NativeClass("SVGParser") +public class SVGParser extends NSObject { + public static class SVGParserPtr extends Ptr {} + static { ObjCRuntime.bind(SVGParser.class); }/**/ + + public SVGParser() {}; + protected SVGParser(long handle) { super(handle); } + protected SVGParser(SkipInit skipInit) { super(skipInit); } + + public SVGParser(String utf8String) { super((SkipInit) null); initObject(init(utf8String)); } + + @Method(selector = "initWithString:") + protected native @Pointer long init(String utf8String); + + @Property(selector = "parserError") + public native NSError getParserError(); + +} diff --git a/vtm-ios/src/svg/SVGRenderer.java b/vtm-ios/src/svg/SVGRenderer.java new file mode 100644 index 00000000..503bd74e --- /dev/null +++ b/vtm-ios/src/svg/SVGRenderer.java @@ -0,0 +1,52 @@ +package svg; + +import org.robovm.apple.coregraphics.CGAffineTransform; +import org.robovm.apple.coregraphics.CGRect; +import org.robovm.apple.coregraphics.CGSize; +import org.robovm.apple.foundation.NSObject; +import org.robovm.apple.uikit.UIColor; +import org.robovm.apple.uikit.UIImage; +import org.robovm.objc.ObjCRuntime; +import org.robovm.objc.annotation.Method; +import org.robovm.objc.annotation.NativeClass; +import org.robovm.objc.annotation.Property; +import org.robovm.rt.bro.annotation.ByVal; +import org.robovm.rt.bro.annotation.Library; +import org.robovm.rt.bro.annotation.MachineSizedFloat; +import org.robovm.rt.bro.annotation.Pointer; +import org.robovm.rt.bro.ptr.Ptr; + +@Library(Library.INTERNAL) +@NativeClass("SVGRenderer") +public class SVGRenderer extends SVGParser implements SVGContext, GHRenderable { + public static class SVGRendererPtr extends Ptr {} + static { ObjCRuntime.bind(SVGRenderer.class); }/**/ + + public SVGRenderer() {}; + protected SVGRenderer(long handle) { super(handle); } + protected SVGRenderer(SkipInit skipInit) { super(skipInit); } + + public SVGRenderer(String utf8String) { super((SkipInit) null); initObject(init(utf8String)); } + + @Method(selector = "initWithString:") + protected native @Pointer long init(String utf8String); + + @Property(selector = "viewRect") + public native @ByVal CGRect getViewRect(); + + @Method(selector = "colorForSVGColorString:") + public native UIColor colorForSVGColorString(String svgColorString); + + @Method(selector = "objectAtURL:") + public native NSObject objectAtURL(String aLocation); + + @Property(selector = "transform") + public native CGAffineTransform getTransform(); + + @Property(selector = "hidden") + public native boolean isHidden(); + + @Method(selector = "asImageWithSize:andScale:") + public native UIImage asImageWithSize(@ByVal CGSize maximumSize, @MachineSizedFloat double scale); + +}