Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

fix(ui): floating panel groups get an opaque title strip in Studio themes (#4509) (#4543)

mjohnson7cde0f6ce430285
diff --git a/crates/ui-egui/src/panel_docking.rs b/crates/ui-egui/src/panel_docking.rs
index 7a1cb4df1..de56d6714 100644
--- a/crates/ui-egui/src/panel_docking.rs
+++ b/crates/ui-egui/src/panel_docking.rs
@@ -404,7 +404,9 @@ pub(crate) fn show(app: &mut PhotocraftApp, ui: &mut egui::Ui) -> bool {
style.tab_height = if t.pro { 28.0 } else { 40.0 };
style.min_pane = 0.0;
style.background = t.card;
- style.tab_background = t.tab_strip;
+ // Studio themes leave the strip transparent over the dock's card; a floating group has no
+ // card behind it, so the canvas showed through its titles (#4509).
+ style.tab_background = if t.tab_strip.a() == 0 { t.card } else { t.tab_strip };
style.active_background = t.card;
style.text = t.text;
style.inactive_text = t.text_dim;
diff --git a/crates/ui-egui/src/panel_docking_tests.rs b/crates/ui-egui/src/panel_docking_tests.rs
index 657232f04..735274eb8 100644
--- a/crates/ui-egui/src/panel_docking_tests.rs
+++ b/crates/ui-egui/src/panel_docking_tests.rs
@@ -162,6 +162,37 @@ fn capture_custom_panel_docking_visual_fixtures() {
}
}
+#[test]
+fn floating_group_titles_are_opaque_in_studio_themes() {
+ // Studio's tab strip is transparent over the dock's card; a floating group must not show the canvas (#4509).
+ let mut app = app();
+ app.run("window.panel.float", json!({"panel":"swatches","x":40,"y":60,"width":300,"height":300})).unwrap();
+ let mut ready = false;
+ let mut h = Harness::builder().with_size(vec2(1280.0, 800.0)).wgpu().build_ui_state(
+ move |ui, app: &mut PhotocraftApp| {
+ if !ready {
+ PhotocraftApp::setup_context(ui.ctx(), crate::theme::ThemeKind::Studio);
+ app.ui.theme = crate::theme::ThemeKind::Studio;
+ ready = true;
+ return;
+ }
+ crate::panels::right_dock(app, ui);
+ egui::CentralPanel::default().frame(egui::Frame::NONE.fill(egui::Color32::from_rgb(255, 0, 255))).show(ui, |_| {});
+ },
+ app,
+ );
+ h.run_steps(5);
+ let area = h.ctx.memory(|m| m.area_rect(egui::Id::new("photocraft-panel-docking").with(("floating", &"swatches".to_string())))).unwrap();
+ let image = h.render().unwrap();
+ let ppp = image.width() as f32 / 1280.0;
+ let strip = egui::Rect::from_min_size(area.min, vec2(area.width(), 40.0)).shrink(2.0);
+ let magenta = (strip.left() as u32..strip.right() as u32)
+ .flat_map(|x| (strip.top() as u32..strip.bottom() as u32).map(move |y| (x, y)))
+ .filter(|&(x, y)| image.get_pixel((x as f32 * ppp) as u32, (y as f32 * ppp) as u32).0[..3] == [255, 0, 255])
+ .count();
+ assert_eq!(magenta, 0, "canvas shows through the floating group's title strip {strip:?}");
+}
+
#[test]
fn escape_cancels_the_first_drag_without_replacing_the_legacy_workspace() {
let mut h = harness(app(), vec2(1280.0, 800.0));