Force a stroke width on pen and line mode

This commit is contained in:
Paul Kaplan 2017-10-26 17:42:15 -04:00
parent b8aadc3c54
commit ab3b4e4555
2 changed files with 17 additions and 1 deletions

View file

@ -9,6 +9,7 @@ import {endPointHit, touching} from '../helper/snapping';
import {drawHitPoint, removeHitPoint} from '../helper/guides'; import {drawHitPoint, removeHitPoint} from '../helper/guides';
import {stylePath} from '../helper/style-path'; import {stylePath} from '../helper/style-path';
import {changeStrokeColor} from '../reducers/stroke-color'; import {changeStrokeColor} from '../reducers/stroke-color';
import {changeStrokeWidth} from '../reducers/stroke-width';
import {changeMode} from '../reducers/modes'; import {changeMode} from '../reducers/modes';
import {clearSelectedItems} from '../reducers/selected-items'; import {clearSelectedItems} from '../reducers/selected-items';
import {MIXED} from '../helper/style-path'; import {MIXED} from '../helper/style-path';
@ -57,7 +58,11 @@ class LineMode extends React.Component {
if (strokeColor === MIXED || strokeColor === null) { if (strokeColor === MIXED || strokeColor === null) {
this.props.onChangeStrokeColor(LineMode.DEFAULT_COLOR); this.props.onChangeStrokeColor(LineMode.DEFAULT_COLOR);
} }
// Force a minimum stroke width
console.log(this.props.colorState.strokeWidth)
if (!this.props.colorState.strokeWidth) {
this.props.onChangeStrokeWidth(1);
}
this.tool = new paper.Tool(); this.tool = new paper.Tool();
this.path = null; this.path = null;
@ -248,6 +253,9 @@ const mapDispatchToProps = dispatch => ({
}, },
onChangeStrokeColor: strokeColor => { onChangeStrokeColor: strokeColor => {
dispatch(changeStrokeColor(strokeColor)); dispatch(changeStrokeColor(strokeColor));
},
onChangeStrokeWidth: strokeWidth => {
dispatch(changeStrokeWidth(strokeWidth));
} }
}); });

View file

@ -5,6 +5,7 @@ import bindAll from 'lodash.bindall';
import Modes from '../modes/modes'; import Modes from '../modes/modes';
import {changeStrokeColor} from '../reducers/stroke-color'; import {changeStrokeColor} from '../reducers/stroke-color';
import {changeStrokeWidth} from '../reducers/stroke-width';
import {changeMode} from '../reducers/modes'; import {changeMode} from '../reducers/modes';
import {clearSelectedItems} from '../reducers/selected-items'; import {clearSelectedItems} from '../reducers/selected-items';
import {MIXED} from '../helper/style-path'; import {MIXED} from '../helper/style-path';
@ -52,6 +53,10 @@ class PenMode extends React.Component {
if (strokeColor === MIXED || strokeColor === null) { if (strokeColor === MIXED || strokeColor === null) {
this.props.onChangeStrokeColor(PenMode.DEFAULT_COLOR) this.props.onChangeStrokeColor(PenMode.DEFAULT_COLOR)
} }
// Force a minimum stroke width
if (!this.props.colorState.strokeWidth) {
this.props.onChangeStrokeWidth(1);
}
this.tool = new PenTool( this.tool = new PenTool(
this.props.clearSelectedItems, this.props.clearSelectedItems,
this.props.onUpdateSvg this.props.onUpdateSvg
@ -102,6 +107,9 @@ const mapDispatchToProps = dispatch => ({
}, },
onChangeStrokeColor: strokeColor => { onChangeStrokeColor: strokeColor => {
dispatch(changeStrokeColor(strokeColor)); dispatch(changeStrokeColor(strokeColor));
},
onChangeStrokeWidth: strokeWidth => {
dispatch(changeStrokeWidth(strokeWidth));
} }
}); });