From: Jay Freeman (saurik) Date: Mon, 1 Sep 2008 00:36:21 +0000 (+0000) Subject: Manually draw icon labels and fix calendar positioning. X-Git-Tag: v0.9.3900~76 X-Git-Url: https://git.saurik.com/winterboard.git/commitdiff_plain/cf31d246adb94c606afe0746bb230f56449f496a Manually draw icon labels and fix calendar positioning. --- diff --git a/Library.mm b/Library.mm index a2c5baa..3dfd303 100644 --- a/Library.mm +++ b/Library.mm @@ -500,12 +500,12 @@ static void SBCalendarIconContentsView$drawRect$(SBCalendarIconContentsView *self, SEL sel, int mode, int orientation, float duration, int id, int animation) { if (Debug_) NSLog(@"WB:Debug:setStatusBarMode:%d", mode); @@ -830,6 +769,13 @@ static void SBIconController$appendIconList$(SBIconController *self return [self wb_appendIconList:list]; } +static id SBIconLabel$initWithSize$label$(SBIconLabel *self, SEL sel, CGSize size, NSString *label) { + self = [self wb_initWithSize:size label:label]; + if (self != nil) + [self setClipsToBounds:NO]; + return self; +} + static void SBIconLabel$setInDock$(SBIconLabel *self, SEL sel, BOOL docked) { id label; object_getInstanceVariable(self, "_label", reinterpret_cast(&label)); @@ -840,14 +786,33 @@ static void SBIconLabel$setInDock$(SBIconLabel *self, SEL sel, BOOL return [self wb_setInDock:docked]; } -/*static id SBIconLabel$drawRect$(SBIconLabel *self, SEL sel, CGRect rect) { - -}*/ +static void SBIconLabel$drawRect$(SBIconLabel *self, SEL sel, CGRect rect) { + CGRect bounds = [self bounds]; -static id SBIconLabel$initWithSize$label$(SBIconLabel *self, SEL sel, CGSize size, NSString *label) { - // XXX: technically I'm misusing self here - return [self wb_initWithSize:size label:[[[WBIconLabel alloc] initWithString:label] autorelease]]; - //return [self wb_initWithSize:size label:label]; + BOOL docked; + object_getInstanceVariable(self, "_inDock", reinterpret_cast(&docked)); + docked = (docked & 0x1) != 0; + + NSString *label; + object_getInstanceVariable(self, "_label", reinterpret_cast(&label)); + + NSString *style = [NSString stringWithFormat:@"" + "font-family: Helvetica; " + "font-weight: bold; " + "font-size: 11px; " + "color: %@; " + "", docked ? @"white" : @"#b3b3b3"]; + + if (docked) + style = [style stringByAppendingString:@"text-shadow: rgba(0, 0, 0, 0.5) 0px -1px 0px; "]; + float max = 75, width = [label sizeWithStyle:style forWidth:320].width; + if (width > max) + style = [style stringByAppendingString:[NSString stringWithFormat:@"letter-spacing: -%f; ", ((width - max) / ([label length] - 1))]]; + if (NSString *custom = [Info_ objectForKey:(docked ? @"DockedIconLabelStyle" : @"UndockedIconLabelStyle")]) + style = [style stringByAppendingString:custom]; + + CGSize size = [label sizeWithStyle:style forWidth:bounds.size.width]; + [label drawAtPoint:CGPointMake((bounds.size.width - size.width) / 2, 0) withStyle:style]; } extern "C" void FindMappedImages(void); @@ -1060,9 +1025,9 @@ extern "C" void WBInitialize() { WBRename(true, "SBButtonBar", @selector(didMoveToSuperview), (IMP) &$didMoveToSuperview); WBRename(true, "SBCalendarIconContentsView", @selector(drawRect:), (IMP) &SBCalendarIconContentsView$drawRect$); WBRename(true, "SBContentLayer", @selector(initWithSize:), (IMP) &SBContentLayer$initWithSize$); - WBRename(true, "SBIconLabel", @selector(setInDock:), (IMP) &SBIconLabel$setInDock$); - //WBRename(true, "SBIconLabel", @selector(drawRect:), (IMP) &SBIconLabel$drawRect$); WBRename(true, "SBIconLabel", @selector(initWithSize:label:), (IMP) &SBIconLabel$initWithSize$label$); + WBRename(true, "SBIconLabel", @selector(setInDock:), (IMP) &SBIconLabel$setInDock$); + WBRename(true, "SBIconLabel", @selector(drawRect:), (IMP) &SBIconLabel$drawRect$); WBRename(true, "SBSlidingAlertDisplay", @selector(updateDesktopImage:), (IMP) &SBSlidingAlertDisplay$updateDesktopImage$); WBRename(true, "SBStatusBarContentsView", @selector(didMoveToSuperview), (IMP) &$didMoveToSuperview); WBRename(true, "SBStatusBarContentsView", @selector(initWithStatusBar:mode:), (IMP) &SBStatusBarContentsView$initWithStatusBar$mode$); diff --git a/control b/control index e75a0d8..6b9cc14 100644 --- a/control +++ b/control @@ -3,11 +3,8 @@ Priority: optional Section: System Maintainer: Jay Freeman (saurik) Architecture: iphoneos-arm -Version: 0.9.2561-1 +Version: 0.9.2563-1 Description: more powerful, open-source SummerBoard - This tool lets you give your device a graphical overhaul. Themes are taken from /Library/Themes (or, now, the older SummerBoard folder). Using the relatively simple frontend you can activate and deactivate multiple themes and give them a priority ordering. - - WinterBoard was designed to accept SummerBoard themes without modification but is much more powerful than its predecessor. With WinterBoard you can theme almost any graphic on the system. You can even easily modify .artwork files without having to hack their contents, all from the safety of your theme folder. Name: WinterBoard Depends: mobilesubstrate (>= 0.9.2560-1) Provides: theme-manager @@ -15,4 +12,4 @@ Conflicts: com.modmyifone.winterboardicon Replaces: com.modmyifone.winterboardicon Author: Jay Freeman (saurik) Depiction: http://cydia.saurik.com/info/winterboard/ -Homepage: http://cydia.saurik.com/info/winterboard/ +Homepage: http://www.saurik.com/id/9