From 6048c9f8662c934a4287a259af8d7a11f6e31b54 Mon Sep 17 00:00:00 2001 From: DD Date: Wed, 13 Sep 2017 17:58:27 -0400 Subject: [PATCH] hook into other tools --- src/containers/blob/blob.js | 4 ++-- src/containers/blob/style-path.js | 4 ---- src/containers/brush-mode.jsx | 3 ++- src/containers/line-mode.jsx | 4 ++-- src/containers/select-mode.jsx | 3 ++- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/containers/blob/blob.js b/src/containers/blob/blob.js index 30bbdc95..a10565c2 100644 --- a/src/containers/blob/blob.js +++ b/src/containers/blob/blob.js @@ -3,6 +3,7 @@ import log from '../../log/log'; import BroadBrushHelper from './broad-brush-helper'; import SegmentBrushHelper from './segment-brush-helper'; import {styleCursorPreview} from './style-path'; +import {clearSelection} from '../../helper/selection'; /** * Shared code for the brush and eraser mode. Adds functions on the paper tool object @@ -232,8 +233,7 @@ class Blobbiness { // Eraser didn't hit anything selected, so assume they meant to erase from all instead of from subset // and deselect the selection if (items.length === 0) { - // TODO: Add back selection handling - // pg.selection.clearSelection(); + clearSelection(); items = paper.project.getItems({ match: function (item) { return blob.isMergeable(lastPath, item) && blob.touches(lastPath, item); diff --git a/src/containers/blob/style-path.js b/src/containers/blob/style-path.js index 658d2f77..26a2527b 100644 --- a/src/containers/blob/style-path.js +++ b/src/containers/blob/style-path.js @@ -2,8 +2,6 @@ const stylePath = function (path, options) { if (options.isEraser) { path.fillColor = 'white'; } else { - // TODO: Add back brush styling. Keep a separate active toolbar style for brush vs pen. - // path = pg.stylebar.applyActiveToolbarStyle(path); path.fillColor = options.fillColor; } }; @@ -14,8 +12,6 @@ const styleCursorPreview = function (path, options) { path.strokeColor = 'cornflowerblue'; path.strokeWidth = 1; } else { - // TODO: Add back brush styling. Keep a separate active toolbar style for brush vs pen. - // path = pg.stylebar.applyActiveToolbarStyle(path); path.fillColor = options.fillColor; } }; diff --git a/src/containers/brush-mode.jsx b/src/containers/brush-mode.jsx index bf1b372a..bbf36f11 100644 --- a/src/containers/brush-mode.jsx +++ b/src/containers/brush-mode.jsx @@ -6,6 +6,7 @@ import Modes from '../modes/modes'; import Blobbiness from './blob/blob'; import {changeBrushSize} from '../reducers/brush-mode'; import {changeMode} from '../reducers/modes'; +import {clearSelection} from '../helper/selection'; import BrushModeComponent from '../components/brush-mode.jsx'; class BrushMode extends React.Component { @@ -42,7 +43,7 @@ class BrushMode extends React.Component { activateTool () { // TODO: Instead of clearing selection, consider a kind of "draw inside" // analogous to how selection works with eraser - // pg.selection.clearSelection(); + clearSelection(); // TODO: This is temporary until a component that provides the brush size is hooked up this.props.canvas.addEventListener('mousewheel', this.onScroll); diff --git a/src/containers/line-mode.jsx b/src/containers/line-mode.jsx index 35e47b53..0af6f939 100644 --- a/src/containers/line-mode.jsx +++ b/src/containers/line-mode.jsx @@ -4,6 +4,7 @@ import {connect} from 'react-redux'; import bindAll from 'lodash.bindall'; import Modes from '../modes/modes'; import {changeStrokeWidth} from '../reducers/stroke-width'; +import {clearSelection} from '../helper/selection'; import LineModeComponent from '../components/line-mode.jsx'; import {changeMode} from '../reducers/modes'; import paper from 'paper'; @@ -42,8 +43,7 @@ class LineMode extends React.Component { return false; // Static component, for now } activateTool () { - // TODO add back selection - // pg.selection.clearSelection(); + clearSelection(); this.props.canvas.addEventListener('mousewheel', this.onScroll); this.tool = new paper.Tool(); diff --git a/src/containers/select-mode.jsx b/src/containers/select-mode.jsx index 79dbe330..104e3e98 100644 --- a/src/containers/select-mode.jsx +++ b/src/containers/select-mode.jsx @@ -62,8 +62,8 @@ class SelectMode extends React.Component { return this._hitOptions; } activateTool () { - clearSelection(); selectRootItem(); + this.boundingBoxTool.setSelectionBounds(); this.tool = new paper.Tool(); const selectMode = this; @@ -126,6 +126,7 @@ class SelectMode extends React.Component { } deactivateTool () { this.props.clearHoveredItem(); + this.boundingBoxTool.removeBoundsPath(); this.tool.remove(); this.tool = null; this.hitResult = null;