/*
* AppController.j
* BugOrFeature
*
* Created by You on May 16, 2015.
* Copyright 2015, Your Company All rights reserved.
*/
@import <Foundation/Foundation.j>
@import <AppKit/AppKit.j>
@implementation AppController : CPObject
{
@outlet CPWindow theWindow;
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
// This is called when the application is done loading.
}
- (void)awakeFromCib
{
// This is called when the cib is done loading.
// You can implement this method on any object instantiated from a Cib.
// It's a useful hook for setting up current UI values, and other things.
// In this case, we want the window from Cib to become our full browser window
[theWindow setFullPlatformWindow:YES];
var windowView = [theWindow contentView];
var aScrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
var aDocumentView = [[CPView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
var clipView = [aScrollView contentView];
[aScrollView setDocumentView:aDocumentView];
[windowView addSubview:aScrollView];
CPLog.trace("scrollView frame : "+CGStringFromRect([aScrollView frame]));
CPLog.trace("documentView frame : "+CGStringFromRect([aDocumentView frame]));
CPLog.trace("clipView frame : "+CGStringFromRect([clipView frame]));
CPLog.trace("documentVisibleRect : "+CGStringFromRect([aScrollView documentVisibleRect]));
var aScale = CGSizeMake(0.5, 0.5);
[aDocumentView setScaleSize:aScale];
CPLog.trace("\n");
CPLog.trace("scale 0.5");
CPLog.trace("\n");
CPLog.trace("scrollView frame : "+CGStringFromRect([aScrollView frame]));
CPLog.trace("documentView frame : "+CGStringFromRect([aDocumentView frame]));
CPLog.trace("clipView frame : "+CGStringFromRect([clipView frame]));
CPLog.trace("documentVisibleRect : "+CGStringFromRect([aScrollView documentVisibleRect]));
}
@end
The exposed rectangle of the clip view’s document view, in the document view’s own coordinate system.
- (CGRect)documentVisibleRect
{
return [_contentView documentVisibleRect];
}
In CPClipView :
- (CGRect)documentVisibleRect
{
return [self convertRect:[self bounds] fromView:_documentView];
}
In CPView :
- (CGRect)convertRect:(CGRect)aRect fromView:(CPView)aView
{
if (self === aView)
return aRect;
return CGRectApplyAffineTransform(aRect, _CPViewGetTransform(aView, self));
}
So the clip view is also "considered" scaled.
Just to explain my point of view : a clip view of 100x100 shows 100x100 pixels of a document view at a 1.0 scale (this is of course OK).
If I apply a 0.5 scale to my document view, the clip view shows 2 times as much pixels so the documentVisibleRect should not be scaled down by 0.5 but scaled up by 2 (1/0.5).
Just my 2¢
Didier.
2015-05-17 10:31:55.428 TestZoom[6532:4078380] scrollView frame : 100.000000
2015-05-17 10:31:55.428 TestZoom[6532:4078380] documentView frame : 200.000000
2015-05-17 10:31:55.428 TestZoom[6532:4078380] clipView frame : 100.000000
2015-05-17 10:31:55.428 TestZoom[6532:4078380] documentVisibleRect : 100.000000
2015-05-17 10:31:55.428 TestZoom[6532:4078380]
2015-05-17 10:31:55.428 TestZoom[6532:4078380] scale 0.5
2015-05-17 10:31:55.428 TestZoom[6532:4078380]
2015-05-17 10:31:55.429 TestZoom[6532:4078380] scrollView frame : 100.000000
2015-05-17 10:31:55.429 TestZoom[6532:4078380] documentView frame : 200.000000
2015-05-17 10:31:55.429 TestZoom[6532:4078380] clipView frame : 100.000000
2015-05-17 10:31:55.429 TestZoom[6532:4078380] documentVisibleRect : 200.000000
You can open an issue on github with your example :). Even better you can propose a fix if you know how to fix that ;)