This also adds some "responsiveness" so that UI elements are hidden before everything has to be occluded Release Notes: - Improved search UI. It now works in narrower panes, and avoids scrolling the editor on open. <img width="899" alt="Screenshot 2024-04-11 at 21 33 17" src="https://github.com/zed-industries/zed/assets/94272/44b95d4f-08d6-4c40-a175-0e594402ca01"> <img width="508" alt="Screenshot 2024-04-11 at 21 33 45" src="https://github.com/zed-industries/zed/assets/94272/baf4638d-427b-43e6-ad67-13d43f0f18a2"> <img width="361" alt="Screenshot 2024-04-11 at 21 34 00" src="https://github.com/zed-industries/zed/assets/94272/ff60b561-2f77-49c0-9df7-e26227fe9225"> <img width="348" alt="Screenshot 2024-04-11 at 21 37 03" src="https://github.com/zed-industries/zed/assets/94272/a2a700a2-ce99-41bd-bf47-9b14d7082b0e">
30 lines
1.0 KiB
Rust
30 lines
1.0 KiB
Rust
use gpui::{rems, Length, Rems, WindowContext};
|
|
|
|
/// The base size of a rem, in pixels.
|
|
pub const BASE_REM_SIZE_IN_PX: f32 = 16.;
|
|
|
|
/// Returns a rem value derived from the provided pixel value and the base rem size (16px).
|
|
///
|
|
/// This can be used to compute rem values relative to pixel sizes, without
|
|
/// needing to hard-code the rem value.
|
|
///
|
|
/// For instance, instead of writing `rems(0.875)` you can write `rems_from_px(14.)`
|
|
#[inline(always)]
|
|
pub fn rems_from_px(px: f32) -> Rems {
|
|
rems(px / BASE_REM_SIZE_IN_PX)
|
|
}
|
|
|
|
/// Returns a [`Length`] corresponding to the specified percentage of the viewport's width.
|
|
///
|
|
/// `percent` should be a value between `0.0` and `1.0`.
|
|
pub fn vw(percent: f32, cx: &mut WindowContext) -> Length {
|
|
Length::from(cx.viewport_size().width * percent)
|
|
}
|
|
|
|
/// Returns a [`Length`] corresponding to the specified percentage of the viewport's height.
|
|
///
|
|
/// `percent` should be a value between `0.0` and `1.0`.
|
|
pub fn vh(percent: f32, cx: &mut WindowContext) -> Length {
|
|
Length::from(cx.viewport_size().height * percent)
|
|
}
|