From 7652000177bb831755a1715213f6eea5ad94cdcd Mon Sep 17 00:00:00 2001 From: StarArawn <toasterthegamer@gmail.com> Date: Mon, 13 Dec 2021 11:37:32 -0500 Subject: [PATCH] More cleanup.. --- README.md | 6 +++++- examples/bevy.rs | 2 +- examples/counter.rs | 2 +- examples/full_ui.rs | 2 +- examples/global_counter.rs | 2 +- examples/image.rs | 2 +- examples/nine_patch.rs | 2 +- kayak_core/src/context.rs | 20 ------------------- kayak_render_macros/src/attribute.rs | 2 +- kayak_render_macros/src/function_component.rs | 4 ++-- kayak_render_macros/src/lib.rs | 8 ++++---- kayak_widgets/src/element.rs | 10 ---------- src/lib.rs | 2 +- 13 files changed, 19 insertions(+), 45 deletions(-) delete mode 100644 kayak_widgets/src/element.rs diff --git a/README.md b/README.md index eb3e6bc..7ac4177 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 ebc2f49..53b9118 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 3bfe4df..1a82854 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 2ac8416..0771ca4 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 6c46afd..feaf84d 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 25aade5..436500f 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 340b2bb..2e99a11 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 a5cd1c4..9027cd8 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 5cedf71..6b99fc0 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 c75438a..84af347 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 dcedd3d..468b4ab 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 2972b94..0000000 --- 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 ef4090a..fe3152e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -pub mod components { +pub mod widgets { pub use kayak_widgets::*; } -- GitLab