Skip to content

Commit 96e0a8e

Browse files
johncosfmboxrocket6803
authored andcommitted
use IconButton instead of Option
1 parent 2aa8a51 commit 96e0a8e

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

game/addons/tools/Code/Assets/PreviewSoundFIle.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,14 @@ public override Widget CreateWidget( Widget parent )
3030
previewWidget.Play();
3131
}
3232

33-
var autoPlay = previewWidget.ToolBar.AddOption( "Auto-Play", "slideshow" );
34-
autoPlay.Toggled = ( value ) =>
33+
previewWidget.ToolBar.AddWidget( new IconButton( "slideshow" )
3534
{
36-
var icon = new Bitmap( 64, 64 );
37-
icon.SetFill( Theme.Blue );
38-
if ( value )
39-
icon.DrawRoundRect( new( 0, 64 ), 8f );
40-
icon.DrawText( new( "slideshow", Theme.Text, 56, "Material Icons" ), new( 0, 64 ), TextFlag.Center | TextFlag.DontClip );
41-
autoPlay.SetIcon( Pixmap.FromBitmap( icon ) );
42-
};
43-
autoPlay.Checkable = true;
44-
autoPlay.Bind( "Checked" ).From( this, nameof( AutoPlay ) );
45-
autoPlay.Toggled.Invoke( AutoPlay );
35+
ToolTip = "Auto-Play",
36+
IconSize = 18,
37+
IsToggle = true,
38+
IsActive = AutoPlay,
39+
OnToggled = ( value ) => AutoPlay = value
40+
} );
4641

4742
return previewWidget;
4843
}

game/addons/tools/Code/Widgets/SoundPlayer/SoundPlayer.cs

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)