]> git.saurik.com Git - winterboard.git/blobdiff - Library.mm
Fixed 2.1 icon clipping bug.
[winterboard.git] / Library.mm
index 34efd272a2c15e20950d98c23a0f55f5fa0ff496..aeb4868128d986b37b29c59965a77ed4ffb3a44e 100644 (file)
@@ -129,6 +129,8 @@ void WBInject(const char *classname, const char *oldname, IMP newimp, const char
 /* }}} */
 
 @protocol WinterBoard
+- (void) wb_cacheImageForIcon:(SBIcon *)icon;
+- (UIImage *) wb_getCachedImagedForIcon:(SBIcon *)icon;
 - (CGSize) wb_renderedSizeOfNode:(id)node constrainedToWidth:(float)width;
 - (void *) _node;
 - (void) wb_updateDesktopImage:(UIImage *)image;
@@ -229,6 +231,23 @@ static NSString *$pathForIcon$(SBApplication<WinterBoard> *self) {
     return nil;
 }
 
+static NSMutableDictionary *Cache_;
+
+static void SBIconModel$cacheImageForIcon$(SBIconModel<WinterBoard> *self, SEL sel, SBIcon *icon) {
+    [self wb_cacheImageForIcon:icon];
+    NSString *key([icon displayIdentifier]);
+    if (UIImage *value = [icon icon])
+        [Cache_ setObject:value forKey:key];
+}
+
+static UIImage *SBIconModel$getCachedImagedForIcon$(SBIconModel<WinterBoard> *self, SEL sel, SBIcon *icon) {
+    NSString *key([icon displayIdentifier]);
+    if (UIImage *image = [Cache_ objectForKey:key])
+        return image;
+    else
+        return [self wb_getCachedImagedForIcon:icon];
+}
+
 static UIImage *SBApplicationIcon$icon(SBApplicationIcon<WinterBoard> *self, SEL sel) {
     if (![Info_ boolForKey:@"ComposeStoreIcons"])
         if (NSString *path = $pathForIcon$([self application]))
@@ -801,9 +820,11 @@ static CGSize WebCoreFrameBridge$renderedSizeOfNode$constrainedToWidth$(WebCoreF
 static void SBIconLabel$drawRect$(SBIconLabel<WinterBoard> *self, SEL sel, CGRect rect) {
     CGRect bounds = [self bounds];
 
+    static Ivar drawMoreLegibly = object_getInstanceVariable(self, "_drawMoreLegibly", NULL);
+
     BOOL docked;
-    object_getInstanceVariable(self, "_inDock", reinterpret_cast<void **>(&docked));
-    docked = (docked & 0x1) != 0;
+    Ivar ivar = object_getInstanceVariable(self, "_inDock", reinterpret_cast<void **>(&docked));
+    docked = (docked & (ivar_getOffset(ivar) == ivar_getOffset(drawMoreLegibly) ? 0x2 : 0x1)) != 0;
 
     NSString *label;
     object_getInstanceVariable(self, "_label", reinterpret_cast<void **>(&label));
@@ -1033,6 +1054,9 @@ extern "C" void WBInitialize() {
 
     WBRename(true, "WebCoreFrameBridge", @selector(renderedSizeOfNode:constrainedToWidth:), (IMP) &WebCoreFrameBridge$renderedSizeOfNode$constrainedToWidth$);
 
+    WBRename(true, "SBIconModel", @selector(cacheImageForIcon:), (IMP) &SBIconModel$cacheImageForIcon$);
+    WBRename(true, "SBIconModel", @selector(getCachedImagedForIcon:), (IMP) &SBIconModel$getCachedImagedForIcon$);
+
     WBRename(true, "SBApplication", @selector(pathForIcon), (IMP) &SBApplication$pathForIcon);
     WBRename(true, "SBApplicationIcon", @selector(icon), (IMP) &SBApplicationIcon$icon);
     WBRename(true, "SBBookmarkIcon", @selector(icon), (IMP) &SBBookmarkIcon$icon);
@@ -1059,6 +1083,7 @@ extern "C" void WBInitialize() {
     UIImages_ = [[NSMutableDictionary alloc] initWithCapacity:16];
     PathImages_ = [[NSMutableDictionary alloc] initWithCapacity:16];
     Files_ = [[NSMutableDictionary alloc] initWithCapacity:16];
+    Cache_ = [[NSMutableDictionary alloc] initWithCapacity:64];
 
     themes_ = [[NSMutableArray alloc] initWithCapacity:8];