update tui to use taffy dimention directly (#501)

This commit is contained in:
Demonthos 2022-07-19 11:27:19 -05:00 committed by GitHub
parent d090b24f8d
commit 39cbc82107
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 9 deletions

View file

@ -1,8 +1,7 @@
use dioxus_native_core::layout_attributes::UnitSystem;
use std::io::Stdout;
use taffy::{
geometry::Point,
prelude::{Layout, Size},
prelude::{Dimension, Layout, Size},
Taffy,
};
use tui::{backend::CrosstermBackend, layout::Rect, style::Color};
@ -252,8 +251,9 @@ impl RinkWidget for &Node {
BorderStyle::Hidden => 0.0,
BorderStyle::None => 0.0,
_ => match border.radius {
UnitSystem::Percent(p) => p * area.width as f32 / 100.0,
UnitSystem::Point(p) => p,
Dimension::Percent(p) => p * area.width as f32 / 100.0,
Dimension::Points(p) => p,
_ => todo!(),
}
.abs()
.min((area.width as f32 / RADIUS_MULTIPLIER[0]) / 2.0)

View file

@ -31,11 +31,12 @@
use dioxus_core::Attribute;
use dioxus_native_core::{
layout_attributes::{parse_value, UnitSystem},
layout_attributes::parse_value,
node_ref::{AttributeMask, NodeMask, NodeView},
state::ParentDepState,
};
use dioxus_native_core_macro::sorted_str_slice;
use taffy::prelude::*;
use crate::style::{RinkColor, RinkStyle};
@ -127,8 +128,8 @@ impl Borders {
pub struct BorderEdge {
pub color: Option<RinkColor>,
pub style: BorderStyle,
pub width: UnitSystem,
pub radius: UnitSystem,
pub width: Dimension,
pub radius: Dimension,
}
impl Default for BorderEdge {
@ -136,8 +137,8 @@ impl Default for BorderEdge {
Self {
color: None,
style: BorderStyle::None,
width: UnitSystem::Point(0.0),
radius: UnitSystem::Point(0.0),
width: Dimension::Points(0.0),
radius: Dimension::Points(0.0),
}
}
}