@@ -16,6 +16,7 @@ import (
16
16
"github.com/axe/axe-go/pkg/impl/opengl"
17
17
"github.com/axe/axe-go/pkg/input"
18
18
"github.com/axe/axe-go/pkg/ui"
19
+ "github.com/axe/axe-go/pkg/ui/ua"
19
20
"github.com/axe/axe-go/pkg/util"
20
21
)
21
22
@@ -168,7 +169,7 @@ func main() {
168
169
})
169
170
170
171
// Global Animations
171
- userInterface .Theme .Animations .ForEvent .Set (ui .AnimationEventEnabled , WiggleAnimation )
172
+ userInterface .Theme .Animations .ForEvent .Set (ui .AnimationEventEnabled , ua . Wiggle )
172
173
173
174
// Cursors
174
175
cursors := ui .TileGrid (10 , 8 , 56 , 56 , 559 , 449 , 0 , 0 , "cursors" )
@@ -306,8 +307,8 @@ func main() {
306
307
Easing : ease .TinyBounce ,
307
308
Save : true ,
308
309
Frames : []ui.BasicAnimationFrame {
309
- {Rotate : 360 , Time : 0 , Origin : ui .NewAmountPointUnit (0.5 , 0.5 , ui . UnitParent )},
310
- {Rotate : 0 , Time : 1 , Origin : ui .NewAmountPointUnit (0.5 , 0.5 , ui . UnitParent )},
310
+ {Rotate : 360 , Time : 0 , Origin : ui .NewAmountPointParent (0.5 , 0.5 )},
311
+ {Rotate : 0 , Time : 1 , Origin : ui .NewAmountPointParent (0.5 , 0.5 )},
311
312
},
312
313
})
313
314
}),
@@ -548,8 +549,8 @@ func main() {
548
549
newButton (ui.Placement {}, "Hide & Show Animation" , false , nil ).Edit (func (b * ui.Base ) {
549
550
b .Colors .Set (BackgroundColor , ui .ColorOrange )
550
551
b .Colors .Set (TextColor , ui .ColorBlack )
551
- b .Animations .ForEvent .Set (ui .AnimationEventShow , FadeInAnimation )
552
- b .Animations .ForEvent .Set (ui .AnimationEventHide , FadeOutAnimation )
552
+ b .Animations .ForEvent .Set (ui .AnimationEventShow , ua . FadeIn )
553
+ b .Animations .ForEvent .Set (ui .AnimationEventHide , ua . FadeOut )
553
554
b .Events .OnPointer .Add (func (ev * ui.PointerEvent ) {
554
555
if ! ev .Capture && ev .Type == ui .PointerEventDown {
555
556
b .Hide ()
@@ -568,7 +569,7 @@ func main() {
568
569
}, false )
569
570
}),
570
571
newButton (ui.Placement {}, "Remove Animating" , false , nil ).Edit (func (b * ui.Base ) {
571
- b .Animations .ForEvent .Set (ui .AnimationEventRemove , ExplodeAnimation )
572
+ b .Animations .ForEvent .Set (ui .AnimationEventRemove , ua . Explode . WithDuration ( 0.2 ) )
572
573
b .Events .OnPointer .Add (func (ev * ui.PointerEvent ) {
573
574
if ! ev .Capture && ev .Type == ui .PointerEventDown {
574
575
b .Remove ()
@@ -704,102 +705,6 @@ const (
704
705
TextColor
705
706
)
706
707
707
- // Animations
708
-
709
- var OriginCenter = ui .NewAmountPointUnit (0.5 , 0.5 , ui .UnitParent )
710
-
711
- var WiggleAnimation = ui.BasicAnimation {
712
- Save : true , // save on component so the pointer is inverse transformed against it
713
- Duration : 1.0 ,
714
- Frames : []ui.BasicAnimationFrame {
715
- {Time : 0 , Rotate : 0 , Origin : OriginCenter },
716
- {Time : .125 , Rotate : - 45 , Origin : OriginCenter },
717
- {Time : .375 , Rotate : 45 , Origin : OriginCenter },
718
- {Time : .583 , Rotate : - 30 , Origin : OriginCenter },
719
- {Time : .75 , Rotate : 30 , Origin : OriginCenter },
720
- {Time : .875 , Rotate : - 15 , Origin : OriginCenter },
721
- {Time : .9583 , Rotate : 15 , Origin : OriginCenter },
722
- {Time : 1 , Rotate : 0 , Origin : OriginCenter },
723
- },
724
- }
725
-
726
- var RevealAnimation = ui.BasicAnimation {
727
- Duration : 1.0 ,
728
- Frames : []ui.BasicAnimationFrame {
729
- {Time : 0 , Scale : & ui.Coord {X : 1 }, Origin : OriginCenter },
730
- {Time : 1 , Scale : & ui.Coord {X : 1 , Y : 1 }, Origin : OriginCenter },
731
- },
732
- }
733
-
734
- var FadeInAnimation = ui.BasicAnimation {
735
- Save : true ,
736
- Duration : 0.5 ,
737
- Frames : []ui.BasicAnimationFrame {
738
- {Time : 0 , Transparency : 1 },
739
- {Time : 1 , Transparency : 0 },
740
- },
741
- }
742
-
743
- var FadeOutAnimation = ui.BasicAnimation {
744
- Save : true ,
745
- Duration : 0.5 ,
746
- Frames : []ui.BasicAnimationFrame {
747
- {Time : 0 , Transparency : 0 },
748
- {Time : 1 , Transparency : 1 },
749
- },
750
- }
751
-
752
- var FadeOutSlideUpAnimation = ui.BasicAnimation {
753
- Save : true ,
754
- Duration : 0.7 ,
755
- Frames : []ui.BasicAnimationFrame {
756
- {Time : 0 , Origin : OriginCenter },
757
- {Time : 1 , Translate : ui.AmountPoint {Y : ui.Amount {Value : - 100 }}, Origin : OriginCenter , Transparency : 1 },
758
- },
759
- }
760
-
761
- var FadeInSlideDownAnimation = ui.BasicAnimation {
762
- Save : true ,
763
- Duration : 0.7 ,
764
- Frames : []ui.BasicAnimationFrame {
765
- {Time : 0 , Transparency : 1 , Translate : ui.AmountPoint {Y : ui.Amount {Value : - 100 }}, Origin : OriginCenter },
766
- {Time : 1 , Origin : OriginCenter },
767
- },
768
- }
769
-
770
- var FadeInSlideRightAnimation = ui.BasicAnimation {
771
- Save : true ,
772
- Duration : 0.7 ,
773
- Frames : []ui.BasicAnimationFrame {
774
- {Time : 0 , Translate : ui.AmountPoint {X : ui.Amount {Value : - 100 }}, Origin : OriginCenter , Transparency : 1 },
775
- {Time : 1 , Origin : OriginCenter },
776
- },
777
- }
778
-
779
- var ExplodeAnimation = ui.BasicAnimation {
780
- Duration : 0.2 ,
781
- Frames : []ui.BasicAnimationFrame {
782
- {Time : 0 , Transparency : 0 , Scale : & ui.Coord {X : 1 , Y : 1 }, Origin : OriginCenter },
783
- {Time : 1 , Transparency : 1 , Scale : & ui.Coord {X : 4 , Y : 4 }, Origin : OriginCenter },
784
- },
785
- }
786
-
787
- var CollapseOpenAnimation = ui.BasicAnimation {
788
- Duration : 0.3 ,
789
- Frames : []ui.BasicAnimationFrame {
790
- {Time : 0 , Scale : & ui.Coord {X : 1 , Y : 0 }, Transparency : 1 },
791
- {Time : 1 , Scale : & ui.Coord {X : 1 , Y : 1 }, Transparency : 0 },
792
- },
793
- }
794
-
795
- var CollapseCloseAnimation = ui.BasicAnimation {
796
- Duration : 0.3 ,
797
- Frames : []ui.BasicAnimationFrame {
798
- {Time : 0 , Scale : & ui.Coord {X : 1 , Y : 1 }, Transparency : 0 },
799
- {Time : 1 , Scale : & ui.Coord {X : 1 , Y : 0 }, Transparency : 1 },
800
- },
801
- }
802
-
803
708
// Temporary component generators
804
709
805
710
func newScrollingSection (sensitivity float32 , children ... * ui.Base ) * ui.Base {
@@ -859,8 +764,8 @@ func newCollapsibleSection(text string, children ...*ui.Base) *ui.Base {
859
764
section := & ui.Base {
860
765
Animations : & ui.Animations {
861
766
ForEvent : ds .NewEnumMap (map [ui.AnimationEvent ]ui.AnimationFactory {
862
- ui .AnimationEventShow : CollapseOpenAnimation ,
863
- ui .AnimationEventHide : CollapseCloseAnimation ,
767
+ ui .AnimationEventShow : ua . RevealDown . Merge ( ua . FadeIn ). WithDuration ( 0.3 ) ,
768
+ ui .AnimationEventHide : ua . RevealDown . Merge ( ua . FadeIn ). Reverse (). WithDuration ( 0.3 ) ,
864
769
}),
865
770
},
866
771
Children : children ,
@@ -942,7 +847,7 @@ func newDraggable() *ui.Base {
942
847
var buttonTemplate = & ui.Template {
943
848
Animations : & ui.Animations {
944
849
ForEvent : ds .NewEnumMap (map [ui.AnimationEvent ]ui.AnimationFactory {
945
- ui .AnimationEventShow : FadeInAnimation ,
850
+ ui .AnimationEventShow : ua . FadeIn ,
946
851
}),
947
852
},
948
853
Colors : ui .NewColors (map [ui.ThemeColor ]ui.Colorable {
@@ -1039,8 +944,8 @@ func newTooltip(text string, delayTime float32, hideTime float32, around *ui.Bas
1039
944
},
1040
945
Animations : & ui.Animations {
1041
946
ForEvent : ds .NewEnumMap (map [ui.AnimationEvent ]ui.AnimationFactory {
1042
- ui .AnimationEventShow : FadeInAnimation ,
1043
- ui .AnimationEventRemove : FadeOutAnimation ,
947
+ ui .AnimationEventShow : ua . FadeIn ,
948
+ ui .AnimationEventRemove : ua . FadeOut ,
1044
949
}),
1045
950
},
1046
951
Layers : []ui.Layer {{
@@ -1309,12 +1214,12 @@ func newWindow(title string, placement ui.Placement) *ui.Base {
1309
1214
Focusable : true ,
1310
1215
Animations : & ui.Animations {
1311
1216
ForEvent : ds .NewEnumMap (map [ui.AnimationEvent ]ui.AnimationFactory {
1312
- ui .AnimationEventShow : FadeInSlideDownAnimation ,
1217
+ ui .AnimationEventShow : ua . FadeInDown ,
1313
1218
}),
1314
1219
Named : id.NewDenseKeyMap [ui.AnimationFactory , uint16 , uint8 ](
1315
1220
id .WithStringMap (map [string ]ui.AnimationFactory {
1316
- "hide" : FadeOutSlideUpAnimation ,
1317
- "show" : FadeInSlideRightAnimation ,
1221
+ "hide" : ua . FadeOutUp ,
1222
+ "show" : ua . FadeInDown ,
1318
1223
}),
1319
1224
),
1320
1225
},
0 commit comments