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 BroadBrushHelper from './broad-brush-helper';
|
||||||
import SegmentBrushHelper from './segment-brush-helper';
|
import SegmentBrushHelper from './segment-brush-helper';
|
||||||
import {styleCursorPreview} from './style-path';
|
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
|
* 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
|
// Eraser didn't hit anything selected, so assume they meant to erase from all instead of from subset
|
||||||
// and deselect the selection
|
// and deselect the selection
|
||||||
if (items.length === 0) {
|
if (items.length === 0) {
|
||||||
// TODO: Add back selection handling
|
clearSelection();
|
||||||
// pg.selection.clearSelection();
|
|
||||||
items = paper.project.getItems({
|
items = paper.project.getItems({
|
||||||
match: function (item) {
|
match: function (item) {
|
||||||
return blob.isMergeable(lastPath, item) && blob.touches(lastPath, item);
|
return blob.isMergeable(lastPath, item) && blob.touches(lastPath, item);
|
||||||
|
|
|
@ -2,8 +2,6 @@ const stylePath = function (path, options) {
|
||||||
if (options.isEraser) {
|
if (options.isEraser) {
|
||||||
path.fillColor = 'white';
|
path.fillColor = 'white';
|
||||||
} else {
|
} 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;
|
path.fillColor = options.fillColor;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -14,8 +12,6 @@ const styleCursorPreview = function (path, options) {
|
||||||
path.strokeColor = 'cornflowerblue';
|
path.strokeColor = 'cornflowerblue';
|
||||||
path.strokeWidth = 1;
|
path.strokeWidth = 1;
|
||||||
} else {
|
} 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;
|
path.fillColor = options.fillColor;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,6 +6,7 @@ import Modes from '../modes/modes';
|
||||||
import Blobbiness from './blob/blob';
|
import Blobbiness from './blob/blob';
|
||||||
import {changeBrushSize} from '../reducers/brush-mode';
|
import {changeBrushSize} from '../reducers/brush-mode';
|
||||||
import {changeMode} from '../reducers/modes';
|
import {changeMode} from '../reducers/modes';
|
||||||
|
import {clearSelection} from '../helper/selection';
|
||||||
import BrushModeComponent from '../components/brush-mode.jsx';
|
import BrushModeComponent from '../components/brush-mode.jsx';
|
||||||
|
|
||||||
class BrushMode extends React.Component {
|
class BrushMode extends React.Component {
|
||||||
|
@ -42,7 +43,7 @@ class BrushMode extends React.Component {
|
||||||
activateTool () {
|
activateTool () {
|
||||||
// TODO: Instead of clearing selection, consider a kind of "draw inside"
|
// TODO: Instead of clearing selection, consider a kind of "draw inside"
|
||||||
// analogous to how selection works with eraser
|
// 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
|
// TODO: This is temporary until a component that provides the brush size is hooked up
|
||||||
this.props.canvas.addEventListener('mousewheel', this.onScroll);
|
this.props.canvas.addEventListener('mousewheel', this.onScroll);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import {connect} from 'react-redux';
|
||||||
import bindAll from 'lodash.bindall';
|
import bindAll from 'lodash.bindall';
|
||||||
import Modes from '../modes/modes';
|
import Modes from '../modes/modes';
|
||||||
import {changeStrokeWidth} from '../reducers/stroke-width';
|
import {changeStrokeWidth} from '../reducers/stroke-width';
|
||||||
|
import {clearSelection} from '../helper/selection';
|
||||||
import LineModeComponent from '../components/line-mode.jsx';
|
import LineModeComponent from '../components/line-mode.jsx';
|
||||||
import {changeMode} from '../reducers/modes';
|
import {changeMode} from '../reducers/modes';
|
||||||
import paper from 'paper';
|
import paper from 'paper';
|
||||||
|
@ -42,8 +43,7 @@ class LineMode extends React.Component {
|
||||||
return false; // Static component, for now
|
return false; // Static component, for now
|
||||||
}
|
}
|
||||||
activateTool () {
|
activateTool () {
|
||||||
// TODO add back selection
|
clearSelection();
|
||||||
// pg.selection.clearSelection();
|
|
||||||
this.props.canvas.addEventListener('mousewheel', this.onScroll);
|
this.props.canvas.addEventListener('mousewheel', this.onScroll);
|
||||||
this.tool = new paper.Tool();
|
this.tool = new paper.Tool();
|
||||||
|
|
||||||
|
|
|
@ -62,8 +62,8 @@ class SelectMode extends React.Component {
|
||||||
return this._hitOptions;
|
return this._hitOptions;
|
||||||
}
|
}
|
||||||
activateTool () {
|
activateTool () {
|
||||||
clearSelection();
|
|
||||||
selectRootItem();
|
selectRootItem();
|
||||||
|
this.boundingBoxTool.setSelectionBounds();
|
||||||
this.tool = new paper.Tool();
|
this.tool = new paper.Tool();
|
||||||
|
|
||||||
const selectMode = this;
|
const selectMode = this;
|
||||||
|
@ -126,6 +126,7 @@ class SelectMode extends React.Component {
|
||||||
}
|
}
|
||||||
deactivateTool () {
|
deactivateTool () {
|
||||||
this.props.clearHoveredItem();
|
this.props.clearHoveredItem();
|
||||||
|
this.boundingBoxTool.removeBoundsPath();
|
||||||
this.tool.remove();
|
this.tool.remove();
|
||||||
this.tool = null;
|
this.tool = null;
|
||||||
this.hitResult = null;
|
this.hitResult = null;
|
||||||
|
|
Loading…
Reference in a new issue