aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/InkingControl.tsx
diff options
context:
space:
mode:
authorkimdahey <claire_kim1@brown.edu>2019-09-17 16:16:20 -0400
committerkimdahey <claire_kim1@brown.edu>2019-09-17 16:16:20 -0400
commitf520d5a821b515e0c216f055e93f0549bd6733a9 (patch)
treed55d25a4280bf89d3c39fd8989700ca00b328a2e /src/client/views/InkingControl.tsx
parent147c208a9a1196d2ded540e28dc3d7f26d5ba0a9 (diff)
parent1310633790e3db50a31a1cc6d357306d7884a053 (diff)
fixed merge conflicts
Diffstat (limited to 'src/client/views/InkingControl.tsx')
-rw-r--r--src/client/views/InkingControl.tsx33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/client/views/InkingControl.tsx b/src/client/views/InkingControl.tsx
index aa573f16b..57dad5e6b 100644
--- a/src/client/views/InkingControl.tsx
+++ b/src/client/views/InkingControl.tsx
@@ -51,8 +51,17 @@ export class InkingControl extends React.Component {
let oldColors = selected.map(view => {
let targetDoc = view.props.Document.layout instanceof Doc ? view.props.Document.layout : view.props.Document.isTemplate ? view.props.Document : Doc.GetProto(view.props.Document);
let oldColor = StrCast(targetDoc.backgroundColor);
- if (view.props.ContainingCollectionView && view.props.ContainingCollectionView.props.Document.colorPalette) {
- let cp = Cast(view.props.ContainingCollectionView.props.Document.colorPalette, listSpec("string")) as string[];
+ let matchedColor = this._selectedColor;
+ const cv = view.props.ContainingCollectionView;
+ let ruleProvider: Doc | undefined;
+ if (cv) {
+ if (!cv.props.Document.colorPalette) {
+ let defaultPalette = ["rg14,229,239)", "rgb(255,246,209)", "rgb(255,188,156)", "rgb(247,220,96)", "rgb(122,176,238)",
+ "rgb(209,150,226)", "rgb(127,235,144)", "rgb(252,188,189)", "rgb(247,175,81)",];
+ let colorPalette = Cast(cv.props.Document.colorPalette, listSpec("string"));
+ if (!colorPalette) cv.props.Document.colorPalette = new List<string>(defaultPalette);
+ }
+ let cp = Cast(cv.props.Document.colorPalette, listSpec("string")) as string[];
let closest = 0;
let dist = 10000000;
let ccol = Utils.fromRGBAstr(StrCast(targetDoc.backgroundColor));
@@ -65,21 +74,13 @@ export class InkingControl extends React.Component {
}
}
cp[closest] = "rgba(" + color.rgb.r + "," + color.rgb.g + "," + color.rgb.b + "," + color.rgb.a + ")";
- view.props.ContainingCollectionView.props.Document.colorPalette = new List(cp);
- targetDoc.backgroundColor = cp[closest];
- } else
- targetDoc.backgroundColor = this._selectedColor;
- if (view.props.Document.heading) {
- let cv = view.props.ContainingCollectionView;
- let ruleProvider = cv && (Cast(cv.props.Document.ruleProvider, Doc) as Doc);
- let parback = cv && StrCast(cv.props.Document.backgroundColor);
- cv && parback && ((ruleProvider ? ruleProvider : cv.props.Document)["ruleColor_" + NumCast(view.props.Document.heading)] = Utils.toRGBAstr(color.rgb));
- // if (parback && cv && parback.indexOf("rgb") !== -1) {
- // let parcol = Utils.fromRGBAstr(parback);
- // let hsl = Utils.RGBToHSL(parcol.r, parcol.g, parcol.b);
- // cv && ((ruleProvider ? ruleProvider : cv.props.Document)["ruleColor_" + NumCast(view.props.Document.heading)] = color.hsl.s - hsl.s);
- // }
+ cv.props.Document.colorPalette = new List(cp);
+ matchedColor = cp[closest];
+ ruleProvider = (view.props.Document.heading && cv && cv.props.ruleProvider) ? cv.props.ruleProvider : undefined;
+ ruleProvider && ((Doc.GetProto(ruleProvider)["ruleColor_" + NumCast(view.props.Document.heading)] = Utils.toRGBAstr(color.rgb)));
}
+ !ruleProvider && (targetDoc.backgroundColor = matchedColor);
+
return {
target: targetDoc,
previous: oldColor