aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2023-09-28 00:45:58 -0400
committerbobzel <zzzman@gmail.com>2023-09-28 00:45:58 -0400
commit442cb6eb721008191bccb4eae7fcf576aa460461 (patch)
tree00f53e1827edab17675aa03e97cd5f549e68660c /src
parent35fbb1809fab2600e3fd948d8bbcd0c29417680a (diff)
fixed resetView to not apply to groups.
Diffstat (limited to 'src')
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 9df96fabc..a64ccbb2c 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -1768,14 +1768,12 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
const appearance = ContextMenu.Instance.findByDescription('Appearance...');
const appearanceItems = appearance && 'subitems' in appearance ? appearance.subitems : [];
- appearanceItems.push({
- description: 'Reset View',
- event: () => {
- this.props.Document[this.panXFieldKey] = this.props.Document[this.panYFieldKey] = 0;
- this.props.Document[this.scaleFieldKey] = 1;
- },
- icon: 'compress-arrows-alt',
- });
+ !this.props.Document._isGroup &&
+ appearanceItems.push({
+ description: 'Reset View',
+ event: () => CollectionFreeFormView.ResetView(this),
+ icon: 'compress-arrows-alt',
+ });
!Doc.noviceMode &&
appearanceItems.push({
description: 'Toggle auto arrange',
@@ -2099,6 +2097,22 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
</div>
);
}
+ /// resetView restores a freeform collection to unit scale and centered at (0,0) UNLESS
+ // the view is a group, in which case this does nothing (since Groups calculate their own scale and center)
+ static ResetView(view?: CollectionFreeFormView) {
+ if (view) {
+ if (view.props.Document._isGroup) return;
+ view.props.Document[view.panXFieldKey] = view.props.Document[view.panYFieldKey] = 0;
+ view.props.Document[view.scaleFieldKey] = 1;
+ } else {
+ SelectionManager.Docs()
+ .filter(doc => !doc._isGroup)
+ .forEach(doc => {
+ doc._freeform_panX = doc._freeform_panY = 0;
+ doc._freeform_scale = 1;
+ });
+ }
+ }
}
interface CollectionFreeFormOverlayViewProps {
@@ -2345,8 +2359,5 @@ ScriptingGlobals.add(function sendToBack(doc: Doc) {
SelectionManager.Views().forEach(view => view.props.CollectionFreeFormDocumentView?.().props.CollectionFreeFormView.bringToFront(view.rootDoc, true));
});
ScriptingGlobals.add(function resetView() {
- SelectionManager.Docs().forEach(doc => {
- doc._freeform_panX = doc._freeform_panY = 0;
- doc._freeform_scale = 1;
- });
+ CollectionFreeFormView.ResetView();
});