]> git.saurik.com Git - winterboard.git/commitdiff
Reimplement iOS 5.x icon label styling.
authorJay Freeman (saurik) <saurik@saurik.com>
Sat, 10 Mar 2012 23:47:42 +0000 (23:47 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Sat, 10 Mar 2012 23:47:42 +0000 (23:47 +0000)
Library.mm

index 84c30908949ae2d2aabdd26983ca0ce7dfa64c4b..d5aeac04768cb89be7420ab5e4f3abc6ba38413b 100644 (file)
@@ -683,42 +683,41 @@ static struct WBStringDrawingState {
     NSString *info_;
 } *stringDrawingState_;
 
-MSInstanceMessageHook4(CGSize, NSString, drawAtPoint,forWidth,withFont,lineBreakMode, CGPoint, point, float, width, UIFont *, font, int, mode) {
+MSInstanceMessageHook6(CGSize, NSString, drawAtPoint,forWidth,withFont,lineBreakMode,letterSpacing,includeEmoji, CGPoint, point, float, width, UIFont *, font, int, mode, float, spacing, BOOL, emoji) {
     WBStringDrawingState *state(stringDrawingState_);
     if (state == NULL)
-        return MSOldCall(point, width, font, mode);
+        return MSOldCall(point, width, font, mode, spacing, emoji);
 
     if (--state->count_ == 0)
         stringDrawingState_ = state->next_;
     if (state->info_ == nil)
-        return MSOldCall(point, width, font, mode);
+        return MSOldCall(point, width, font, mode, spacing, emoji);
 
     NSString *info([Info_ objectForKey:state->info_]);
     if (info == nil)
-        return MSOldCall(point, width, font, mode);
+        return MSOldCall(point, width, font, mode, spacing, emoji);
 
     NSString *base(state->base_ ?: @"");
     [self drawAtPoint:point withStyle:[NSString stringWithFormat:@"%@;%@;%@", [font markupDescription], base, info]];
     return CGSizeZero;
 }
 
-MSInstanceMessageHook2(CGSize, NSString, drawAtPoint,withFont, CGPoint, point, UIFont *, font) {
+MSInstanceMessageHook4(CGSize, NSString, sizeWithFont,forWidth,lineBreakMode,letterSpacing, UIFont *, font, float, width, int, mode, float, spacing) {
     WBStringDrawingState *state(stringDrawingState_);
     if (state == NULL)
-        return MSOldCall(point, font);
+        return MSOldCall(font, width, mode, spacing);
 
     if (--state->count_ == 0)
         stringDrawingState_ = state->next_;
     if (state->info_ == nil)
-        return MSOldCall(point, font);
+        return MSOldCall(font, width, mode, spacing);
 
     NSString *info([Info_ objectForKey:state->info_]);
     if (info == nil)
-        return MSOldCall(point, font);
+        return MSOldCall(font, width, mode, spacing);
 
     NSString *base(state->base_ ?: @"");
-    [self drawAtPoint:point withStyle:[NSString stringWithFormat:@"%@;%@;%@", [font markupDescription], base, info]];
-    return CGSizeZero;
+    return [self sizeWithStyle:[NSString stringWithFormat:@"%@;%@;%@", [font markupDescription], base, info] forWidth:width];
 }
 
 MSInstanceMessageHook1(CGSize, NSString, sizeWithFont, UIFont *, font) {
@@ -1503,7 +1502,7 @@ MSInstanceMessageHook2(CGSize, WebCoreFrameBridge, renderedSizeOfNode,constraine
 }
 // }}}
 
-MSInstanceMessageHook1(void, SBIconLabel, drawRect, CGRect, rect) {
+MSInstanceMessage1(void, SBIconLabel, drawRect, CGRect, rect) {
     CGRect bounds = [self bounds];
 
     static Ivar drawMoreLegibly = object_getInstanceVariable(self, "_drawMoreLegibly", NULL);
@@ -1556,6 +1555,23 @@ MSInstanceMessageHook1(void, SBIconLabel, drawRect, CGRect, rect) {
     [label drawAtPoint:CGPointMake((bounds.size.width - size.width) / 2, 0) withStyle:style];
 }
 
+MSInstanceMessage0(CGImageRef, SBIconLabel, buildLabelImage) {
+    bool docked((MSHookIvar<unsigned>(self, "_inDock") & 0x2) != 0);
+
+    WBStringDrawingState labelState = {NULL, 2, [NSString stringWithFormat:@""
+        "color: %@;"
+    ,
+        (docked || !SummerBoard_ ? @"white" : @"#b3b3b3")
+    ], docked ? @"DockedIconLabelStyle" : @"UndockedIconLabelStyle"};
+
+    stringDrawingState_ = &labelState;
+
+    CGImageRef image(MSOldCall());
+
+    stringDrawingState_ = NULL;
+    return image;
+}
+
 // ChatKit {{{
 MSInstanceMessageHook2(id, CKBalloonView, initWithFrame,delegate, CGRect, frame, id, delegate) {
     if ((self = MSOldCall(frame, delegate)) != nil) {
@@ -1839,6 +1855,11 @@ static void SBInitialize() {
     WBRename(SBDockIconListView, setFrame:, setFrame$);
     MSHookMessage(object_getClass($SBDockIconListView), @selector(shouldShowNewDock), &$SBDockIconListView$shouldShowNewDock, &_SBDockIconListView$shouldShowNewDock);
 
+    if (kCFCoreFoundationVersionNumber < 600)
+        WBRename(SBIconLabel, drawRect:, drawRect$);
+    else
+        WBRename(SBIconLabel, buildLabelImage, buildLabelImage);
+
     WBRename(SBIconLabel, initWithSize:label:, initWithSize$label$);
     WBRename(SBIconLabel, setInDock:, setInDock$);