diff options
author | Pierre Frisch | 2011-12-22 07:25:50 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-01-27 11:18:17 -0800 |
commit | b89a7ee8b956c96a1dcee995ea840feddc5d4b27 (patch) | |
tree | 0f3136ab0ecdbbbed6a83576581af0a53124d6f1 /js/tools/FillTool.js | |
parent | 2401f05d1f4b94d45e4568b81fc73e67b969d980 (diff) | |
download | ninja-b89a7ee8b956c96a1dcee995ea840feddc5d4b27.tar.gz |
First commit of Ninja to ninja-internal
Signed-off-by: Valerio Virgillito <rmwh84@motorola.com>
Diffstat (limited to 'js/tools/FillTool.js')
-rw-r--r-- | js/tools/FillTool.js | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/js/tools/FillTool.js b/js/tools/FillTool.js new file mode 100644 index 00000000..477966da --- /dev/null +++ b/js/tools/FillTool.js | |||
@@ -0,0 +1,65 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | /* <copyright> | ||
8 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
9 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
10 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
11 | </copyright> */ | ||
12 | |||
13 | var Montage = require("montage/core/core").Montage, | ||
14 | ModifierToolBase = require("js/tools/modifier-tool-base").ModifierToolBase, | ||
15 | ElementsMediator = require("js/mediators/element-mediator").ElementMediator; | ||
16 | |||
17 | exports.FillTool = Montage.create(ModifierToolBase, { | ||
18 | _canSnap: { value: false }, | ||
19 | _canColor: { value: true }, | ||
20 | |||
21 | HandleMouseMove: { | ||
22 | value : function (event) | ||
23 | { | ||
24 | var obj = this.application.ninja.stage.GetElement(event); | ||
25 | var cursor = "url('images/cursors/fill.png') 17 12, default"; | ||
26 | var canColor = true; | ||
27 | if (obj) | ||
28 | { | ||
29 | var name = obj.nodeName; | ||
30 | if ((name !== 'CANVAS') && (name !== 'DIV')) | ||
31 | { | ||
32 | cursor = "url('images/cursors/nofill.png') 17 12, default"; | ||
33 | canColor = false; | ||
34 | } | ||
35 | } | ||
36 | this.application.ninja.stage.drawingCanvas.style.cursor = cursor; | ||
37 | this._canColor = canColor; | ||
38 | } | ||
39 | }, | ||
40 | |||
41 | HandleLeftButtonUp: { | ||
42 | value : function () { | ||
43 | //if(this._isDrawing) | ||
44 | { | ||
45 | this.application.ninja.stage.clearDrawingCanvas(); | ||
46 | this._hasDraw = false; | ||
47 | this._isDrawing = false; | ||
48 | } | ||
49 | } | ||
50 | }, | ||
51 | |||
52 | // Called by modifier tool base's HandleLeftButtonDown after updating selection (if needed) | ||
53 | startDraw: { | ||
54 | value: function(event) { | ||
55 | this.isDrawing = true; | ||
56 | |||
57 | if(this._canColor) | ||
58 | { | ||
59 | var color = this.application.ninja.colorController.colorToolbar.fill; | ||
60 | ElementsMediator.setColor(this.application.ninja.selectedElements, color, true, "Change", "fillTool"); | ||
61 | } | ||
62 | } | ||
63 | } | ||
64 | |||
65 | }); \ No newline at end of file | ||