aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBob Zeleznik <zzzman@gmail.com>2019-08-02 18:21:23 -0400
committerBob Zeleznik <zzzman@gmail.com>2019-08-02 18:21:23 -0400
commitfe9017c3cdc2481f4bcce40dcc1514a6f7af37dc (patch)
tree115cf92bb0f54f1894a10ed06809a2953bd57f5c /src
parentb6341b2c64f7b2431bd4e1b8b6fa69d296f6b7be (diff)
improvements to grouping with backgrounds
Diffstat (limited to 'src')
-rw-r--r--src/client/views/collections/CollectionBaseView.tsx2
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx68
-rw-r--r--src/client/views/nodes/DocumentView.tsx9
3 files changed, 44 insertions, 35 deletions
diff --git a/src/client/views/collections/CollectionBaseView.tsx b/src/client/views/collections/CollectionBaseView.tsx
index c595a4c56..6801b94fd 100644
--- a/src/client/views/collections/CollectionBaseView.tsx
+++ b/src/client/views/collections/CollectionBaseView.tsx
@@ -147,7 +147,7 @@ export class CollectionBaseView extends React.Component<CollectionViewProps> {
<div id="collectionBaseView"
style={{
pointerEvents: this.props.Document.isBackground ? "none" : "all",
- boxShadow: `#9c9396 ${StrCast(this.props.Document.boxShadow, "0.2vw 0.2vw 0.8vw")}`
+ boxShadow: this.props.Document.isBackground ? undefined : `#9c9396 ${StrCast(this.props.Document.boxShadow, "0.2vw 0.2vw 0.8vw")}`
}}
className={this.props.className || "collectionView-cont"}
onContextMenu={this.props.onContextMenu} ref={this.props.contentRef}>
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 232ac22c9..bc1aee159 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -108,6 +108,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
private addDocument = (newBox: Doc, allowDuplicates: boolean) => {
this.props.addDocument(newBox, false);
this.bringToFront(newBox);
+ this.updateClusters();
return true;
}
private selectDocuments = (docs: Doc[]) => {
@@ -175,34 +176,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
this.bringToFront(d);
});
- let sets: (Doc[])[] = []
- this.childDocs.map(c => {
- let included = []
- for (let i = 0; i < sets.length; i++) {
- for (let j = 0; j < sets[i].length; j++) {
- if (this.bounsdSelect(c, sets[i][j])) {
- included.push(i);
- break;
- }
- }
- }
- if (included.length === 0)
- sets.push([c]);
- else if (included.length === 1)
- sets[included[0]].push(c);
- else {
- sets[included[0]].push(c);
- for (let s = 1; s < included.length; s++) {
- sets[included[0]].push(...sets[included[s]]);
- sets[included[s]].length = 0;
- }
- }
- });
- for (let s = 0; s < sets.length; s++) {
- for (let i = 0; i < sets[s].length; i++) {
- Doc.GetProto(sets[s][i]).cluster = s;
- }
- }
+ this.updateClusters();
}
}
else if (de.data instanceof DragManager.AnnotationDragData) {
@@ -224,6 +198,38 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
}
@action
+ updateClusters() {
+ let sets: (Doc[])[] = []
+ this.childDocs.map(c => {
+ let included = []
+ for (let i = 0; i < sets.length; i++) {
+ for (let j = 0; j < sets[i].length; j++) {
+ if (this.bounsdSelect(c, sets[i][j])) {
+ included.push(i);
+ break;
+ }
+ }
+ }
+ if (included.length === 0)
+ sets.push([c]);
+ else if (included.length === 1)
+ sets[included[0]].push(c);
+ else {
+ sets[included[0]].push(c);
+ for (let s = 1; s < included.length; s++) {
+ sets[included[0]].push(...sets[included[s]]);
+ sets[included[s]].length = 0;
+ }
+ }
+ });
+ for (let s = 0; s < sets.length; s++) {
+ for (let i = 0; i < sets[s].length; i++) {
+ Doc.GetProto(sets[s][i]).cluster = s;
+ }
+ }
+ }
+
+ @action
onPointerDown = (e: React.PointerEvent): void => {
if (e.button === 0 && !e.shiftKey && !e.altKey && (!this.isAnnotationOverlay || this.zoomScaling() !== 1) && this.props.active()) {
document.removeEventListener("pointermove", this.onPointerMove);
@@ -247,8 +253,8 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
let cluster = this.childDocs.reduce((cluster, cd) => {
let cx = NumCast(cd.x) - this._groupingBorder;
let cy = NumCast(cd.y) - this._groupingBorder;
- let cw = NumCast(cd.width) + this._groupingBorder;
- let ch = NumCast(cd.height) + this._groupingBorder;
+ let cw = NumCast(cd.width) + 2 * this._groupingBorder;
+ let ch = NumCast(cd.height) + 2 * this._groupingBorder;
if (this.intersectRect({ left: cx, top: cy, width: cw, height: ch }, { left: probe[0], top: probe[1], width: 1, height: 1 }))
return NumCast(cd.cluster);
return cluster;
@@ -392,7 +398,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
}
bringToFront = (doc: Doc, sendToBack?: boolean) => {
- if (sendToBack) {
+ if (sendToBack || doc.isBackground) {
doc.zIndex = 0;
return;
}
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index d79b58a7b..16ae5471d 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -695,7 +695,8 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
});
}
let showTextTitle = showTitle && StrCast(this.layoutDoc.layout).startsWith("<FormattedTextBox") ? showTitle : undefined;
- let colors = ["#da42429e", "#31ea318c", "#4a7ae2c4", "#d809ff", "#ff7601", "#1dffff", "#000000ad"];
+ let colors = ["#da42429e", "#31ea318c", "#8c4000", "#4a7ae2c4", "#d809ff", "#ff7601", "#1dffff", "yellow", "#1b8231f2", "#000000ad"];
+ let groupCol = colors[NumCast(this.props.Document.cluster) % colors.length];
return (
<div className={`documentView-node${this.topMost ? "-topmost" : ""}`}
ref={this._mainCont}
@@ -704,7 +705,9 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
color: foregroundColor,
outlineColor: "maroon",
outlineStyle: "dashed",
- boxShadow: `${colors[NumCast(this.props.Document.cluster) % colors.length]} ${StrCast(this.props.Document.boxShadow, `0vw 0vw ${50 / this.props.ContentScaling()}px`)}`,
+ boxShadow: this.layoutDoc.isBackground ?
+ `0px 0px 50px 50px ${groupCol}` :
+ `${groupCol} ${StrCast(this.props.Document.boxShadow, `0vw 0vw ${50 / this.props.ContentScaling()}px`)}`,
outlineWidth: BoolCast(this.layoutDoc.libraryBrush) && !StrCast(Doc.GetProto(this.props.Document).borderRounding) ?
`${this.props.ScreenToLocalTransform().Scale}px` : "0px",
marginLeft: BoolCast(this.layoutDoc.libraryBrush) && StrCast(Doc.GetProto(this.props.Document).borderRounding) ?
@@ -714,7 +717,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
border: BoolCast(this.layoutDoc.libraryBrush) && StrCast(Doc.GetProto(this.props.Document).borderRounding) ?
`dashed maroon ${this.props.ScreenToLocalTransform().Scale}px` : undefined,
borderRadius: "inherit",
- background: backgroundColor,
+ background: this.layoutDoc.isBackground ? groupCol : backgroundColor,
width: nativeWidth,
height: nativeHeight,
transform: `scale(${this.props.ContentScaling()})`,