From 0ac7f12d00273003b0d0ca87df7bf553fa2e93c0 Mon Sep 17 00:00:00 2001 From: Monika Hedman Date: Tue, 19 Feb 2019 16:08:16 -0500 Subject: centering update 2/19 --- src/client/views/DocumentManager.tsx | 30 +++++++++++++++------- .../views/collections/CollectionDockingView.tsx | 6 ++--- 2 files changed, 24 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/client/views/DocumentManager.tsx b/src/client/views/DocumentManager.tsx index 4d8756107..81231bf13 100644 --- a/src/client/views/DocumentManager.tsx +++ b/src/client/views/DocumentManager.tsx @@ -102,9 +102,9 @@ export class DocumentManager { // XView = (-node.X * scale) + (window.innerWidth / 2) - (node.Width * scale / 2); // YView = (-node.Y * scale) + (window.innerHeight / 2) - (node.Height * scale / 2); // RootStore.Instance.MainNodeCollection.SetViewportXY(XView, YView); - scale = docView.props.GetTransform().Scale - XView = (-docView.props.GetTransform().TranslateX * scale) + (window.innerWidth / 2) - (width * scale / 2) - YView = (-docView.props.GetTransform().TranslateY * scale) + (window.innerHeight / 2) - (height * scale / 2) + scale = docView.props.ScreenToLocalTransform().Scale + XView = (-docView.props.ScreenToLocalTransform().TranslateX * scale) + (window.innerWidth / 2) - (width * scale / 2) + YView = (-docView.props.ScreenToLocalTransform().TranslateY * scale) + (window.innerHeight / 2) - (height * scale / 2) //set x and y view of parent } //parent is not main, parent is centered and calls itself @@ -118,19 +118,31 @@ export class DocumentManager { let tempView = this.getDocumentView(docView.props.ContainingCollectionView.props.DocumentForCollection) - console.log(docView.props.ContainingCollectionView.props.DocumentForCollection.GetNumber(KeyStore.Width, 0)) + //console.log(docView.props.ContainingCollectionView.props.DocumentForCollection.GetNumber(KeyStore.NativeWidth, 0)) + + // let parentWidth = docView.props.ContainingCollectionView.props.DocumentForCollection.GetNumber(KeyStore.Width, 0) + // let parentHeight = docView.props.ContainingCollectionView.props.DocumentForCollection.GetNumber(KeyStore.Height, 0) let parentWidth = docView.props.ContainingCollectionView.props.DocumentForCollection.GetNumber(KeyStore.Width, 0) let parentHeight = docView.props.ContainingCollectionView.props.DocumentForCollection.GetNumber(KeyStore.Height, 0) + //_htmlElement!.clientWidth - console.log("parent width: " + parentWidth + ", parent height: " + parentHeight) + // console.log("window width: " + window.innerWidth + ", window height: " + window.innerHeight) + // console.log("parent width: " + parentWidth + ", parent height: " + parentHeight) if (tempView != null) { console.log("View is NOT null") - scale = tempView.props.GetTransform().Scale - XView = (-docView.props.GetTransform().TranslateX * scale) + (parentWidth / 2) - (width * scale / 2); - YView = (-docView.props.GetTransform().TranslateY * scale) + (parentHeight / 2) - (height * scale / 2); + scale = tempView.props.ScreenToLocalTransform().Scale + + parentWidth *= scale + parentHeight *= scale + + console.log("window width: " + window.innerWidth + ", window height: " + window.innerHeight) + console.log("parent width: " + parentWidth + ", parent height: " + parentHeight) + + XView = (-docView.props.ScreenToLocalTransform().TranslateX * scale) + (parentWidth / 2) - (width * scale / 2); + YView = (-docView.props.ScreenToLocalTransform().TranslateY * scale) + (parentHeight / 2) - (height * scale / 2); //node.Parent.setViewportXY(XView, YView); this.setViewportXY(docView.props.ContainingCollectionView, XView, YView) @@ -143,7 +155,7 @@ export class DocumentManager { private setViewportXY(collection: CollectionViewBase, x: number, y: number) { if (collection.props.BackgroundView != null) { - collection.props.BackgroundView.props.GetTransform().center(x, y) + collection.props.ScreenToLocalTransform().center(x, y) } } diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx index c870a9cf0..6a0a1de78 100644 --- a/src/client/views/collections/CollectionDockingView.tsx +++ b/src/client/views/collections/CollectionDockingView.tsx @@ -100,7 +100,7 @@ export class CollectionDockingView extends CollectionViewBase { if (value[i].Id === component) { return ( Transform.Identity} + ScreenToLocalTransform={() => Transform.Identity} isTopMost={true} Scaling={1} ContainingCollectionView={this} DocumentView={undefined} />); @@ -314,9 +314,9 @@ class RenderClass { ReactDOM.render(( { + ScreenToLocalTransform={() => { let { scale, translateX, translateY } = Utils.GetScreenTransform(this._htmlElement); - return this._collectionDockingView.props.GetTransform().scale(scale).translate(-translateX, -translateY) + return this._collectionDockingView.props.ScreenToLocalTransform().scale(scale).translate(-translateX, -translateY) }} isTopMost={true} Scaling={scaling} -- cgit v1.2.3-70-g09d2