]> git.saurik.com Git - winterboard.git/blobdiff - Library.mm
Fixed lock widget overlaps.
[winterboard.git] / Library.mm
index e46acb62079541682b37dd35805ceb780649182c..2a4483a42e548240f3e2377ed76c5918ff073cc0 100644 (file)
 #import <SpringBoard/SBApplication.h>
 #import <SpringBoard/SBApplicationIcon.h>
 #import <SpringBoard/SBAppWindow.h>
+#import <SpringBoard/SBAwayView.h>
 #import <SpringBoard/SBBookmarkIcon.h>
 #import <SpringBoard/SBButtonBar.h>
 #import <SpringBoard/SBCalendarIconContentsView.h>
 #import <SpringBoard/SBContentLayer.h>
 #import <SpringBoard/SBIconController.h>
 #import <SpringBoard/SBIconLabel.h>
+#import <SpringBoard/SBIconList.h>
 #import <SpringBoard/SBIconModel.h>
-#import <SpringBoard/SBSlidingAlertDisplay.h>
 #import <SpringBoard/SBStatusBarContentsView.h>
 #import <SpringBoard/SBStatusBarController.h>
 #import <SpringBoard/SBStatusBarOperatorNameView.h>
@@ -94,6 +95,7 @@ Class $UIToolbar;
 
 Class $SBApplication;
 Class $SBApplicationIcon;
+Class $SBAwayView;
 Class $SBBookmarkIcon;
 Class $SBButtonBar;
 Class $SBCalendarIconContentsView;
@@ -101,8 +103,8 @@ Class $SBContentLayer;
 Class $SBIconBadge;
 Class $SBIconController;
 Class $SBIconLabel;
+Class $SBIconList;
 Class $SBIconModel;
-Class $SBSlidingAlertDisplay;
 Class $SBStatusBarContentsView;
 Class $SBStatusBarController;
 Class $SBStatusBarOperatorNameView;
@@ -686,14 +688,14 @@ MSHook(id, SBContentLayer$initWithSize$, SBContentLayer *self, SEL sel, CGSize s
     return self;
 }
 
-MSHook(void, SBSlidingAlertDisplay$updateDesktopImage$, SBSlidingAlertDisplay *self, SEL sel, UIImage *image) {
+MSHook(void, SBAwayView$updateDesktopImage$, SBAwayView *self, SEL sel, UIImage *image) {
     NSString *path = $getTheme$([NSArray arrayWithObject:@"LockBackground.html"]);
     UIView *&_backgroundView(MSHookIvar<UIView *>(self, "_backgroundView"));
 
     if (path != nil && _backgroundView != nil)
         path = nil;
 
-    _SBSlidingAlertDisplay$updateDesktopImage$(self, sel, image);
+    _SBAwayView$updateDesktopImage$(self, sel, image);
 
     if (path != nil) {
         CGRect bounds = [self bounds];
@@ -856,29 +858,54 @@ MSHook(void, SBStatusBarTimeView$drawRect$, SBStatusBarTimeView *self, SEL sel,
 }
 
 @interface UIView (WinterBoard)
-- (bool) wb$isImageView;
+- (bool) wb$isWBImageView;
 @end
 
 @implementation UIView (WinterBoard)
 
-- (bool) wb$isImageView {
+- (bool) wb$isWBImageView {
     return false;
 }
 
 @end
 
-@interface UIImageView (WinterBoard)
-- (bool) wb$isImageView;
+@interface WBImageView : UIImageView {
+}
+
+- (bool) wb$isWBImageView;
+- (void) wb$updateFrame;
 @end
 
-@implementation UIImageView (WinterBoard)
+@implementation WBImageView
 
-- (bool) wb$isImageView {
+- (bool) wb$isWBImageView {
     return true;
 }
 
+- (void) wb$updateFrame {
+    CGRect frame([self frame]);
+    frame.origin.y = 0;
+
+    for (UIView *view(self); ; ) {
+        view = [view superview];
+        if (view == nil)
+            break;
+        frame.origin.y -= [view frame].origin.y;
+    }
+
+    [self setFrame:frame];
+}
+
 @end
 
+MSHook(void, SBIconList$setFrame$, SBIconList *self, SEL sel, CGRect frame) {
+    NSArray *subviews([self subviews]);
+    WBImageView *view([subviews count] == 0 ? nil : [subviews objectAtIndex:0]);
+    if (view != nil && [view wb$isWBImageView])
+        [view wb$updateFrame];
+    _SBIconList$setFrame$(self, sel, frame);
+}
+
 MSHook(void, SBIconController$noteNumberOfIconListsChanged, SBIconController *self, SEL sel) {
     SBIconModel *&_iconModel(MSHookIvar<SBIconModel *>(self, "_iconModel"));
     NSArray *lists([_iconModel iconLists]);
@@ -887,13 +914,16 @@ MSHook(void, SBIconController$noteNumberOfIconListsChanged, SBIconController *se
         if (NSString *path = $getTheme$([NSArray arrayWithObject:[NSString stringWithFormat:@"Page%u.png", i]])) {
             SBIconList *list([lists objectAtIndex:i]);
             NSArray *subviews([list subviews]);
-            UIImageView *view([subviews count] == 0 ? nil : [subviews objectAtIndex:0]);
-            if (view == nil || ![view wb$isImageView]) {
-                view = [[[UIImageView alloc] init] autorelease];
+
+            WBImageView *view([subviews count] == 0 ? nil : [subviews objectAtIndex:0]);
+            if (view == nil || ![view wb$isWBImageView]) {
+                view = [[[WBImageView alloc] init] autorelease];
                 [list insertSubview:view atIndex:0];
             }
+
             UIImage *image([UIImage imageWithContentsOfFile:path]);
             [view setImage:image];
+            [view wb$updateFrame];
         }
 
     return _SBIconController$noteNumberOfIconListsChanged(self, sel);
@@ -1256,6 +1286,7 @@ extern "C" void WBInitialize() {
 
         $SBApplication = objc_getClass("SBApplication");
         $SBApplicationIcon = objc_getClass("SBApplicationIcon");
+        $SBAwayView = objc_getClass("SBAwayView");
         $SBBookmarkIcon = objc_getClass("SBBookmarkIcon");
         $SBButtonBar = objc_getClass("SBButtonBar");
         $SBCalendarIconContentsView = objc_getClass("SBCalendarIconContentsView");
@@ -1263,8 +1294,8 @@ extern "C" void WBInitialize() {
         $SBIconBadge = objc_getClass("SBIconBadge");
         $SBIconController = objc_getClass("SBIconController");
         $SBIconLabel = objc_getClass("SBIconLabel");
+        $SBIconList = objc_getClass("SBIconList");
         $SBIconModel = objc_getClass("SBIconModel");
-        $SBSlidingAlertDisplay = objc_getClass("SBSlidingAlertDisplay");
         $SBStatusBarContentsView = objc_getClass("SBStatusBarContentsView");
         $SBStatusBarController = objc_getClass("SBStatusBarController");
         $SBStatusBarOperatorNameView = objc_getClass("SBStatusBarOperatorNameView");
@@ -1287,10 +1318,12 @@ extern "C" void WBInitialize() {
         WBRename(SBIconLabel, initWithSize:label:, initWithSize$label$);
         WBRename(SBIconLabel, setInDock:, setInDock$);
 
+        WBRename(SBIconList, setFrame:, setFrame$);
+
         WBRename(SBIconModel, cacheImageForIcon:, cacheImageForIcon$);
         WBRename(SBIconModel, getCachedImagedForIcon:, getCachedImagedForIcon$);
 
-        WBRename(SBSlidingAlertDisplay, updateDesktopImage:, updateDesktopImage$);
+        WBRename(SBAwayView, updateDesktopImage:, updateDesktopImage$);
         WBRename(SBStatusBarContentsView, didMoveToSuperview, didMoveToSuperview);
         WBRename(SBStatusBarContentsView, initWithStatusBar:mode:, initWithStatusBar$mode$);
         WBRename(SBStatusBarController, setStatusBarMode:orientation:duration:fenceID:animation:, setStatusBarMode$orientation$duration$fenceID$animation$);