Skip to content
Snippets Groups Projects
Commit 76520001 authored by StarArawn's avatar StarArawn
Browse files

More cleanup..

parent ce55442d
No related branches found
No related tags found
No related merge requests found
...@@ -20,7 +20,7 @@ Kayak UI is in the very early stages of development. Important features are miss ...@@ -20,7 +20,7 @@ Kayak UI is in the very early stages of development. Important features are miss
- Basic widget and global state management - Basic widget and global state management
- Input events - Input events
- Fast and accurate layouts using morphorm: https://github.com/geom3trik/morphorm - 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. - Style system built to kind of mimic CSS styles.
- Image and Nine patch rendering. - Image and Nine patch rendering.
...@@ -31,6 +31,10 @@ Kayak UI is in the very early stages of development. Important features are miss ...@@ -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. - 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). - Fully integrated into bevy to capture input events, use bevy assets(images, etc).
## Missing features
- Tree diffing
- Removing of widgets.
## Example Screenshot ## Example Screenshot
<img src="images/screen1.png" alt="Kayak UI" width="600" /> <img src="images/screen1.png" alt="Kayak UI" width="600" />
......
...@@ -6,7 +6,7 @@ use bevy::{ ...@@ -6,7 +6,7 @@ use bevy::{
}; };
use bevy_kayak_ui::{BevyContext, BevyKayakUIPlugin, FontMapping, UICameraBundle}; use bevy_kayak_ui::{BevyContext, BevyKayakUIPlugin, FontMapping, UICameraBundle};
use kayak_core::Index; use kayak_core::Index;
use kayak_ui::components::App; use kayak_ui::widgets::App;
use kayak_ui::core::{rsx, widget}; use kayak_ui::core::{rsx, widget};
use kayak_widgets::Window; use kayak_widgets::Window;
......
...@@ -9,7 +9,7 @@ use kayak_core::{ ...@@ -9,7 +9,7 @@ use kayak_core::{
styles::{Style, StyleProp, Units}, styles::{Style, StyleProp, Units},
Bound, EventType, Index, MutableBound, OnEvent, Bound, EventType, Index, MutableBound, OnEvent,
}; };
use kayak_ui::components::App; use kayak_ui::widgets::App;
use kayak_ui::core::{rsx, widget}; use kayak_ui::core::{rsx, widget};
use kayak_widgets::{Button, Text, Window}; use kayak_widgets::{Button, Text, Window};
......
...@@ -11,7 +11,7 @@ use kayak_core::{ ...@@ -11,7 +11,7 @@ use kayak_core::{
styles::{LayoutType, Style, StyleProp, Units}, styles::{LayoutType, Style, StyleProp, Units},
widget, Bound, Children, EventType, Index, MutableBound, OnEvent, widget, Bound, Children, EventType, Index, MutableBound, OnEvent,
}; };
use kayak_ui::components::App; use kayak_ui::widgets::App;
use kayak_ui::core::rsx; use kayak_ui::core::rsx;
#[widget] #[widget]
......
...@@ -7,7 +7,7 @@ use bevy::{ ...@@ -7,7 +7,7 @@ use bevy::{
use bevy_kayak_ui::{BevyContext, BevyKayakUIPlugin, FontMapping, UICameraBundle}; use bevy_kayak_ui::{BevyContext, BevyKayakUIPlugin, FontMapping, UICameraBundle};
use kayak_widgets::{Text, Window}; use kayak_widgets::{Text, Window};
use kayak_core::{bind, Binding, Bound, Index, MutableBound}; use kayak_core::{bind, Binding, Bound, Index, MutableBound};
use kayak_ui::components::App; use kayak_ui::widgets::App;
use kayak_ui::core::{rsx, widget}; use kayak_ui::core::{rsx, widget};
#[derive(Clone, PartialEq)] #[derive(Clone, PartialEq)]
......
...@@ -7,7 +7,7 @@ use bevy::{ ...@@ -7,7 +7,7 @@ use bevy::{
use bevy_kayak_ui::{BevyContext, BevyKayakUIPlugin, ImageManager, UICameraBundle}; use bevy_kayak_ui::{BevyContext, BevyKayakUIPlugin, ImageManager, UICameraBundle};
use kayak_widgets::Image; use kayak_widgets::Image;
use kayak_core::Index; use kayak_core::Index;
use kayak_ui::components::App; use kayak_ui::widgets::App;
use kayak_ui::core::rsx; use kayak_ui::core::rsx;
fn startup( fn startup(
......
...@@ -10,7 +10,7 @@ use kayak_core::{ ...@@ -10,7 +10,7 @@ use kayak_core::{
styles::{Style, StyleProp, Units}, styles::{Style, StyleProp, Units},
Index, Index,
}; };
use kayak_ui::components::App; use kayak_ui::widgets::App;
use kayak_ui::core::rsx; use kayak_ui::core::rsx;
use kayak_widgets::NinePatch; use kayak_widgets::NinePatch;
......
...@@ -186,26 +186,6 @@ impl KayakContext { ...@@ -186,26 +186,6 @@ impl KayakContext {
return None; 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) { pub fn set_global_state<T: resources::Resource>(&mut self, state: T) {
self.global_state.insert(state); self.global_state.insert(state);
} }
......
...@@ -52,7 +52,7 @@ impl Attribute { ...@@ -52,7 +52,7 @@ impl Attribute {
.join("_"); .join("_");
let error_message = format!( 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 alternative_name
); );
......
...@@ -3,7 +3,7 @@ use proc_macro_error::emit_error; ...@@ -3,7 +3,7 @@ use proc_macro_error::emit_error;
use quote::{quote, ToTokens}; use quote::{quote, ToTokens};
use syn::spanned::Spanned; 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 struct_name = f.sig.ident;
let (impl_generics, ty_generics, where_clause) = f.sig.generics.split_for_impl(); let (impl_generics, ty_generics, where_clause) = f.sig.generics.split_for_impl();
let inputs = f.sig.inputs; let inputs = f.sig.inputs;
...@@ -25,7 +25,7 @@ pub fn create_function_component(f: syn::ItemFn) -> TokenStream { ...@@ -25,7 +25,7 @@ pub fn create_function_component(f: syn::ItemFn) -> TokenStream {
} }
} }
syn::FnArg::Receiver(rec) => { 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 None
} }
}) })
......
...@@ -5,11 +5,11 @@ mod tags; ...@@ -5,11 +5,11 @@ mod tags;
mod arc_function; mod arc_function;
mod attribute; mod attribute;
mod child;
mod children;
mod partial_eq; mod partial_eq;
mod widget; mod widget;
mod widget_attributes; mod widget_attributes;
mod child;
mod children;
use partial_eq::impl_dyn_partial_eq; use partial_eq::impl_dyn_partial_eq;
use proc_macro::TokenStream; use proc_macro::TokenStream;
...@@ -36,7 +36,7 @@ pub fn render(input: TokenStream) -> TokenStream { ...@@ -36,7 +36,7 @@ pub fn render(input: TokenStream) -> TokenStream {
TokenStream::from(result) TokenStream::from(result)
} }
/// Generate a renderable component tree, before rendering it /// Generate a renderable widget tree, before rendering it
#[proc_macro] #[proc_macro]
#[proc_macro_error] #[proc_macro_error]
pub fn rsx(input: TokenStream) -> TokenStream { pub fn rsx(input: TokenStream) -> TokenStream {
...@@ -65,7 +65,7 @@ pub fn rsx(input: TokenStream) -> TokenStream { ...@@ -65,7 +65,7 @@ pub fn rsx(input: TokenStream) -> TokenStream {
#[proc_macro_error] #[proc_macro_error]
pub fn widget(_attr: TokenStream, item: TokenStream) -> TokenStream { pub fn widget(_attr: TokenStream, item: TokenStream) -> TokenStream {
let f = parse_macro_input!(item as syn::ItemFn); 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)] #[proc_macro_derive(DynPartialEq)]
......
use kayak_core::{component, rsx, Render, Update};
#[component]
pub fn Element<Children: Render + Update + Clone>(children: Children) {
rsx! {
<>
{children}
</>
}
}
pub mod components { pub mod widgets {
pub use kayak_widgets::*; pub use kayak_widgets::*;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment