diff --git a/README.md b/README.md index eb3e6bcaa2aa5f348ba8d239f79b7288137c7eed..7ac4177fc88727e96762bf749b86fd89b61c7090 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Kayak UI is in the very early stages of development. Important features are miss - Basic widget and global state management - Input events - Fast and accurate layouts using morphorm: https://github.com/geom3trik/morphorm -- A bunch of default components check out `kayak_components`! +- A bunch of default widgets check out `kayak_widgets`! - Style system built to kind of mimic CSS styles. - Image and Nine patch rendering. @@ -31,6 +31,10 @@ Kayak UI is in the very early stages of development. Important features are miss - Custom UI node to ensure UI renders on top of 3D and 2D entities. - Fully integrated into bevy to capture input events, use bevy assets(images, etc). +## Missing features +- Tree diffing +- Removing of widgets. + ## Example Screenshot <img src="images/screen1.png" alt="Kayak UI" width="600" /> diff --git a/examples/bevy.rs b/examples/bevy.rs index ebc2f496053a1ff825ddf04856695aa0d117abb1..53b911830107188738db4f8ce2fed7ed4f67e813 100644 --- a/examples/bevy.rs +++ b/examples/bevy.rs @@ -6,7 +6,7 @@ use bevy::{ }; use bevy_kayak_ui::{BevyContext, BevyKayakUIPlugin, FontMapping, UICameraBundle}; use kayak_core::Index; -use kayak_ui::components::App; +use kayak_ui::widgets::App; use kayak_ui::core::{rsx, widget}; use kayak_widgets::Window; diff --git a/examples/counter.rs b/examples/counter.rs index 3bfe4dfc6c2f2b82bba241e37066464fe9ab15a6..1a8285431e329c723555116e9b84b4da7a728541 100644 --- a/examples/counter.rs +++ b/examples/counter.rs @@ -9,7 +9,7 @@ use kayak_core::{ styles::{Style, StyleProp, Units}, Bound, EventType, Index, MutableBound, OnEvent, }; -use kayak_ui::components::App; +use kayak_ui::widgets::App; use kayak_ui::core::{rsx, widget}; use kayak_widgets::{Button, Text, Window}; diff --git a/examples/full_ui.rs b/examples/full_ui.rs index 2ac8416776332479f813784a4d2b3143fe5ae73d..0771ca47bb726b9c99f34d887785b660606a9eed 100644 --- a/examples/full_ui.rs +++ b/examples/full_ui.rs @@ -11,7 +11,7 @@ use kayak_core::{ styles::{LayoutType, Style, StyleProp, Units}, widget, Bound, Children, EventType, Index, MutableBound, OnEvent, }; -use kayak_ui::components::App; +use kayak_ui::widgets::App; use kayak_ui::core::rsx; #[widget] diff --git a/examples/global_counter.rs b/examples/global_counter.rs index 6c46afda86b2e418be84fe47c8b70dbbc2d5101c..feaf84d14b76790084193066cbc590e1aca43d4a 100644 --- a/examples/global_counter.rs +++ b/examples/global_counter.rs @@ -7,7 +7,7 @@ use bevy::{ use bevy_kayak_ui::{BevyContext, BevyKayakUIPlugin, FontMapping, UICameraBundle}; use kayak_widgets::{Text, Window}; use kayak_core::{bind, Binding, Bound, Index, MutableBound}; -use kayak_ui::components::App; +use kayak_ui::widgets::App; use kayak_ui::core::{rsx, widget}; #[derive(Clone, PartialEq)] diff --git a/examples/image.rs b/examples/image.rs index 25aade54a03c759ebcaf94af99cd74abd2dfe945..436500f052c6dd67640f3ea2a6eb56bf56ae8963 100644 --- a/examples/image.rs +++ b/examples/image.rs @@ -7,7 +7,7 @@ use bevy::{ use bevy_kayak_ui::{BevyContext, BevyKayakUIPlugin, ImageManager, UICameraBundle}; use kayak_widgets::Image; use kayak_core::Index; -use kayak_ui::components::App; +use kayak_ui::widgets::App; use kayak_ui::core::rsx; fn startup( diff --git a/examples/nine_patch.rs b/examples/nine_patch.rs index 340b2bb9f436b564fbc8f836396635581615ee87..2e99a11ea4c83fa4c1d665a9867cb6c01be2e17b 100644 --- a/examples/nine_patch.rs +++ b/examples/nine_patch.rs @@ -10,7 +10,7 @@ use kayak_core::{ styles::{Style, StyleProp, Units}, Index, }; -use kayak_ui::components::App; +use kayak_ui::widgets::App; use kayak_ui::core::rsx; use kayak_widgets::NinePatch; diff --git a/kayak_core/src/context.rs b/kayak_core/src/context.rs index a5cd1c4c6f6c3b0af68a75e579e4340450c82136..9027cd8c69222377ef133ae955cf9cc5c0a988e4 100644 --- a/kayak_core/src/context.rs +++ b/kayak_core/src/context.rs @@ -186,26 +186,6 @@ impl KayakContext { return None; } - // pub fn set_state<T: resources::Resource + Clone>(&mut self, state: T) { - // if self.component_states.contains_key(&self.current_id) { - // let states = self.component_states.get(&self.current_id).unwrap(); - // if states.contains::<T>() { - // let mut mutate_t = states.get_mut::<T>().unwrap(); - // if let Ok(mut dirty_nodes) = self.widget_manager.dirty_nodes.lock() { - // dirty_nodes.insert(self.current_id); - // } - // *mutate_t = state; - // } else { - // panic!( - // "No specific state created for component with id: {:?}!", - // self.current_id - // ); - // } - // } else { - // // Do nothing.. - // } - // } - pub fn set_global_state<T: resources::Resource>(&mut self, state: T) { self.global_state.insert(state); } diff --git a/kayak_render_macros/src/attribute.rs b/kayak_render_macros/src/attribute.rs index 5cedf71fc2f739d7c361a75ad9b8a674b8108558..6b99fc067fdd7f13da368ea22c1246d9b6960632 100644 --- a/kayak_render_macros/src/attribute.rs +++ b/kayak_render_macros/src/attribute.rs @@ -52,7 +52,7 @@ impl Attribute { .join("_"); let error_message = format!( - "Can't use dash-delimited values on custom components. Did you mean `{}`?", + "Can't use dash-delimited values on custom widgets. Did you mean `{}`?", alternative_name ); diff --git a/kayak_render_macros/src/function_component.rs b/kayak_render_macros/src/function_component.rs index c75438a99b2fbc4df706aa1fa02c7b3e17e12e15..84af3472495189cce45a1beaa05ee3ef1e53f1d2 100644 --- a/kayak_render_macros/src/function_component.rs +++ b/kayak_render_macros/src/function_component.rs @@ -3,7 +3,7 @@ use proc_macro_error::emit_error; use quote::{quote, ToTokens}; use syn::spanned::Spanned; -pub fn create_function_component(f: syn::ItemFn) -> TokenStream { +pub fn create_function_widget(f: syn::ItemFn) -> TokenStream { let struct_name = f.sig.ident; let (impl_generics, ty_generics, where_clause) = f.sig.generics.split_for_impl(); let inputs = f.sig.inputs; @@ -25,7 +25,7 @@ pub fn create_function_component(f: syn::ItemFn) -> TokenStream { } } syn::FnArg::Receiver(rec) => { - emit_error!(rec.span(), "Don't use `self` on components"); + emit_error!(rec.span(), "Don't use `self` on widgets"); None } }) diff --git a/kayak_render_macros/src/lib.rs b/kayak_render_macros/src/lib.rs index dcedd3dffbd299ec280bf2cac86171f869e12d9e..468b4ab2f91f57326609df1bd7e6876177174057 100644 --- a/kayak_render_macros/src/lib.rs +++ b/kayak_render_macros/src/lib.rs @@ -5,11 +5,11 @@ mod tags; mod arc_function; mod attribute; +mod child; +mod children; mod partial_eq; mod widget; mod widget_attributes; -mod child; -mod children; use partial_eq::impl_dyn_partial_eq; use proc_macro::TokenStream; @@ -36,7 +36,7 @@ pub fn render(input: TokenStream) -> TokenStream { TokenStream::from(result) } -/// Generate a renderable component tree, before rendering it +/// Generate a renderable widget tree, before rendering it #[proc_macro] #[proc_macro_error] pub fn rsx(input: TokenStream) -> TokenStream { @@ -65,7 +65,7 @@ pub fn rsx(input: TokenStream) -> TokenStream { #[proc_macro_error] pub fn widget(_attr: TokenStream, item: TokenStream) -> TokenStream { let f = parse_macro_input!(item as syn::ItemFn); - function_component::create_function_component(f) + function_component::create_function_widget(f) } #[proc_macro_derive(DynPartialEq)] diff --git a/kayak_widgets/src/element.rs b/kayak_widgets/src/element.rs deleted file mode 100644 index 2972b9473ffa462d91f5ea25021ecc51dbf440d0..0000000000000000000000000000000000000000 --- a/kayak_widgets/src/element.rs +++ /dev/null @@ -1,10 +0,0 @@ -use kayak_core::{component, rsx, Render, Update}; - -#[component] -pub fn Element<Children: Render + Update + Clone>(children: Children) { - rsx! { - <> - {children} - </> - } -} diff --git a/src/lib.rs b/src/lib.rs index ef4090a722fce06ee2f46035ad9d895341e0cfb9..fe3152e13cd960a05e266cd143a7b82a62a4a86a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -pub mod components { +pub mod widgets { pub use kayak_widgets::*; }