def on_mouse_drag(self, x, y, dx, dy, button, modifier): if not self.dragging: return c = self.sprite ni = self._to_index(x, y) cx, cy = getinterp(c, 'x'), getinterp(c, 'y') if isinstance(cx, AbstractInterp): cx = cx._to if isinstance(cy, AbstractInterp): cy = cy._to oi = self._to_index(cx + self.item_width // 2, cy + self.item_height // 2) if oi != ni: c.zindex = self.cur_zindex self.cur_zindex += 1 ll = list(reversed(self.sprites)) ll[oi[1]].remove(c) ll[ni[1]].insert(ni[0], c) self.update()
def arrange(self): csl = self.control_list if not csl: return n = len(csl) w, h, = self.width, self.height offs = 20 csw = offs * (n-1) + 93 cor_x, cor_y = (w - csw)/2, (h - 125)/2 for i, cs in enumerate(csl): if isinstance(getinterp(cs, 'x'), AbstractInterp): cs.x = SineInterp(cs.x, i*offs + cor_x, 0.6) cs.y = SineInterp(cs.y, cor_y, 0.6) else: cs.x, cs.y = i*offs + cor_x, cor_y