diff options
author | bob <bcz@cs.brown.edu> | 2019-07-03 12:00:59 -0400 |
---|---|---|
committer | bob <bcz@cs.brown.edu> | 2019-07-03 12:00:59 -0400 |
commit | c619bad0281ea6f248c48b8d418f324f67f530dd (patch) | |
tree | 197b8cef6b4ac6a6a527a5148f3f170a6f6638ad /src/new_fields/Doc.ts | |
parent | 5e35e1895bb54568bbf8cc3991480e20edd1de83 (diff) |
added to fitToBox to treeviews. fixed some fitToBox issues. moved notifications button to library tree view.
Diffstat (limited to 'src/new_fields/Doc.ts')
-rw-r--r-- | src/new_fields/Doc.ts | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index 734a90731..29d35e19f 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -249,6 +249,18 @@ export namespace Doc { return true; } + export function ComputeContentBounds(doc: Doc) { + let bounds = DocListCast(doc.data).reduce((bounds, doc) => { + var [sptX, sptY] = [NumCast(doc.x), NumCast(doc.y)]; + let [bptX, bptY] = [sptX + doc[WidthSym](), sptY + doc[HeightSym]()]; + return { + x: Math.min(sptX, bounds.x), y: Math.min(sptY, bounds.y), + r: Math.max(bptX, bounds.r), b: Math.max(bptY, bounds.b) + }; + }, { x: Number.MAX_VALUE, y: Number.MAX_VALUE, r: Number.MIN_VALUE, b: Number.MIN_VALUE }); + return bounds; + } + // // Resolves a reference to a field by returning 'doc' if o field extension is specified, // otherwise, it returns the extension document stored in doc.<fieldKey>_ext. |