From 5a1ff8177da1cba4eccc006ffb8c3ba78065ef97 Mon Sep 17 00:00:00 2001 From: Pixel Date: Tue, 15 Dec 2009 17:45:05 -0800 Subject: Adding a little bit more visibility over the objects. --- dalos.lua | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'dalos.lua') diff --git a/dalos.lua b/dalos.lua index 6594e0e..cd2c849 100644 --- a/dalos.lua +++ b/dalos.lua @@ -162,16 +162,22 @@ dalosp.canvas = { if self.stateful.rghtbutton then self.stateful.panning = true else - self.stateful.leftclk = self:findobj(x,y) + local obj, ind = self:findobj(x, y) + self.stateful.leftclk = obj + table.remove(self.objects, ind) + table.insert(self.objects, obj) self.ox, self.oy = x, y self.bx, self.by = x, y + self:draw() end else if not self.stateful.linking and self.stateful.leftclk and not self.stateful.dragging then self.stateful.leftclk.obj:activate() elseif self.stateful.linking then local dest = self:findobj(x,y) - if dest == self.stateful.linking then + if not dest then + -- just do nothing, huh... + elseif dest == self.stateful.linking then self:setstatus(dalosp.canvas.stypes.ERROR, "Can't link: origin is the same as destination") elseif dest.obj.ninputs <= 0 then self:setstatus(dalosp.canvas.stypes.ERROR, "Can't link: destination has no input") @@ -195,9 +201,13 @@ dalosp.canvas = { if self.stateful.leftbutton then self.stateful.panning = true else - self.stateful.rghtclk = self:findobj(x, y) + local obj, ind = self:findobj(x, y) + self.stateful.rghtclk = obj + table.remove(self.objects, ind) + table.insert(self.objects, obj) self.ox, self.oy = x, y self.bx, self.by = x, y + self:draw() end else if not self.stateful.moving and self.stateful.rghtclk and not self.stateful.dragging then @@ -297,6 +307,7 @@ dalosp.object = { cv:Foreground(self.color) cv:Box(x1, x2, y1, y2) cv:Foreground(cd.BLACK) + cv:Rect(x1, x2, y1, y2) cv:TextAlignment(cd.SOUTH) cv:Text(cx, y2, self.name) cv:TextAlignment(cd.NORTH) -- cgit v1.2.3