|
|
|
@ -367,14 +367,38 @@ function handle_event(state, context, event, options = {}) {
@@ -367,14 +367,38 @@ function handle_event(state, context, event, options = {}) {
|
|
|
|
|
} else if (other_event.type === EVENT.UNDO) { |
|
|
|
|
// do not undo an undo, we are not Notepad
|
|
|
|
|
} else if (other_event.type === EVENT.IMAGE) { |
|
|
|
|
console.log('TODO: undo image'); |
|
|
|
|
other_event.deleted = true; |
|
|
|
|
const image = get_image(context, other_event.image_id); |
|
|
|
|
if (image !== null) { |
|
|
|
|
image.deleted = true; |
|
|
|
|
} |
|
|
|
|
need_draw = true; |
|
|
|
|
break; |
|
|
|
|
} else if (other_event.type === EVENT.IMAGE_MOVE) { |
|
|
|
|
// TODO
|
|
|
|
|
console.log('TODO: undo image move'); |
|
|
|
|
other_event.deleted = true; |
|
|
|
|
const image = get_image(context, other_event.image_id); |
|
|
|
|
if (image !== null) { |
|
|
|
|
image.move_head -= 2; |
|
|
|
|
image.at.x = image.move_history[image.move_head - 2]; |
|
|
|
|
image.at.y = image.move_history[image.move_head - 1]; |
|
|
|
|
need_draw = true; |
|
|
|
|
} else { |
|
|
|
|
console.warning('Undo image move for a non-existent image'); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} else if (other_event.type === EVENT.IMAGE_SCALE) { |
|
|
|
|
// TODO
|
|
|
|
|
console.log('TODO: undo image scale'); |
|
|
|
|
other_event.deleted = true; |
|
|
|
|
const image = get_image(context, other_event.image_id); |
|
|
|
|
if (image !== null) { |
|
|
|
|
image.scale_head -= 4; |
|
|
|
|
image.at.x = image.scale_history[image.scale_head - 4]; |
|
|
|
|
image.at.y = image.scale_history[image.scale_head - 3]; |
|
|
|
|
image.width = image.scale_history[image.scale_head - 2]; |
|
|
|
|
image.height = image.scale_history[image.scale_head - 1]; |
|
|
|
|
need_draw = true; |
|
|
|
|
} else { |
|
|
|
|
console.warning('Undo image scale for a non-existent image'); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} else if (other_event.type === EVENT.ERASER) { |
|
|
|
|
const stroke = state.events[other_event.stroke_id]; |
|
|
|
@ -433,6 +457,14 @@ function handle_event(state, context, event, options = {}) {
@@ -433,6 +457,14 @@ function handle_event(state, context, event, options = {}) {
|
|
|
|
|
|
|
|
|
|
if (image) { |
|
|
|
|
// if (config.debug_print) console.debug('move image', image_id, 'to', image_event.x, image_event.y);
|
|
|
|
|
if (image.move_head < image.move_history.length) { |
|
|
|
|
image.move_history[image.move_head] = event.x; |
|
|
|
|
image.move_history[image.move_head + 1] = event.y; |
|
|
|
|
} else { |
|
|
|
|
image.move_history.push(event.x, event.y); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
image.move_head += 2; |
|
|
|
|
image.at.x = event.x; |
|
|
|
|
image.at.y = event.y; |
|
|
|
|
need_draw = true; |
|
|
|
@ -447,6 +479,17 @@ function handle_event(state, context, event, options = {}) {
@@ -447,6 +479,17 @@ function handle_event(state, context, event, options = {}) {
|
|
|
|
|
const image = get_image(context, image_id); |
|
|
|
|
|
|
|
|
|
if (image !== null) { |
|
|
|
|
if (image.scale_head < image.scale_history.length) { |
|
|
|
|
image.scale_history[image.scale_head] = image.at.x; |
|
|
|
|
image.scale_history[image.scale_head + 1] = image.at.y; |
|
|
|
|
image.scale_history[image.scale_head + 2] = image.width; |
|
|
|
|
image.scale_history[image.scale_head + 3] = image.height; |
|
|
|
|
} else { |
|
|
|
|
image.scale_history.push(image.at.x, image.at.y, image.width, image.height); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
image.scale_head += 4; |
|
|
|
|
|
|
|
|
|
scale_image(context, image, event.corner, {'x': event.x, 'y': event.y}); |
|
|
|
|
need_draw = true; |
|
|
|
|
} |
|
|
|
|