Tuesday, January 23rd 2018, 4:45am UTC+1

You are not logged in.

  • Login
  • Register

mrohit2011

Beginner

Date of registration: Jul 1st 2017

Posts: 19

1

Saturday, January 6th 2018, 10:03am

ListView Swipe.

Dear Segger Team,

I have tried to implement listview siwpe using the touch call back as shown below. Output generated by below logic is not smooth also it is very slow. So please suggest me some better technique to implement it.

C/C++ Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
static void _cbSwipe(WM_MESSAGE* pMsg) {
switch (pMsg->MsgId) {
case WM_TOUCH :
{
static int last_y;
int y;

const GUI_PID_STATE* pState = (const GUI_PID_STATE*)pMsg->Data.p;
if (pMsg->Data.p) { /* Something happened in our area (pressed or released) */
if (pState->Pressed) 
{
hWinScrollBarV = WM_GetScrollbarV(pMsg->hWin);
scrollval = SCROLLBAR_GetValue(hWinScrollBarV);

//WM_SetCapture(pMsg->hWin, 1);
if(last_y)
{
y = pState->y;
if(y > last_y) 
{
printf("Scroll Down\r\n");
scrollval++;
SCROLLBAR_SetValue(hWinScrollBarV, scrollval);
}
if(y < last_y) 
{
printf("Scroll Up\r\n");
scrollval--;
SCROLLBAR_SetValue(hWinScrollBarV, scrollval);
}
}
last_y = pState->y;
}else {
last_y=0;
}
}else {
last_y=0;
}
LISTVIEW_Callback(pMsg);
}
break;

default:
LISTVIEW_Callback(pMsg);
break;
}
}



Rgds,
Rohit.

This post has been edited 3 times, last edit by "mrohit2011" (Jan 6th 2018, 10:07am)


SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 469

2

Monday, January 8th 2018, 11:40am

Hi,

Attached is an example on how you could scroll the LISTVIEW by touching any where into the LISTVIEW. Although, the scroll bar is hidden we still use its value to scroll up and down.

But this way it is not possible to accelerate the LISTVIEW and let it scroll to its end (like a menu on a mobile device).

You might also try the SWIPELIST widget, but it is more like a menu and doesn't multiple columns.

Regards
Sven
SEGGER - Schoenen has attached the following file:

Similar threads