@@ -8,6 +8,8 @@ use crate::icons::{self, Icon};
88use crate :: theme:: { self , Tokens } ;
99use crate :: { SlideApp , ViewMode } ;
1010
11+ /// The status bar: slide counter, proofing language and status message on the left; notes,
12+ /// comments, views and zoom on the right.
1113pub fn status_bar ( app : & mut SlideApp , ui : & mut Ui ) {
1214 let t = Tokens :: get ( ui. ctx ( ) ) ;
1315 egui:: Panel :: bottom ( "status" ) . exact_size ( 28.0 ) . frame ( egui:: Frame :: NONE . fill ( t. chrome ) ) . show ( ui, |ui| {
@@ -19,22 +21,31 @@ pub fn status_bar(app: &mut SlideApp, ui: &mut Ui) {
1921 _ => "Slide Master" . to_string ( ) ,
2022 } ;
2123 let p = ui. painter ( ) ;
22- p. text ( pos2 ( rect. min . x + 14.0 , rect. center ( ) . y ) , Align2 :: LEFT_CENTER , & left, theme:: font ( 12.0 ) , t. text_dim ) ;
24+ // Left to right: slide counter, language, status message. Each starts at its usual column, or
25+ // after the one before it when that runs long ("Slide 100 of 120", "… (not checked)").
26+ let sr = p. text ( pos2 ( rect. min . x + 14.0 , rect. center ( ) . y ) , Align2 :: LEFT_CENTER , & left, theme:: font ( 12.0 ) , t. text_dim ) ;
27+ // Where the controls on the right begin; nothing on the left paints or clicks past it.
28+ let right_x = rect. max . x - 560.0 ;
2329 // The selection's proofing language; a click opens Review › Language.
2430 let ( lang, no_proof) = crate :: dialogs:: selected_language ( app) ;
2531 let name = crate :: squiggles:: lang_name ( & lang) + if no_proof { " (not checked)" } else { "" } ;
26- let lr = p. text ( pos2 ( rect. min . x + 120.0 , rect. center ( ) . y ) , Align2 :: LEFT_CENTER , & name, theme:: font ( 12.0 ) , t. text_dim ) ;
27- if ui. interact ( lr. expand ( 3.0 ) , ui. id ( ) . with ( "status_lang" ) , Sense :: click ( ) ) . on_hover_text ( "Language" ) . clicked ( ) {
32+ let lx = ( rect. min . x + 120.0 ) . max ( sr. max . x + 16.0 ) ;
33+ let lclip = Rect :: from_min_max ( pos2 ( lx - 3.0 , rect. min . y ) , pos2 ( right_x. max ( lx - 3.0 ) , rect. max . y ) ) ;
34+ let lr = p. with_clip_rect ( lclip) . text ( pos2 ( lx, rect. center ( ) . y ) , Align2 :: LEFT_CENTER , & name, theme:: font ( 12.0 ) , t. text_dim ) ;
35+ let hit = lr. expand ( 3.0 ) . intersect ( lclip) ;
36+ if hit. is_positive ( ) && ui. interact ( hit, ui. id ( ) . with ( "status_lang" ) , Sense :: click ( ) ) . on_hover_text ( "Language" ) . clicked ( ) {
2837 app. dialog = Some ( crate :: dialogs:: Dialog :: new ( "language" ) ) ;
2938 }
30- // Transient status message.
39+ // Transient status message, clipped before the controls on the right .
3140 if let Some ( msg) = app. fresh_status ( ) {
32- p. text ( pos2 ( rect. min . x + 290.0 , rect. center ( ) . y ) , Align2 :: LEFT_CENTER , & msg, theme:: font ( 12.0 ) , t. accent ) ;
41+ let mx = ( rect. min . x + 290.0 ) . max ( lr. max . x + 16.0 ) ;
42+ let clip = Rect :: from_min_max ( pos2 ( mx, rect. min . y ) , pos2 ( right_x. max ( mx) , rect. max . y ) ) ;
43+ p. with_clip_rect ( clip) . text ( pos2 ( mx, rect. center ( ) . y ) , Align2 :: LEFT_CENTER , & msg, theme:: font ( 12.0 ) , t. accent ) ;
3344 ui. ctx ( ) . request_repaint_after ( std:: time:: Duration :: from_millis ( 500 ) ) ;
3445 }
3546 let mut right = ui. new_child (
3647 egui:: UiBuilder :: new ( )
37- . max_rect ( Rect :: from_min_max ( pos2 ( rect . max . x - 560.0 , rect. min . y ) , pos2 ( rect. max . x - 8.0 , rect. max . y ) ) )
48+ . max_rect ( Rect :: from_min_max ( pos2 ( right_x , rect. min . y ) , pos2 ( rect. max . x - 8.0 , rect. max . y ) ) )
3849 . layout ( egui:: Layout :: right_to_left ( egui:: Align :: Center ) ) ,
3950 ) ;
4051 right. spacing_mut ( ) . item_spacing . x = 4.0 ;
0 commit comments