+ widget.height = self.widgets_height
+ widget.size_hint = self.widgets_size_hint
+ g.add_widget(widget)
+ self._canvas.add_widget(g)
+
+ def detach_widget(self, widget):
+ "Detach grabbable widget from canvas and show widget destination"
+
+ # Show widget destination
+ self.destination = Destination()
+ self.destination.height = self.widgets_height
+ self.destination.size_hint = self.widgets_size_hint
+ widget.parent.add_widget(self.destination, index=get_index(widget))
+
+ # Place widget in the root window
+ widget.parent.remove_widget(widget)
+ widget.size_hint = (None, None)
+ widget.width = 150
+ widget.height = 50
+ self.get_root_window().add_widget(widget)
+
+ def point_widget(self, widget, position):
+ if not self.destination:
+ raise Exception("Wrong status: destination point not specified")
+
+ # Widget info about destination
+ widget_idx = get_index(widget)
+ zone = get_zone(widget, *position)
+
+ # Remove destination
+ box = self.destination.parent
+ box.remove_widget(self.destination)
+
+ # Put destination in the right place
+ if zone in ('left', 'right') and widget.parent.orientation != 'horizontal':
+ parent = widget.parent
+ box = self.create_box()
+ parent.add_widget(box, index=widget_idx)
+ parent.remove_widget(widget)
+ box.add_widget(widget)
+ if zone == 'left':
+ box.add_widget(self.destination, index=1)
+ else:
+ box.add_widget(self.destination, index=0)
+ else:
+ widget.parent.add_widget(self.destination, index=widget_idx)
+
+ # Remove useless boxes
+ if isinstance(box, BoxLayout) and len(box.children) == 1:
+ child = box.children[0]
+ box.remove_widget(child)
+ box.parent.add_widget(child, index=get_index(box))
+ box.parent.remove_widget(box)
+
+ def attach_widget(self, widget):
+ """
+ Attach grabbable widget to the destination
+ """
+ widget.parent.remove_widget(widget)
+ widget.height = self.widgets_height
+ widget.size_hint = self.widgets_size_hint
+
+ dest_idx = get_index(self.destination)
+ self.destination.parent.add_widget(widget, index=dest_idx)
+ self.destination.parent.remove_widget(self.destination)
+ self.destination = None