From 556a89c0f1993e818f00e4a61884998dc05609d1 Mon Sep 17 00:00:00 2001 From: Taehyub Kim Date: Fri, 13 May 2022 16:05:23 +0900 Subject: [PATCH] [NUI] DragAndDrop: Fit drag window to shadow view --- src/Tizen.NUI/src/public/DragAndDrop/DragAndDrop.cs | 20 +++++++++++++++++--- test/NUIDnDSource/NUIDnDSource.cs | 1 + 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Tizen.NUI/src/public/DragAndDrop/DragAndDrop.cs b/src/Tizen.NUI/src/public/DragAndDrop/DragAndDrop.cs index 59b839c..2bbf523 100755 --- a/src/Tizen.NUI/src/public/DragAndDrop/DragAndDrop.cs +++ b/src/Tizen.NUI/src/public/DragAndDrop/DragAndDrop.cs @@ -39,8 +39,8 @@ namespace Tizen.NUI private Dictionary targetEventDictionary = new Dictionary(); private View mShadowView; private Window mDragWindow; - private const int shadowWidth = 150; - private const int shadowHeight = 150; + private int shadowWidth = 100; + private int shadowHeight = 100; [EditorBrowsable(EditorBrowsableState.Never)] private DragAndDrop() : this(Interop.DragAndDrop.New(), true) @@ -74,6 +74,20 @@ namespace Tizen.NUI throw new ArgumentNullException(nameof(shadowView)); } + shadowWidth = (int)shadowView.Size.Width; + shadowHeight = (int)shadowView.Size.Height; + + // Prevents shadowView size from being smaller than 100 pixel + if (shadowView.Size.Width < 100) + { + shadowWidth = 100; + } + + if (shadowView.Size.Height < 100) + { + shadowHeight = 100; + } + if (null == mDragWindow) { mDragWindow = new Window("DragWindow", new Rectangle(-shadowWidth, -shadowHeight, shadowWidth, shadowHeight), true) @@ -82,7 +96,7 @@ namespace Tizen.NUI }; } - shadowView.SetSize(shadowWidth, shadowHeight); + mDragWindow.SetWindowSize(new Size(shadowWidth, shadowHeight)); shadowView.SetOpacity(0.9f); if (mShadowView) diff --git a/test/NUIDnDSource/NUIDnDSource.cs b/test/NUIDnDSource/NUIDnDSource.cs index af1ddcf..8725d34 100644 --- a/test/NUIDnDSource/NUIDnDSource.cs +++ b/test/NUIDnDSource/NUIDnDSource.cs @@ -157,6 +157,7 @@ namespace NUIDnDSource { Tizen.Log.Debug("NUIDnDSource", "StartDragAndDrop"); shadowView = new ImageView(Tizen.Applications.Application.Current.DirectoryInfo.SharedResource + "dragsource.png"); + shadowView.Size = new Size(150, 150); DragData dragData; dragData.MimeType = "text/uri-list"; dragData.Data = Tizen.Applications.Application.Current.DirectoryInfo.SharedResource + "dragsource.png"; -- 2.7.4