@@ -1558,6 +1558,40 @@ impl SnowGui {
15581558 }
15591559 }
15601560
1561+ fn draw_fast_forward_button ( & self , ui : & mut egui:: Ui ) -> egui:: Response {
1562+ let is_active = self . emu . is_fastforward ( ) ;
1563+ let selection_color = ui. visuals ( ) . selection . stroke . color ;
1564+ let icon = egui_material_icons:: icons:: ICON_FAST_FORWARD ;
1565+ let mut text = egui:: RichText :: new ( icon) ;
1566+ if is_active {
1567+ text = text. color ( selection_color) ;
1568+ }
1569+
1570+ let response = ui
1571+ . add_enabled ( self . emu . is_running ( ) , egui:: Button :: new ( text) )
1572+ . on_hover_text ( "Fast-forward execution" ) ;
1573+
1574+ if is_active {
1575+ let font_id = egui:: FontId :: proportional ( 9.0 ) ;
1576+ let badge_text = egui:: WidgetText :: from (
1577+ egui:: RichText :: new ( self . emu . effective_speed_label ( ) ) . font ( font_id) ,
1578+ ) ;
1579+ let galley = badge_text. into_galley (
1580+ ui,
1581+ Some ( egui:: TextWrapMode :: Extend ) ,
1582+ f32:: MAX ,
1583+ egui:: FontSelection :: Default ,
1584+ ) ;
1585+ let badge_pos = egui:: pos2 (
1586+ response. rect . right ( ) - galley. size ( ) . x - 1.0 ,
1587+ response. rect . top ( ) + 1.0 ,
1588+ ) ;
1589+ ui. painter ( ) . galley ( badge_pos, galley, selection_color) ;
1590+ }
1591+
1592+ response
1593+ }
1594+
15611595 fn draw_toolbar ( & mut self , ctx : & egui:: Context , ui : & mut egui:: Ui ) {
15621596 ui. horizontal ( |ui| {
15631597 ui. style_mut ( ) . text_styles . insert (
@@ -1606,15 +1640,7 @@ impl SnowGui {
16061640 self . emu . run ( ) ;
16071641 }
16081642
1609- if ui
1610- . add_enabled (
1611- self . emu . is_running ( ) ,
1612- egui:: Button :: new ( egui_material_icons:: icons:: ICON_FAST_FORWARD )
1613- . selected ( self . emu . is_fastforward ( ) ) ,
1614- )
1615- . on_hover_text ( "Fast-forward execution" )
1616- . clicked ( )
1617- {
1643+ if self . draw_fast_forward_button ( ui) . clicked ( ) {
16181644 self . emu . toggle_fastforward ( ) ;
16191645 }
16201646
0 commit comments