2
* This file is part of the dis-Emi-A HaXe Library. Copyright © edA-qa mort-ora-y
3
* For full copyright and license information please refer to doc/license.txt.
11
/*hidden*/ class __FXDescriptor implements FXDescriptor
13
public var cl : Class<Dynamic>;
14
public var seq : String;
15
public var args : Dynamic;
17
public function new() { }
21
* An assistance class for using effects/transformations on widgets on
27
* Used to create an FX description which can be used by other functions
28
* in this class. This provides future compatibility to other methods of
31
static public function createActorFX( cl : Class<Dynamic>, seq : String, ?args : Dynamic ) : FXDescriptor
33
var fx = new __FXDescriptor();
41
* Ends the lifetime of a Widget with the provided FX. At the end of the
42
* FX the widget will have been removed from the parent.
44
* @param widget [in] the widget to apply the fx to
45
* @param fx [in] an FXDescriptor as created by FXBuilder
46
* @param completion [in] what to do when the FX is complete
48
static public function endWidget( widget : Widget, fx : FXDescriptor, ?completion : ui.Action )
50
ASSERT_IS( fx, __FXDescriptor );
51
var _fx = cast( fx, __FXDescriptor );
52
ASSERT_NOTNULL( widget.getNative().parent );
53
var p = widget.getNative().parent;
54
p.removeChild( widget.getNative() );
56
//translate position (TODO: Handle scaling and non-0 origins, etc...)
58
var x = widget.getNative().x;
59
var y = widget.getNative().y;
60
widget.getNative().x = 0;
61
widget.getNative().y = 0;
63
var c : ui.anim.Actor = Type.createInstance(
65
[ DynamicUtil.merge( { item: widget }, _fx.args ) ]
67
//resize and move container
68
c.resize( widget.getNative().width, widget.getNative().height );
71
c.actorSetSequence( _fx.seq, Action.bind2( __endFX, c, completion ) );
75
* Begins the lifetime of a Widget with the provided FX. The parent of the
76
* widget should already be set, and the initial sizing complete.
78
static public function beginWidget( widget : Widget, fx : FXDescriptor, ?completion : Action )
80
ASSERT_IS( fx, __FXDescriptor );
81
var _fx = cast( fx, __FXDescriptor );
82
ASSERT_NOTNULL( widget.getNative().parent );
83
var p = widget.getNative().parent;
84
p.removeChild( widget.getNative() );
86
//translate position (TODO: Handle scaling and non-0 origins, etc...)
88
var x = widget.getNative().x;
89
var y = widget.getNative().y;
90
widget.getNative().x = 0;
91
widget.getNative().y = 0;
93
var c : ui.anim.Actor = Type.createInstance(
95
[ DynamicUtil.merge( { item: widget }, _fx.args ) ]
97
//resize and move container
98
c.resize( widget.getNative().width, widget.getNative().height );
101
c.actorSetSequence( _fx.seq, Action.bind1( __beginFX, {
104
completion: completion,
112
* onWidget does an FX on an existing widget. Though at the moment this does
113
* the same thing as beginWidget, there are some exception cases whcih will be
114
* implemented later which will diverge the two, thus, use this call if the widget
117
static public function onWidget( widget : Widget, fx : FXDescriptor, ?completion : Action )
119
beginWidget( widget, fx, completion );
122
/*hidden*/ static function __beginFX( data : Dynamic )
124
data.actor.destroy();
125
data.parent.addChild( data.widget.getNative() );
126
data.widget.move( data.x, data.y );
127
if( data.completion != null )
128
Action.handle( data.widget.getNative(), data.completion );
131
/*hidden*/ static function __endFX( act : ui.anim.Actor, action : ui.Action )
133
act.parent.removeChild( act );
135
ui.Action.handle( act.getNative(), action );