small change

This commit is contained in:
2024-11-22 05:29:56 +01:00
parent ec4b42e978
commit 533ec30597
2 changed files with 10 additions and 5 deletions
+2 -1
View File
@@ -22,5 +22,6 @@ crossterm = "0.28.1"
regex = "1.11.1"
lazy_static = "1.4"
paste = "1.0.15"
osui-element = "0.1.1"
osui-element = "0.1.5"
dyn-clone = "1.0.17"
flume = "=0.10.12"
+8 -4
View File
@@ -43,7 +43,7 @@ pub use app::run;
pub mod prelude {
pub use crate::ui::Color::*;
pub use crate::{self as osui, css, rsx, rsx_elem, ui::*, Handler};
pub use crate::{Element, Value, style};
pub use crate::{style, Element, Value};
// useful for Element making
pub use crate::{run_handler, Children, ElementCore, ElementWidget};
pub use crossterm::event::{Event, KeyCode, KeyEvent, KeyEventKind};
@@ -93,7 +93,6 @@ pub trait ElementCore: Send + Sync {
fn get_element_by_id(&mut self, id: &str) -> Option<&mut Element>;
fn get_child(&mut self) -> Option<&mut Element>;
fn set_styling(&mut self, styling: &HashMap<crate::ui::StyleName, crate::ui::Style>);
fn type_id(&self) -> std::any::TypeId;
}
pub trait ElementWidget: ElementCore + std::fmt::Debug {
@@ -141,7 +140,7 @@ impl<T> std::fmt::Debug for Handler<T> {
//////////////////////////////////////////////////////////////////////////////////////////////////
/// Child enum of an `Element`
///
///
/// # Example
/// ```
/// // Check if it's text
@@ -153,7 +152,7 @@ impl<T> std::fmt::Debug for Handler<T> {
/// // do something
/// }
/// ```
///
///
/// # Useful for
/// - `Element::event`
/// - `Element::render`
@@ -191,3 +190,8 @@ impl Children {
}
}
}
/// Converts a `Element` into the struct
pub fn convert<T>(widget: &mut Box<dyn ElementWidget>) -> &mut Box<T> {
unsafe { &mut *(widget as *mut _ as *mut Box<T>) }
}