mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2024-12-22 21:42:30 -05:00
Rename undo formats, and make format change on costume change skip convert
This commit is contained in:
parent
c6a282c97b
commit
40871b1c0f
4 changed files with 12 additions and 12 deletions
|
@ -115,7 +115,7 @@ class PaperCanvas extends React.Component {
|
|||
this.props.clearHoveredItem();
|
||||
this.props.clearPasteOffset();
|
||||
if (svg) {
|
||||
this.props.changeFormat(Formats.VECTOR);
|
||||
this.props.changeFormat(Formats.VECTOR_SKIP_CONVERT);
|
||||
// Store the zoom/pan and restore it after importing a new SVG
|
||||
const oldZoom = paper.project.view.zoom;
|
||||
const oldCenter = paper.project.view.center.clone();
|
||||
|
|
|
@ -43,8 +43,8 @@ const performUndo = function (undoState, dispatchPerformUndo, setSelectedItems,
|
|||
if (undoState.pointer > 0) {
|
||||
const state = undoState.stack[undoState.pointer - 1];
|
||||
_restore(state, setSelectedItems, onUpdateSvg);
|
||||
const format = isVector(state.paintEditorFormat) ? Formats.UNDO_VECTOR :
|
||||
isBitmap(state.paintEditorFormat) ? Formats.UNDO_BITMAP : null;
|
||||
const format = isVector(state.paintEditorFormat) ? Formats.VECTOR_SKIP_CONVERT :
|
||||
isBitmap(state.paintEditorFormat) ? Formats.BITMAP_SKIP_CONVERT : null;
|
||||
if (!format) {
|
||||
log.error(`Invalid format: ${state.paintEditorFormat}`);
|
||||
}
|
||||
|
@ -57,8 +57,8 @@ const performRedo = function (undoState, dispatchPerformRedo, setSelectedItems,
|
|||
if (undoState.pointer >= 0 && undoState.pointer < undoState.stack.length - 1) {
|
||||
const state = undoState.stack[undoState.pointer + 1];
|
||||
_restore(state, setSelectedItems, onUpdateSvg);
|
||||
const format = isVector(state.paintEditorFormat) ? Formats.UNDO_VECTOR :
|
||||
isBitmap(state.paintEditorFormat) ? Formats.UNDO_BITMAP : null;
|
||||
const format = isVector(state.paintEditorFormat) ? Formats.VECTOR_SKIP_CONVERT :
|
||||
isBitmap(state.paintEditorFormat) ? Formats.BITMAP_SKIP_CONVERT : null;
|
||||
if (!format) {
|
||||
log.error(`Invalid format: ${state.paintEditorFormat}`);
|
||||
}
|
||||
|
|
|
@ -3,17 +3,17 @@ import keyMirror from 'keymirror';
|
|||
const Formats = keyMirror({
|
||||
BITMAP: null,
|
||||
VECTOR: null,
|
||||
// Undo formats are conversions caused by the undo/redo stack
|
||||
UNDO_BITMAP: null,
|
||||
UNDO_VECTOR: null
|
||||
// Format changes which should not trigger conversions, for instance undo
|
||||
BITMAP_SKIP_CONVERT: null,
|
||||
VECTOR_SKIP_CONVERT: null
|
||||
});
|
||||
|
||||
const isVector = function (format) {
|
||||
return format === Formats.VECTOR || format === Formats.UNDO_VECTOR;
|
||||
return format === Formats.VECTOR || format === Formats.VECTOR_SKIP_CONVERT;
|
||||
};
|
||||
|
||||
const isBitmap = function (format) {
|
||||
return format === Formats.BITMAP || format === Formats.UNDO_BITMAP;
|
||||
return format === Formats.BITMAP || format === Formats.BITMAP_SKIP_CONVERT;
|
||||
};
|
||||
|
||||
export {
|
||||
|
|
|
@ -64,7 +64,7 @@ const undoSnapshot = function (snapshot) {
|
|||
};
|
||||
};
|
||||
/**
|
||||
* @param {Format} format Either UNDO_VECTOR or UNDO_BITMAP
|
||||
* @param {Format} format Either VECTOR_SKIP_CONVERT or BITMAP_SKIP_CONVERT
|
||||
* @return {Action} undo action
|
||||
*/
|
||||
const undo = function (format) {
|
||||
|
@ -74,7 +74,7 @@ const undo = function (format) {
|
|||
};
|
||||
};
|
||||
/**
|
||||
* @param {Format} format Either UNDO_VECTOR or UNDO_BITMAP
|
||||
* @param {Format} format Either VECTOR_SKIP_CONVERT or BITMAP_SKIP_CONVERT
|
||||
* @return {Action} undo action
|
||||
*/
|
||||
const redo = function (format) {
|
||||
|
|
Loading…
Reference in a new issue