3 #import <Foundation/NSArray.h>
4 #import <Foundation/NSNull.h>
5 #import <CoreGraphics/CGGeometry.h>
6 #import <SpringBoard/SBButtonBar.h>
7 #import <SpringBoard/SBIcon.h>
9 MSHook(float, SBButtonBar$leftMarginForIconRowArray$, SBButtonBar *self, SEL sel, NSArray *row) {
10 return [row indexOfObject:[NSNull null]] == NSNotFound ? 4 : _SBButtonBar$leftMarginForIconRowArray$(self, sel, row);
13 static int $SBButtonBar$maxIconColumns(SBButtonBar *self, SEL sel) {
17 static unsigned $SBButtonBar$count(SBButtonBar *self) {
18 NSArray *&_iconMatrix(MSHookIvar<NSArray *>(self, "_iconMatrix"));
19 NSArray *row([_iconMatrix objectAtIndex:0]);
22 if (icon != [NSNull null])
27 static float $SBButtonBar$topIconPadding(SBButtonBar *self, SEL sel) {
28 return $SBButtonBar$count(self);
31 MSHook(void, SBIcon$setOrigin$, SBIcon *self, SEL sel, CGPoint origin) {
32 unsigned count(origin.y);
33 //NSLog(@"C:%u=(%f,%f)", count, origin.x, origin.y);
35 if (count < 70 && count > 40)
37 else if (count > 10 || count < 0)
40 origin.x = (origin.x - 4) / 76 * 63 + 4;
44 _SBIcon$setOrigin$(self, sel, origin);
47 MSHook(CGPoint, SBButtonBar$originForIconAtX$Y$, SBButtonBar *self, SEL sel, int x, int y) {
48 CGPoint origin;//(_SBButtonBar$originForIconAtX$Y$(self, sel, x, y));
49 //NSLog(@"f:%u,%u=(%f,%f)", x, y, origin.x, origin.y);
52 unsigned count($SBButtonBar$count(self)), gap;
53 unsigned space(320 - 60 * count);
56 gap = space / (count + 1);
57 else // I hate people who love Apple.
60 origin.x = (space - gap * (count - 1)) / 2 + (60 + gap) * x;
65 extern "C" void TweakInitialize() {
66 Class $SBButtonBar(objc_getClass("SBButtonBar"));
67 _SBButtonBar$leftMarginForIconRowArray$ = MSHookMessage($SBButtonBar, @selector(leftMarginForIconRowArray:), &$SBButtonBar$leftMarginForIconRowArray$);
68 MSHookMessage($SBButtonBar, @selector(maxIconColumns), &$SBButtonBar$maxIconColumns);
69 MSHookMessage($SBButtonBar, @selector(topIconPadding), &$SBButtonBar$topIconPadding);
70 _SBButtonBar$originForIconAtX$Y$ = MSHookMessage($SBButtonBar, @selector(originForIconAtX:Y:), &$SBButtonBar$originForIconAtX$Y$);
72 Class $SBIcon(objc_getClass("SBIcon"));
73 _SBIcon$setOrigin$ = MSHookMessage($SBIcon, @selector(setOrigin:), &$SBIcon$setOrigin$);