is there any way to use GX_ANIMATION_SCREEN_DRAG with SSP 1.2.0? Or anyway to implement drag-and-drop functionality with SSP 1.2.0?
In reply to JB:
In reply to isaenz:
the GX_ANIMATION_SCREEN_DRAG type of animation is not available in SSP 1.2.0.
Could you specify what final result would you like to get? Animation for changing window or animation for moving some widget around the screen to place it in desirable place?
I will see what can be done with SSP 1.2.0 to achieve similar functionality.
In reply to anper:
we want to implement two functions:
1. Move an image (or an object) from one place to another (the positions are preset, let's say there are two icons and we want to move the image from one to another):
2. Change the positions of two images (or objects). Almost same assumption as previous case; let's say we have two icons and want their images to be exchanged:
We would like the image dragged to follow the touch, I mean, we'd like it to move along with our finger.
Do you see it possible to implement this with SSP 1.2.0?
I managed to implement simple drag and drop functionality in the following way:
In GUIX Studio I added an event function for the widget which is going to be dragged. In the definition of this function I handle the GX_EVENT_PEN_DRAG event and call the gx_widget_shift() function. The x_shift and y_shift parameters can be calculated based on the GUIX event coordinates, which are accessible through the event_ptr->gx_event_payload.gx_event_pointdata (where event_ptr is a pointer to the event structure).
To be able to drop the dragged widget only in the predefined places you can implement some sort of array containing predefined coordinates. Then you would have to implement the logic which will move the dropped widget to the closest predefined point. The gx_widget_shift() function can be used for this purpose again.
To swap two widgets you would have to additionaly move the widget which is going to be replaced by the dropped one. To do that you could compare their coordinates and, if they are the same, make the swap. Again the gx_widget_shift() function can be used for this. The coordinates of the widget can be obtained through the widget->gx_widget_size (where widget is a pointer to the widget structure). This is in case of a prompt widget. For other types of widgets it should be similar however.
Could you share with us the code you developed? We're using a custom board, but we also have a PE-HMI1, so if you could translate it to this board (SSP1.2.0) it would be great.
I will try to prepare a simple example for PE-HMI1.
it is on the go. When I was writing my earlier post I was using a SK-S7G2 board. I try to do the same using PE-HMI1. Hopefully today I will be able to post it here.
please find enclosed an example project of drag and drop functionality for a PE-HMI1, SSP 1.2.0. It is based on the "GUIX Hello World" project.
The key parts of the code are:
Two additional functionalities, "snap to" and "swap", need to be implemented.
In reply to Imanol:
the behavior which you observe is caused by the order of GUIX events. Looking carefully at them in Debug mode, I determined that the GX_EVENT_CLICKED event (received in the parent window event handler) precedes the GX_EVENT_PEN_DRAG event (received in the dragged widget event handler). Additional logic could be required as a solution, to ignore GX_EVENT_CLICKED (or GX_EVENT_PEN_UP) events while dragging is expected. Please refer to the modified project:
Please also notice that there are some GUIX issues in the SSP 1.2.0, which are fixed in newer SSP versions.
I don't experience such issue. However, I do see that the fast movement of the widget is noticeably ragged. This can be reduced by increasing the "Update Hz" property of the Touch Panel Framework:
Do you observe the flickering while running the project shared in my previous post or while running your own project? Do you see it on the PE-HMI1 board?
We have ported the mechanisms you show us in our previous post to our platform. You can see a video with the behaviour attached to the post.