Display selected color and button to turn off draw mode in canvas

This commit is contained in:
yflory
2017-04-07 14:54:02 +02:00
parent 84029ac2d7
commit dedf2b3c69
4 changed files with 41 additions and 5 deletions

View File

@@ -47,6 +47,7 @@ define([
var $colors = $('#colors');
var $cursors = $('#cursors');
var $toggle = $('#toggleDraw');
var $width = $('#width');
var $widthLabel = $('label[for="width"]');
@@ -82,6 +83,11 @@ define([
//context.stroke();
var img = ccanvas.toDataURL("image/png");
var $img = $('<img>', {
src: img,
title: 'Current brush'
});
$controls.find('.selected').html('').append($img);
canvas.freeDrawingCursor = 'url('+img+') '+size/2+' '+size/2+', crosshair';
};
@@ -143,12 +149,20 @@ define([
setColor(color);
});
module.draw = true;
var toggleDrawMode = function () {
module.draw = !module.draw;
canvas.isDrawingMode = module.draw;
$toggle.text(module.draw ? Messages.canvas_disable : Messages.canvas_enable);
};
$toggle.click(toggleDrawMode);
var setEditable = function (bool) {
if (readOnly && bool) { return; }
if (bool) { $controls.show(); }
else { $controls.hide(); }
canvas.isDrawingMode = bool;
canvas.isDrawingMode = bool ? module.draw : false;
if (!bool) {
canvas.deactivateAll();
canvas.renderAll();