prelude and transform macro
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
pub mod div;
|
||||
pub mod flex;
|
||||
|
||||
pub use div::*;
|
||||
pub use flex::*;
|
||||
|
||||
use crate::Element;
|
||||
|
||||
impl Element for String {
|
||||
|
||||
@@ -3,6 +3,11 @@ pub mod resources;
|
||||
pub mod tick;
|
||||
pub mod velocity;
|
||||
|
||||
pub use id::*;
|
||||
pub use resources::*;
|
||||
pub use tick::*;
|
||||
pub use velocity::*;
|
||||
|
||||
use std::{
|
||||
any::{type_name, Any},
|
||||
fmt::Debug,
|
||||
|
||||
@@ -16,6 +16,15 @@ pub mod style;
|
||||
pub mod utils;
|
||||
pub mod widget;
|
||||
|
||||
pub mod prelude {
|
||||
pub use crate::{
|
||||
elements::*, extensions::*, frontend::*, render_scope::*, state::*, style::*, utils::*,
|
||||
widget::*, *,
|
||||
};
|
||||
|
||||
pub use crate::style::{Dimension::{Full, Content}, Position::{Center, End}};
|
||||
}
|
||||
|
||||
pub struct Screen {
|
||||
pub widgets: Mutex<Vec<Arc<Widget>>>,
|
||||
extensions: Mutex<Vec<Arc<Mutex<Box<dyn Extension + Send + Sync>>>>>,
|
||||
|
||||
@@ -123,6 +123,15 @@ macro_rules! event_handler {
|
||||
}};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! transform {
|
||||
($($f:ident: $v:expr),* $(,)?) => {{
|
||||
let mut t = Transform::new();
|
||||
$(t.$f = $v.into();)*
|
||||
t
|
||||
}};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! rsx {
|
||||
($($inner:tt)*) => {{
|
||||
|
||||
+2
-9
@@ -1,11 +1,4 @@
|
||||
use osui::{
|
||||
elements::{div::Div, flex::FlexCol},
|
||||
frontend::Rsx,
|
||||
rsx,
|
||||
state::use_state,
|
||||
style::Transform,
|
||||
Screen,
|
||||
};
|
||||
use osui::prelude::*;
|
||||
|
||||
fn main() -> std::io::Result<()> {
|
||||
let screen = Screen::new();
|
||||
@@ -39,7 +32,7 @@ fn test(inc: i32) -> Rsx {
|
||||
rsx! {
|
||||
@Transform::new().dimensions(40, 3);
|
||||
Div {
|
||||
@Transform::center().dimensions(8, 1);
|
||||
@transform! { x: Center, y: Center, width: 5 };
|
||||
Div {
|
||||
%count
|
||||
"{count}"
|
||||
|
||||
@@ -139,3 +139,15 @@ impl Position {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u16> for Position {
|
||||
fn from(value: u16) -> Self {
|
||||
Self::Const(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u16> for Dimension {
|
||||
fn from(value: u16) -> Self {
|
||||
Self::Const(value)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user