]> git.jsancho.org Git - kivyforms.git/commitdiff
Create boxes only when needed
authorJavier Sancho <jsf@jsancho.org>
Wed, 18 Jul 2018 11:35:25 +0000 (13:35 +0200)
committerJavier Sancho <jsf@jsancho.org>
Wed, 18 Jul 2018 11:35:25 +0000 (13:35 +0200)
kivyforms/formcanvas.py

index 4cd1b802f55db19210d226a2ca2952d111123575..0e233fbf5836066ee01215332820b43fbf05b346 100644 (file)
@@ -70,20 +70,19 @@ class Grabbable(BoxLayout):
                     widget.parent.add_widget(self, index=idx + 1)
                 elif widget.point_area == 'bottom':
                     widget.parent.add_widget(self, index=idx)
-                elif widget.point_area == 'left':
-                    parent = widget.parent
-                    box = parent.create_box()
-                    parent.add_widget(box, index=idx)
-                    box.add_widget(self)
-                    parent.remove_widget(widget)
-                    box.add_widget(widget)
                 else:
                     parent = widget.parent
-                    box = parent.create_box()
-                    parent.add_widget(box, index=idx)
-                    parent.remove_widget(widget)
-                    box.add_widget(widget)
-                    box.add_widget(self)
+                    if not isinstance(parent, BoxLayout):
+                        box = parent.create_box()
+                        parent.add_widget(box, index=idx)
+                        parent.remove_widget(widget)
+                        box.add_widget(widget)
+                        idx = 0
+                        parent = box
+                    if widget.point_area == 'left':
+                        parent.add_widget(self, index=idx + 1)
+                    else:
+                        parent.add_widget(self, index=idx)
                 widget.point()
                 break
         else: