mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2024-12-22 21:42:30 -05:00
hook into other tools
This commit is contained in:
parent
3fa8073bd1
commit
6048c9f866
5 changed files with 8 additions and 10 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue