From 4d15bf1cf2e37d15214c3c57fbb59da5465f30c8 Mon Sep 17 00:00:00 2001 From: bobzel Date: Mon, 20 Nov 2023 09:53:58 -0500 Subject: added rotation to transforms (partially done) --- src/client/views/DocumentDecorations.tsx | 4 ++-- src/client/views/nodes/CollectionFreeFormDocumentView.tsx | 6 +++++- src/client/views/nodes/VideoBox.tsx | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src/client/views') diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx index 6663c5ee8..dc5839bdd 100644 --- a/src/client/views/DocumentDecorations.tsx +++ b/src/client/views/DocumentDecorations.tsx @@ -69,7 +69,7 @@ export class DocumentDecorations extends React.Component<{ PanelWidth: number; P const center = {x: (this.Bounds.x+this.Bounds.r)/2, y: (this.Bounds.y+this.Bounds.b)/2}; const {x,y} = Utils.rotPt(e.clientX - center.x, e.clientY - center.y, - -NumCast(SelectionManager.Docs().lastElement()?.rotation)/180*Math.PI); + -NumCast(SelectionManager.Views().lastElement()?.screenToLocalTransform().RotateDeg)); (this._showNothing = !(this.Bounds.x !== Number.MAX_VALUE && // (this.Bounds.x > center.x+x + this._resizeBorderWidth / 2 || this.Bounds.r < center.x+x - this._resizeBorderWidth / 2 || @@ -698,7 +698,7 @@ export class DocumentDecorations extends React.Component<{ PanelWidth: number; P const bounds = this.ClippedBounds; const useLock = bounds.r - bounds.x > 135 && seldocview.CollectionFreeFormDocumentView; const useRotation = !hideResizers && seldocview.rootDoc.type !== DocumentType.EQUATION && seldocview.CollectionFreeFormDocumentView; // when do we want an object to not rotate? - const rotation = SelectionManager.Views().length == 1 ? seldocview.docViewPath.reduce((rot, view) => rot + NumCast(view.rootDoc._rotation), 0) : 0; + const rotation = SelectionManager.Views().length == 1 ? seldocview.screenToLocalTransform().RotateDeg : 0; // Radius constants const useRounding = seldocview.ComponentView instanceof ImageBox || seldocview.ComponentView instanceof FormattedTextBox || seldocview.ComponentView instanceof CollectionFreeFormView; diff --git a/src/client/views/nodes/CollectionFreeFormDocumentView.tsx b/src/client/views/nodes/CollectionFreeFormDocumentView.tsx index 5fbe5d0e3..ab124eede 100644 --- a/src/client/views/nodes/CollectionFreeFormDocumentView.tsx +++ b/src/client/views/nodes/CollectionFreeFormDocumentView.tsx @@ -226,7 +226,11 @@ export class CollectionFreeFormDocumentView extends DocComponent this.props.ScreenToLocalTransform().translate(-this.props.w_X(), -this.props.w_Y()); + screenToLocalTransform = () => + this.props + .ScreenToLocalTransform() + .translate(-this.props.w_X(), -this.props.w_Y()) + .rotateDeg(this.props.w_Rotation?.() || 0); returnThis = () => this; /// this indicates whether the doc view is activated because of its relationshop to a group diff --git a/src/client/views/nodes/VideoBox.tsx b/src/client/views/nodes/VideoBox.tsx index 459b3036d..6ebf84738 100644 --- a/src/client/views/nodes/VideoBox.tsx +++ b/src/client/views/nodes/VideoBox.tsx @@ -938,7 +938,7 @@ export class VideoBox extends ViewBoxAnnotatableComponent