From 872ec21822712c615524e26b05d534dfbf150103 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Tue, 2 Sep 2014 12:55:15 -0700 Subject: [PATCH] Added removeLastTool() to toolBar.js --- examples/toolBars.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/examples/toolBars.js b/examples/toolBars.js index 064ae372fd..092ab5992e 100644 --- a/examples/toolBars.js +++ b/examples/toolBars.js @@ -127,7 +127,7 @@ Tool.IMAGE_HEIGHT = 50; Tool.IMAGE_WIDTH = 50; ToolBar = function(x, y, direction) { - this.tools = []; + this.tools = new Array(); this.x = x; this.y = y; this.width = 0; @@ -161,9 +161,25 @@ ToolBar = function(x, y, direction) { }); } - this.tools[this.tools.length] = new Tool(properties, selectable, selected); + this.tools.push(new Tool(properties, selectable, selected)); return ((this.tools.length) - 1); } + + this.removeLastTool = function() { + this.tools.pop().cleanup(); + + if (direction == ToolBar.HORIZONTAL) { + this.width -= Tool.IMAGE_WIDTH + ToolBar.SPACING; + } else { + this.height -= Tool.IMAGE_HEIGHT + ToolBar.SPACING; + } + if (this.back != null) { + Overlays.editOverlay(this.back, { + width: this.width + 2 * ToolBar.SPACING, + height: this.height + 2 * ToolBar.SPACING + }); + } + } this.move = function(x, y) { var dx = x - this.x;