Skip to content

Commit

Permalink
Remove use of absolute paths
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoburns committed Nov 22, 2023
1 parent 63fe0dd commit 875bfaf
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/widget/taffy_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

use crate::geometry::Axis;
use crate::widget::{AccessCx, BoxConstraints, Event};
use ::taffy::style::AvailableSpace;
use accesskit::NodeId;
use glazier::kurbo::Affine;
use vello::kurbo::{Point, Size};
Expand All @@ -26,7 +25,7 @@ use super::{contexts::LifeCycleCx, EventCx, LayoutCx, LifeCycle, PaintCx, Pod, U
/// Type inference gets confused because we're just passing None here. So we give
/// it a concrete type to work with (even though we never construct the inner type)
type DummyMeasureFunction =
fn(taffy::Size<Option<f32>>, taffy::Size<AvailableSpace>) -> taffy::Size<f32>;
fn(taffy::Size<Option<f32>>, taffy::Size<taffy::AvailableSpace>) -> taffy::Size<f32>;

/// TaffyLayout is a simple widget which does layout for a ViewSequence.
///
Expand Down Expand Up @@ -114,18 +113,18 @@ fn to_taffy_constraints(
},
available_space: taffy::Size {
width: if max.width.is_finite() {
AvailableSpace::Definite(max.width as f32)
taffy::AvailableSpace::Definite(max.width as f32)
} else if min.width.is_sign_negative() {
AvailableSpace::MinContent
taffy::AvailableSpace::MinContent
} else {
AvailableSpace::MaxContent
taffy::AvailableSpace::MaxContent
},
height: if max.height.is_finite() {
AvailableSpace::Definite(max.height as f32)
taffy::AvailableSpace::Definite(max.height as f32)
} else if min.height.is_sign_negative() {
AvailableSpace::MinContent
taffy::AvailableSpace::MinContent
} else {
AvailableSpace::MaxContent
taffy::AvailableSpace::MaxContent
},
},
axis,
Expand Down Expand Up @@ -207,7 +206,7 @@ impl<'w, 'a, 'b> taffy::PartialLayoutTree for TaffyLayoutCtx<'w, 'a, 'b> {
taffy::NodeId::from(child_index)
}

fn get_style(&self, node_id: taffy::NodeId) -> &::taffy::style::Style {
fn get_style(&self, node_id: taffy::NodeId) -> &taffy::Style {
let node_id = usize::from(node_id);
if node_id == usize::MAX {
&self.widget.style
Expand All @@ -223,7 +222,7 @@ impl<'w, 'a, 'b> taffy::PartialLayoutTree for TaffyLayoutCtx<'w, 'a, 'b> {
}
}

fn set_unrounded_layout(&mut self, node_id: taffy::NodeId, layout: &::taffy::tree::Layout) {
fn set_unrounded_layout(&mut self, node_id: taffy::NodeId, layout: &taffy::Layout) {
self.widget.children[usize::from(node_id)].set_origin(
self.cx,
Point {
Expand All @@ -248,8 +247,8 @@ impl<'w, 'a, 'b> taffy::PartialLayoutTree for TaffyLayoutCtx<'w, 'a, 'b> {
fn compute_child_layout(
&mut self,
node_id: taffy::NodeId,
input: ::taffy::tree::LayoutInput,
) -> ::taffy::tree::LayoutOutput {
input: taffy::LayoutInput,
) -> taffy::LayoutOutput {
let box_constraints: BoxConstraints = to_box_constraints(&input);
match input.run_mode {
taffy::RunMode::PerformLayout => {
Expand Down

0 comments on commit 875bfaf

Please sign in to comment.