Commits

Anonymous committed 50b62c6

work-around for scroll on resize problem

Comments (0)

Files changed (5)

 
 - (void)setDocument:(MyPDFDoc*) myDoc;
 
-- (void)windowResized:(NSNotification *)notification;
+- (void)windowResized;
 
 - (void)setScroll:(float)hPos verticalPosition:(float)vPos;
 
 -(double)currentHorizontalScrollPosition;
 -(double)currentVerticalScrollPosition;
 
+-(void)update;
+
 #pragma mark c callbacks 
 void beginRendering(void* data);
 void endRendering(void* data, bool canceled);
 -(BOOL)isFlipped {
     return YES;
 }
-
+/*
+-(void)setNeedsDisplay:(BOOL)flag {
+    if ([self doesPDFViewHaveDoc] && flag) {
+        _tronPDFView->Update();
+    }
+    [super setNeedsDisplay:flag];
+}
+*/
 - (void)drawRect:(NSRect)dirtyRect {
     if ([self doesPDFViewHaveDoc]) {
         const char* bgra = _tronPDFView->GetBuffer();
         _tronPDFView->SetPageViewMode(pdftron::PDF::PDFView::e_fit_width);
         _tronPDFView->SetPagePresentationMode(pdftron::PDF::PDFView::e_single_continuous);
         _tronPDFView->SetPageSpacing(10, 10, 20, 10);
-        [self windowResized:nil];
+        [self windowResized];
     }
 }
 /*
  */
 
 
-- (void)windowResized:(NSNotification *)notification;
+- (void)windowResized;
 {
     if (_tronPDFView)
     {
     return vPos;
 }
 
+-(void)update {
+    if ([self doesPDFViewHaveDoc]) {
+        _tronPDFView->Update();
+    }
+}
+
 -(void)goToNextPage:(id)sender {
     if ([self doesPDFViewHaveDoc]) {
         _tronPDFView->GotoNextPage();
 
 }
 
--(void)handleScrollChange:(NSNotification *)notfication;
 -(void)handleFrameChange:(NSNotification *)notification;
 -(void)setScroll:(double) horizontalPosition verticalPosition:(double) vPos;
 

TronScrollView.mm

     NSLog(@"reflectScrolledClipView");
     [super reflectScrolledClipView:cView];
     TronPDFView * pdfView = [self documentView];
-    float vPos = [[self verticalScroller] floatValue];
-    float hPos = [[self horizontalScroller] floatValue];
-    [pdfView setScroll:hPos verticalPosition:vPos];
+    if ([pdfView inLiveResize]) {
+        double vPos = [pdfView currentVerticalScrollPosition];
+        double hPos = [pdfView currentHorizontalScrollPosition];
+        [[self verticalScroller] setDoubleValue:vPos];
+        [[self horizontalScroller] setDoubleValue:hPos];
+        [pdfView update];
+    } else {
+        float vPos = [[self verticalScroller] floatValue];
+        float hPos = [[self horizontalScroller] floatValue];
+        [pdfView setScroll:hPos verticalPosition:vPos];
+    }
+    [pdfView setNeedsDisplay:YES];
 }
-
--(void)handleScrollChange:(NSNotification*)notfication {
-    NSLog(@"TronScrollView handleScrollChange");
-    TronPDFView * pdfView = [self documentView];
-    [self setScroll:[pdfView currentHorizontalScrollPosition] verticalPosition:[pdfView currentVerticalScrollPosition]];
-}
-     
      
 -(void)handleFrameChange:(NSNotification*)notification {
     NSLog(@"TronScrollView handleFrameChanged");
     NSScroller * vScroller = [self verticalScroller];
     float oldh = [hScroller floatValue];
     float oldv = [vScroller floatValue];
-    [pdfView windowResized:nil];
+    [pdfView windowResized];
     float h = [hScroller floatValue];
     float v = [vScroller floatValue];
-    [self setScroll:oldh verticalPosition:oldv];
+    //[self setScroll:oldh verticalPosition:oldv];
     NSLog(@"oldh: %0.4f, oldV: %0.4f, h: %0.4f, v: %0.4f", oldh, oldv, h, v);
 }
 

cocoapdf.xcodeproj/quincy.mode1v3

 				<key>PBXProjectModuleGUID</key>
 				<string>24D75F2A120FD4B9008529E9</string>
 				<key>PBXProjectModuleLabel</key>
-				<string>TronPDFView.mm</string>
+				<string>TronScrollView.mm</string>
 				<key>PBXSplitModuleInNavigatorKey</key>
 				<dict>
 					<key>Split0</key>
 						<key>PBXProjectModuleGUID</key>
 						<string>24D75F2E120FD4FA008529E9</string>
 						<key>PBXProjectModuleLabel</key>
-						<string>TronPDFView.mm</string>
+						<string>TronScrollView.mm</string>
 						<key>_historyCapacity</key>
 						<integer>0</integer>
 						<key>bookmark</key>
-						<string>2403A5C91218E1B5004855EE</string>
+						<string>2403A65A1218FDC0004855EE</string>
 						<key>history</key>
 						<array>
-							<string>24D75F34120FD62F008529E9</string>
 							<string>24D75F9A120FE338008529E9</string>
-							<string>24D75FAA120FF3B8008529E9</string>
-							<string>24EAD9A012177DE40017DCEF</string>
-							<string>2403A4CB1218C392004855EE</string>
-							<string>2403A4D51218C443004855EE</string>
 							<string>2403A4F31218C911004855EE</string>
-							<string>2403A5C81218E1B5004855EE</string>
-							<string>2403A5BC1218DB21004855EE</string>
+							<string>2403A6061218F5F4004855EE</string>
+							<string>2403A6121218F6B9004855EE</string>
+							<string>2403A6231218F828004855EE</string>
+							<string>2403A64C1218FD33004855EE</string>
+							<string>2403A6581218FDC0004855EE</string>
+							<string>2403A6591218FDC0004855EE</string>
+							<string>2403A6521218FDA2004855EE</string>
 						</array>
 					</dict>
 					<key>SplitCount</key>
 										<key>_historyCapacity</key>
 										<integer>0</integer>
 										<key>bookmark</key>
-										<string>2403A5C71218E1B5004855EE</string>
+										<string>2403A6571218FDC0004855EE</string>
 										<key>history</key>
 										<array>
 											<string>241D2A8211FBCBED0067260B</string>
 	<integer>5</integer>
 	<key>WindowOrderList</key>
 	<array>
+		<string>2403A65B1218FDC0004855EE</string>
 		<string>2403A5AB1218CDDC004855EE</string>
 		<string>2403A4B41218BEF4004855EE</string>
 		<string>2403A4B51218BEF4004855EE</string>
 		<string>1CD10A99069EF8BA00B06720</string>
-		<string>2492503F11CB2A5D0076F523</string>
 		<string>/Users/quincy/Repositories/CocoaPDF/cocoapdf.xcodeproj</string>
 		<string>1C78EAAD065D492600B07095</string>
+		<string>2492503F11CB2A5D0076F523</string>
 		<string>24D75F2A120FD4B9008529E9</string>
 	</array>
 	<key>WindowString</key>
 								<key>Frame</key>
 								<string>{{0, 0}, {730, 510}}</string>
 								<key>RubberWindowFrame</key>
-								<string>484 193 730 551 0 0 1280 778 </string>
+								<string>490 145 730 551 0 0 1280 778 </string>
 							</dict>
 							<key>Module</key>
 							<string>PBXDebugCLIModule</string>
 			<key>ToolbarConfiguration</key>
 			<string>xcode.toolbar.config.consoleV3</string>
 			<key>WindowString</key>
-			<string>484 193 730 551 0 0 1280 778 </string>
+			<string>490 145 730 551 0 0 1280 778 </string>
 			<key>WindowToolGUID</key>
 			<string>1C78EAAD065D492600B07095</string>
 			<key>WindowToolIsVisible</key>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.