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>
8 #import <SpringBoard/SBIconModel.h>
10 MSHook(float, SBButtonBar$leftMarginForIconRowArray$, SBButtonBar *self, SEL sel, NSArray *row) {
11 return [row indexOfObject:[NSNull null]] == NSNotFound ? 4 : _SBButtonBar$leftMarginForIconRowArray$(self, sel, row);
14 static int $SBButtonBar$maxIconColumns(SBButtonBar *self, SEL sel) {
18 static unsigned $SBButtonBar$count(SBButtonBar *self) {
19 NSArray *&_iconMatrix(MSHookIvar<NSArray *>(self, "_iconMatrix"));
20 NSArray *row([_iconMatrix objectAtIndex:0]);
23 if (icon != [NSNull null])
28 static float $SBButtonBar$topIconPadding(SBButtonBar *self, SEL sel) {
29 return 313370 + $SBButtonBar$count(self);
32 MSHook(void, SBIcon$setOrigin$, SBIcon *self, SEL sel, CGPoint origin) {
33 unsigned count(origin.y);
40 else if (count > 10 || count < 0)
43 origin.x = (origin.x - 4) / 76 * 63 + 4;
47 _SBIcon$setOrigin$(self, sel, origin);
50 MSHook(CGPoint, SBButtonBar$originForIconAtX$Y$, SBButtonBar *self, SEL sel, int x, int y) {
51 CGPoint origin;//(_SBButtonBar$originForIconAtX$Y$(self, sel, x, y));
52 //NSLog(@"f:%u,%u=(%f,%f)", x, y, origin.x, origin.y);
55 unsigned count($SBButtonBar$count(self)), gap;
56 unsigned space(320 - 60 * count);
59 gap = space / (count + 1);
60 else // I hate people who love Apple.
63 origin.x = (space - gap * (count - 1)) / 2 + (60 + gap) * x;
68 static int $SBIconModel$maxIconListCount(SBIconModel *self, SEL sel) {
72 extern "C" void TweakInitialize() {
73 Class $SBButtonBar(objc_getClass("SBButtonBar"));
74 MSHookMessage($SBButtonBar, @selector(leftMarginForIconRowArray:), MSHake(SBButtonBar$leftMarginForIconRowArray$));
75 MSHookMessage($SBButtonBar, @selector(maxIconColumns), &$SBButtonBar$maxIconColumns);
76 MSHookMessage($SBButtonBar, @selector(topIconPadding), &$SBButtonBar$topIconPadding);
77 MSHookMessage($SBButtonBar, @selector(originForIconAtX:Y:), MSHake(SBButtonBar$originForIconAtX$Y$));
79 Class $SBIcon(objc_getClass("SBIcon"));
80 MSHookMessage($SBIcon, @selector(setOrigin:), MSHake(SBIcon$setOrigin$));
82 Class $SBIconModel(objc_getClass("SBIconModel"));
83 Class $$SBIconModel(object_getClass($SBIconModel));
84 MSHookMessage($$SBIconModel, @selector(maxIconListCount), &$SBIconModel$maxIconListCount);