Encode rem values derived from pixels using rems_from_px
(#9367)
This PR adds a new `rems_from_px` helper function that can be used to compute rem values based on a pixel value. This is something we do fairly commonly, where we want to express a size that is a given pixel size at the base rem size (e.g., "14px when the rem size is 16px"). `rems_from_px` helps make the intent more explicit, as well as prevent the base rem size from being duplicated everywhere. Note: Ideally we would want `rems_from_px` to be `const`, but that depends on https://github.com/rust-lang/rust/issues/57241. Release Notes: - N/A
This commit is contained in:
parent
a78576a6db
commit
404adbce5b
13 changed files with 54 additions and 35 deletions
|
@ -1,7 +1,9 @@
|
|||
use crate::prelude::*;
|
||||
use std::cmp::Ordering;
|
||||
|
||||
use gpui::{AnyElement, IntoElement, Stateful};
|
||||
use smallvec::SmallVec;
|
||||
use std::cmp::Ordering;
|
||||
|
||||
use crate::{prelude::*, BASE_REM_SIZE_IN_PX};
|
||||
|
||||
/// The position of a [`Tab`] within a list of tabs.
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
|
@ -51,9 +53,9 @@ impl Tab {
|
|||
}
|
||||
}
|
||||
|
||||
pub const CONTAINER_HEIGHT_IN_REMS: f32 = 29. / 16.;
|
||||
pub const CONTAINER_HEIGHT_IN_REMS: f32 = 29. / BASE_REM_SIZE_IN_PX;
|
||||
|
||||
const CONTENT_HEIGHT_IN_REMS: f32 = 28. / 16.;
|
||||
const CONTENT_HEIGHT_IN_REMS: f32 = 28. / BASE_REM_SIZE_IN_PX;
|
||||
|
||||
pub fn position(mut self, position: TabPosition) -> Self {
|
||||
self.position = position;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue