This commit is contained in:
Nathan Sobo
2023-11-02 22:56:04 -06:00
parent a731f8fb1e
commit f3b8a9d8c2
26 changed files with 1782 additions and 1665 deletions
+1
View File
@@ -29,6 +29,7 @@ pub struct ForegroundExecutor {
}
#[must_use]
#[derive(Debug)]
pub enum Task<T> {
Ready(Option<T>),
Spawned(async_task::Task<T>),
+12
View File
@@ -819,6 +819,18 @@ impl From<Pixels> for f64 {
}
}
impl From<Pixels> for u32 {
fn from(pixels: Pixels) -> Self {
pixels.0 as u32
}
}
impl From<Pixels> for usize {
fn from(pixels: Pixels) -> Self {
pixels.0 as usize
}
}
#[derive(
Add, AddAssign, Clone, Copy, Default, Div, Eq, Hash, Ord, PartialEq, PartialOrd, Sub, SubAssign,
)]
@@ -411,6 +411,7 @@ impl MacTextSystemState {
descent: typographic_bounds.descent.into(),
runs,
font_size,
len: text.len(),
}
}
+9
View File
@@ -167,6 +167,15 @@ impl TextStyle {
Ok(self)
}
pub fn font(&self) -> Font {
Font {
family: self.font_family.clone(),
features: self.font_features.clone(),
weight: self.font_weight,
style: self.font_style,
}
}
pub fn to_run(&self, len: usize) -> TextRun {
TextRun {
len,
+1 -1
View File
@@ -151,7 +151,7 @@ impl TextSystem {
pub fn layout_text(
&self,
text: &SharedString,
text: &str,
font_size: Pixels,
runs: &[TextRun],
wrap_width: Option<Pixels>,
+4
View File
@@ -29,6 +29,10 @@ impl Line {
)
}
pub fn width(&self) -> Pixels {
self.layout.width
}
pub fn wrap_count(&self) -> usize {
self.layout.wrap_boundaries.len()
}
@@ -16,6 +16,7 @@ pub struct LineLayout {
pub ascent: Pixels,
pub descent: Pixels,
pub runs: Vec<ShapedRun>,
pub len: usize,
}
#[derive(Debug)]
+1
View File
@@ -1655,6 +1655,7 @@ impl<'a, V: 'static> ViewContext<'a, V> {
}
}
// todo!("change this to return a reference");
pub fn view(&self) -> View<V> {
self.view.clone()
}