From d20f587871d13f958c7a99f559584c7622ef8527 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 18 Nov 2011 16:24:16 +0100 Subject: Update About document and fix some search UI bugs in iOS app. --- ios/About.pdf | Bin 131735 -> 0 bytes ios/About.xps | Bin 0 -> 76673 bytes ios/MuPDF.xcodeproj/project.pbxproj | 8 ++++---- ios/document.c | 3 --- ios/main.m | 23 ++++++++++++----------- 5 files changed, 16 insertions(+), 18 deletions(-) delete mode 100644 ios/About.pdf create mode 100644 ios/About.xps (limited to 'ios') diff --git a/ios/About.pdf b/ios/About.pdf deleted file mode 100644 index 763c467e..00000000 Binary files a/ios/About.pdf and /dev/null differ diff --git a/ios/About.xps b/ios/About.xps new file mode 100644 index 00000000..3fcec260 Binary files /dev/null and b/ios/About.xps differ diff --git a/ios/MuPDF.xcodeproj/project.pbxproj b/ios/MuPDF.xcodeproj/project.pbxproj index 61542780..56f6275a 100644 --- a/ios/MuPDF.xcodeproj/project.pbxproj +++ b/ios/MuPDF.xcodeproj/project.pbxproj @@ -8,7 +8,7 @@ /* Begin PBXBuildFile section */ 9644E9A0146ACEC000E5B70A /* document.c in Sources */ = {isa = PBXBuildFile; fileRef = 9644E99E146ACEC000E5B70A /* document.c */; }; - 9683F619145F4F84000E1607 /* About.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 9683F618145F4F84000E1607 /* About.pdf */; }; + 9668C8D91476A30200D7BA52 /* About.xps in Resources */ = {isa = PBXBuildFile; fileRef = 9668C8D81476A30200D7BA52 /* About.xps */; }; 968F2E9C14539C880085264E /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 968F2E9B14539C880085264E /* UIKit.framework */; }; 968F2E9E14539C880085264E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 968F2E9D14539C880085264E /* Foundation.framework */; }; 968F2EA014539C880085264E /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 968F2E9F14539C880085264E /* CoreGraphics.framework */; }; @@ -39,7 +39,7 @@ /* Begin PBXFileReference section */ 9644E99E146ACEC000E5B70A /* document.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = document.c; sourceTree = ""; }; 9644E99F146ACEC000E5B70A /* document.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = document.h; sourceTree = ""; }; - 9683F618145F4F84000E1607 /* About.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = About.pdf; sourceTree = ""; }; + 9668C8D81476A30200D7BA52 /* About.xps */ = {isa = PBXFileReference; lastKnownFileType = file; path = About.xps; sourceTree = ""; }; 968461E214642DB00012AE09 /* libLibraries.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libLibraries.a; sourceTree = BUILT_PRODUCTS_DIR; }; 968F2E8E14539BEB0085264E /* build_libs.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = build_libs.sh; sourceTree = ""; }; 968F2E8F14539BEB0085264E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -86,7 +86,7 @@ 968F2E9214539BF10085264E /* Sources */ = { isa = PBXGroup; children = ( - 9683F618145F4F84000E1607 /* About.pdf */, + 9668C8D81476A30200D7BA52 /* About.xps */, 96BD2B36145AC485001CEBC3 /* Icon.png */, 96F2341414603FBA004A8A22 /* Icon@2x.png */, 96BD2B35145AC485001CEBC3 /* Icon-72.png */, @@ -212,8 +212,8 @@ files = ( 96BD2B38145AC485001CEBC3 /* Icon-72.png in Resources */, 96BD2B39145AC485001CEBC3 /* Icon.png in Resources */, - 9683F619145F4F84000E1607 /* About.pdf in Resources */, 96F2341514603FBA004A8A22 /* Icon@2x.png in Resources */, + 9668C8D91476A30200D7BA52 /* About.xps in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/ios/document.c b/ios/document.c index 9e46644c..7f3b97ab 100644 --- a/ios/document.c +++ b/ios/document.c @@ -80,7 +80,6 @@ load_page(struct document *doc, int number) pdf_free_page(doc->pdf_page); } doc->pdf_page = NULL; -printf("load pdf page %d\n", number); error = pdf_load_page(&doc->pdf_page, doc->pdf, number); if (error) fz_catch(error, "cannot load page %d", number); @@ -89,7 +88,6 @@ printf("load pdf page %d\n", number); if (doc->xps_page) xps_free_page(doc->xps, doc->xps_page); doc->xps_page = NULL; -printf("load xps page %d\n", number); error = xps_load_page(&doc->xps_page, doc->xps, number); if (error) fz_catch(error, "cannot load page %d", number); @@ -225,7 +223,6 @@ search_page(struct document *doc, int number, char *needle) for (pos = 0; pos < len; pos++) { n = match(text, needle, pos); if (n) { - printf("found a match at page %d, pos %d!\n", number, pos); for (i = 0; i < n; i++) { fz_bbox r = bboxat(text, pos + i); if (!fz_is_empty_bbox(r) && doc->hit_count < nelem(doc->hit_bbox)) diff --git a/ios/main.m b/ios/main.m index db6e1edd..52d901fe 100644 --- a/ios/main.m +++ b/ios/main.m @@ -1,4 +1,4 @@ -#import +#import #undef ABS #undef MIN @@ -364,7 +364,7 @@ static UIImage *renderTile(struct document *doc, int number, CGSize screenSize, { int row = [indexPath row]; if (row == 0) - [self openDocument: @"../MuPDF.app/About.pdf"]; + [self openDocument: @"../MuPDF.app/About.xps"]; else [self openDocument: [files objectAtIndex: row - 1]]; } @@ -455,11 +455,11 @@ static UIImage *renderTile(struct document *doc, int number, CGSize screenSize, - (id) initWithSearchResults: (int)n forDocument: (struct document *)doc { - self = [super init]; + self = [super initWithFrame: CGRectMake(0,0,100,100)]; if (self) { [self setOpaque: NO]; - pageSize = CGSizeMake(1,1); + pageSize = CGSizeMake(100,100); for (int i = 0; i < n && i < nelem(hitRects); i++) { fz_bbox bbox = search_result_bbox(doc, i); // this is thread-safe enough @@ -476,6 +476,8 @@ static UIImage *renderTile(struct document *doc, int number, CGSize screenSize, - (void) setPageSize: (CGSize)s { pageSize = s; + // if page takes a long time to load we may have drawn at the initial (wrong) size + [self setNeedsDisplay]; } - (void) drawRect: (CGRect)r @@ -623,10 +625,15 @@ static UIImage *renderTile(struct document *doc, int number, CGSize screenSize, loadingView = nil; } + if (hitView) + [hitView setPageSize: pageSize]; + if (!imageView) { imageView = [[UIImageView alloc] initWithImage: image]; imageView.opaque = YES; [self addSubview: imageView]; + if (hitView) + [self bringSubviewToFront: hitView]; } else { [imageView setImage: image]; } @@ -659,11 +666,6 @@ static UIImage *renderTile(struct document *doc, int number, CGSize screenSize, [self setContentSize: imageView.frame.size]; - if (hitView) { - [hitView setPageSize: pageSize]; - [self bringSubviewToFront: hitView]; - } - [self layoutIfNeeded]; } @@ -705,7 +707,6 @@ static UIImage *renderTile(struct document *doc, int number, CGSize screenSize, if (hitView && imageView) [hitView setFrame: [imageView frame]]; - } - (UIView*) viewForZoomingInScrollView: (UIScrollView*)scrollView @@ -1124,7 +1125,7 @@ static UIImage *renderTile(struct document *doc, int number, CGSize screenSize, - (void) showSearchResults: (int)count forPage: (int)number { - printf("search found %d matches on page %d\n", count, number); + printf("search found match on page %d\n", number); searchPage = number; [self gotoPage: number animated: NO]; for (MuPageView *view in [canvas subviews]) -- cgit v1.2.3