Add public instance methods to View class for getting locations and sizes

Resolves #1760
This commit is contained in:
Rossen Hristov
2016-03-15 16:41:57 +02:00
parent 3cb0ce0a93
commit fe3d176dd6
5 changed files with 222 additions and 9 deletions

View File

@@ -363,6 +363,32 @@ export class View extends viewCommon.View {
return false;
}
public getLocationInWindow(): viewDefinition.Point {
if (!this._nativeView || !this._nativeView.getWindowToken()) {
return undefined;
}
var nativeArray = (<any>Array).create("int", 2);
this._nativeView.getLocationInWindow(nativeArray);
return {
x: utils.layout.toDeviceIndependentPixels(nativeArray[0]),
y: utils.layout.toDeviceIndependentPixels(nativeArray[1]),
}
}
public getLocationOnScreen(): viewDefinition.Point {
if (!this._nativeView || !this._nativeView.getWindowToken()) {
return undefined;
}
var nativeArray = (<any>Array).create("int", 2);
this._nativeView.getLocationOnScreen(nativeArray);
return {
x: utils.layout.toDeviceIndependentPixels(nativeArray[0]),
y: utils.layout.toDeviceIndependentPixels(nativeArray[1]),
}
}
public static resolveSizeAndState(size: number, specSize: number, specMode: number, childMeasuredState: number): number {
var result = size;
switch (specMode) {