Author Topic: Listbox Animation in a layout (animate.nut question)  (Read 3829 times)

iOtero

  • Sr. Member
  • ****
  • Posts: 414
    • View Profile
Listbox Animation in a layout (animate.nut question)
« on: May 26, 2019, 04:38:28 AM »
In a layout I use this code so that when I do not change the game in the listbox for a while, the listbox is hidden. And when I press up or down key (back game, previous game) come back.

Code: [Select]
fe.do_nut("mds/animate.nut");

local lbx = flx*0.74;
local lby = fly*0.17;
local lbw = flw*0.25;
local lbh = flh*0.84;

// Listbox
::OBJECTS <- {lbx = fe.add_listbox(lbx, lby, lbw, lbh)}
OBJECTS.lbx.rows = 21;
OBJECTS.lbx.selbg_alpha=0;
OBJECTS.lbx.set_rgb(R,G,B);
OBJECTS.lbx.set_sel_rgb(R2,G2,B2);
OBJECTS.lbx.align = my_align;

local move_lbx1 = {when = Transition.ToNewSelection, property ="x", start = OBJECTS.lbx.x + OBJECTS.lbx.width, end = OBJECTS.lbx.x, time = 1}
local move_lbx2 = {when = When.ToNewSelection, property ="x", start = OBJECTS.lbx.x, end = OBJECTS.lbx.x + (OBJECTS.lbx.width*1.5), time = 600, delay=3500}
animation.add(PropertyAnimation(OBJECTS.lbx, move_lbx1));
animation.add(PropertyAnimation(OBJECTS.lbx, move_lbx2));

I have the problem when I change the filter with the left and right keys (prev filter, next filter): I do not know what code to include so that pressing the left or right returns the listbox, which it does not do, obviously.

I have tried this, but it does not work well, the actions are duplicated and not synchronized:

Code: [Select]
fe.do_nut("mds/animate.nut");

local lbx = flx*0.74;
local lby = fly*0.17;
local lbw = flw*0.25;
local lbh = flh*0.84;

// Listbox
::OBJECTS <- {lbx = fe.add_listbox(lbx, lby, lbw, lbh)}
OBJECTS.lbx.rows = 21;
OBJECTS.lbx.selbg_alpha=0;
OBJECTS.lbx.set_rgb(R,G,B);
OBJECTS.lbx.set_sel_rgb(R2,G2,B2);
OBJECTS.lbx.align = my_align;

local move_lbx1 = {when = Transition.ToNewSelection, property ="x", start = OBJECTS.lbx.x + OBJECTS.lbx.width, end = OBJECTS.lbx.x, time = 1}
local move_lbx2 = {when = When.ToNewSelection, property ="x", start = OBJECTS.lbx.x, end = OBJECTS.lbx.x + (OBJECTS.lbx.width*1.5), time = 600, delay=3500}
local move_lbx3 = {when = Transition.ToNewList, property ="x", start = OBJECTS.lbx.x + OBJECTS.lbx.width, end = OBJECTS.lbx.x, time = 1}
local move_lbx4 = {when = When.ToNewList, property ="x", start = OBJECTS.lbx.x, end = OBJECTS.lbx.x + (OBJECTS.lbx.width*1.5), time = 600, delay=3500}
animation.add(PropertyAnimation(OBJECTS.lbx, move_lbx1));
animation.add(PropertyAnimation(OBJECTS.lbx, move_lbx2));
animation.add(PropertyAnimation(OBJECTS.lbx, move_lbx3));
animation.add(PropertyAnimation(OBJECTS.lbx, move_lbx4));

This does not work either:

Code: [Select]
local move_lbx1 = {when = Transition.ToNewSelection && Transition.ToNewList, property ="x", start = OBJECTS.lbx.x + OBJECTS.lbx.width, end = OBJECTS.lbx.x, time = 1}
local move_lbx2 = {when = When.ToNewSelection && When.ToNewList, property ="x", start = OBJECTS.lbx.x, end = OBJECTS.lbx.x + (OBJECTS.lbx.width*1.5), time = 600, delay=3500}
animation.add(PropertyAnimation(OBJECTS.lbx, move_lbx1));
animation.add(PropertyAnimation(OBJECTS.lbx, move_lbx2));
« Last Edit: May 26, 2019, 05:03:11 AM by iOtero »
Nacer a los 15 años Una novela de iOtero

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Listbox Animation in a layout (animate.nut question)
« Reply #1 on: May 26, 2019, 07:14:07 AM »
I don’t use the animation module. Not a pro at it.

You could try including a signal handler. You have a little bit more control.

iOtero

  • Sr. Member
  • ****
  • Posts: 414
    • View Profile
Re: Listbox Animation in a layout (animate.nut question)
« Reply #2 on: May 26, 2019, 10:01:36 AM »
I don’t use the animation module. Not a pro at it.

You could try including a signal handler. You have a little bit more control.

It seems a good idea about the signal handler, what I do not know is whether it will be compatible with animate.nut. I'll have to study it.
Thanks, Keil.
Nacer a los 15 años Una novela de iOtero

iOtero

  • Sr. Member
  • ****
  • Posts: 414
    • View Profile
Re: Listbox Animation in a layout (animate.nut question)
« Reply #3 on: June 05, 2019, 10:43:44 AM »
I have not gotten it to work in any way.

Any new help?

Thanks.
Nacer a los 15 años Una novela de iOtero

iOtero

  • Sr. Member
  • ****
  • Posts: 414
    • View Profile
Re: Listbox Animation in a layout (animate.nut question)
« Reply #4 on: July 26, 2019, 06:06:59 AM »
I have already solved it, you just had to add a new list option and change transition options for when options.  8)
Nacer a los 15 años Una novela de iOtero

asahendrix

  • Full Member
  • ***
  • Posts: 76
    • View Profile
Re: Listbox Animation in a layout (animate.nut question)
« Reply #5 on: August 07, 2019, 04:26:35 PM »
I have already solved it, you just had to add a new list option and change transition options for when options.  8)

I’m new to coding but this is a great idea! Could you post the full working code please? :)