2018-09-17 13:38:16 -04:00
|
|
|
import paper from '@scratch/paper';
|
|
|
|
import {CHANGE_SELECTED_ITEMS} from './selected-items';
|
|
|
|
|
2018-07-12 15:48:30 -04:00
|
|
|
const SET_FILLED = 'scratch-paint/fill-bitmap-shapes/SET_FILLED';
|
|
|
|
const initialState = true;
|
|
|
|
|
|
|
|
const reducer = function (state, action) {
|
|
|
|
if (typeof state === 'undefined') state = initialState;
|
|
|
|
switch (action.type) {
|
|
|
|
case SET_FILLED:
|
|
|
|
return action.filled;
|
2018-09-17 13:38:16 -04:00
|
|
|
case CHANGE_SELECTED_ITEMS:
|
|
|
|
if (action.bitmapMode &&
|
|
|
|
action.selectedItems &&
|
|
|
|
action.selectedItems[0] instanceof paper.Shape) {
|
|
|
|
return action.selectedItems[0].strokeWidth === 0;
|
|
|
|
}
|
|
|
|
return state;
|
2018-07-12 15:48:30 -04:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Action creators ==================================
|
|
|
|
const setShapesFilled = function (filled) {
|
|
|
|
return {
|
|
|
|
type: SET_FILLED,
|
|
|
|
filled: filled
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export {
|
|
|
|
reducer as default,
|
|
|
|
setShapesFilled
|
|
|
|
};
|