buggy af
This commit is contained in:
+14
-11
@@ -83,7 +83,6 @@ pub struct StyleElement {
|
||||
pub height: Number,
|
||||
pub visible: bool,
|
||||
pub outline: bool,
|
||||
pub other: HashMap<String, Box<dyn StyleCore>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -129,7 +128,7 @@ impl StyleElement {
|
||||
.into_iter()
|
||||
.map(|p| {
|
||||
format!(
|
||||
"{}{}{}{p}\x1b[0m",
|
||||
"\0{}{}{}\0{p}\0\x1b[0m\0",
|
||||
self.color.ansi(),
|
||||
self.background.ansi_bg(),
|
||||
self.font.ansi()
|
||||
@@ -148,12 +147,11 @@ impl Default for StyleElement {
|
||||
font: Vec::new(),
|
||||
outline_color: Color::NoColor,
|
||||
x: Number::Default,
|
||||
y: Number::Default,
|
||||
y: Number::Px(0),
|
||||
width: Number::Default,
|
||||
height: Number::Default,
|
||||
visible: true,
|
||||
outline: false,
|
||||
other: HashMap::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -305,13 +303,18 @@ impl StyleCore for Vec<Font> {
|
||||
}
|
||||
|
||||
impl Number {
|
||||
pub fn as_size(&self, text_size: u16, frame_size: u16) -> u16 {
|
||||
pub fn as_size_raw(&self, frame_size: u16) -> u16 {
|
||||
match self {
|
||||
Number::Px(s) => *s,
|
||||
Number::Pe(pe) => (frame_size * pe) / 100,
|
||||
Number::Default => frame_size,
|
||||
crate::ui::Number::Auto => text_size,
|
||||
_ => 0,
|
||||
_ => frame_size,
|
||||
}
|
||||
}
|
||||
pub fn as_size(&self, frame_size: u16, outline: bool) -> u16 {
|
||||
if outline {
|
||||
self.as_size_raw(frame_size) - 2
|
||||
} else {
|
||||
self.as_size_raw(frame_size)
|
||||
}
|
||||
}
|
||||
pub fn as_position_y(&self, used: &Vec<u16>, content_size: u16, frame_size: u16) -> u16 {
|
||||
@@ -320,14 +323,14 @@ impl Number {
|
||||
crate::ui::Number::Pe(pe) => (frame_size * pe) / 100,
|
||||
crate::ui::Number::Center => (frame_size - content_size) / 2,
|
||||
crate::ui::Number::Auto | crate::ui::Number::Default => {
|
||||
let mut x = 0;
|
||||
let mut y = 0;
|
||||
for (i, n) in used.iter().enumerate() {
|
||||
if *n == 0 {
|
||||
x = i as u16;
|
||||
y = i as u16;
|
||||
break;
|
||||
}
|
||||
}
|
||||
x
|
||||
y
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user