* claim: #4107 * Keep bottom viewport overlays above the floating History card (#4107) In the floating layout the History card covered the analysis legend and the frame-rate readout (#3896). One bottom inset, computed from the History card (zero when History is hidden or docked), now positions every bottom-anchored viewport overlay: the surface-analysis and Continuity legends, the frame-rate readout, the command-progress chip and the navigation bar fallback.
This commit is contained in:
1 parent
9761d75699
commit
0db2abbeca
5 files changed
+107
-12
No files matched your search
@@ -53,7 +53,7 @@ pub(crate) fn paint(app: &mut SolveApp, ctx: &egui::Context, painter: &egui::Pai
|
||||
let size = galley.size() + vec2(16.0, 8.0);
|
||||
let r = Rect::from_min_size(pos2(rect.right() - 12.0 - size.x, rect.bottom() - 12.0 - size.y), size);
|
||||
painter.rect(r, 4.0, t.overlay, Stroke::new(1.0, t.border), egui::StrokeKind::Inside);
|
||||
crate::scenario::publish_handle("viewport:frame_rate", r.center());
|
||||
crate::scenario::publish_target("viewport:frame_rate", r);
|
||||
painter.galley(r.center() - galley.size() / 2.0, galley, t.text);
|
||||
}
|
||||
|
||||
|
||||
@@ -130,6 +130,26 @@ pub(crate) fn covered(app: &SolveApp, p: egui::Pos2) -> bool {
|
||||
covered_rects(app).iter().any(|r| r.contains(p))
|
||||
}
|
||||
|
||||
/// Space reserved below viewport overlays by the floating History card. Its rect is set before
|
||||
/// the viewport is painted, so showing or hiding History takes effect in the same frame. History
|
||||
/// docked as the left sidebar sits beside the viewport, not below it, so it reserves nothing.
|
||||
pub(crate) fn viewport_bottom_inset(app: &SolveApp, viewport: Rect) -> f32 {
|
||||
if app.ui.layout != LayoutMode::Floating || (app.ui.show_timeline && app.preferences.timeline_left) {
|
||||
return 0.0;
|
||||
}
|
||||
app.shell
|
||||
.history
|
||||
.filter(|r| r.is_finite() && r.width() >= 1.0 && r.height() >= 30.0)
|
||||
.map_or(0.0, |history| (viewport.bottom() - history.top() + SHELL_GAP).clamp(0.0, viewport.height().max(0.0)))
|
||||
}
|
||||
|
||||
/// Bottom-anchored overlays share the content area's History clearance without moving the
|
||||
/// viewport's projection or its left and right anchors.
|
||||
pub(crate) fn bottom_overlay_rect(app: &SolveApp, mut viewport: Rect) -> Rect {
|
||||
viewport.max.y -= viewport_bottom_inset(app, viewport);
|
||||
viewport
|
||||
}
|
||||
|
||||
/// The former central panel remains the anchor for controls and docked panels.
|
||||
pub(crate) fn content_rect(app: &SolveApp, viewport: Rect) -> Rect {
|
||||
app.shell.content.unwrap_or(viewport).intersect(viewport)
|
||||
|
||||
@@ -203,7 +203,8 @@ fn continuity_legend(app: &SolveApp, painter: &egui::Painter, proj: &Proj) {
|
||||
let (row, pad, swatch) = (18.0, 8.0, 22.0);
|
||||
let text_width = rows.iter().map(|(label, _)| painter.layout_no_wrap(label.to_string(), font.clone(), tk.text).size().x).fold(0.0, f32::max);
|
||||
let size = egui::vec2(pad + swatch + 8.0 + text_width + pad, rows.len() as f32 * row + 2.0 * pad);
|
||||
let frame = egui::Rect::from_min_size(proj.rect.left_bottom() + egui::vec2(16.0, -(size.y + 16.0)), size);
|
||||
let available = crate::shell::bottom_overlay_rect(app, proj.rect);
|
||||
let frame = egui::Rect::from_min_size(available.left_bottom() + egui::vec2(16.0, -(size.y + 16.0)), size);
|
||||
painter.rect_filled(frame, 4.0, tk.panel.gamma_multiply(0.9));
|
||||
crate::scenario::publish_rect("continuity_legend", frame);
|
||||
for (i, (label, col)) in rows.iter().enumerate() {
|
||||
|
||||
@@ -1865,7 +1865,7 @@ fn analysis_legend(app: &SolveApp, painter: &egui::Painter, rect: Rect) {
|
||||
let h = pad * 2.0 + 18.0 + along.as_ref().map_or(0.0, |_| row) + row * rows.len() as f32;
|
||||
let r = Rect::from_min_size(pos2(rect.left() + 12.0, rect.bottom() - 12.0 - h), vec2(230.0, h));
|
||||
painter.rect(r, t.radius_md, t.overlay, Stroke::new(1.0, t.border), egui::StrokeKind::Inside);
|
||||
crate::scenario::publish_handle("analysis:legend", r.center());
|
||||
crate::scenario::publish_target("analysis:legend", r);
|
||||
let mut y = r.top() + pad;
|
||||
painter.text(pos2(r.left() + pad, y), Align2::LEFT_TOP, title, FontId::proportional(t.font_button), t.text);
|
||||
y += 18.0;
|
||||
@@ -2726,8 +2726,9 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
});
|
||||
painter.add(egui_wgpu::Callback::new_paint_callback(rect, cb));
|
||||
}
|
||||
analysis_legend(app, &painter, rect);
|
||||
crate::frame_rate::paint(app, ui.ctx(), &painter, rect);
|
||||
let overlay_rect = crate::shell::bottom_overlay_rect(app, rect);
|
||||
analysis_legend(app, &painter, overlay_rect);
|
||||
crate::frame_rate::paint(app, ui.ctx(), &painter, overlay_rect);
|
||||
|
||||
// ---- interaction ----
|
||||
// A tool's click that moved on the way (#2448) clicks where the button is let go.
|
||||
@@ -3184,7 +3185,7 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
crate::select_other::show(app, ui.ctx());
|
||||
axis_view(app, ui, rect);
|
||||
nav_bar(app, ui, rect);
|
||||
agent_chip(app, ui, rect);
|
||||
agent_chip(app, ui, overlay_rect);
|
||||
transient_messages(app, ui, rect);
|
||||
}
|
||||
|
||||
@@ -4051,12 +4052,10 @@ fn nav_bar(app: &mut SolveApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
let menu_id = ui.id().with("nav_view_menu");
|
||||
let mut menu_open = ui.data(|d| d.get_temp::<bool>(menu_id)).unwrap_or(false);
|
||||
let w = items.len() as f32 * 30.0 + 10.0;
|
||||
let bar = app
|
||||
.viewport
|
||||
.layout
|
||||
.as_ref()
|
||||
.map(|l| l.navigation)
|
||||
.unwrap_or_else(|| Rect::from_center_size(pos2(rect.center().x, rect.bottom() - 22.0), vec2(w, 30.0)));
|
||||
let bar = app.viewport.layout.as_ref().map(|l| l.navigation).unwrap_or_else(|| {
|
||||
let available = crate::shell::bottom_overlay_rect(app, rect);
|
||||
Rect::from_center_size(pos2(available.center().x, available.bottom() - 22.0), vec2(w, 30.0))
|
||||
});
|
||||
crate::scenario::publish_rect("nav:outer", bar);
|
||||
let active = ui.rect_contains_pointer(bar)
|
||||
|| ui.rect_contains_pointer(axis_rect(app, rect))
|
||||
|
||||
@@ -356,3 +356,78 @@ fn compass_circle_grabs_on_hover_and_the_home_chip_points() {
|
||||
h.settle();
|
||||
assert_ne!(h.output.cursor_icon, egui::CursorIcon::Grab, "no hand away from the compass");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bottom_readouts_clear_floating_history_on_the_first_frame() {
|
||||
let mut h = Harness::new();
|
||||
h.app.home.open = false;
|
||||
h.app.ui.layout = LayoutMode::Floating;
|
||||
h.app.preferences.timeline_left = false;
|
||||
h.app.preferences.show_frame_rate = true;
|
||||
for command in ["inspect.draft", "inspect.accessibility", "inspect.curvature_map"] {
|
||||
h.app.session.analysis = None;
|
||||
h.app.run(command, json!({})).unwrap();
|
||||
for shown in [false, true, false, true] {
|
||||
h.app.ui.show_timeline = shown;
|
||||
h.frame();
|
||||
let viewport = h.app.viewport.layout.as_ref().unwrap().viewport;
|
||||
let history = crate::scenario::rect_of("history:card");
|
||||
assert_eq!(history.is_some(), shown);
|
||||
for name in ["analysis:legend", "viewport:frame_rate"] {
|
||||
let readout = crate::scenario::rect_of(name).unwrap();
|
||||
assert!(viewport.contains_rect(readout), "{name}: {readout:?}");
|
||||
if let Some(history) = history {
|
||||
assert!(!readout.intersects(history), "{name}: {readout:?} overlaps {history:?}");
|
||||
} else {
|
||||
assert!((readout.bottom() - (viewport.bottom() - 12.0)).abs() < 0.01);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
h.app.session.analysis = None;
|
||||
h.app.run("inspect.draft", json!({})).unwrap();
|
||||
// Start with a measured floating card, then switch without a settling frame.
|
||||
h.app.ui.layout = LayoutMode::Floating;
|
||||
h.app.ui.show_timeline = true;
|
||||
h.frame();
|
||||
h.app.ui.layout = LayoutMode::Docked;
|
||||
h.frame();
|
||||
let viewport = h.app.viewport.layout.as_ref().unwrap().viewport;
|
||||
let history = crate::scenario::rect_of("history:strip").unwrap();
|
||||
for name in ["analysis:legend", "viewport:frame_rate"] {
|
||||
let readout = crate::scenario::rect_of(name).unwrap();
|
||||
assert!(!readout.intersects(history));
|
||||
assert!((readout.bottom() - (viewport.bottom() - 12.0)).abs() < 0.01);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn continuity_legend_clears_floating_history() {
|
||||
let mut h = Harness::new();
|
||||
h.app.ui.layout = LayoutMode::Floating;
|
||||
h.app.preferences.timeline_left = false;
|
||||
h.app.ui.show_timeline = true;
|
||||
h.app.run("solid.box", json!({"length":20,"width":20,"height":20})).unwrap();
|
||||
h.app.start("inspect.continuity");
|
||||
h.frame();
|
||||
let legend = crate::scenario::rect_of("continuity_legend").unwrap();
|
||||
let history = crate::scenario::rect_of("history:card").unwrap();
|
||||
assert!(!legend.intersects(history), "{legend:?} overlaps {history:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn left_history_sidebar_leaves_bottom_readouts_at_the_bottom() {
|
||||
let mut h = Harness::new();
|
||||
h.app.home.open = false;
|
||||
h.app.ui.layout = LayoutMode::Floating;
|
||||
h.app.preferences.timeline_left = true;
|
||||
h.app.preferences.show_frame_rate = true;
|
||||
h.app.ui.show_timeline = true;
|
||||
h.app.run("inspect.draft", json!({})).unwrap();
|
||||
h.frame();
|
||||
let viewport = h.app.viewport.layout.as_ref().unwrap().viewport;
|
||||
for name in ["analysis:legend", "viewport:frame_rate"] {
|
||||
let readout = crate::scenario::rect_of(name).unwrap();
|
||||
assert!((readout.bottom() - (viewport.bottom() - 12.0)).abs() < 0.01, "{name}: {readout:?} in {viewport:?}");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user