1 #include <CydiaSubstrate/CydiaSubstrate.h>
3 %apt Package: com.saurik.iphone.fid
4 %apt Author: Jay Freeman (saurik) <saurik@saurik.com>
6 %apt Name: Five Icon Dock
7 %apt Description: fits even more stuff right down there
8 %apt Depiction: http://cydia.saurik.com/info/com.saurik.iphone.fid/
9 %apt Tag: purpose::extension, role::enduser
11 %apt Depends: mobilesubstrate (>= 0.9.3005-1), firmware (>= 2.2), firmware (<< 3.0) | com.chpwn.iconsupport (>= 1.7.3-1)
12 %apt Conflicts: gsc.wildcat
14 %bundle com.apple.springboard
16 %flag -framework Foundation
18 #import <Foundation/NSArray.h>
19 #import <Foundation/NSAutoreleasePool.h>
20 #import <Foundation/NSNull.h>
22 #import <CoreGraphics/CGGeometry.h>
24 @interface ISIconSupport : NSObject {
27 + (ISIconSupport *) sharedInstance;
28 - (void) addExtension:(NSString *)name;
32 @interface SBDockIconListView : NSObject {
37 MSClassHook(SBButtonBar)
38 MSClassHook(SBDockIconListView)
40 MSClassHook(SBIconModel)
42 MSMetaClassHook(SBDockIconListView)
43 MSMetaClassHook(SBIconModel)
45 __attribute__((__constructor__))
46 static void MSFixClass() {
48 $SBIcon = objc_getClass("SBIconView");
51 MSInstanceMessageHook1(float, SBButtonBar, leftMarginForIconRowArray, NSArray *, row) {
52 return [row indexOfObject:[NSNull null]] == NSNotFound ? 4 : MSOldCall(row);
55 MSInstanceMessageHook0(int, SBButtonBar, maxIconColumns) {
59 MSClassMessageHook1(NSUInteger, SBDockIconListView, iconColumnsForInterfaceOrientation, NSInteger, orientation) {
63 static unsigned $SBButtonBar$count(SBButtonBar *self) {
64 MSIvarHook(NSArray *, _iconMatrix);
65 NSArray *row([_iconMatrix objectAtIndex:0]);
68 if (icon != [NSNull null])
73 MSInstanceMessageHook0(float, SBButtonBar, topIconPadding) {
74 return 313370 + $SBButtonBar$count(self);
77 MSInstanceMessageHook1(void, SBIcon, setOrigin, CGPoint, origin) {
78 unsigned count(origin.y);
85 else if (count > 10 || count < 0)
88 origin.x = (origin.x - 4) / 76 * 63 + 4;
95 MSInstanceMessageHook2(CGPoint, SBButtonBar, originForIconAtX,Y, int, x, int, y) {
96 CGPoint origin;//(MSOldCall(x, y, ));
97 //NSLog(@"f:%u,%u=(%f,%f)", x, y, origin.x, origin.y);
100 unsigned count($SBButtonBar$count(self)), gap;
101 unsigned space(320 - 60 * count);
104 gap = space / (count + 1);
105 else // I hate people who love Apple.
108 origin.x = (space - gap * (count - 1)) / 2 + (60 + gap) * x;
113 // XXX: merge with previous function if possible, but not until after iPhone 4
114 MSInstanceMessageHook2(CGPoint, SBDockIconListView, originForIconAtX,Y, int, x, int, y) {
115 CGPoint origin;//(MSOldCall(x, y, ));
116 //NSLog(@"f:%u,%u=(%f,%f)", x, y, origin.x, origin.y);
119 unsigned count([[self icons] count]), gap;
120 unsigned space(320 - 60 * count);
123 gap = space / (count + 1);
124 else // I hate people who love Apple.
127 origin.x = (space - gap * (count - 1)) / 2 + (60 + gap) * x;
132 // XXX: merge with previous functions if possible, but not until after iPhone 5S ;P
133 MSInstanceMessage1(CGPoint, SBDockIconListView, originForIconAtIndex, NSInteger, index) {
134 CGPoint origin(MSOldCall(0));
136 unsigned count([[self icons] count]), gap;
137 unsigned space(320 - 60 * count);
140 gap = space / (count + 1);
141 else // I hate people who love Apple.
144 origin.x = (space - gap * (count - 1)) / 2 + (60 + gap) * index;
150 NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
152 if (dlopen("/Library/MobileSubstrate/DynamicLibraries/IconSupport.dylib", RTLD_GLOBAL | RTLD_LAZY) != NULL)
153 if (Class $ISIconSupport = objc_getClass("ISIconSupport"))
154 [[$ISIconSupport sharedInstance] addExtension:@"com.saurik.iphone.fid"];
156 if (kCFCoreFoundationVersionNumber >= 800)
157 MSHookMessage($SBDockIconListView, @selector(originForIconAtIndex:), MSHake(SBDockIconListView$originForIconAtIndex$));