From 415d2ccc7e07bdf885f76d2ae117852898498f45 Mon Sep 17 00:00:00 2001 From: StarArawn <toasterthegamer@gmail.com> Date: Thu, 16 Dec 2021 09:16:25 -0500 Subject: [PATCH] Fixed up the examples to use the new render! macro. --- examples/bevy.rs | 8 ++------ examples/clipping.rs | 8 ++------ examples/counter.rs | 8 ++------ examples/full_ui.rs | 7 ++----- examples/global_counter.rs | 7 ++----- examples/if.rs | 9 ++------- examples/image.rs | 7 ++----- examples/nine_patch.rs | 8 ++------ 8 files changed, 16 insertions(+), 46 deletions(-) diff --git a/examples/bevy.rs b/examples/bevy.rs index de2fa16..54e72cb 100644 --- a/examples/bevy.rs +++ b/examples/bevy.rs @@ -6,7 +6,7 @@ use bevy::{ }; use kayak_ui::bevy::{BevyContext, BevyKayakUIPlugin, FontMapping, UICameraBundle}; use kayak_ui::core::Index; -use kayak_ui::core::{rsx, widget}; +use kayak_ui::core::{render, rsx, widget}; use kayak_widgets::{App, Window}; #[widget] @@ -40,11 +40,7 @@ fn startup( }; let context = BevyContext::new(window_size.x, window_size.y, |styles, context| { - // Hack to trick the proc macro for right now.. - let parent_id: Option<Index> = None; - let children: Option<kayak_ui::core::Children> = None; - - rsx! { + render! { <App styles={Some(styles.clone())}> <Window position={(50.0, 50.0)} size={(300.0, 300.0)} title={"Window 1".to_string()}> {} diff --git a/examples/clipping.rs b/examples/clipping.rs index f3fb5da..d33210b 100644 --- a/examples/clipping.rs +++ b/examples/clipping.rs @@ -7,7 +7,7 @@ use bevy::{ use kayak_ui::bevy::{BevyContext, BevyKayakUIPlugin, FontMapping, ImageManager, UICameraBundle}; use kayak_ui::core::{ layout_cache::Space, - rsx, + render, styles::{Style, StyleProp, Units}, Index, }; @@ -34,10 +34,6 @@ fn startup( let panel_brown_handle = image_manager.get(&handle); let context = BevyContext::new(window_size.x, window_size.y, |styles, context| { - // Hack to trick the proc macro for right now.. - let parent_id: Option<Index> = None; - let children: Option<kayak_ui::core::Children> = None; - let nine_patch_styles = Style { width: StyleProp::Value(Units::Pixels(512.0)), height: StyleProp::Value(Units::Pixels(512.0)), @@ -72,7 +68,7 @@ Vivamus pulvinar dui et elit volutpat hendrerit. Praesent luctus dolor ut rutrum Vestibulum rutrum imperdiet nisl, et consequat massa porttitor vel. Ut velit justo, vehicula a nulla eu, auctor eleifend metus. Ut egestas malesuada metus, sit amet pretium nunc commodo ac. Pellentesque gravida, nisl in faucibus volutpat, libero turpis mattis orci, vitae tincidunt ligula ligula ut tortor. Maecenas vehicula lobortis odio in molestie. Curabitur dictum elit sed arcu dictum, ut semper nunc cursus. Donec semper felis non nisl tincidunt elementum. "#.to_string(); - rsx! { + render! { <App styles={Some(styles.clone())}> <NinePatch styles={Some(nine_patch_styles)} diff --git a/examples/counter.rs b/examples/counter.rs index fd925c6..8cc9258 100644 --- a/examples/counter.rs +++ b/examples/counter.rs @@ -6,7 +6,7 @@ use bevy::{ }; use kayak_ui::bevy::{BevyContext, BevyKayakUIPlugin, FontMapping, UICameraBundle}; use kayak_ui::core::{ - rsx, + render, rsx, styles::{Style, StyleProp, Units}, widget, Bound, EventType, Index, MutableBound, OnEvent, }; @@ -73,11 +73,7 @@ fn startup( }; let context = BevyContext::new(window_size.x, window_size.y, |styles, context| { - // Hack to trick the proc macro for right now.. - let parent_id: Option<Index> = None; - let children: Option<kayak_ui::core::Children> = None; - - rsx! { + render! { <App styles={Some(styles.clone())}> <Counter /> </App> diff --git a/examples/full_ui.rs b/examples/full_ui.rs index efa0aca..141c5e1 100644 --- a/examples/full_ui.rs +++ b/examples/full_ui.rs @@ -7,7 +7,7 @@ use bevy::{ use kayak_ui::bevy::{BevyContext, BevyKayakUIPlugin, FontMapping, ImageManager, UICameraBundle}; use kayak_ui::core::{ layout_cache::Space, - rsx, + render, rsx, styles::{LayoutType, Style, StyleProp, Units}, widget, Bound, Children, EventType, Index, MutableBound, OnEvent, }; @@ -101,9 +101,6 @@ fn startup( let panel_brown_handle = image_manager.get(&handle); let context = BevyContext::new(window_size.x, window_size.y, |styles, context| { - // Hack to trick the proc macro for right now.. - let parent_id: Option<Index> = None; - let nine_patch_styles = Style { layout_type: StyleProp::Value(LayoutType::Column), width: StyleProp::Value(Units::Pixels(512.0)), @@ -147,7 +144,7 @@ fn startup( ..Style::default() }; - rsx! { + render! { <App styles={Some(app_styles)}> <NinePatch styles={Some(nine_patch_styles)} diff --git a/examples/global_counter.rs b/examples/global_counter.rs index cbf2d0d..6a0691d 100644 --- a/examples/global_counter.rs +++ b/examples/global_counter.rs @@ -5,7 +5,7 @@ use bevy::{ DefaultPlugins, }; use kayak_ui::bevy::{BevyContext, BevyKayakUIPlugin, FontMapping, UICameraBundle}; -use kayak_ui::core::{bind, rsx, widget, Binding, Bound, Index, MutableBound}; +use kayak_ui::core::{bind, render, rsx, widget, Binding, Bound, Index, MutableBound}; use kayak_widgets::{App, Text, Window}; #[derive(Clone, PartialEq)] @@ -57,10 +57,7 @@ fn startup( commands.insert_resource(bind(GlobalCount(0))); let context = BevyContext::new(window_size.x, window_size.y, |styles, context| { - // Hack to trick the proc macro for right now.. - let parent_id: Option<Index> = None; - let children: Option<kayak_ui::core::Children> = None; - rsx! { + render! { <App styles={Some(styles.clone())}> <Counter /> </App> diff --git a/examples/if.rs b/examples/if.rs index 288b8d4..cb57cb2 100644 --- a/examples/if.rs +++ b/examples/if.rs @@ -6,7 +6,7 @@ use bevy::{ }; use kayak_ui::bevy::{BevyContext, BevyKayakUIPlugin, FontMapping, UICameraBundle}; use kayak_ui::core::{ - rsx, + render, rsx, styles::{Style, StyleProp, Units}, widget, Bound, EventType, Index, MutableBound, OnEvent, }; @@ -75,12 +75,7 @@ fn startup( }; let context = BevyContext::new(window_size.x, window_size.y, |styles, context| { - // Hack to trick the proc macro for right now.. - let parent_id: Option<Index> = None; - let children: Option<kayak_ui::core::Children> = None; - let tree = kayak_ui::core::WidgetTree::new(); - - rsx! { + render! { <App styles={Some(styles.clone())}> <Removal /> </App> diff --git a/examples/image.rs b/examples/image.rs index 178d9e6..7672550 100644 --- a/examples/image.rs +++ b/examples/image.rs @@ -5,7 +5,7 @@ use bevy::{ DefaultPlugins, }; use kayak_ui::bevy::{BevyContext, BevyKayakUIPlugin, ImageManager, UICameraBundle}; -use kayak_ui::core::{rsx, Index}; +use kayak_ui::core::{render, Index}; use kayak_widgets::{App, Image}; fn startup( @@ -26,10 +26,7 @@ fn startup( let ui_image_handle = image_manager.get(&handle); let context = BevyContext::new(window_size.x, window_size.y, |styles, context| { - // Hack to trick the proc macro for right now.. - let parent_id: Option<Index> = None; - let children: Option<kayak_ui::core::Children> = None; - rsx! { + render! { <App styles={Some(styles.clone())}> <Image handle={ui_image_handle} /> </App> diff --git a/examples/nine_patch.rs b/examples/nine_patch.rs index 238cf55..f608f7d 100644 --- a/examples/nine_patch.rs +++ b/examples/nine_patch.rs @@ -7,7 +7,7 @@ use bevy::{ use kayak_ui::bevy::{BevyContext, BevyKayakUIPlugin, ImageManager, UICameraBundle}; use kayak_ui::core::{ layout_cache::Space, - rsx, + render, styles::{Style, StyleProp, Units}, Index, }; @@ -31,10 +31,6 @@ fn startup( let ui_image_handle = image_manager.get(&handle); let context = BevyContext::new(window_size.x, window_size.y, |styles, context| { - // Hack to trick the proc macro for right now.. - let parent_id: Option<Index> = None; - let children: Option<kayak_ui::core::Children> = None; - // The border prop splits up the image into 9 quadrants like so: // 1----2----3 // | | @@ -64,7 +60,7 @@ fn startup( ..Style::default() }; - rsx! { + render! { <App styles={Some(styles.clone())}> <NinePatch styles={Some(nine_patch_styles)} -- GitLab