Slick Forums

Discuss the Slick 2D Library
It is currently Thu May 23, 2013 7:39 pm

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: What is AnimationState ?
PostPosted: Wed Feb 08, 2012 6:06 pm 
Offline

Joined: Thu Aug 11, 2011 7:24 pm
Posts: 17
hi all,

I'm creating my own inventory panel with TWL and I have a problem. I don't manage to make out what are AnimationState, and they are very important ...
I've read the source code, but I still don't understand ...

FaZeGa


Top
 Profile  
 
PostPosted: Wed Feb 08, 2012 7:43 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1173
AnimationState is a class (and an interface) which manage animation states.
These states are named (managed by AnimationState.StateKey) and can either be active (true) or inactive/not preset (false).
Also each state has a timer associated which counts the time since that state was last changed.

It is easiest explained for a Button (you can use the Theme Editor to look at the active animation states for every widget).
The Button has the following states: "hover", "pressed", "armed", "selected" and "keyboardFocus".
The theme can check for any combination of states using the if/unless conditions to decide how the button should be rendered.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
PostPosted: Thu Feb 09, 2012 5:54 am 
Offline
Game Developer
User avatar

Joined: Wed Feb 17, 2010 12:24 am
Posts: 594
MatthiasM wrote:
AnimationState is a class (and an interface) which manage animation states.
These states are named (managed by AnimationState.StateKey) and can either be active (true) or inactive/not preset (false).
Also each state has a timer associated which counts the time since that state was last changed.

It is easiest explained for a Button (you can use the Theme Editor to look at the active animation states for every widget).
The Button has the following states: "hover", "pressed", "armed", "selected" and "keyboardFocus".
The theme can check for any combination of states using the if/unless conditions to decide how the button should be rendered.


Hover and pressed make sense, but what are armed and selected ?


Top
 Profile  
 
PostPosted: Thu Feb 09, 2012 6:07 am 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1173
"armed" is a combination of "hover" and "pressed". This state of the button (see ButtonModel) is used to indicate that on release it will fire the callback.
"selected" applies only to toggle buttons.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
PostPosted: Thu Feb 09, 2012 12:33 pm 
Offline

Joined: Thu Aug 11, 2011 7:24 pm
Posts: 17
Ok, thank you very much, now that's clear.

But in the inventory source code in the TWL examples, the icons are drawing with an animation state, which is settled for the item slot, not for the icon. I don't understand that. I tried to change the Image in Slick Image, and that does not work.


Top
 Profile  
 
PostPosted: Thu Feb 09, 2012 10:00 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1173
Huh?

In the inventory demo each item slot is a widget. It has it's own AnimationState which uses the following states (in that demo):
"dragActive" - that item is currently being dragged around
"dropOk" - the currently dragged item can be dropped in this slot
"dropBlocked" - the currently dragged item can NOT be dropped in this slot

You can add as many animation states as you want. It is common to declare them as public private final fields at the top of the class which uses them.

And the AnimationState is also used for drawing the icons in paintWidget.
But the icons in the demo theme do not check for any states.

The application/widgets should expose as much state as possible to give the theme designer maximum flexibility.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group