Kinetic scrolling listbox based on MoSync ListBox

10 posts / 0 new
Last post
ezyclie
ezyclie's picture
Offline
Mobile Wizard
Joined: 4 Mar 2010
Posts:
Kinetic scrolling listbox based on MoSync ListBox

Like the subject, this listbox gives u kinetic scrolling animation when u swipe ur finger up/down.

How to use:

MyListBox *listBox = new MyListBox(0, 0, WIDTH, HEIGHT, NULL, MyListBox::LBO_VERTICAL, MyListBox::LBA_LINEAR, true);

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

I've had a good play with this, and it is working really nicely. I've also tried to clean it up a bit, and inherit from ListBox and override where necessary, but I've got stuck on a similar problem to you. In this case, TimerListener is private and not protected, so it is inaccessible from my derived class. I've added a comment on the issues page to get this changed as well.

I've uploaded a short video of this working though for people to look at.

http://screencast.com/t/ZjI4Mzg5Z

Thanks

vinaykasireddy
vinaykasireddy's picture
Offline
Joined: 14 Jul 2010
Posts:

Hi Rival,

When i test the code in the emulator i am getting "40028 panic error".

By the way, can you provide your code(inherited from ListBox)

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Hmm. Memory alignment error, I don't know common causes of it. Fredrik might know.

My code is enclosed.
[attachment=0]KineticListBox.cpp[/attachment]
[attachment=1]KineticListBox.h[/attachment]

AttachmentSize
KineticListBox.h 8.89 KB
KineticListBox.cpp 27.54 KB
Fredrik Eldh
Fredrik's picture
Offline
Mobile Sorcerer
Joined: 16 Feb 2009
Posts:

Memory alignment errors are caused by broken pointers, which may themselves be caused by buffer overruns, or any number of other errors. You should turn on extra warnings, and "warnings as errors" in your projects' build settings. That helps highlight some potential errors.

fafilippini
fafilippini's picture
Offline
Joined: 25 May 2011
Posts:

Hi Sam,

I am having a problem with the KineticListBox. It works fine if the screen is full of labels, but in case it is not sometimes I have the list going to the bottom of the screen and the widgets are selectable like if they were in the top position.

Moreover I have seen that the position is not updated even when I scroll down the list, if I click on a newly appeared widget, I get selected two widgets: the one I clicked, and the one previously in that position.

Is there a solution to the touch points to update the position of the list??

Thank you,

Fabrizio

alortiz
alortiz's picture
Offline
Joined: 26 May 2011
Posts:

i'm also using KineticListBox for scroll an element list of labels and i get the same errors.

For the first one i was thinking on calculate the total width which i will need to show the elements, and if it's bigger than my listbox width, i use a kineticlistbox object, else, i will use a simple list box wihtout scroll.

For the second error, i was thinking on modify the kinetic listbox and create a variable which contains the pixels moving from the stop screen to the next stop. It would say us where is the screen situation in the listbox.
I've watched that the variable yOffset contains a number which is the movement in negative, but i don't know how to convert it into pixels (i think that all the width objects is in pixels, but i don't know if that's true). anyone knows how can i convert it into pixels??

I hope that you understand my ideas and i hope that any one can help us.

If i get the code, i will share here Wink

alortiz
alortiz's picture
Offline
Joined: 26 May 2011
Posts:

ok, i modified the kinetic method for made my example, i only add the next function in the method "pointerPressEvent" and i add a screen for show the selected label.

if ((this->selectedIndex) % 2 == 1) {
//Es par, sumamos 1 para no dividir 0/2
	children[this->selectedIndex]->setBackgroundColor(0x00BFFF);
} else {
	children[this->selectedIndex]->setBackgroundColor(0x0040FF);
}
children[i]->setBackgroundColor(0x000000);

I add some Labels to the kinetic list box, and i paint their background with two different types of blue.

If i choose one of the label, it will print black, and the previous checked will be printed with its original color (one of the blues that i switch when i create the labels).

If i click the footer button "Right Button" i will go to another screen which print the label caption. Clicking again on the screen we return to the kinetic layout.

I need to know one thing, is posible to change the scroll movement?? i try to say, can i modify the kinetic method for get a static listbox and not move more when i'm in the last element of the list box?

And another thing more, i had a problem with the memory, if i change many times between the main screen and the Label screens i get a Heap error, how can i delete the memory which i'm using in the hidden screens?? is it posible??

Here is my project Wink

AttachmentSize
GSLayouts.zip 23.37 KB
Son Dinh
chocopiex's picture
Offline
Joined: 14 Mar 2011
Posts:
fafilippini wrote:

Hi Sam,

I am having a problem with the KineticListBox. It works fine if the screen is full of labels, but in case it is not sometimes I have the list going to the bottom of the screen and the widgets are selectable like if they were in the top position.

Hi Sam,

We faced with this problem, too. Have you a solution for this issue??

Thanks.

Son Dinh
chocopiex's picture
Offline
Joined: 14 Mar 2011
Posts:

Hi,

I fixed. This is code of RunTimerEvent() :
// if not full items
if (((getChildren().size()-1)*c->getHeight())<= getHeight() ){
stop();
yOffset = 0;
}
else{

if(((yOffset>>16)*-1) > c->getPosition().y+c->getHeight()-getHeight()) {
stop();
yOffset = ((c->getPosition().y+c->getHeight()-getHeight()) << 16)*-1;
}
}

Rgs,

AttachmentSize
KineticListBox.rar 7.18 KB