Skip to content

Commit 2ed7bb5

Browse files
authored
Merge pull request storytold#1165 from emmertex/fix/1146-overlay-popover-width
UI-1146: compact Color Overlay Settings popover
2 parents 2c0bd87 + 50f6d9b commit 2ed7bb5

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

‎crates/ui-egui/src/panels/masking.rs‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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).
12491249
pub 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.
12521256
pub(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
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### Narrower Color Overlay Settings
2+
- The Color Overlay Settings popover and its Opacity slider are now compact, so they no longer reach over the photo (issue #1146).

0 commit comments

Comments
 (0)