From 4f027d250f0374fb06b221f6cb53a8e356358f0f Mon Sep 17 00:00:00 2001 From: gambas Date: Wed, 19 Jun 2019 13:09:06 +0200 Subject: [PATCH] Fix drag & drop on drop targets that are children of another drop target. [GB.GUI.BASE] * BUG: Fix drag & drop on drop targets that are children of another drop target. --- comp/src/gb.gui.base/.src/Draw.module | 6 +-- comp/src/gb.gui.base/.src/_Gui.class | 59 +++++++++++++++++++++++---- 2 files changed, 54 insertions(+), 11 deletions(-) diff --git a/comp/src/gb.gui.base/.src/Draw.module b/comp/src/gb.gui.base/.src/Draw.module index 7d03b2863..419c39338 100644 --- a/comp/src/gb.gui.base/.src/Draw.module +++ b/comp/src/gb.gui.base/.src/Draw.module @@ -483,7 +483,7 @@ Private Sub DrawEllipse(iAction As Integer, X As Float, Y As Float, W As Float, fOffset = GetStrokeOffset() Paint.Translate(fOffset, fOffset) Paint.Stroke - Paint.Translate(- fOffset, - fOffset) + Paint.Translate(-fOffset, -fOffset) Endif End @@ -570,7 +570,7 @@ Public Sub PolyLine(Points As Integer[]) fOffset = GetStrokeOffset() Paint.Translate(fOffset, fOffset) Paint.Stroke - Paint.Translate(- fOffset, - fOffset) + Paint.Translate(-fOffset, -fOffset) End @@ -598,7 +598,7 @@ Public Sub Polygon(Points As Integer[]) Paint.Background = GetForeground() Paint.Translate(fOffset, fOffset) Paint.Stroke - Paint.Translate(- fOffset, - fOffset) + Paint.Translate(-fOffset, -fOffset) Endif diff --git a/comp/src/gb.gui.base/.src/_Gui.class b/comp/src/gb.gui.base/.src/_Gui.class index 01147f4d7..5cd3a8365 100644 --- a/comp/src/gb.gui.base/.src/_Gui.class +++ b/comp/src/gb.gui.base/.src/_Gui.class @@ -148,13 +148,14 @@ Static Public Sub _ShowDNDFrame(hCtrl As Control, X As Integer, Y As Integer, W HideDNDFrame() - For I = 0 To 3 + For I = 0 To 0 $aFrame[I] = New DrawingArea(hCtrl.Window) As "DNDFrame" With $aFrame[I] .Background = Color.SetAlpha(Color.SelectedBackground, 192) .Ignore = True .Drop = True .Name = "#DndFrame" & CStr(I) + .Design = True '.Enabled = False End With Next @@ -162,7 +163,7 @@ Static Public Sub _ShowDNDFrame(hCtrl As Control, X As Integer, Y As Integer, W Endif If W <= 0 Or If H <= 0 Then - For I = 0 To 3 + For I = 0 To 0 $aFrame[I].Hide Next Return @@ -250,23 +251,65 @@ End Static Public Sub DndFrame_Drag() 'Debug + Dim X As Integer + Dim Y As Integer + + X = Drag.X + Y = Drag.Y + Drag.X += $iFrameX Drag.Y += $iFrameY + Object.Raise($hFrameCtrl, "Drag") - Drag.X -= $iFrameX - Drag.Y -= $iFrameY + + Drag.X = X + Drag.Y = Y End Static Public Sub DndFrame_DragMove() - 'Debug Drag.X;; Drag.Y;; "/";; $iFrameX;; $iFrameY + Dim hCont As Container + Dim hCtrl As Control + Dim X As Integer + Dim Y As Integer + $bInFrame = True Drag.X += $iFrameX Drag.Y += $iFrameY - Object.Raise($hFrameCtrl, "DragMove") - Drag.X -= $iFrameX - Drag.Y -= $iFrameY + + hCtrl = $hFrameCtrl + + While hCtrl Is Container + hCont = hCtrl + $aFrame[0].Hide + hCtrl = hCont.FindChild(Drag.X - hCont.ClientX, Drag.Y - hCont.ClientY) + $aFrame[0].Show + + If Not hCtrl Then + hCtrl = hCont + Break + Endif + + Drag.X -= hCtrl.X + hCont.ClientX + Drag.Y -= hCtrl.Y + hCont.ClientY + If hCtrl.Drop Then + Object.Raise(hCtrl, "Drag") + Else + If hCtrl Is Container Then Continue + Drag.X += hCtrl.X + hCont.ClientX + Drag.Y += hCtrl.Y + hCont.ClientY + hCtrl = hCont + Endif + + Break + + Wend + + Object.Raise(hCtrl, "DragMove") + + Drag.X = X + Drag.Y = Y End