]> git.saurik.com Git - fiveicondock.git/blobdiff - Tweak.mm
Upgrading Five Icon Dock to new API.
[fiveicondock.git] / Tweak.mm
index 8e6a74d67471cd64b32717d47f2575c409a1d6d6..28e7ebb95ea608750a4f047540c866ddf2e4fb65 100644 (file)
--- a/Tweak.mm
+++ b/Tweak.mm
@@ -7,16 +7,22 @@
 #import <SpringBoard/SBIcon.h>
 #import <SpringBoard/SBIconModel.h>
 
-MSHook(float, SBButtonBar$leftMarginForIconRowArray$, SBButtonBar *self, SEL sel, NSArray *row) {
-    return [row indexOfObject:[NSNull null]] == NSNotFound ? 4 : _SBButtonBar$leftMarginForIconRowArray$(self, sel, row);
+MSHookClass(SBButtonBar)
+MSHookClass(SBIcon)
+MSHookClass(SBIconModel)
+
+MSHookMetaClass(SBIconModel)
+
+MSMessageHook1(float, SBButtonBar, leftMarginForIconRowArray, NSArray *row) {
+    return [row indexOfObject:[NSNull null]] == NSNotFound ? 4 : MSCall1(SBButtonBar, leftMarginForIconRowArray, row);
 }
 
-static int $SBButtonBar$maxIconColumns(SBButtonBar *self, SEL sel) {
-    return 5;
+MSMessageHook0(int, SBButtonBar, maxIconColumns) {
+    return 10;
 }
 
 static unsigned $SBButtonBar$count(SBButtonBar *self) {
-    NSArray *&_iconMatrix(MSHookIvar<NSArray *>(self, "_iconMatrix"));
+    MSIvar(NSArray *, _iconMatrix);
     NSArray *row([_iconMatrix objectAtIndex:0]);
     unsigned count(0);
     for (id icon in row)
@@ -25,11 +31,11 @@ static unsigned $SBButtonBar$count(SBButtonBar *self) {
     return count;
 }
 
-static float $SBButtonBar$topIconPadding(SBButtonBar *self, SEL sel) {
+MSMessageHook0(float, SBButtonBar, topIconPadding) {
     return 313370 + $SBButtonBar$count(self);
 }
 
-MSHook(void, SBIcon$setOrigin$, SBIcon *self, SEL sel, CGPoint origin) {
+MSMessageHook1(void, SBIcon, setOrigin, CGPoint origin) {
     unsigned count(origin.y);
     if (count < 313370)
         goto set;
@@ -44,11 +50,11 @@ MSHook(void, SBIcon$setOrigin$, SBIcon *self, SEL sel, CGPoint origin) {
 
     origin.y = 11;
   set:
-    _SBIcon$setOrigin$(self, sel, origin);
+    MSCall1(SBIcon, setOrigin, origin);
 }
 
-MSHook(CGPoint, SBButtonBar$originForIconAtX$Y$, SBButtonBar *self, SEL sel, int x, int y) {
-    CGPoint origin;//(_SBButtonBar$originForIconAtX$Y$(self, sel, x, y));
+MSMessageHook2(CGPoint, SBButtonBar, originForIconAtX,Y, int x, int y) {
+    CGPoint origin;//(_SBButtonBar$originForIconAtX$Y$(self, _cmd, x, y));
     //NSLog(@"f:%u,%u=(%f,%f)", x, y, origin.x, origin.y);
     origin.y = 11;
 
@@ -65,21 +71,6 @@ MSHook(CGPoint, SBButtonBar$originForIconAtX$Y$, SBButtonBar *self, SEL sel, int
     return origin;
 }
 
-static int $SBIconModel$maxIconListCount(SBIconModel *self, SEL sel) {
+MSMetaMessageHook0(int, SBIconModel, maxIconListCount) {
     return 16;
 }
-
-extern "C" void TweakInitialize() {
-    Class $SBButtonBar(objc_getClass("SBButtonBar"));
-    MSHookMessage($SBButtonBar, @selector(leftMarginForIconRowArray:), MSHake(SBButtonBar$leftMarginForIconRowArray$));
-    MSHookMessage($SBButtonBar, @selector(maxIconColumns), &$SBButtonBar$maxIconColumns);
-    MSHookMessage($SBButtonBar, @selector(topIconPadding), &$SBButtonBar$topIconPadding);
-    MSHookMessage($SBButtonBar, @selector(originForIconAtX:Y:), MSHake(SBButtonBar$originForIconAtX$Y$));
-
-    Class $SBIcon(objc_getClass("SBIcon"));
-    MSHookMessage($SBIcon, @selector(setOrigin:), MSHake(SBIcon$setOrigin$));
-
-    Class $SBIconModel(objc_getClass("SBIconModel"));
-    Class $$SBIconModel(object_getClass($SBIconModel));
-    MSHookMessage($$SBIconModel, @selector(maxIconListCount), &$SBIconModel$maxIconListCount);
-}