@@ -205,7 +205,7 @@ func main() {
205
205
textAnimation := ui.BasicTextAnimation {
206
206
Settings : []ui.BasicTextAnimationSettings {{
207
207
Kind : ui .BasicTextAnimationKindChar ,
208
- Frames : []ui.BasicTextAnimationFrame {{
208
+ Frames : []ui.BasicAnimationFrame {{
209
209
Translate : ui .NewAmountPoint (0 , 40 ),
210
210
Scale : & ui.Coord {X : 4 , Y : 4 },
211
211
Origin : ui .NewAmountPointUnit (0.5 , 1 , ui .UnitParent ),
@@ -222,7 +222,7 @@ func main() {
222
222
}, {
223
223
Start : 11 ,
224
224
Kind : ui .BasicTextAnimationKindWord ,
225
- Frames : []ui.BasicTextAnimationFrame {{
225
+ Frames : []ui.BasicAnimationFrame {{
226
226
Translate : ui .NewAmountPoint (0 , - 10 ),
227
227
Color : ui .Alpha (0 ),
228
228
Time : 0 ,
@@ -235,7 +235,7 @@ func main() {
235
235
}, {
236
236
Start : 39 ,
237
237
Kind : ui .BasicTextAnimationKindLine ,
238
- Frames : []ui.BasicTextAnimationFrame {{
238
+ Frames : []ui.BasicAnimationFrame {{
239
239
Translate : ui .NewAmountPoint (- 100 , 0 ),
240
240
Color : ui .Alpha (0 ),
241
241
Time : 0 ,
@@ -248,7 +248,7 @@ func main() {
248
248
}, {
249
249
Start : 159 ,
250
250
Kind : ui .BasicTextAnimationKindColumn ,
251
- Frames : []ui.BasicTextAnimationFrame {{
251
+ Frames : []ui.BasicAnimationFrame {{
252
252
Translate : ui .NewAmountPoint (- 10 , 0 ),
253
253
Color : ui .Alpha (0 ),
254
254
Time : 0 ,
@@ -264,12 +264,19 @@ func main() {
264
264
textWindow := newWindow ("Test Window" , ui .Absolute (900 , 20 , 500 , 400 ))
265
265
textWindow .Children = append (textWindow .Children ,
266
266
& ui.Base {
267
- Placement : ui .MaximizeOffset (10 , 34 , 10 , 10 ),
267
+ Placement : ui .MaximizeOffset (10 , 44 , 10 , 10 ),
268
268
IgnoreLayoutPreferredHeight : true ,
269
269
Clip : ui .Maximized (),
270
270
Layout : ui.LayoutStatic {
271
271
EnforcePreferredSize : true ,
272
272
},
273
+ Events : ui.Events {
274
+ OnPointer : func (ev * ui.PointerEvent ) {
275
+ if ! ev .Capture && ev .Type == ui .PointerEventWheel {
276
+ fmt .Printf ("Wheel event: %+v\n " , ev .Amount )
277
+ }
278
+ },
279
+ },
273
280
Children : []* ui.Base {{
274
281
Layers : []ui.Layer {{
275
282
Visual : ui .MustTextToVisual (strings .Join ([]string {
@@ -283,7 +290,7 @@ func main() {
283
290
"{p}{h:0.25}25% aligned?" ,
284
291
"{p}{h}{w:word}This should wrap at the word and not at the character and should take up at least two lines. Resize the window!" ,
285
292
"{p}{pt:20}{h:0.5}{w:char}This should wrap at the character and not at the word and be centered." ,
286
- }, "\n " )).Animate (textAnimation ),
293
+ }, "\n " )).Play (textAnimation ),
287
294
}},
288
295
Events : ui.Events {
289
296
OnPointer : func (ev * ui.PointerEvent ) {
@@ -298,8 +305,19 @@ func main() {
298
305
},
299
306
},
300
307
},
301
- newButton (ui.Placement {}.Attach (1 , 0 , 100 , 30 ).Shift (- 10 , 10 ), "Do a barrel roll!" , false , func () {
302
-
308
+ newButton (ui.Placement {}.Attach (1 , 0 , 0 , 0 ), "{h:center}{w:none}Do a barrel roll!" , false , func () {
309
+ textWindow .Play (ui.BasicAnimation {
310
+ Duration : 1.0 ,
311
+ Easing : func (x float32 ) float32 {
312
+ inv := 1.0 - x
313
+ return (1.0 - util .Abs (inv * inv * util .Cos (x * x * 7.0 )))
314
+ },
315
+ Save : true ,
316
+ Frames : []ui.BasicAnimationFrame {
317
+ {Rotate : 360 , Time : 0 , Origin : ui .NewAmountPointUnit (0.5 , 0.5 , ui .UnitParent )},
318
+ {Rotate : 0 , Time : 1 , Origin : ui .NewAmountPointUnit (0.5 , 0.5 , ui .UnitParent )},
319
+ },
320
+ })
303
321
}),
304
322
},
305
323
},
@@ -311,7 +329,7 @@ func main() {
311
329
frame := userInterface .Named .Get (layoutColumnName )
312
330
layout := frame .Layout .(* ui.LayoutColumn )
313
331
change (layout )
314
- frame .Dirty ( ui . DirtyPlacement )
332
+ frame .Relayout ( )
315
333
}
316
334
layoutColumnWindow := newWindow ("Layout Column" , ui .Absolute (10 , 500 , 300 , 300 ))
317
335
layoutColumnWindow .Children = append (layoutColumnWindow .Children , & ui.Base {
@@ -366,7 +384,7 @@ func main() {
366
384
frame := userInterface .Named .Get (layoutRowName )
367
385
layout := frame .Layout .(* ui.LayoutRow )
368
386
change (layout )
369
- frame .Dirty ( ui . DirtyPlacement )
387
+ frame .Relayout ( )
370
388
}
371
389
layoutRowWindow := newWindow ("Layout Row" , ui .Absolute (800 , 500 , 300 , 300 ))
372
390
layoutRowWindow .Children = append (layoutRowWindow .Children , & ui.Base {
@@ -568,7 +586,7 @@ func main() {
568
586
frame := userInterface .Named .Get (layoutInlineName )
569
587
layout := frame .Layout .(* ui.LayoutInline )
570
588
change (layout )
571
- frame .Dirty ( ui . DirtyPlacement )
589
+ frame .Relayout ( )
572
590
}
573
591
layoutInlineWindow := newWindow ("Layout Inline" , ui .Absolute (20 , 700 , 300 , 300 ))
574
592
layoutInlineWindow .Children = append (layoutInlineWindow .Children ,
@@ -720,17 +738,17 @@ var FadeInAnimation = ui.BasicAnimation{
720
738
Save : true ,
721
739
Duration : 0.5 ,
722
740
Frames : []ui.BasicAnimationFrame {
723
- {Time : 0 , Transparency : 1 },
724
- {Time : 1 , Transparency : 0 },
741
+ {Time : 0 , Color : ui . Alpha ( 0 ) },
742
+ {Time : 1 , Color : ui . Alpha ( 1 ) },
725
743
},
726
744
}
727
745
728
746
var FadeOutAnimation = ui.BasicAnimation {
729
747
Save : true ,
730
748
Duration : 0.5 ,
731
749
Frames : []ui.BasicAnimationFrame {
732
- {Time : 0 , Transparency : 0 },
733
- {Time : 1 , Transparency : 1 },
750
+ {Time : 0 , Color : ui . Alpha ( 1 ) },
751
+ {Time : 1 , Color : ui . Alpha ( 0 ) },
734
752
},
735
753
}
736
754
@@ -739,15 +757,15 @@ var FadeOutSlideUpAnimation = ui.BasicAnimation{
739
757
Duration : 0.7 ,
740
758
Frames : []ui.BasicAnimationFrame {
741
759
{Time : 0 , Origin : OriginCenter },
742
- {Time : 1 , Translate : ui.AmountPoint {Y : ui.Amount {Value : - 100 }}, Origin : OriginCenter , Transparency : 1 },
760
+ {Time : 1 , Translate : ui.AmountPoint {Y : ui.Amount {Value : - 100 }}, Origin : OriginCenter , Color : ui . Alpha ( 0 ) },
743
761
},
744
762
}
745
763
746
764
var FadeInSlideDownAnimation = ui.BasicAnimation {
747
765
Save : true ,
748
766
Duration : 0.7 ,
749
767
Frames : []ui.BasicAnimationFrame {
750
- {Time : 0 , Transparency : 1 , Translate : ui.AmountPoint {Y : ui.Amount {Value : - 100 }}, Origin : OriginCenter },
768
+ {Time : 0 , Color : ui . Alpha ( 0 ) , Translate : ui.AmountPoint {Y : ui.Amount {Value : - 100 }}, Origin : OriginCenter },
751
769
{Time : 1 , Origin : OriginCenter },
752
770
},
753
771
}
@@ -756,32 +774,32 @@ var FadeInSlideRightAnimation = ui.BasicAnimation{
756
774
Save : true ,
757
775
Duration : 0.7 ,
758
776
Frames : []ui.BasicAnimationFrame {
759
- {Time : 0 , Translate : ui.AmountPoint {X : ui.Amount {Value : - 100 }}, Origin : OriginCenter , Transparency : 1 },
777
+ {Time : 0 , Translate : ui.AmountPoint {X : ui.Amount {Value : - 100 }}, Origin : OriginCenter , Color : ui . Alpha ( 0 ) },
760
778
{Time : 1 , Origin : OriginCenter },
761
779
},
762
780
}
763
781
764
782
var ExplodeAnimation = ui.BasicAnimation {
765
783
Duration : 0.2 ,
766
784
Frames : []ui.BasicAnimationFrame {
767
- {Time : 0 , Transparency : 0 , Scale : & ui.Coord {X : 1 , Y : 1 }, Origin : OriginCenter },
768
- {Time : 1 , Transparency : 1 , Scale : & ui.Coord {X : 4 , Y : 4 }, Origin : OriginCenter },
785
+ {Time : 0 , Color : ui . Alpha ( 1 ) , Scale : & ui.Coord {X : 1 , Y : 1 }, Origin : OriginCenter },
786
+ {Time : 1 , Color : ui . Alpha ( 0 ) , Scale : & ui.Coord {X : 4 , Y : 4 }, Origin : OriginCenter },
769
787
},
770
788
}
771
789
772
790
var CollapseOpenAnimation = ui.BasicAnimation {
773
791
Duration : 0.3 ,
774
792
Frames : []ui.BasicAnimationFrame {
775
- {Time : 0 , Scale : & ui.Coord {X : 1 , Y : 0 }, Transparency : 1 },
776
- {Time : 1 , Scale : & ui.Coord {X : 1 , Y : 1 }, Transparency : 0 },
793
+ {Time : 0 , Scale : & ui.Coord {X : 1 , Y : 0 }, Color : ui . Alpha ( 0 ) },
794
+ {Time : 1 , Scale : & ui.Coord {X : 1 , Y : 1 }, Color : ui . Alpha ( 1 ) },
777
795
},
778
796
}
779
797
780
798
var CollapseCloseAnimation = ui.BasicAnimation {
781
799
Duration : 0.3 ,
782
800
Frames : []ui.BasicAnimationFrame {
783
- {Time : 0 , Scale : & ui.Coord {X : 1 , Y : 1 }, Transparency : 0 },
784
- {Time : 1 , Scale : & ui.Coord {X : 1 , Y : 0 }, Transparency : 1 },
801
+ {Time : 0 , Scale : & ui.Coord {X : 1 , Y : 1 }, Color : ui . Alpha ( 1 ) },
802
+ {Time : 1 , Scale : & ui.Coord {X : 1 , Y : 0 }, Color : ui . Alpha ( 0 ) },
785
803
},
786
804
}
787
805
@@ -1297,12 +1315,12 @@ func newWindow(title string, placement ui.Placement) *ui.Base {
1297
1315
}
1298
1316
switch ev .Type {
1299
1317
case ui .DragEventStart :
1300
- frame .Transparency . Set (0.2 )
1318
+ frame .SetTransparency (0.2 )
1301
1319
frame .BringToFront ()
1302
1320
case ui .DragEventMove :
1303
1321
frame .SetPlacement (frame .Placement .Shift (ev .DeltaMove .X , ev .DeltaMove .Y ))
1304
1322
case ui .DragEventEnd :
1305
- frame .Transparency . Set (0 )
1323
+ frame .SetTransparency (0 )
1306
1324
}
1307
1325
},
1308
1326
},
@@ -1369,11 +1387,11 @@ func newWindowClose(win *ui.Base, barSize float32) *ui.Base {
1369
1387
Events : ui.Events {
1370
1388
OnPointer : func (ev * ui.PointerEvent ) {
1371
1389
if ! ev .Capture && ev .Type == ui .PointerEventUp {
1372
- win .Transparency . Set (1 )
1390
+ win .SetTransparency (1 )
1373
1391
1374
1392
go func () {
1375
1393
time .Sleep (time .Second * 3 )
1376
- win .Transparency . Set (0 )
1394
+ win .SetTransparency (0 )
1377
1395
}()
1378
1396
}
1379
1397
},
@@ -1498,7 +1516,7 @@ func newWindowResizer(win *ui.Base, cursor id.Identifier, placement ui.Placement
1498
1516
ev .Stop = true
1499
1517
switch ev .Type {
1500
1518
case ui .DragEventStart :
1501
- win .Transparency . Set (0.2 )
1519
+ win .SetTransparency (0.2 )
1502
1520
start = win .Placement
1503
1521
case ui .DragEventMove :
1504
1522
current := win .Placement
@@ -1515,7 +1533,7 @@ func newWindowResizer(win *ui.Base, cursor id.Identifier, placement ui.Placement
1515
1533
case ui .DragEventCancel :
1516
1534
win .SetPlacement (start )
1517
1535
case ui .DragEventEnd :
1518
- win .Transparency . Set (0 )
1536
+ win .SetTransparency (0 )
1519
1537
}
1520
1538
}
1521
1539
},
0 commit comments