@@ -10,7 +10,7 @@ public partial class SoundPlayer : Widget
1010
1111 public ToolBar ToolBar { get ; private set ; }
1212
13- private readonly Option PlayOption ;
13+ private readonly IconButton PlayOption ;
1414
1515 private bool _prevPlay = false ;
1616
@@ -27,7 +27,12 @@ public SoundPlayer( Widget parent ) : base( parent )
2727 ToolBar = header . Add ( new ToolBar ( this ) ) ;
2828 ToolBar . NoSystemBackground = false ;
2929 ToolBar . SetIconSize ( 18 ) ;
30- PlayOption = ToolBar . AddOption ( "Play" , "play_arrow" , ( ) => Playing = ! Playing ) ;
30+ PlayOption = ToolBar . AddWidget ( new IconButton ( "play_arrow" )
31+ {
32+ ToolTip = "Play" ,
33+ IconSize = 18 ,
34+ OnClick = ( ) => Playing = ! Playing
35+ } ) ;
3136
3237 var timecode = header . Add ( new Label ( this ) ) ;
3338 timecode . Bind ( "Text" ) . ReadOnly ( ) . From ( ( ) =>
@@ -38,21 +43,21 @@ public SoundPlayer( Widget parent ) : base( parent )
3843 } , null ) ;
3944 timecode . Alignment = TextFlag . RightCenter ;
4045
41- var skipStart = ToolBar . AddOption ( "Skip to Start" , "skip_previous" , ( ) => Timeline . MoveScrubber ( 0 ) ) ;
46+ ToolBar . AddWidget ( new IconButton ( "skip_previous" )
47+ {
48+ ToolTip = "Skip to Start" ,
49+ IconSize = 18 ,
50+ OnClick = ( ) => Timeline . MoveScrubber ( 0 )
51+ } ) ;
4252 ToolBar . AddSeparator ( ) ;
43- var loop = ToolBar . AddOption ( "Loop" , "repeat" ) ;
44- loop . Toggled = ( value ) =>
53+ ToolBar . AddWidget ( new IconButton ( "repeat" )
4554 {
46- var icon = new Bitmap ( 64 , 64 ) ;
47- icon . SetFill ( Theme . Blue ) ;
48- if ( value )
49- icon . DrawRoundRect ( new ( 0 , 64 ) , 8f ) ;
50- icon . DrawText ( new ( "repeat" , Theme . Text , 64 , "Material Icons" ) , new ( 0 , 64 ) , TextFlag . Center | TextFlag . DontClip ) ;
51- loop . SetIcon ( Pixmap . FromBitmap ( icon ) ) ;
52- } ;
53- loop . Bind ( "Checked" ) . From ( this , nameof ( Repeating ) ) ;
54- loop . Checkable = true ;
55- loop . Toggled . Invoke ( Repeating ) ;
55+ ToolTip = "Loop" ,
56+ IconSize = 18 ,
57+ IsToggle = true ,
58+ IsActive = Repeating ,
59+ OnToggled = ( value ) => Repeating = value
60+ } ) ;
5661
5762 Timeline = Layout . Add ( new TimelineView ( this ) , 1 ) ;
5863 }
@@ -89,7 +94,7 @@ protected void OnFrame()
8994 Timeline . OnFrame ( ) ;
9095 Time = Timeline . Time ;
9196
92- PlayOption . Text = Playing ? "Pause" : "Play" ;
97+ PlayOption . ToolTip = Playing ? "Pause" : "Play" ;
9398 PlayOption . Icon = Playing ? "pause" : "play_arrow" ;
9499
95100 if ( Application . FocusWidget . IsValid ( ) )
0 commit comments