Skip to content

Commit fbfd08e

Browse files
Logic draft for Ctrl+Drag widget positioning
1 parent 227d60c commit fbfd08e

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/ui/layout/LayoutManipulator.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,10 +335,10 @@ void LayoutManipulator::dragLeaveEvent(QGraphicsSceneDragDropEvent* /*event*/)
335335
resetPen();
336336
}
337337

338-
// Takes care of creating new widgets when user drops the right mime type here
339-
// (dragging from the CreateWidgetDockWidget)
340338
void LayoutManipulator::dropEvent(QGraphicsSceneDragDropEvent* event)
341339
{
340+
// Takes care of creating new widgets when user drops the right mime type here
341+
// (dragging from the CreateWidgetDockWidget)
342342
auto bytes = event->mimeData()->data("application/x-ceed-widget-type");
343343
if (bytes.size() > 0)
344344
{
@@ -354,6 +354,7 @@ void LayoutManipulator::dropEvent(QGraphicsSceneDragDropEvent* event)
354354
return;
355355
}
356356

357+
// Drop existing widgets into this widget as children with Ctrl+Drag
357358
bytes = event->mimeData()->data("application/x-ceed-widget-paths");
358359
if (bytes.size() > 0)
359360
{
@@ -368,6 +369,11 @@ void LayoutManipulator::dropEvent(QGraphicsSceneDragDropEvent* event)
368369

369370
if (event->dropAction() == Qt::MoveAction)
370371
{
372+
// calc offset
373+
// get pos of the widget in old parent (need widget that we started to drag, or always first? or drag start pos, if more than one widget?)
374+
// get pos of the drop inside this
375+
//event->scenePos() - scenePos();
376+
371377
_visualMode.moveWidgetsInHierarchy(std::move(widgetPaths), this, getWidget()->getChildCount());
372378
event->acceptProposedAction();
373379
return;
@@ -379,6 +385,7 @@ void LayoutManipulator::dropEvent(QGraphicsSceneDragDropEvent* event)
379385

380386
void LayoutManipulator::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
381387
{
388+
// Ctrl+Drag to reparent selected widgets
382389
if (event->modifiers() & Qt::ControlModifier)
383390
{
384391
event->accept();

0 commit comments

Comments
 (0)