cleanup elements #13
This commit is contained in:
+9
-9
@@ -10,6 +10,15 @@ pub struct Div {
|
||||
size: (u16, u16),
|
||||
}
|
||||
|
||||
impl Div {
|
||||
pub fn new() -> Self {
|
||||
Div {
|
||||
children: Mutex::new(Vec::new()),
|
||||
size: (0, 0),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Element for Div {
|
||||
fn render(&mut self, scope: &mut crate::render_scope::RenderScope) {
|
||||
let (width, height) = scope.get_size_or(self.size.0, self.size.1);
|
||||
@@ -59,12 +68,3 @@ impl Element for Div {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl Div {
|
||||
pub fn new() -> Self {
|
||||
Div {
|
||||
children: Mutex::new(Vec::new()),
|
||||
size: (0, 0),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+20
-20
@@ -17,6 +17,26 @@ pub struct FlexCol {
|
||||
size: (u16, u16),
|
||||
}
|
||||
|
||||
impl FlexRow {
|
||||
pub fn new(gap: u16) -> Self {
|
||||
Self {
|
||||
children: Mutex::new(Vec::new()),
|
||||
size: (0, 0),
|
||||
gap,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl FlexCol {
|
||||
pub fn new(gap: u16) -> Self {
|
||||
Self {
|
||||
children: Mutex::new(Vec::new()),
|
||||
size: (0, 0),
|
||||
gap,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Element for FlexRow {
|
||||
fn render(&mut self, scope: &mut crate::render_scope::RenderScope) {
|
||||
let (width, height) = scope.get_size_or(self.size.0, self.size.1);
|
||||
@@ -73,16 +93,6 @@ impl Element for FlexRow {
|
||||
}
|
||||
}
|
||||
|
||||
impl FlexRow {
|
||||
pub fn new(gap: u16) -> Self {
|
||||
Self {
|
||||
children: Mutex::new(Vec::new()),
|
||||
size: (0, 0),
|
||||
gap,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Element for FlexCol {
|
||||
fn render(&mut self, scope: &mut crate::render_scope::RenderScope) {
|
||||
let (width, height) = scope.get_size_or(self.size.0, self.size.1);
|
||||
@@ -138,13 +148,3 @@ impl Element for FlexCol {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl FlexCol {
|
||||
pub fn new(gap: u16) -> Self {
|
||||
Self {
|
||||
children: Mutex::new(Vec::new()),
|
||||
size: (0, 0),
|
||||
gap,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
pub mod div;
|
||||
pub mod flex;
|
||||
pub mod shape;
|
||||
|
||||
pub use div::*;
|
||||
pub use flex::*;
|
||||
pub use shape::*;
|
||||
|
||||
use crate::Element;
|
||||
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user