* claim: #6755 * Frame rate readout stays beside a right-side pane, not under it (#6755) The readout and its details sat in the viewport's bottom-right corner even under the floating Assistant. They now move just left of any pane over that corner and come back when it closes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6e63f8bd97
commit
56f09f3993
2 files changed
+100
-10
No files matched your search
@@ -138,11 +138,29 @@ fn budget_colour(t: &Tokens, ms: f32) -> Color32 {
|
||||
}
|
||||
}
|
||||
|
||||
/// Records this frame and paints the readout in the view's bottom-right corner, with the details
|
||||
/// above it when they are on. The readout asks for no frames of its own, so it shows how often the
|
||||
/// view is really drawn and leaves an idle window idle (a readout that redrew every frame kept the
|
||||
/// GPU busy on an untouched window); the details show the frames the view drew. Once the frames
|
||||
/// stop, one more frame a little over [`IDLE_AFTER`] later shows the view idle.
|
||||
/// The readout's distance from the view's edges and from the panes beside it.
|
||||
const MARGIN: f32 = 12.0;
|
||||
|
||||
/// `readout` moved left until none of the `panes` covering the view overlaps it, `MARGIN` clear
|
||||
/// of the leftmost of them; it stops at the view's left edge.
|
||||
fn beside_panes(mut readout: Rect, view: Rect, panes: &[Rect]) -> Rect {
|
||||
for _ in 0..panes.len().min(32) {
|
||||
let Some(pane) = panes.iter().find(|p| p.is_finite() && p.is_positive() && p.intersects(readout)) else { break };
|
||||
let left = (pane.left() - MARGIN - readout.width()).max(view.left() + MARGIN);
|
||||
if left >= readout.left() {
|
||||
break;
|
||||
}
|
||||
readout = readout.translate(vec2(left - readout.left(), 0.0));
|
||||
}
|
||||
readout
|
||||
}
|
||||
|
||||
/// Records this frame and paints the readout in the view's bottom-right corner, left of a pane over
|
||||
/// that corner, with the details above it when they are on. The readout asks for no frames of its
|
||||
/// own, so it shows how often the view is really drawn and leaves an idle window idle (a readout
|
||||
/// that redrew every frame kept the GPU busy on an untouched window); the details show the frames
|
||||
/// the view drew. Once the frames stop, one more frame a little over [`IDLE_AFTER`] later shows the
|
||||
/// view idle.
|
||||
pub(crate) fn paint(app: &mut SolveApp, ui: &egui::Ui, painter: &egui::Painter, rect: Rect) {
|
||||
if !app.preferences.show_frame_rate {
|
||||
app.frame_rate = FrameRate::default();
|
||||
@@ -164,7 +182,9 @@ pub(crate) fn paint(app: &mut SolveApp, ui: &egui::Ui, painter: &egui::Painter,
|
||||
let font = FontId::monospace(t.font_body);
|
||||
let galley = painter.layout_no_wrap(text, font.clone(), t.text);
|
||||
let size = galley.size() + vec2(16.0, 8.0);
|
||||
let mut r = Rect::from_min_size(pos2(rect.right() - 12.0 - size.x, rect.bottom() - 12.0 - size.y), size);
|
||||
let r = Rect::from_min_size(pos2(rect.right() - MARGIN - size.x, rect.bottom() - MARGIN - size.y), size);
|
||||
// Just left of a pane over the view's right side (the Assistant, a dialog), not under it (#6755).
|
||||
let mut r = beside_panes(r, rect, &crate::shell::covered_rects(app));
|
||||
// Above the navigation bar where a narrow view brings the two together.
|
||||
if let Some(nav) = app.viewport.layout.as_ref().map(|l| l.navigation)
|
||||
&& r.intersects(nav.expand(4.0))
|
||||
@@ -184,18 +204,18 @@ pub(crate) fn paint(app: &mut SolveApp, ui: &egui::Ui, painter: &egui::Painter,
|
||||
}
|
||||
}
|
||||
|
||||
/// The details above the readout `below`: the frame-time graph with the triangles over it, the
|
||||
/// histogram and what the GPU drew.
|
||||
/// The details above the readout `below`, flush with its right edge: the frame-time graph with the
|
||||
/// triangles over it, the histogram and what the GPU drew.
|
||||
fn details(app: &SolveApp, painter: &egui::Painter, view: Rect, below: Rect, drawn: crate::gpu::DrawStats, font: &FontId) {
|
||||
let t = Tokens::get();
|
||||
let (pad, row, label_h, graph_h, hist_h) = (8.0, 16.0, 12.0, 56.0, 40.0);
|
||||
let lines = 7.0 + 0.8; // seven rows and the adapter's name
|
||||
let w = 300.0_f32.min(view.width() - 24.0);
|
||||
let w = 300.0_f32.min(below.right() - view.left() - MARGIN);
|
||||
let h = pad * 2.0 + row + label_h + graph_h + 6.0 + hist_h + row + lines * row;
|
||||
if w < 160.0 || h > view.height() - below.height() - 30.0 {
|
||||
return;
|
||||
}
|
||||
let panel = Rect::from_min_size(pos2(view.right() - 12.0 - w, below.top() - 6.0 - h), vec2(w, h));
|
||||
let panel = Rect::from_min_size(pos2(below.right() - w, below.top() - 6.0 - h), vec2(w, h));
|
||||
painter.rect(panel, t.radius_sm, t.dialog_bg, t.control_border_stroke(t.border), egui::StrokeKind::Inside);
|
||||
crate::scenario::publish_handle("viewport:frame_details", panel.center());
|
||||
let inner = panel.shrink(pad);
|
||||
@@ -414,6 +434,26 @@ mod tests {
|
||||
assert!(handle_at("viewport:frame_details").is_none());
|
||||
}
|
||||
|
||||
/// Panes over the readout push it left, a pane-free corner keeps it, and hostile or
|
||||
/// view-wide panes never push it out of the view (#6755).
|
||||
#[test]
|
||||
fn the_readout_moves_left_of_the_panes_over_it() {
|
||||
use egui::{Rect, pos2};
|
||||
let view = Rect::from_min_max(pos2(0.0, 0.0), pos2(1000.0, 600.0));
|
||||
let readout = Rect::from_min_max(pos2(850.0, 560.0), pos2(988.0, 588.0));
|
||||
assert_eq!(super::beside_panes(readout, view, &[]), readout);
|
||||
let top = Rect::from_min_max(pos2(700.0, 0.0), pos2(1000.0, 100.0));
|
||||
assert_eq!(super::beside_panes(readout, view, &[top]), readout, "a pane above leaves it in the corner");
|
||||
let chat = Rect::from_min_max(pos2(600.0, 40.0), pos2(992.0, 593.0));
|
||||
let dialog = Rect::from_min_max(pos2(380.0, 500.0), pos2(590.0, 580.0));
|
||||
let moved = super::beside_panes(readout, view, &[chat, dialog]);
|
||||
assert_eq!((moved.right(), moved.size()), (dialog.left() - 12.0, readout.size()), "left of both");
|
||||
let nan = Rect::from_min_max(pos2(f32::NAN, 0.0), pos2(1000.0, 600.0));
|
||||
assert_eq!(super::beside_panes(readout, view, &[nan]), readout);
|
||||
let everything = view.expand(10.0);
|
||||
assert_eq!(super::beside_panes(readout, view, &[everything]).left(), 12.0, "stops at the view's left edge");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn counts_are_grouped_by_thousands() {
|
||||
assert_eq!(grouped(0), "0");
|
||||
|
||||
@@ -557,3 +557,53 @@ fn left_history_sidebar_leaves_bottom_readouts_at_the_bottom() {
|
||||
assert!((readout.bottom() - (viewport.bottom() - 12.0)).abs() < 0.01, "{name}: {readout:?} in {viewport:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// The frame-rate readout and its details sit just left of a pane over the view's bottom-right
|
||||
/// corner (the Assistant), follow it as it opens, changes width and closes, and stay in the
|
||||
/// visible view; with the pane on the left they keep the corner (#6755).
|
||||
#[test]
|
||||
fn frame_rate_readout_stays_beside_a_right_pane() {
|
||||
use crate::scenario::{handle_at, rect_of};
|
||||
for mode in [LayoutMode::Floating, LayoutMode::Docked] {
|
||||
let mut h = Harness::new();
|
||||
h.app.home.open = false;
|
||||
h.call("ui.set", json!({"layout": mode}));
|
||||
h.app.preferences.show_frame_rate = true;
|
||||
h.app.preferences.frame_rate_details = true;
|
||||
h.app.preferences.agent_chat_side = "right".into();
|
||||
h.frames(3);
|
||||
let in_corner = |h: &Harness| {
|
||||
let viewport = h.app.viewport.layout.as_ref().unwrap().viewport;
|
||||
let readout = rect_of("viewport:frame_rate").expect("the readout is drawn");
|
||||
assert!((readout.right() - (viewport.right() - 12.0)).abs() < 0.01, "{mode:?}: {readout:?} in {viewport:?}");
|
||||
};
|
||||
in_corner(&h);
|
||||
// The Assistant's narrowest, a middle and its widest width.
|
||||
for width in [280.0, 480.0, 760.0] {
|
||||
h.call("ui.agent_chat", json!({"open": true, "picker": false, "side": "right", "width": width}));
|
||||
h.frames(3);
|
||||
let viewport = h.app.viewport.layout.as_ref().unwrap().viewport;
|
||||
let pane = rect_of("agent_chat:panel").expect("the Assistant is drawn");
|
||||
let readout = rect_of("viewport:frame_rate").expect("the readout is drawn");
|
||||
assert!(viewport.contains_rect(readout), "{mode:?}, {width}: {readout:?} outside {viewport:?}");
|
||||
assert!(readout.right() <= pane.left() - 12.0 + 0.01, "{mode:?}, {width}: {readout:?} under {pane:?}");
|
||||
if mode == LayoutMode::Floating {
|
||||
assert!((readout.right() - (pane.left() - 12.0)).abs() < 0.01, "{width}: {readout:?} not just left of {pane:?}");
|
||||
}
|
||||
for covered in crate::shell::covered_rects(&h.app) {
|
||||
assert!(!readout.intersects(covered), "{mode:?}, {width}: {readout:?} under {covered:?}");
|
||||
}
|
||||
let details = handle_at("viewport:frame_details").expect("the details are drawn");
|
||||
assert!(viewport.contains(details) && details.x < pane.left(), "{mode:?}, {width}: details at {details:?}, pane {pane:?}");
|
||||
}
|
||||
h.call("ui.agent_chat", json!({"open": false}));
|
||||
h.frames(3);
|
||||
assert!(rect_of("agent_chat:panel").is_none());
|
||||
in_corner(&h);
|
||||
// On the left the pane leaves the corner free.
|
||||
h.call("ui.agent_chat", json!({"open": true, "side": "left"}));
|
||||
h.frames(3);
|
||||
assert!(rect_of("agent_chat:panel").is_some());
|
||||
in_corner(&h);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user