aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/InkingStroke.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-01-25 00:07:39 -0500
committerGitHub <noreply@github.com>2024-01-25 00:07:39 -0500
commitbdcada2f285a3cdbefe55f5dc46836b7cbe6423d (patch)
tree0058dae39c9c9ebfe16f4659bd1fa98715260873 /src/client/views/InkingStroke.tsx
parenteae271b661465c915ea3a27ff25406409c4b377f (diff)
parentf71d5693bb2c7e79e459a97d9a855cd0542dd7e9 (diff)
Merge pull request #291 from brown-dash/UpgradingRedux
Upgrading redux
Diffstat (limited to 'src/client/views/InkingStroke.tsx')
-rw-r--r--src/client/views/InkingStroke.tsx19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/client/views/InkingStroke.tsx b/src/client/views/InkingStroke.tsx
index c652e8966..92644d3c5 100644
--- a/src/client/views/InkingStroke.tsx
+++ b/src/client/views/InkingStroke.tsx
@@ -34,21 +34,19 @@ import { InteractionUtils } from '../util/InteractionUtils';
import { SnappingManager } from '../util/SnappingManager';
import { UndoManager } from '../util/UndoManager';
import { ContextMenu } from './ContextMenu';
-import { ViewBoxBaseComponent } from './DocComponent';
+import { ViewBoxBaseComponent, ViewBoxInterface } from './DocComponent';
import { Colors } from './global/globalEnums';
import { InkControlPtHandles, InkEndPtHandles } from './InkControlPtHandles';
import './InkStroke.scss';
import { InkStrokeProperties } from './InkStrokeProperties';
import { InkTangentHandles } from './InkTangentHandles';
-import { DocComponentView } from './nodes/DocumentView';
import { FieldView, FieldViewProps } from './nodes/FieldView';
import { FormattedTextBox } from './nodes/formattedText/FormattedTextBox';
import { PinProps, PresBox } from './nodes/trails';
import { StyleProp } from './StyleProvider';
-import { Transform } from '../util/Transform';
const { default: { INK_MASK_SIZE } } = require('./global/globalCssVariables.module.scss'); // prettier-ignore
@observer
-export class InkingStroke extends ViewBoxBaseComponent<FieldViewProps>() {
+export class InkingStroke extends ViewBoxBaseComponent<FieldViewProps>() implements ViewBoxInterface {
static readonly MaskDim = INK_MASK_SIZE; // choose a really big number to make sure mask fits over container (which in theory can be arbitrarily big)
public static LayoutString(fieldStr: string) {
return FieldView.LayoutString(InkingStroke, fieldStr);
@@ -64,7 +62,7 @@ export class InkingStroke extends ViewBoxBaseComponent<FieldViewProps>() {
@observable _nearestScrPt?: { X: number; Y: number }; // nearst screen point on the ink stroke ""
componentDidMount() {
- this._props.setContentView?.(this);
+ this._props.setContentViewBox?.(this);
this._disposers.selfDisper = reaction(
() => this._props.isSelected(), // react to stroke being deselected by turning off ink handles
selected => !selected && (InkStrokeProperties.Instance._controlButton = false)
@@ -122,7 +120,8 @@ export class InkingStroke extends ViewBoxBaseComponent<FieldViewProps>() {
@action
onPointerDown = (e: React.PointerEvent) => {
this._handledClick = false;
- const inkView = this._props.docViewPath().lastElement();
+ const inkView = this.DocumentView?.();
+ if (!inkView) return;
const { inkData, inkScaleX, inkScaleY, inkStrokeWidth, inkTop, inkLeft } = this.inkScaledData();
const screenPts = inkData
.map(point =>
@@ -162,7 +161,7 @@ export class InkingStroke extends ViewBoxBaseComponent<FieldViewProps>() {
InkStrokeProperties.Instance._currentPoint = -1;
this._handledClick = true; // mark the double-click pseudo pointerevent so we can block the real mouse event from propagating to DocumentView
if (isEditing) {
- this._nearestT && this._nearestSeg !== undefined && InkStrokeProperties.Instance.addPoints(this._props.docViewPath().lastElement(), this._nearestT, this._nearestSeg, this.inkScaledData().inkData.slice());
+ this._nearestT && this._nearestSeg !== undefined && InkStrokeProperties.Instance.addPoints(inkView, this._nearestT, this._nearestSeg, this.inkScaledData().inkData.slice());
}
}
}),
@@ -331,8 +330,8 @@ export class InkingStroke extends ViewBoxBaseComponent<FieldViewProps>() {
);
};
- _subContentView: DocComponentView | undefined;
- setSubContentView = (doc: DocComponentView) => (this._subContentView = doc);
+ _subContentView: ViewBoxInterface | undefined;
+ setSubContentView = (doc: ViewBoxInterface) => (this._subContentView = doc);
@computed get fillColor() {
const isInkMask = BoolCast(this.layoutDoc.stroke_isInkMask);
return isInkMask ? DashColor(StrCast(this.layoutDoc.fillColor, 'transparent')).blacken(0).rgb().toString() : this._props.styleProvider?.(this.layoutDoc, this._props, StyleProp.FillColor) ?? 'transparent';
@@ -461,7 +460,7 @@ export class InkingStroke extends ViewBoxBaseComponent<FieldViewProps>() {
<FormattedTextBox
{...this._props}
setHeight={undefined}
- setContentView={this.setSubContentView} // this makes the inkingStroke the "dominant" component - ie, it will show the inking UI when selected (not text)
+ setContentViewBox={this.setSubContentView} // this makes the inkingStroke the "dominant" component - ie, it will show the inking UI when selected (not text)
yPadding={10}
xPadding={10}
fieldKey="text"