aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/util/InteractionUtils.ts2
-rw-r--r--src/client/views/Touchable.tsx4
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx23
-rw-r--r--src/client/views/nodes/DocumentView.tsx8
-rw-r--r--src/pen-gestures/GestureUtils.ts16
-rw-r--r--src/pen-gestures/ndollar.ts2
6 files changed, 31 insertions, 24 deletions
diff --git a/src/client/util/InteractionUtils.ts b/src/client/util/InteractionUtils.ts
index 7390890c6..7c386abc2 100644
--- a/src/client/util/InteractionUtils.ts
+++ b/src/client/util/InteractionUtils.ts
@@ -53,7 +53,7 @@ export namespace InteractionUtils {
* @param oldPoint2 - previous point 2
*/
export function Pinching(pt1: React.Touch, pt2: React.Touch, oldPoint1: React.Touch, oldPoint2: React.Touch): number {
- let threshold = 3;
+ let threshold = window.devicePixelRatio;
let oldDist = TwoPointEuclidist(oldPoint1, oldPoint2);
let newDist = TwoPointEuclidist(pt1, pt2);
diff --git a/src/client/views/Touchable.tsx b/src/client/views/Touchable.tsx
index 5dcfec768..a647dec04 100644
--- a/src/client/views/Touchable.tsx
+++ b/src/client/views/Touchable.tsx
@@ -18,9 +18,9 @@ export abstract class Touchable<T = {}> extends React.Component<T> {
protected onTouchStart = (e: React.TouchEvent): void => {
for (let i = 0; i < e.targetTouches.length; i++) {
let pt: any = e.targetTouches.item(i);
- // pen is also a touch, but with a radius of 0.5 (at least with the surface pens). i doubt anyone's fingers are 2 pixels wide,
+ // pen is also a touch, but with a radius of 0.5 (at least with the surface pens).
// and this seems to be the only way of differentiating pen and touch on touch events
- if (pt.radiusX > 2 && pt.radiusY > 2) {
+ if (pt.radiusX > 0.5 && pt.radiusY > 0.5) {
this.prevPoints.set(pt.identifier, pt);
}
}
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 6dd472c84..bec0ace5a 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -340,8 +340,23 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
let points = this._points.map(p => ({ X: p.X - B.left, Y: p.Y - B.top }));
let result = GestureUtils.GestureRecognizer.Recognize(new Array(points));
- if (result) {
- console.log(result.Name);
+ if (result && result.Score > 0.75) {
+ switch (result.Name) {
+ case GestureUtils.Gestures.Box:
+ let bounds = { x: Math.min(...this._points.map(p => p.X)), r: Math.max(...this._points.map(p => p.X)), y: Math.min(...this._points.map(p => p.y)), b: Math.max(...this._points.map(p => p.Y)) };
+ let sel = this.getActiveDocuments().filter(doc => {
+ let l = NumCast(doc.x);
+ let r = l + doc[WidthSym]();
+ let t = NumCast(doc.y);
+ let b = t + doc[HeightSym]();
+ doc.x = l - B.left - B.width / 2;
+ doc.y = t - B.top - B.height / 2;
+ return !(bounds.x > r || bounds.r < l || bounds.y > b || bounds.b < t);
+ });
+ this.addDocument(Docs.Create.FreeformDocument(sel, { x: B.left, y: B.top, width: B.width, height: B.height, panX: 0, panY: 0 }));
+ sel.forEach(d => this.props.removeDocument(d));
+ break;
+ }
this._points = [];
}
else {
@@ -474,8 +489,8 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
let rawDelta = (dir * (d1 + d2));
// this floors and ceils the delta value to prevent jitteriness
- let delta = Math.sign(rawDelta) * Math.min(Math.abs(rawDelta), 16);
- this.zoom(centerX, centerY, delta);
+ let delta = Math.sign(rawDelta) * Math.min(Math.abs(rawDelta), 8);
+ this.zoom(centerX, centerY, delta * window.devicePixelRatio);
this.prevPoints.set(pt1.identifier, pt1);
this.prevPoints.set(pt2.identifier, pt2);
}
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 38c46b258..dfeadb8c0 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -142,7 +142,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
(Math.abs(e.clientX - this._downX) < Utils.DRAG_THRESHOLD && Math.abs(e.clientY - this._downY) < Utils.DRAG_THRESHOLD)) {
e.stopPropagation();
let preventDefault = true;
- if (this._doubleTap && this.props.renderDepth && !this.onClickHandler ?.script) { // disable double-click to show full screen for things that have an on click behavior since clicking them twice can be misinterpreted as a double click
+ if (this._doubleTap && this.props.renderDepth && !this.onClickHandler?.script) { // disable double-click to show full screen for things that have an on click behavior since clicking them twice can be misinterpreted as a double click
let fullScreenAlias = Doc.MakeAlias(this.props.Document);
if (StrCast(fullScreenAlias.layoutKey) !== "layoutCustom" && fullScreenAlias.layoutCustom !== undefined) {
fullScreenAlias.layoutKey = "layoutCustom";
@@ -362,7 +362,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
@undoBatch
@action
setCustomView = (custom: boolean): void => {
- if (this.props.ContainingCollectionView ?.props.DataDoc || this.props.ContainingCollectionView ?.props.Document.isTemplateDoc) {
+ if (this.props.ContainingCollectionView?.props.DataDoc || this.props.ContainingCollectionView?.props.Document.isTemplateDoc) {
Doc.MakeMetadataFieldTemplate(this.props.Document, this.props.ContainingCollectionView.props.Document);
} else {
custom ? DocumentView.makeCustomViewClicked(this.props.Document, this.props.DataDoc) : DocumentView.makeNativeViewClicked(this.props.Document);
@@ -687,10 +687,10 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
return <div className={`documentView-node${this.topMost ? "-topmost" : ""}`} ref={this._mainCont}
onDrop={this.onDrop} onContextMenu={this.onContextMenu} onPointerDown={this.onPointerDown} onClick={this.onClick}
onPointerEnter={e => {
- console.log("Brush" + this.props.Document.title);
+ // console.log("Brush" + this.props.Document.title);
Doc.BrushDoc(this.props.Document);
}} onPointerLeave={e => {
- console.log("UnBrush" + this.props.Document.title);
+ // console.log("UnBrush" + this.props.Document.title);
Doc.UnBrushDoc(this.props.Document);
}}
diff --git a/src/pen-gestures/GestureUtils.ts b/src/pen-gestures/GestureUtils.ts
index 7a14452c8..955dad5b4 100644
--- a/src/pen-gestures/GestureUtils.ts
+++ b/src/pen-gestures/GestureUtils.ts
@@ -2,7 +2,9 @@ import { NDollarRecognizer } from "./ndollar";
import { Type } from "typescript";
import { InkField } from "../new_fields/InkField";
import { Docs } from "../client/documents/Documents";
-import { Doc } from "../new_fields/Doc";
+import { Doc, WidthSym, HeightSym } from "../new_fields/Doc";
+import { NumCast } from "../new_fields/Types";
+import { CollectionFreeFormView } from "../client/views/collections/collectionFreeForm/CollectionFreeFormView";
export namespace GestureUtils {
namespace GestureDataTypes {
@@ -15,21 +17,11 @@ export namespace GestureUtils {
export const GestureRecognizer = new NDollarRecognizer(false);
- export function GestureOptions(name: Gestures, gestureData: any): (() => any)[] {
+ export function GestureOptions(name: string, gestureData?: any): (params: {}) => any {
switch (name) {
case Gestures.Box:
- if (gestureData as GestureDataTypes.BoxData) {
- return BoxOptions(gestureData as GestureDataTypes.BoxData);
- }
break;
}
throw new Error("This means that you're trying to do something with the gesture that hasn't been defined yet. Define it in GestureUtils.ts");
}
-
- function BoxOptions(gestureData: GestureDataTypes.BoxData): (() => any)[] {
- if (gestureData instanceof Array) {
- return [() => Docs.Create.FreeformDocument(gestureData as Doc[], {})];
- }
- return [];
- }
} \ No newline at end of file
diff --git a/src/pen-gestures/ndollar.ts b/src/pen-gestures/ndollar.ts
index 5d4384202..8c8e079a4 100644
--- a/src/pen-gestures/ndollar.ts
+++ b/src/pen-gestures/ndollar.ts
@@ -168,7 +168,7 @@ export class NDollarRecognizer {
//
this.Multistrokes = new Array(NumMultistrokes);
this.Multistrokes[0] = new Multistroke(GestureUtils.Gestures.Box, useBoundedRotationInvariance, new Array(
- new Array(new Point(30, 146), new Point(30, 222), new Point(106, 225), new Point(106, 146))
+ new Array(new Point(30, 146), new Point(30, 222), new Point(106, 225), new Point(106, 146), new Point(30, 146))
));
//