left, top, right, bottom = self.style['padding'] x0 = self.offsets[start] x1 = self.offsets[stop] return (self.left + left + x0 - 1, self.top, x1-x0 + 2, self.height) def scan_offset(self, (x,y)): left, top, right, bottom = self.style['padding'] x -= self.left + left k = 0 best = abs(x - 0) for index, offset in enumerate(self.offsets): v = abs(x - offset) if v <= best: best = v k = index return k, best ** 2.0 + abs(y - clamp(self.top, self.top + self.height, y)) ** 2.0 class Container(Box): def __init__(self, nodes, style): self.nodes = nodes self.offset0 = [0] * (len(nodes) + 1) self.offset1 = [0] * (len(nodes) + 1) self.flow0 = [0] * len(nodes) self.flow1 = [0] * len(nodes) self.base0 = 0 self.base1 = 0 Box.__init__(self, (0, 0, 0, 0), style) def __getitem__(self, i): return self.nodes[i]
def move(self, position, drag): index = clamp(0, len(self.field), position) if drag: self.head = index else: self.head = self.tail = index