diff --git a/source/frontend/patchcanvas/patchcanvas.py b/source/frontend/patchcanvas/patchcanvas.py index 98ff77d11..a6a35893a 100644 --- a/source/frontend/patchcanvas/patchcanvas.py +++ b/source/frontend/patchcanvas/patchcanvas.py @@ -363,7 +363,7 @@ def addGroup(group_id, group_name, split=SPLIT_UNDEF, icon=ICON_APPLICATION): elif old_matching_group is not None and old_matching_group[0]: group_sbox.setPos(old_matching_group[2]) else: - group_sbox.setPos(CanvasGetNewGroupPos(True)) + group_sbox.setPos(group_box.x() + group_box.boundingRect().width() + 300, group_box.y()) canvas.last_z_value += 1 group_sbox.setZValue(canvas.last_z_value) diff --git a/source/frontend/patchcanvas/utils.py b/source/frontend/patchcanvas/utils.py index 33e638c89..336b9b0ec 100644 --- a/source/frontend/patchcanvas/utils.py +++ b/source/frontend/patchcanvas/utils.py @@ -36,21 +36,27 @@ def CanvasGetNewGroupPos(horizontal): new_pos = QPointF(canvas.initial_pos) items = canvas.scene.items() - break_loop = False - while not break_loop: + #break_loop = False + while True: break_for = False for i, item in enumerate(items): if item and item.type() == CanvasBoxType: - if item.sceneBoundingRect().contains(new_pos): + if item.sceneBoundingRect().adjusted(-5, -5, 5, 5).contains(new_pos): + itemRect = item.boundingRect() if horizontal: - new_pos += QPointF(item.boundingRect().width() + 15, 0) + new_pos += QPointF(itemRect.width() + 50, 0) else: - new_pos += QPointF(0, item.boundingRect().height() + 15) + itemHeight = itemRect.height() + if itemHeight < 30: + new_pos += QPointF(0, itemHeight + 50) + else: + new_pos.setY(item.scenePos().y() + itemHeight + 20) break_for = True break - - if i >= len(items) - 1 and not break_for: - break_loop = True + else: + if not break_for: + break + #break_loop = True return new_pos