@@ -1248,10 +1248,15 @@ fn mask_menu(app: &mut LccApp, ui: &mut egui::Ui, id: u32, name: &str, visible:
12481248/// Overlay colours offered as swatches (the colour of the selected one is used for the tint).
12491249pub const OVERLAY_COLORS : [ [ u8 ; 3 ] ; 5 ] = [ [ 230 , 30 , 40 ] , [ 40 , 200 , 70 ] , [ 40 , 110 , 240 ] , [ 250 , 210 , 30 ] , [ 255 , 255 , 255 ] ] ;
12501250
1251+ /// Width of the Color Overlay Settings popup: the swatch row plus a short Opacity slider, so the
1252+ /// popup fits beside the right panel instead of reaching over the photo (#1146).
1253+ pub ( crate ) const COLOR_OVERLAY_POPUP_WIDTH : f32 = 220.0 ;
1254+
12511255/// Color Overlay Settings popup: custom color selection swatches and opacity control.
12521256pub ( crate ) fn color_overlay_popup ( app : & mut LccApp , ui : & mut egui:: Ui ) {
12531257 let t = Tokens :: get ( ui. ctx ( ) ) ;
1254- ui. set_min_width ( 200.0 ) ;
1258+ // the slider takes all the width it is offered, and a popup offers the whole window
1259+ ui. set_width ( COLOR_OVERLAY_POPUP_WIDTH ) ;
12551260 ui. label ( egui:: RichText :: new ( crate :: i18n:: tr ( "Color Overlay Settings" ) ) . font ( t. semibold ( 12.0 ) ) . color ( t. text_label ) ) ;
12561261 ui. add_space ( 4.0 ) ;
12571262
@@ -2577,4 +2582,23 @@ mod tests {
25772582 assert ! ( !enter_submits( false , false , true ) ) ;
25782583 assert ! ( !enter_submits( false , true , false ) ) ;
25792584 }
2585+
2586+ #[ test]
2587+ fn the_color_overlay_popup_stays_narrow_on_a_wide_window ( ) {
2588+ let app = LccApp :: new ( lcc_engine:: Session :: new ( ) , crate :: Services { png : None , ..Default :: default ( ) } ) ;
2589+ // the headless view's context has the app's fonts and theme installed
2590+ let mut h = crate :: headless:: Headless :: new ( app, [ 3200.0 , 1400.0 ] , 1.0 ) ;
2591+ h. settle ( std:: time:: Duration :: from_secs ( 30 ) ) ;
2592+ let ctx = h. view . ctx . clone ( ) ;
2593+ let input = egui:: RawInput { screen_rect : Some ( egui:: Rect :: from_min_size ( egui:: Pos2 :: ZERO , vec2 ( 3200.0 , 1400.0 ) ) ) , ..Default :: default ( ) } ;
2594+ let mut width = 0.0 ;
2595+ let mut out = ctx. run_ui ( input, |root| {
2596+ egui:: Area :: new ( egui:: Id :: new ( "overlayPopupTest" ) ) . show ( root. ctx ( ) , |ui| {
2597+ color_overlay_popup ( & mut h. app , ui) ;
2598+ width = ui. min_rect ( ) . width ( ) ;
2599+ } ) ;
2600+ } ) ;
2601+ out. textures_delta . clear ( ) ;
2602+ assert ! ( width > 0.0 && width <= COLOR_OVERLAY_POPUP_WIDTH + 1.0 , "popup is {width} points wide" ) ;
2603+ }
25802604}
0 commit comments