Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clamp time panel height to avoid visual glitches #3169

Merged
merged 2 commits into from
Sep 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions crates/re_time_panel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ impl TimePanel {
ui: &mut egui::Ui,
time_panel_expanded: bool,
) {
// this is the size of everything above the central panel (window title bar, top bar on web,
// etc.)
let screen_header_height = ui.cursor().top();

let top_bar_height = 28.0;
let margin = ctx.re_ui.bottom_panel_margin();
let mut panel_frame = ctx.re_ui.bottom_panel_frame();
Expand All @@ -76,7 +80,7 @@ impl TimePanel {
panel_frame.inner_margin.right = 0.0;
}

let screen_height = ui.ctx().screen_rect().width();
let window_height = ui.ctx().screen_rect().height();

let collapsed = egui::TopBottomPanel::bottom("time_panel_collapsed")
.resizable(false)
Expand All @@ -85,12 +89,14 @@ impl TimePanel {
.default_height(44.0);

let min_height = 150.0;
let min_top_space = 150.0 + screen_header_height;
let expanded = egui::TopBottomPanel::bottom("time_panel_expanded")
.resizable(true)
.show_separator_line(false)
.frame(panel_frame)
.min_height(min_height)
.default_height((0.25 * screen_height).clamp(min_height, 250.0).round());
.max_height((window_height - min_top_space).at_least(min_height).round())
.default_height((0.25 * window_height).clamp(min_height, 250.0).round());

egui::TopBottomPanel::show_animated_between_inside(
ui,
Expand Down