Skip to content

Commit

Permalink
Fix scene view bounds on high dpi displays
Browse files Browse the repository at this point in the history
  • Loading branch information
benfrankel committed Dec 12, 2023
1 parent 2d6e42f commit 03a0511
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
7 changes: 1 addition & 6 deletions src/state/editor_screen/scene_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,23 +93,18 @@ pub struct SceneViewBounds {

fn update_scene_view_bounds(
root: Res<AppRoot>,
ui_scale: Res<UiScale>,
mut bounds: ResMut<SceneViewBounds>,
window_query: Query<&Window>,
camera_query: Query<(&Camera, &OrthographicProjection, &GlobalTransform), Without<SceneView>>,
scene_view_query: Query<(&Node, &GlobalTransform), With<SceneView>>,
) {
let Ok(window) = window_query.get(root.window) else {
return;
};
let Ok((camera, proj, camera_gt)) = camera_query.get(root.camera) else {
return;
};
let Ok((scene_view, scene_view_gt)) = scene_view_query.get_single() else {
return;
};

let rect = scene_view.physical_rect(scene_view_gt, window.scale_factor(), ui_scale.0);
let rect = scene_view.logical_rect(scene_view_gt);
let rect = Rect::from_corners(
camera.viewport_to_world_2d(camera_gt, rect.min).unwrap(),
camera.viewport_to_world_2d(camera_gt, rect.max).unwrap(),
Expand Down
4 changes: 2 additions & 2 deletions src/ui/tooltip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ fn show_tooltip_on_hover(

let rect = node.logical_rect(gt);

let width = window.width() as f32;
let height = window.height() as f32;
let width = window.width();
let height = window.height();
let (left, right, top, bottom) = (
rect.min.x + tooltip.offset.x,
rect.max.x + tooltip.offset.x,
Expand Down

0 comments on commit 03a0511

Please sign in to comment.