# HG changeset patch # User lbessard # Date 1220808099 -7200 # Node ID 27abdcf9a46034498ba8f4f845f82b8fbb8cddd8 # Parent d9391572655fc5731eb947af25f9f81fc73f1eb2 Bug with PowerRail resize fixed diff -r d9391572655f -r 27abdcf9a460 graphics/LD_Objects.py --- a/graphics/LD_Objects.py Sun Sep 07 15:29:12 2008 +0200 +++ b/graphics/LD_Objects.py Sun Sep 07 19:21:39 2008 +0200 @@ -269,9 +269,14 @@ def OnLeftDown(self, event, dc, scaling): self.RealConnectors = [] height = self.Size[1] - self.Extensions[0] - self.Extensions[1] - for connector in self.Connectors: - position = connector.GetRelPosition() - self.RealConnectors.append(float(position.y - self.Extensions[0])/float(max(1, height))) + if height > 0: + for connector in self.Connectors: + position = connector.GetRelPosition() + self.RealConnectors.append(max(0., min(float(position.y - self.Extensions[0]) / float(height), 1.))) + elif len(self.Connectors) > 1: + self.RealConnectors = map(lambda x : x * 1 / (len(self.Connectors) - 1), xrange(len(self.Connectors))) + else: + self.RealConnectors = [0.5] Graphic_Element.OnLeftDown(self, event, dc, scaling) # Method called when a LeftUp event have been generated @@ -315,7 +320,10 @@ def Resize(self, x, y, width, height): self.Move(x, y) - self.SetSize(LD_POWERRAIL_WIDTH, height) + if self.Parent.GetDrawingMode() == FREEDRAWING_MODE: + self.SetSize(width, height) + else: + self.SetSize(LD_POWERRAIL_WIDTH, height) # Refreshes the powerrail state according to move defined and handle selected def ProcessDragging(self, movex, movey, centered, scaling):