X-Git-Url: https://git.saurik.com/cydia.git/blobdiff_plain/facbc56de5a9dd53b0ce257f414cf9b9beee2229..092934d18a7bb1b3e1d768657293e99f432b5d0a:/UICaboodle/RVBook.mm diff --git a/UICaboodle/RVBook.mm b/UICaboodle/RVBook.mm index cef1acee..a6f53181 100644 --- a/UICaboodle/RVBook.mm +++ b/UICaboodle/RVBook.mm @@ -18,6 +18,47 @@ #import "RVPage.h" +@interface NSObject (UICaboodleRVBook) +- (float) widthForButtonContents:(float)width; +@end + +@implementation NSObject (UICaboodleRVBook) + +- (float) widthForButtonContents:(float)width { + return width; +} + +@end + +@interface UIImage (UICaboodleRVBook) +- (float) widthForButtonContents:(float)width; +@end + +@implementation UIImage (UICaboodleRVBook) + +- (float) widthForButtonContents:(float)width { + return [self size].width + 8; +} + +@end + +@interface RVNavigationBar : UINavigationBar { +} + +- (id) createButtonWithContents:(id)contents width:(float)width barStyle:(int)barStyle buttonStyle:(int)style isRight:(BOOL)right; +@end + +@implementation RVNavigationBar + +- (id) createButtonWithContents:(id)contents width:(float)width barStyle:(int)barStyle buttonStyle:(int)style isRight:(BOOL)right { + float adjust = [contents widthForButtonContents:width]; + NSLog(@"cc:%@:%g:%g", contents, width, adjust); + width = adjust; + return [super createButtonWithContents:contents width:width barStyle:barStyle buttonStyle:style isRight:right]; +} + +@end + @implementation RVBook - (void) dealloc { @@ -59,7 +100,7 @@ CGSize navsize = [UINavigationBar defaultSize]; CGRect navrect = {{0, 0}, navsize}; - navbar_ = [[UINavigationBar alloc] initWithFrame:navrect]; + navbar_ = [[RVNavigationBar alloc] initWithFrame:navrect]; [self addSubview:navbar_]; [navbar_ setBarStyle:0]; @@ -157,18 +198,19 @@ [navbar_ setAccessoryView:[page accessoryView] animate:animated removeOnPop:NO]; } -- (void) setTitle:(NSString *)title forPage:(RVPage *)page { +- (void) setBackButtonTitle:(NSString *)title forPage:(RVPage *)page { if ([pages_ count] == 0 || page != [pages_ lastObject]) return; UINavigationItem *navitem = [navbar_ topItem]; - [navitem setTitle:title]; + [navitem setBackButtonTitle:title]; } -- (void) setBackButtonTitle:(NSString *)title forPage:(RVPage *)page { +- (void) reloadTitleForPage:(RVPage *)page { if ([pages_ count] == 0 || page != [pages_ lastObject]) return; UINavigationItem *navitem = [navbar_ topItem]; - [navitem setBackButtonTitle:title]; + NSString *title = [self getTitleForPage:page]; + [navitem setTitle:title]; } - (void) reloadButtonsForPage:(RVPage *)page {