Permalink
Browse files

Add source code for CoconutKit 2.0.2

  • Loading branch information...
defagos committed Jan 16, 2013
1 parent 08436d2 commit 711b8b590f6f9b9571ee64cfa34f6932ff331be0
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -17,6 +17,7 @@
#import "HLSCursor.h"
#import "HLSError.h"
#import "HLSExpandingSearchBar.h"
+#import "HLSFileManager.h"
#import "HLSFloat.h"
#import "HLSKeyboardInformation.h"
#import "HLSLabel.h"
@@ -35,6 +36,7 @@
#import "HLSSlideshow.h"
#import "HLSStackController.h"
#import "HLSStackPushSegue.h"
+#import "HLSStandardFileManager.h"
#import "HLSSubtitleTableViewCell.h"
#import "HLSTableSearchDisplayViewController.h"
#import "HLSTableViewCell.h"
@@ -44,8 +44,8 @@
*
* Running animations (this includes animations which have been paused) are automatically paused and resumed (if they
* were running before) when the application enters, respectively exits background. Note that this mechanism works
- * perfectly within the iOS simulator and on the device, though views will appear to "jump" on the device (not within
- * the simulator). This is not a bug and has no negative effect on the animation behavior (in particular, delegate
+ * perfectly within the iOS simulator and on the device, though views will appear to "jump" on the device and on
+ * iOS >= 6 simulators. This is not a bug and has no negative effect on the animation behavior (in particular, delegate
* methods are still called correctly), but is a consequence of the application screenshot which is displayed when
* the application exits background. The screenshot made when the application enters background namely reflects the
* non-animated view / layer state, which explains why the views seem to jump.
@@ -71,6 +71,7 @@
NSUInteger m_currentRepeatCount;
NSTimeInterval m_remainingTimeBeforeStart; // the time remaining before the start time is reached
NSTimeInterval m_elapsedTime; // the currently elapsed time (does not include pauses)
+ BOOL m_runningBeforeEnteringBackground; // was the animation running before the application entered background?
BOOL m_pausedBeforeEnteringBackground; // was the animation paused before the application entered background?
BOOL m_running;
BOOL m_playing;
View
@@ -6,6 +6,8 @@
// Copyright 2011 Hortis. All rights reserved.
//
+#import "HLSAnimation.h"
+
// Macros
#define kCursorShadowOffsetDefault CGSizeMake(0, -1)
@@ -35,29 +37,29 @@
*
* Designated initializer: -initWithFrame:
*/
-@interface HLSCursor : UIView {
+@interface HLSCursor : UIView <HLSAnimationDelegate> {
@private
- NSArray *m_elementViews;
- CGFloat m_spacing;
+ NSArray *m_elementWrapperViews;
+ NSArray *m_elementWrapperViewSizeValues;
UIView *m_pointerView;
UIView *m_pointerContainerView;
CGSize m_pointerViewTopLeftOffset;
CGSize m_pointerViewBottomRightOffset;
+ NSTimeInterval m_animationDuration;
NSUInteger m_selectedIndex;
- BOOL m_dragging;
CGFloat m_initialDraggingXOffset;
- BOOL m_grabbed;
+ BOOL m_moved;
+ BOOL m_moving;
+ BOOL m_dragging;
+ BOOL m_holding;
+ BOOL m_creatingViews;
BOOL m_viewsCreated;
NSUInteger m_initialIndex;
+ CGFloat m_spacing;
id<HLSCursorDataSource> m_dataSource;
id<HLSCursorDelegate> m_delegate;
}
-/**
- * Spacing between elements displayed by the cursor (default is 20 px)
- */
-@property (nonatomic, assign) CGFloat spacing;
-
/**
* The pointer view, which can either be set programatically or using a xib. If nil, the default pointer will be used.
* If you use a custom view, be sure it can stretch properly since the pointer view frame will be adjusted depending
@@ -68,12 +70,19 @@
*/
@property (nonatomic, retain) IBOutlet UIView *pointerView;
+/**
+ * The duration of cursor animations
+ *
+ * Default is 0.2
+ */
+@property (nonatomic, assign) NSTimeInterval animationDuration;
+
/**
* Pointer view offsets. Use these offsets to make the pointer rectangle larger or smaller than the element it points
- * at. By default the pointer view frame is 10px larger in all directions
+ * at
*/
-@property (nonatomic, assign) CGSize pointerViewTopLeftOffset; // Default is (-10px, -10px)
-@property (nonatomic, assign) CGSize pointerViewBottomRightOffset; // Default is (10px, 10px)
+@property (nonatomic, assign) CGSize pointerViewTopLeftOffset; // Default is (-10px, -10px); set negative values to grow larger
+@property (nonatomic, assign) CGSize pointerViewBottomRightOffset; // Default is (10px, 10px); set negative values to grow larger
/**
* Get the currently selected element. During the time the pointer is moved the selected index is not updated. This value
@@ -84,8 +93,10 @@
/**
* Move the pointer to a specific element. This setter can also be used to set the initially selected element before the
* cursor is displayed (in this case, the animated parameter is ignored)
+ *
+ * If the animated property has been set to NO, the animated parameter is ignored
*/
-- (void)moveToIndex:(NSUInteger)index animated:(BOOL)animated;
+- (void)setSelectedIndex:(NSUInteger)index animated:(BOOL)animated;
/**
* Reload the cursor from the data source. The pointer is left at the same index where it was, except if the index
@@ -129,19 +140,26 @@
@protocol HLSCursorDelegate <NSObject>
@optional
+
+// Triggered when the user performs starts touching the cursor
+- (void)cursor:(HLSCursor *)cursor didTouchDownNearIndex:(NSUInteger)index;
+
// Triggered when the pointer leaves a selected element at a given index
- (void)cursor:(HLSCursor *)cursor didMoveFromIndex:(NSUInteger)index;
// Triggered when the pointer stops moving, selecting a new element
- (void)cursor:(HLSCursor *)cursor didMoveToIndex:(NSUInteger)index;
// Triggered when the user starts dragging the pointer
-- (void)cursorDidStartDragging:(HLSCursor *)cursor;
+- (void)cursorDidStartDragging:(HLSCursor *)cursor nearIndex:(NSUInteger)index;
// Triggered when the user is dragging the pointer. The nearest index is given as parameter
- (void)cursor:(HLSCursor *)cursor didDragNearIndex:(NSUInteger)index;
// Triggered when the user stops dragging the pointer
-- (void)cursorDidStopDragging:(HLSCursor *)cursor;
+- (void)cursorDidStopDragging:(HLSCursor *)cursor nearIndex:(NSUInteger)index;
+
+// Triggered when the user stops touching the cursor
+- (void)cursor:(HLSCursor *)cursor didTouchUpNearIndex:(NSUInteger)index;
@end
@@ -0,0 +1,103 @@
+//
+// HLSFileManager.h
+// CoconutKit
+//
+// Created by Samuel Défago on 12/13/12.
+// Copyright (c) 2012 Hortis. All rights reserved.
+//
+
+/**
+ * Concrete subclasses of HLSFileManager must implement the set of methods declared by the following protocol
+ */
+@protocol HLSFileManagerAbstract <NSObject>
+@optional
+
+/**
+ * Return the content of the file at the given location. Large files should be mapped into virtual memory
+ */
+- (NSData *)contentsOfFileAtPath:(NSString *)path error:(NSError **)pError;
+
+/**
+ * Create a file with the specified content at the given location
+ *
+ * Return YES iff successful
+ */
+- (BOOL)createFileAtPath:(NSString *)path contents:(NSData *)contents error:(NSError **)pError;
+
+/**
+ * Create a directory at the specified path (create intermediate directories if enabled, otherwise fails if the parent directory does not
+ * exist)
+ *
+ * Return YES iff successful
+ */
+- (BOOL)createDirectoryAtPath:(NSString *)path withIntermediateDirectories:(BOOL)withIntermediateDirectories error:(NSError **)pError;
+
+/**
+ * List the contents of the specified directory
+ */
+- (NSArray *)contentsOfDirectoryAtPath:(NSString *)path error:(NSError **)pError;
+
+/**
+ * Return YES iff the file or folder exists at the specified path (and whether it is a directory or not; you can pass NULL if you do not
+ * need this information)
+ */
+- (BOOL)fileExistsAtPath:(NSString *)path isDirectory:(BOOL *)pIsDirectory;
+
+/**
+ * Copy the file or directory at the specified path to a new location
+ *
+ * Return YES iff successful
+ */
+- (BOOL)copyItemAtPath:(NSString *)sourcePath toPath:(NSString *)destinationPath error:(NSError **)pError;
+
+/**
+ * Move the file or directory at the specified path to a new location
+ *
+ * Return YES iff successful
+ */
+- (BOOL)moveItemAtPath:(NSString *)sourcePath toPath:(NSString *)destinationPath error:(NSError **)pError;
+
+/**
+ * Remove the file or directory at the specified path
+ *
+ * Return YES iff successful
+ */
+- (BOOL)removeItemAtPath:(NSString *)path error:(NSError **)pError;
+
+@end
+
+/**
+ * Abstract class for file operations. Subclass and implement methods from the HLSFileManagerAbstract protocol to create
+ * your own concrete file management classes. Subclasses should be implemented in a thread-safe manner.
+ *
+ * For convenience, a default file manager is provided. By default it is simply an instance of HLSStandardFileManager,
+ * which corresponds to the usual behavior you can expect from NSFileManager. You can change the default file manager
+ * at any time if you want.
+ *
+ * Internally, CoconutKit uses the currently installed default file manager to perform disk read and write operations.
+ * By setting your own file manager as default manager, you can therefore tailor the way CoconutKit reads and writes
+ * data to meet the requirements of your application.
+ *
+ * For all methods, paths represent locations relative to the managed storage, and should be given using the standard
+ * notation /path/to/some/file.txt. The / at the beginning represents the storage root
+ *
+ * Designated initializer: -init
+ */
+@interface HLSFileManager : NSObject <HLSFileManagerAbstract>
+
+/**
+ * Set the default file manager. The previously installed one is returned
+ */
++ (HLSFileManager *)setDefaultManager:(HLSFileManager *)defaultManager;
+
+/**
+ * Return the current default file manager
+ */
++ (HLSFileManager *)defaultManager;
+
+/**
+ * Return YES iff the file or folder exists at the specified path
+ */
+- (BOOL)fileExistsAtPath:(NSString *)path;
+
+@end
@@ -51,41 +51,44 @@
}
/**
- * Create a model manager using the model file given as parameter (lookup is performed in the main bundle) and
- * saving data at the specified store path within an SQLite store (the store file name bears the model name).
- * If the store file already exists it is reused
+ * Create a model manager using the model file given as parameter (lookup is performed in the specified bundle,
+ * or in the main bundle if nil) and saving data at the specified store path within an SQLite store (the store
+ * file name bears the model name). If the store file already exists it is reused
*
* For information about the configuration and options parameters
* please refer to the documentation of
* - [NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:]
*/
+ (HLSModelManager *)SQLiteManagerWithModelFileName:(NSString *)modelFileName
+ inBundle:(NSBundle *)bundle
configuration:(NSString *)configuration
storeDirectory:(NSString *)storeDirectory
options:(NSDictionary *)options;
/**
- * Create a model manager using the model file given as parameter (lookup is performed in the main bundle) and
- * saving data in-memory
+ * Create a model manager using the model file given as parameter (lookup is performed in the specified bundle,
+ * or in the main bundle if nil) and saving data in-memory
*
* For information about the configuration and options parameters
* please refer to the documentation of
* - [NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:]
*/
+ (HLSModelManager *)inMemoryModelManagerWithModelFileName:(NSString *)modelFileName
+ inBundle:(NSBundle *)bundle
configuration:(NSString *)configuration
options:(NSDictionary *)options;
/**
- * Create a model manager using the model file given as parameter (lookup is performed in the main bundle) and
- * saving data at the specified store path within a binary file (the store file name bears the model name).
- * If the store file already exists it is reused
+ * Create a model manager using the model file given as parameter (lookup is performed in the specified bundle,
+ * or in the main bundle if nil) and saving data at the specified store path within a binary file (the store file
+ * name bears the model name). If the store file already exists it is reused
*
* For information about the configuration and options parameters
* please refer to the documentation of
* - [NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:]
*/
+ (HLSModelManager *)binaryModelManagerWithModelFileName:(NSString *)modelFileName
+ inBundle:(NSBundle *)bundle
configuration:(NSString *)configuration
storeDirectory:(NSString *)storeDirectory
options:(NSDictionary *)options;
@@ -125,8 +128,8 @@
+ (void)deleteObjectFromCurrentModelContext:(NSManagedObject *)managedObject;
/**
- * Create a model manager using the model file given as parameter (lookup is performed in the main bundle), and
- * saving it in the specified directory.
+ * Create a model manager using the model file given as parameter (lookup is performed in the specified bundle,
+ * or in the main bundle if nil), and saving it in the specified directory.
*
* For information about the storeType, configuration and options parameters
* please refer to the documentation of
@@ -138,7 +141,8 @@
* Convenience constructors have been provided for easy instantiation of the most common store types and are the
* preferred way of instantiating model managers.
*/
-- (id)initWithModelFileName:(NSString *)modelFileName
+- (id)initWithModelFileName:(NSString *)modelFileName
+ inBundle:(NSBundle *)bundle
storeType:(NSString *)storeType
configuration:(NSString *)configuration
storeDirectory:(NSString *)storeDirectory
@@ -148,6 +152,8 @@
*/
- (HLSModelManager *)duplicate;
+- (BOOL)migrateStoreToURL:(NSURL *)url withStoreType:(NSString *)storeType error:(NSError **)pError;
+
/**
* Access to Core Data internals
*/
@@ -146,8 +146,8 @@
* once the placeholder view controller has been displayed once.
*
* The order of the outlets in an IBOutletCollection is unreliable (it is sadly not the order in which they are bound
- * in the nib). To fix this, the placeholderViews property expects you to index placeholder views using the UIView tag
- * property, and will sort them in increasing order
+ * in the nib). Though this issue seems to affect only storyboards on iOS 5 and 6, the placeholderViews property expects
+ * you to index placeholder views using the UIView tag property, and will sort them in increasing order
*/
@property (nonatomic, retain) IBOutletCollection(UIView) NSArray *placeholderViews;
@@ -0,0 +1,16 @@
+//
+// HLSStandardFileManager.h
+// CoconutKit
+//
+// Created by Samuel Défago on 12/13/12.
+// Copyright (c) 2012 Hortis. All rights reserved.
+//
+
+#import "HLSFileManager.h"
+
+/**
+ * A standard NSFileManager-based file manager
+ */
+@interface HLSStandardFileManager : HLSFileManager
+
+@end
Oops, something went wrong.

0 comments on commit 711b8b5

Please sign in to comment.