WIP
This commit is contained in:
@@ -29,6 +29,7 @@ pub struct ForegroundExecutor {
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
#[derive(Debug)]
|
||||
pub enum Task<T> {
|
||||
Ready(Option<T>),
|
||||
Spawned(async_task::Task<T>),
|
||||
|
||||
@@ -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(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -151,7 +151,7 @@ impl TextSystem {
|
||||
|
||||
pub fn layout_text(
|
||||
&self,
|
||||
text: &SharedString,
|
||||
text: &str,
|
||||
font_size: Pixels,
|
||||
runs: &[TextRun],
|
||||
wrap_width: Option<Pixels>,
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user