From 23e4c17ed59124765161702520dfc346af5702af Mon Sep 17 00:00:00 2001 From: Paul Gardiner Date: Fri, 10 Jan 2014 14:56:45 +0000 Subject: iOS: correctly handle document changes that may affect several pages Interaction with forms may change several pages, so all pages currently represented by view need updating. --- platform/ios/Classes/MuDocumentController.h | 3 ++- platform/ios/Classes/MuDocumentController.m | 8 +++++++- platform/ios/Classes/MuPageView.h | 1 + platform/ios/Classes/MuPageViewNormal.h | 4 +++- platform/ios/Classes/MuPageViewNormal.m | 9 +++++---- platform/ios/Classes/MuPageViewReflow.m | 1 + platform/ios/Classes/MuUpdater.h | 5 +++++ platform/ios/MuPDF.xcodeproj/project.pbxproj | 2 ++ 8 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 platform/ios/Classes/MuUpdater.h (limited to 'platform') diff --git a/platform/ios/Classes/MuDocumentController.h b/platform/ios/Classes/MuDocumentController.h index bc2959e1..4abacc42 100644 --- a/platform/ios/Classes/MuDocumentController.h +++ b/platform/ios/Classes/MuDocumentController.h @@ -9,6 +9,7 @@ #import "MuOutlineController.h" #import "MuDocRef.h" #import "MuDialogCreator.h" +#import "MuUpdater.h" enum { @@ -22,7 +23,7 @@ enum BARMODE_DELETE }; -@interface MuDocumentController : UIViewController +@interface MuDocumentController : UIViewController { fz_document *doc; MuDocRef *docRef; diff --git a/platform/ios/Classes/MuDocumentController.m b/platform/ios/Classes/MuDocumentController.m index 962403ec..0e3beb1e 100644 --- a/platform/ios/Classes/MuDocumentController.m +++ b/platform/ios/Classes/MuDocumentController.m @@ -433,6 +433,12 @@ static void saveDoc(char *current_path, fz_document *doc) barmode = BARMODE_ANNOTATION; } +- (void) update +{ + for (UIView *view in [canvas subviews]) + [view update]; +} + - (void) onMore: (id)sender { [self showAnnotationMenu]; @@ -887,7 +893,7 @@ static void saveDoc(char *current_path, fz_document *doc) UIView *view = reflowMode ? [[MuPageViewReflow alloc] initWithFrame:CGRectMake(number * width, 0, width-GAP, height) document:docRef page:number] - : [[MuPageViewNormal alloc] initWithFrame:CGRectMake(number * width, 0, width-GAP, height) dialogCreator:self document:docRef page:number]; + : [[MuPageViewNormal alloc] initWithFrame:CGRectMake(number * width, 0, width-GAP, height) dialogCreator:self updater:self document:docRef page:number]; [view setScale:scale]; [canvas addSubview: view]; if (showLinks) diff --git a/platform/ios/Classes/MuPageView.h b/platform/ios/Classes/MuPageView.h index 89ce0aca..e3c26549 100644 --- a/platform/ios/Classes/MuPageView.h +++ b/platform/ios/Classes/MuPageView.h @@ -19,4 +19,5 @@ -(void) inkModeOff; -(void) saveSelectionAsMarkup:(int)type; -(void) saveInk; +-(void) update; @end diff --git a/platform/ios/Classes/MuPageViewNormal.h b/platform/ios/Classes/MuPageViewNormal.h index 8378ca74..ce42991a 100644 --- a/platform/ios/Classes/MuPageViewNormal.h +++ b/platform/ios/Classes/MuPageViewNormal.h @@ -13,6 +13,7 @@ #import "MuTextSelectView.h" #import "MuInkView.h" #import "MuAnnotSelectView.h" +#import "MuUpdater.h" @interface MuPageViewNormal : UIScrollView { @@ -42,8 +43,9 @@ float tileScale; BOOL cancel; id dialogCreator; + id updater; } -- (id) initWithFrame: (CGRect)frame dialogCreator:(id)dia document: (MuDocRef *)aDoc page: (int)aNumber; +- (id) initWithFrame: (CGRect)frame dialogCreator:(id)dia updater:(id)upd document: (MuDocRef *)aDoc page: (int)aNumber; - (void) displayImage: (UIImage*)image; - (void) resizeImage; - (void) loadPage; diff --git a/platform/ios/Classes/MuPageViewNormal.m b/platform/ios/Classes/MuPageViewNormal.m index 49c07eaf..8c67dc4e 100644 --- a/platform/ios/Classes/MuPageViewNormal.m +++ b/platform/ios/Classes/MuPageViewNormal.m @@ -631,7 +631,7 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa annot_list = create_annot_list(doc, page); } --(id) initWithFrame:(CGRect)frame dialogCreator:(id)dia document:(MuDocRef *)aDoc page:(int)aNumber +-(id) initWithFrame:(CGRect)frame dialogCreator:(id)dia updater:(id)upd document:(MuDocRef *)aDoc page:(int)aNumber { self = [super initWithFrame: frame]; if (self) { @@ -640,6 +640,7 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa number = aNumber; cancel = NO; dialogCreator = dia; + updater = upd; selectedAnnotationIndex = -1; [self setShowsVerticalScrollIndicator: NO]; @@ -1212,7 +1213,7 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa if (accepted) { dispatch_async(dispatch_get_main_queue(), ^{ - [self update]; + [updater update]; }); } else @@ -1233,7 +1234,7 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa if (accepted) { dispatch_async(dispatch_get_main_queue(), ^{ - [self update]; + [updater update]; }); } else @@ -1360,7 +1361,7 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa int changed = [self passTapToPage:ipt]; if (changed) dispatch_async(dispatch_get_main_queue(), ^{ - [self update]; + [updater update]; }); }); return [[[MuTapResultWidget alloc] init] autorelease]; diff --git a/platform/ios/Classes/MuPageViewReflow.m b/platform/ios/Classes/MuPageViewReflow.m index 523a73e1..4a60df00 100644 --- a/platform/ios/Classes/MuPageViewReflow.m +++ b/platform/ios/Classes/MuPageViewReflow.m @@ -123,6 +123,7 @@ NSString *textAsHtml(fz_document *doc, int pageNum) -(void) saveInk {} -(void) deselectAnnotation {} -(void) deleteSelectedAnnotation {} +-(void) update {} -(void) resetZoomAnimated: (BOOL)animated { diff --git a/platform/ios/Classes/MuUpdater.h b/platform/ios/Classes/MuUpdater.h new file mode 100644 index 00000000..0291f821 --- /dev/null +++ b/platform/ios/Classes/MuUpdater.h @@ -0,0 +1,5 @@ +#import + +@protocol MuUpdater +- (void)update; +@end diff --git a/platform/ios/MuPDF.xcodeproj/project.pbxproj b/platform/ios/MuPDF.xcodeproj/project.pbxproj index 492ea205..bb5f7a46 100644 --- a/platform/ios/MuPDF.xcodeproj/project.pbxproj +++ b/platform/ios/MuPDF.xcodeproj/project.pbxproj @@ -99,6 +99,7 @@ 96E1CDEB1779A60700FCF717 /* iTunesArtwork.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = iTunesArtwork.png; sourceTree = ""; }; 96E1CDEC1779A60700FCF717 /* x_alt_blue.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = x_alt_blue.png; sourceTree = ""; }; 96E1CDED1779A60700FCF717 /* x_alt_blue@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "x_alt_blue@2x.png"; sourceTree = ""; }; + DA012CA218803D1C00E47712 /* MuUpdater.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = MuUpdater.h; path = Classes/MuUpdater.h; sourceTree = ""; }; DA1C689817E85E8E0061F586 /* MuLibraryController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MuLibraryController.h; path = Classes/MuLibraryController.h; sourceTree = ""; }; DA1C689917E85E8E0061F586 /* MuLibraryController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MuLibraryController.m; path = Classes/MuLibraryController.m; sourceTree = ""; }; DA1C689C17E861020061F586 /* MuOutlineController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MuOutlineController.h; path = Classes/MuOutlineController.h; sourceTree = ""; }; @@ -290,6 +291,7 @@ DAFF997A187C12430081C756 /* MuChoiceFieldController.xib */, DAF81D5918800D1800B0F028 /* TapImage.h */, DAF81D5A18800D1800B0F028 /* TapImage.m */, + DA012CA218803D1C00E47712 /* MuUpdater.h */, ); name = Classes; sourceTree = ""; -- cgit v1.2.3