mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2024-12-23 05:52:42 -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.clearHoveredItem();
|
||||||
this.props.clearPasteOffset();
|
this.props.clearPasteOffset();
|
||||||
if (svg) {
|
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
|
// Store the zoom/pan and restore it after importing a new SVG
|
||||||
const oldZoom = paper.project.view.zoom;
|
const oldZoom = paper.project.view.zoom;
|
||||||
const oldCenter = paper.project.view.center.clone();
|
const oldCenter = paper.project.view.center.clone();
|
||||||
|
|
|
@ -43,8 +43,8 @@ const performUndo = function (undoState, dispatchPerformUndo, setSelectedItems,
|
||||||
if (undoState.pointer > 0) {
|
if (undoState.pointer > 0) {
|
||||||
const state = undoState.stack[undoState.pointer - 1];
|
const state = undoState.stack[undoState.pointer - 1];
|
||||||
_restore(state, setSelectedItems, onUpdateSvg);
|
_restore(state, setSelectedItems, onUpdateSvg);
|
||||||
const format = isVector(state.paintEditorFormat) ? Formats.UNDO_VECTOR :
|
const format = isVector(state.paintEditorFormat) ? Formats.VECTOR_SKIP_CONVERT :
|
||||||
isBitmap(state.paintEditorFormat) ? Formats.UNDO_BITMAP : null;
|
isBitmap(state.paintEditorFormat) ? Formats.BITMAP_SKIP_CONVERT : null;
|
||||||
if (!format) {
|
if (!format) {
|
||||||
log.error(`Invalid format: ${state.paintEditorFormat}`);
|
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) {
|
if (undoState.pointer >= 0 && undoState.pointer < undoState.stack.length - 1) {
|
||||||
const state = undoState.stack[undoState.pointer + 1];
|
const state = undoState.stack[undoState.pointer + 1];
|
||||||
_restore(state, setSelectedItems, onUpdateSvg);
|
_restore(state, setSelectedItems, onUpdateSvg);
|
||||||
const format = isVector(state.paintEditorFormat) ? Formats.UNDO_VECTOR :
|
const format = isVector(state.paintEditorFormat) ? Formats.VECTOR_SKIP_CONVERT :
|
||||||
isBitmap(state.paintEditorFormat) ? Formats.UNDO_BITMAP : null;
|
isBitmap(state.paintEditorFormat) ? Formats.BITMAP_SKIP_CONVERT : null;
|
||||||
if (!format) {
|
if (!format) {
|
||||||
log.error(`Invalid format: ${state.paintEditorFormat}`);
|
log.error(`Invalid format: ${state.paintEditorFormat}`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,17 +3,17 @@ import keyMirror from 'keymirror';
|
||||||
const Formats = keyMirror({
|
const Formats = keyMirror({
|
||||||
BITMAP: null,
|
BITMAP: null,
|
||||||
VECTOR: null,
|
VECTOR: null,
|
||||||
// Undo formats are conversions caused by the undo/redo stack
|
// Format changes which should not trigger conversions, for instance undo
|
||||||
UNDO_BITMAP: null,
|
BITMAP_SKIP_CONVERT: null,
|
||||||
UNDO_VECTOR: null
|
VECTOR_SKIP_CONVERT: null
|
||||||
});
|
});
|
||||||
|
|
||||||
const isVector = function (format) {
|
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) {
|
const isBitmap = function (format) {
|
||||||
return format === Formats.BITMAP || format === Formats.UNDO_BITMAP;
|
return format === Formats.BITMAP || format === Formats.BITMAP_SKIP_CONVERT;
|
||||||
};
|
};
|
||||||
|
|
||||||
export {
|
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
|
* @return {Action} undo action
|
||||||
*/
|
*/
|
||||||
const undo = function (format) {
|
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
|
* @return {Action} undo action
|
||||||
*/
|
*/
|
||||||
const redo = function (format) {
|
const redo = function (format) {
|
||||||
|
|
Loading…
Reference in a new issue