From 556f770a4c7e9c9f9df7d8857dd496ff1dedc6e7 Mon Sep 17 00:00:00 2001 From: bobzel Date: Wed, 13 Sep 2023 13:54:53 -0400 Subject: fixed ink lines to highlight with a dropshadow. added a stroke_borderWidth, but no UI for it. --- src/client/util/InteractionUtils.tsx | 4 +++- src/client/views/InkingStroke.tsx | 22 ++++++++++++---------- src/client/views/StyleProvider.tsx | 9 +++++---- 3 files changed, 20 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/client/util/InteractionUtils.tsx b/src/client/util/InteractionUtils.tsx index d0f459291..464643b09 100644 --- a/src/client/util/InteractionUtils.tsx +++ b/src/client/util/InteractionUtils.tsx @@ -108,7 +108,8 @@ export namespace InteractionUtils { opacity: number, nodefs: boolean, downHdlr?: (e: React.PointerEvent) => void, - mask?: boolean + mask?: boolean, + dropshadow?: string ) { const pts = shape ? makePolygon(shape, points) : points; @@ -172,6 +173,7 @@ export namespace InteractionUtils { () { this.layoutDoc._height = Math.round(NumCast(this.layoutDoc[Height]())); }); } + const highlight = !this.controlUndo && this.props.styleProvider?.(this.rootDoc, this.props, StyleProp.Highlighting); + const highlightIndex = highlight?.highlightIndex; + const highlightColor = (!this.props.isSelected() || !isInkMask) && highlight?.highlightIndex ? highlight?.highlightColor : undefined; + const color = StrCast(this.layoutDoc.stroke_outlineColor, !closed && fillColor && fillColor !== 'transparent' ? StrCast(this.layoutDoc.color, 'transparent') : 'transparent'); // Visually renders the polygonal line made by the user. const inkLine = InteractionUtils.CreatePolyline( @@ -411,23 +415,20 @@ export class InkingStroke extends ViewBoxBaseComponent() { '', 'none', 1.0, - false + false, + undefined, + undefined, + color === 'transparent' ? highlightColor : undefined ); - const highlight = !this.controlUndo && this.props.styleProvider?.(this.rootDoc, this.props, StyleProp.Highlighting); - const highlightIndex = highlight?.highlightIndex; - const highlightColor = - (!this.props.isSelected() || !isInkMask) && highlight?.highlightIndex - ? highlight?.highlightColor - : StrCast(this.layoutDoc.stroke_outlineColor, !closed && fillColor && fillColor !== 'transparent' ? StrCast(this.layoutDoc.color, 'transparent') : 'transparent'); // Invisible polygonal line that enables the ink to be selected by the user. const clickableLine = (downHdlr?: (e: React.PointerEvent) => void, mask: boolean = false) => InteractionUtils.CreatePolyline( inkData, inkLeft, inkTop, - mask && highlightColor === 'transparent' ? this.strokeColor : highlightColor, + mask && color === 'transparent' ? this.strokeColor : color, inkStrokeWidth, - inkStrokeWidth + (fillColor ? (closed ? 2 : (highlightIndex ?? 0) + 2) : 2), + inkStrokeWidth + NumCast(this.layoutDoc.stroke_borderWidth) + (fillColor ? (closed ? 2 : (highlightIndex ?? 0) + 2) : 2), StrCast(this.layoutDoc.stroke_lineJoin), StrCast(this.layoutDoc.stroke_lineCap), StrCast(this.layoutDoc.stroke_bezier), @@ -443,7 +444,8 @@ export class InkingStroke extends ViewBoxBaseComponent() { 0.0, false, downHdlr, - mask + mask, + highlightColor ); const fsize = +StrCast(this.props.Document._text_fontSize, '12px').replace('px', ''); // bootsrap 3 style sheet sets line height to be 20px for default 14 point font size. diff --git a/src/client/views/StyleProvider.tsx b/src/client/views/StyleProvider.tsx index 96b2ddf70..1a4b8d7d2 100644 --- a/src/client/views/StyleProvider.tsx +++ b/src/client/views/StyleProvider.tsx @@ -90,12 +90,14 @@ export function DefaultStyleProvider(doc: Opt, props: Opt doc && StrCast(Doc.Layout(doc).layout).includes(InkingStroke.name) && !props?.LayoutTemplateString; const isOpen = property.includes(':open'); const isEmpty = property.includes(':empty'); const boxBackground = property.includes(':box'); const fieldKey = props?.fieldKey ? props.fieldKey + '_' : isCaption ? 'caption_' : ''; const lockedPosition = () => doc && BoolCast(doc._lockedPosition); const backgroundCol = () => props?.styleProvider?.(doc, props, StyleProp.BackgroundColor); + const color = () => props?.styleProvider?.(doc, props, StyleProp.Color); const opacity = () => props?.styleProvider?.(doc, props, StyleProp.Opacity); const layout_showTitle = () => props?.styleProvider?.(doc, props, StyleProp.ShowTitle); // prettier-ignore @@ -120,7 +122,7 @@ export function DefaultStyleProvider(doc: Opt, props: Opt dv.rootDoc === doc); const highlightIndex = Doc.isBrushedHighlightedDegree(doc) || (selected ? Doc.DocBrushStatus.selfBrushed : 0); - const highlightColor = ['transparent', 'rgb(68, 118, 247)', selected ? 'black' : 'rgb(68, 118, 247)', 'orange', 'lightBlue'][highlightIndex]; + const highlightColor = ['transparent', 'rgb(68, 118, 247)', selected ? "black" : 'rgb(68, 118, 247)', 'orange', 'lightBlue'][highlightIndex]; const highlightStyle = ['solid', 'dashed', 'solid', 'solid', 'solid'][highlightIndex]; if (highlightIndex) { return { @@ -263,14 +265,13 @@ export function DefaultStyleProvider(doc: Opt, props: Opt { -- cgit v1.2.3-70-g09d2