Android Question needs help about gesture

ykucuk

Well-Known Member
Licensed User
Longtime User
Hello,

I'm using gesture detector library. It works fine.

I need resize (pinch), drag and rotate panel.

Unfortunately, i didn't any success about that.

- Drag: I need drag in the panel. Parent panel should be the border for a moveable panel.
- Rotate: need rotate panel with 2 fingers
- Resize: need resize panel without original aspect(proportion). Bold squares would be nice at the all corners.

You can find project file at the attachment.

Any help? I tried a week and finally gave up.

Note Im ready for buy a beer )

Thank you.
 

Attachments

  • GD_demo.zip
    405.1 KB · Views: 283

Informatix

Expert
Licensed User
Longtime User
Hello,

I'm using gesture detector library. It works fine.

I need resize (pinch), drag and rotate panel.

Unfortunately, i didn't any success about that.

- Drag: I need drag in the panel. Parent panel should be the border for a moveable panel.
- Rotate: need rotate panel with 2 fingers
- Resize: need resize panel without original aspect(proportion). Bold squares would be nice at the all corners.

You can find project file at the attachment.

Any help? I tried a week and finally gave up.

Note Im ready for buy a beer )

Thank you.
Your code for Drag is right. Your code for Resize has two problems:
1) you have to distinguish between Drag and PinchOpen/Close (one finger on screen vs. two or more fingers). Solution = just count the number of pointers and disable the drag event accordingly;
2) you mixed two examples. One sets GestureDetector to the activity, the other sets GD to a panel, so the origin of the coordinates system is different. Solution = you have to adapt the ResizePanel code to adjust the X,Y position according to the panel coordinates.
Your code for Rotation lacks only the code to rotate the view. Choose one method among the solutions here:
https://www.b4x.com/android/forum/threads/how-can-i-rotate-the-text-on-a-button.83256/#post-527302
 

Attachments

  • GD_demo.zip
    12.8 KB · Views: 327
  • Like
Reactions: eps
Upvote 0

ykucuk

Well-Known Member
Licensed User
Longtime User
Thank you for a quick reply. I already lost a lot of time. Could you do it for me and I can donate ?Please don't understand me the wrong way. I really don't know how to ask this service.
Thank you
 
Upvote 0

ykucuk

Well-Known Member
Licensed User
Longtime User
Another question when user finish resizing(pinch) then panel location changing wrong (like jump to another point). Could you check this, please.
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
You are great. Im going to donate. Thank you.

Is there way resize proportionally. My panel is square and i dont want user can change this during pinch ?
Then compute the proportion in ResizePanel before setting Width and Height (Dim PanelProportion as double = pnlGreen.Width/pnlGreen.Height) and apply this proportion to one dimension (e.g. Width = Height * PanelProportion).
 
Upvote 0

ykucuk

Well-Known Member
Licensed User
Longtime User
Because when you release the second finger, the first finger triggers a Drag event. You should wait until the Touch Action = 1 before allowing to drag after a Pinch Open/Close.

Thanks for the donation.
Dont think im too lazy but i2m really bad about this. Could you do it for me when you have free time

Thank you.
 
Last edited:
Upvote 0

ykucuk

Well-Known Member
Licensed User
Longtime User
It's very simple. Set a boolean (IsDragAllowed) to False when PtrDown goes over 0 and set it to True when PtrDown = 0 and Action = 1 in the Touch event. The default value is True.

Hi,

I tried but no luck. I think my English is also bad as my developer skills.

Only proportionally resize work well.

Could you help me, please? i added the project into the post.
 

Attachments

  • GD_demo.zip
    314.5 KB · Views: 313
Upvote 0

Informatix

Expert
Licensed User
Longtime User
Here are the changes. Nothing complicated:
B4X:
If Not(IsDragAllowed) Then
        IsDragAllowed = (PtrDown = 0 And Action = 1)
End If
The whole code is a bit basic to my taste and can be improved a lot for more natural behavior but if you have difficulties with the current code, you should do with it.
 

Attachments

  • GD_demo.zip
    19.6 KB · Views: 324
Upvote 0

ykucuk

Well-Known Member
Licensed User
Longtime User
Yes but the problem is user create panels at runtime. there can be 3 or 30. how can i set this ?
 
Upvote 0

ykucuk

Well-Known Member
Licensed User
Longtime User
is it like GD1,GD2 or same GD for all panels?

I created 2 manuel panel even i cant move second one. when i click phone always 1st one start moving.
 
Upvote 0
Top