This commit is contained in:
2025-07-29 20:54:12 +02:00
parent 71660418a1
commit 5ca7221afa
3 changed files with 74 additions and 27 deletions
+2
View File
@@ -1,8 +1,10 @@
pub mod div;
pub mod flex;
pub mod shape;
pub use div::*;
pub use flex::*;
pub use shape::*;
use crate::Element;
+59
View File
@@ -0,0 +1,59 @@
use crate::widget::Element;
pub struct RoundedOutline;
impl Element for RoundedOutline {
fn render(&mut self, scope: &mut crate::prelude::RenderScope) {
let (w, h) = scope.get_size_or_parent();
if w > 2 && h > 2 {
let d = "─".repeat(w as usize - 2);
scope.draw_text(&format!(
"╭{d}╮{}\n╰{d}╯",
format!("\n│{}│", " ".repeat(w as usize - 2)).repeat(h as usize - 2),
));
}
}
fn as_any(&self) -> &dyn std::any::Any {
self
}
fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
self
}
}
impl RoundedOutline {
pub fn new() -> Self {
Self
}
}
pub struct Outline;
impl Element for Outline {
fn render(&mut self, scope: &mut crate::prelude::RenderScope) {
let (w, h) = scope.get_size_or_parent();
if w > 2 && h > 2 {
let d = "─".repeat(w as usize - 2);
scope.draw_text(&format!(
"┌{d}┐{}\n└{d}┘",
format!("\n│{}│", " ".repeat(w as usize - 2)).repeat(h as usize - 2),
));
}
}
fn as_any(&self) -> &dyn std::any::Any {
self
}
fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
self
}
}
impl Outline {
pub fn new() -> Self {
Self
}
}