3 #import <Foundation/NSArray.h>
4 #import <Foundation/NSAutoreleasePool.h>
5 #import <Foundation/NSNull.h>
7 #import <CoreGraphics/CGGeometry.h>
9 #import <SpringBoard/SBButtonBar.h>
10 #import <SpringBoard/SBIcon.h>
11 #import <SpringBoard/SBIconModel.h>
13 @interface ISIconSupport : NSObject {
16 + (ISIconSupport *) sharedInstance;
17 - (void) addExtension:(NSString *)name;
21 @interface SBDockIconListView : NSObject {
26 MSClassHook(SBButtonBar)
27 MSClassHook(SBDockIconListView)
29 MSClassHook(SBIconModel)
31 MSMetaClassHook(SBDockIconListView)
32 MSMetaClassHook(SBIconModel)
34 __attribute__((__constructor__))
35 static void MSFixClass() {
37 $SBIcon = objc_getClass("SBIconView");
40 MSInstanceMessageHook1(float, SBButtonBar, leftMarginForIconRowArray, NSArray *, row) {
41 return [row indexOfObject:[NSNull null]] == NSNotFound ? 4 : MSOldCall(row);
44 MSInstanceMessageHook0(int, SBButtonBar, maxIconColumns) {
48 MSClassMessageHook1(int, SBDockIconListView, iconColumnsForInterfaceOrientation, int, orientation) {
52 static unsigned $SBButtonBar$count(SBButtonBar *self) {
53 MSIvarHook(NSArray *, _iconMatrix);
54 NSArray *row([_iconMatrix objectAtIndex:0]);
57 if (icon != [NSNull null])
62 MSInstanceMessageHook0(float, SBButtonBar, topIconPadding) {
63 return 313370 + $SBButtonBar$count(self);
66 MSInstanceMessageHook1(void, SBIcon, setOrigin, CGPoint, origin) {
67 unsigned count(origin.y);
74 else if (count > 10 || count < 0)
77 origin.x = (origin.x - 4) / 76 * 63 + 4;
84 MSInstanceMessageHook2(CGPoint, SBButtonBar, originForIconAtX,Y, int, x, int, y) {
85 CGPoint origin;//(MSOldCall(x, y, ));
86 //NSLog(@"f:%u,%u=(%f,%f)", x, y, origin.x, origin.y);
89 unsigned count($SBButtonBar$count(self)), gap;
90 unsigned space(320 - 60 * count);
93 gap = space / (count + 1);
94 else // I hate people who love Apple.
97 origin.x = (space - gap * (count - 1)) / 2 + (60 + gap) * x;
102 // XXX: merge with previous function if possible, but not until after iPhone 4
103 MSInstanceMessageHook2(CGPoint, SBDockIconListView, originForIconAtX,Y, int, x, int, y) {
104 CGPoint origin;//(MSOldCall(x, y, ));
105 //NSLog(@"f:%u,%u=(%f,%f)", x, y, origin.x, origin.y);
108 unsigned count([[self icons] count]), gap;
109 unsigned space(320 - 60 * count);
112 gap = space / (count + 1);
113 else // I hate people who love Apple.
116 origin.x = (space - gap * (count - 1)) / 2 + (60 + gap) * x;
121 /*MSClassMessageHook0(int, SBIconModel, maxIconListCount) {
126 NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
128 if (dlopen("/Library/MobileSubstrate/DynamicLibraries/IconSupport.dylib", RTLD_GLOBAL | RTLD_LAZY) != NULL)
129 if (Class $ISIconSupport = objc_getClass("ISIconSupport"))
130 [[$ISIconSupport sharedInstance] addExtension:@"com.saurik.iphone.fid"];