-
Notifications
You must be signed in to change notification settings - Fork 0
Add frame selection overhaul for grid shapes #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
657c574
25a543a
57217c3
04e23f2
0f41b03
ae9bec3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import { StateNode, TLPointerEventInfo, TLShape } from '@tldraw/editor' | ||
| import { Group2d, StateNode, TLPointerEventInfo, TLShape } from '@tldraw/editor' | ||
| import { isOverArrowLabel } from '../../../shapes/arrow/arrowLabel' | ||
| import { getTextLabels } from '../../../utils/shapes/shapes' | ||
|
|
||
|
|
@@ -11,6 +11,7 @@ export class PointingShape extends StateNode { | |
|
|
||
| didCtrlOnEnter = false | ||
| didSelectOnEnter = false | ||
| didHitGridLabel = false | ||
|
|
||
| override onEnter(info: TLPointerEventInfo & { target: 'shape' }) { | ||
| const selectedShapeIds = this.editor.getSelectedShapeIds() | ||
|
|
@@ -22,6 +23,19 @@ export class PointingShape extends StateNode { | |
| this.hitShape = info.shape | ||
| this.isDoubleClick = false | ||
| this.didCtrlOnEnter = accelKey | ||
| this.didHitGridLabel = false | ||
| if ((info.shape as any).type === 'grid') { | ||
| const geometry = this.editor.getShapeGeometry(info.shape) | ||
| if (geometry instanceof Group2d) { | ||
| const pointInShapeSpace = this.editor.getPointInShapeSpace(info.shape, currentPagePoint) | ||
| for (const child of geometry.children) { | ||
| if (child.isLabel && child.isPointInBounds(pointInShapeSpace)) { | ||
| this.didHitGridLabel = true | ||
| break | ||
| } | ||
| } | ||
| } | ||
| } | ||
| const outermostSelectingShape = this.editor.getOutermostSelectableShape(info.shape) | ||
| const selectedAncestor = this.editor.findShapeAncestor(outermostSelectingShape, (parent) => | ||
| selectedShapeIds.includes(parent.id) | ||
|
|
@@ -217,6 +231,9 @@ export class PointingShape extends StateNode { | |
|
|
||
| if (this.didCtrlOnEnter) { | ||
| this.parent.transition('brushing', info) | ||
| } else if (this.didSelectOnEnter && (this.hitShape as any).type === 'grid' && !this.didHitGridLabel) { | ||
| this.editor.setSelectedShapes([]) | ||
| this.parent.transition('brushing', { ...info, target: 'canvas' as const }) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shift+drag from grid body loses prior selectionMedium Severity
Additional Locations (1) |
||
| } else { | ||
| this.startTranslating(info) | ||
| } | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.