diff --git a/examples/context.rs b/examples/context.rs index 3c921c7d693a31da0088e665cffcf0f7ad465671..adde9d08646a3691c76dd6b194485b637e2e8abe 100644 --- a/examples/context.rs +++ b/examples/context.rs @@ -57,7 +57,6 @@ struct ThemeButton { pub theme: Theme, } impl Widget for ThemeButton {} -impl WidgetProps for ThemeButton {} #[derive(Bundle)] pub struct ThemeButtonBundle { @@ -142,7 +141,6 @@ fn update_theme_button( #[derive(Component, Debug, Default, Clone, PartialEq)] struct ThemeSelector; impl Widget for ThemeSelector {} -impl WidgetProps for ThemeSelector {} #[derive(Bundle)] pub struct ThemeSelectorBundle { @@ -202,7 +200,6 @@ pub struct ThemeDemo { context_entity: Option<Entity>, } impl Widget for ThemeDemo {} -impl WidgetProps for ThemeDemo {} #[derive(Bundle)] pub struct ThemeDemoBundle { diff --git a/examples/demo.rs b/examples/demo.rs index 96e2a20dcd5e27b01755aca1d5fd64581e7067df..8c704f1addf4430045b1740eb78c2d2b9730c9de 100644 --- a/examples/demo.rs +++ b/examples/demo.rs @@ -19,7 +19,6 @@ fn my_widget_1_render( } impl Widget for MyWidget {} -impl WidgetProps for MyWidget {} fn startup(mut commands: Commands) { let mut context = Context::new(); diff --git a/examples/quads.rs b/examples/quads.rs index d59e9ccef4a44e9996da95c0c5c1a3cd53f78914..0d9e7c415c80563e5bc7bea15a76aa6163db945b 100644 --- a/examples/quads.rs +++ b/examples/quads.rs @@ -7,7 +7,6 @@ use bevy::{ DefaultPlugins, }; use kayak_ui::prelude::{widgets::*, KStyle, *}; -use morphorm::{PositionType, Units}; #[derive(Component, Default, Clone, PartialEq)] pub struct MyQuad { @@ -61,7 +60,6 @@ fn my_quad_update( } impl Widget for MyQuad {} -impl WidgetProps for MyQuad {} #[derive(Bundle)] pub struct MyQuadBundle { diff --git a/examples/simple_state.rs b/examples/simple_state.rs index 3e90b32b27f6c6377599357f75c469c5e4985083..c32fc25b266a56a3b3a8ace5a0978c032076d667 100644 --- a/examples/simple_state.rs +++ b/examples/simple_state.rs @@ -11,7 +11,6 @@ use kayak_ui::prelude::{widgets::*, *}; struct CurrentCount; impl Widget for CurrentCount {} -impl WidgetProps for CurrentCount {} #[derive(Component, Default, PartialEq, Clone)] struct CurrentCountState { diff --git a/examples/tabs/tab.rs b/examples/tabs/tab.rs index 9041a3048c4067d16a4aecf6332b5ec778eea57a..9367d6126ebf39af796e6ce83ef335b77ebfa236 100644 --- a/examples/tabs/tab.rs +++ b/examples/tabs/tab.rs @@ -1,9 +1,8 @@ use bevy::prelude::{Bundle, Color, Commands, Component, Entity, In, Query}; use kayak_ui::prelude::{ - widgets::BackgroundBundle, Edge, KChildren, KStyle, StyleProp, Units, Widget, WidgetContext, - WidgetName, WidgetProps, + rsx, widgets::BackgroundBundle, Edge, KChildren, KStyle, StyleProp, Units, Widget, + WidgetContext, WidgetName, }; -use kayak_ui_macros::rsx; use crate::tab_context::TabContext; @@ -13,7 +12,6 @@ pub struct Tab { } impl Widget for Tab {} -impl WidgetProps for Tab {} #[derive(Bundle)] pub struct TabBundle { diff --git a/examples/tabs/tab_button.rs b/examples/tabs/tab_button.rs index a11df537057200e0c05f49d030f8465375e5bb8a..017cf70ced8f2016ca673789ada58cf8d7faf663 100644 --- a/examples/tabs/tab_button.rs +++ b/examples/tabs/tab_button.rs @@ -3,7 +3,7 @@ use kayak_ui::prelude::{ rsx, widgets::{KButtonBundle, TextProps, TextWidgetBundle}, Event, EventDispatcherContext, EventType, KChildren, KStyle, OnEvent, StyleProp, Units, Widget, - WidgetContext, WidgetName, WidgetProps, WidgetState, + WidgetContext, WidgetName, WidgetState, }; use crate::tab_context::TabContext; @@ -15,7 +15,6 @@ pub struct TabButton { } impl Widget for TabButton {} -impl WidgetProps for TabButton {} #[derive(Bundle)] pub struct TabButtonBundle { diff --git a/examples/tabs/tab_context.rs b/examples/tabs/tab_context.rs index 64fb0e6919b3fd1980e0c15c57dd3fa156311bb8..671bb5ec2167a1c9100973b65e45298e6dde9425 100644 --- a/examples/tabs/tab_context.rs +++ b/examples/tabs/tab_context.rs @@ -12,7 +12,6 @@ pub struct TabContextProvider { } impl Widget for TabContextProvider {} -impl WidgetProps for TabContextProvider {} #[derive(Bundle)] pub struct TabContextProviderBundle { diff --git a/examples/text.rs b/examples/text.rs index 63568971546a08cbfb0928c478a9e4b88746c69d..bcd828245c599bac98d5714ca3fc6301226f1637 100644 --- a/examples/text.rs +++ b/examples/text.rs @@ -33,7 +33,6 @@ fn my_widget_1_update( } impl Widget for MyWidgetProps {} -impl WidgetProps for MyWidgetProps {} #[derive(Bundle)] pub struct MyWidgetBundle { diff --git a/examples/text_box.rs b/examples/text_box.rs index 987311b986dd5ac205a8b506c0e8c8d25ba7d10f..c5ad6b1a38545c3b3f928d64191a24b3e2ffc2ec 100644 --- a/examples/text_box.rs +++ b/examples/text_box.rs @@ -17,7 +17,6 @@ struct TextBoxExampleState { } impl Widget for TextBoxExample {} -impl WidgetProps for TextBoxExample {} #[derive(Bundle)] struct TextBoxExampleBundle { diff --git a/examples/todo/input.rs b/examples/todo/input.rs index c89225f499591bf4ed6e4e7560b767d303ac12f4..8687c848514f86df6512e24bf3ba2a6aaa67fe51 100644 --- a/examples/todo/input.rs +++ b/examples/todo/input.rs @@ -9,7 +9,6 @@ pub struct TodoInputProps { } impl Widget for TodoInputProps {} -impl WidgetProps for TodoInputProps {} #[derive(Bundle)] pub struct TodoInputBundle { diff --git a/examples/todo/items.rs b/examples/todo/items.rs index 3acd87d1f7678317e5c3fd6e667ca79d617f06f2..fc839e032f056e69fe20f83221aea142437ff9a5 100644 --- a/examples/todo/items.rs +++ b/examples/todo/items.rs @@ -7,7 +7,6 @@ use crate::TodoList; pub struct TodoItemsProps; impl Widget for TodoItemsProps {} -impl WidgetProps for TodoItemsProps {} #[derive(Bundle)] pub struct TodoItemsBundle { diff --git a/examples/todo/todo.rs b/examples/todo/todo.rs index 442c42b4ab458f7cdde4f4580fbf3c1e4cc775d3..bd5ca718b65e6e24d8f621a01577d9d99e30eb94 100644 --- a/examples/todo/todo.rs +++ b/examples/todo/todo.rs @@ -31,7 +31,7 @@ impl TodoList { // Our own version of widget_update that handles resource change events. pub fn widget_update_with_resource< - Props: WidgetProps + PartialEq + Component + Clone, + Props: PartialEq + Component + Clone, State: PartialEq + Component + Clone, >( In((widget_context, entity, previous_entity)): In<(WidgetContext, Entity, Entity)>, diff --git a/examples/vec.rs b/examples/vec.rs index c12deddf849a6e67186c4f769d69ecf6ff93bb5f..bb6df14d52c3ec583496bb13fb2b5ad5fd28950c 100644 --- a/examples/vec.rs +++ b/examples/vec.rs @@ -42,7 +42,6 @@ fn my_widget_1_update( } impl Widget for MyWidgetProps {} -impl WidgetProps for MyWidgetProps {} #[derive(Bundle)] pub struct MyWidgetBundle { diff --git a/src/context.rs b/src/context.rs index b1143a895727aaafc58c26b3219464c6c3a2a8da..237cb5f465967493c553b02d6b59e40bb698c879 100644 --- a/src/context.rs +++ b/src/context.rs @@ -21,7 +21,6 @@ use crate::{ render_primitive::RenderPrimitive, styles::KStyle, tree::{Change, Tree}, - widget::WidgetProps, widget_state::WidgetState, Focusable, WindowSize, }; @@ -91,7 +90,7 @@ impl Context { } pub fn add_widget_data< - Props: WidgetProps + Component + Clone + PartialEq, + Props: Component + Clone + PartialEq, State: Component + Clone + PartialEq, >( &mut self, diff --git a/src/widget.rs b/src/widget.rs index 851a1da41b300b7a6a3f0df9fba86f25924c3b2c..c29b1491a01b6358aabbe5be8e6140283b84bb82 100644 --- a/src/widget.rs +++ b/src/widget.rs @@ -19,13 +19,7 @@ pub trait Widget: Send + Sync { #[derive(Component, Default, PartialEq, Clone)] pub struct EmptyState; -/// Used to diff widget props. -pub trait WidgetProps {} - -pub fn widget_update< - Props: WidgetProps + PartialEq + Component + Clone, - State: PartialEq + Component + Clone, ->( +pub fn widget_update<Props: PartialEq + Component + Clone, State: PartialEq + Component + Clone>( In((widget_context, entity, previous_entity)): In<(WidgetContext, Entity, Entity)>, widget_param: WidgetParam<Props, State>, ) -> bool { @@ -33,7 +27,7 @@ pub fn widget_update< } pub fn widget_update_with_context< - Props: WidgetProps + PartialEq + Component + Clone, + Props: PartialEq + Component + Clone, State: PartialEq + Component + Clone, Context: PartialEq + Component + Clone + Default, >( @@ -52,12 +46,7 @@ pub fn widget_update_with_context< } #[derive(SystemParam)] -pub struct WidgetParam< - 'w, - 's, - Props: WidgetProps + PartialEq + Component, - State: PartialEq + Component, -> { +pub struct WidgetParam<'w, 's, Props: PartialEq + Component, State: PartialEq + Component> { pub props_query: Query<'w, 's, &'static Props>, pub old_props_query: Query<'w, 's, &'static Props>, pub mounted_query: Query<'w, 's, Entity, With<Mounted>>, @@ -67,7 +56,7 @@ pub struct WidgetParam< pub widget_names: Query<'w, 's, &'static WidgetName>, } -impl<'w, 's, Props: WidgetProps + PartialEq + Component, State: PartialEq + Component> +impl<'w, 's, Props: PartialEq + Component, State: PartialEq + Component> WidgetParam<'w, 's, Props, State> { pub fn has_changed( diff --git a/src/widgets/app.rs b/src/widgets/app.rs index 47995ed9b41fba2eb54bf703c9e8a935b7c923ca..606a210bbd97c10af4b227bf5b89a7ea67ceb7c1 100644 --- a/src/widgets/app.rs +++ b/src/widgets/app.rs @@ -6,14 +6,13 @@ use crate::{ context::WidgetName, prelude::WidgetContext, styles::{KStyle, RenderCommand, StyleProp}, - widget::{EmptyState, Widget, WidgetParam, WidgetProps}, + widget::{EmptyState, Widget, WidgetParam}, }; #[derive(Component, Default, Clone, PartialEq)] pub struct KayakApp; impl Widget for KayakApp {} -impl WidgetProps for KayakApp {} #[derive(Bundle)] pub struct KayakAppBundle { diff --git a/src/widgets/background.rs b/src/widgets/background.rs index 0bcbaaa07959f6bd6dd364c772db43fee0a5e881..166c4e15b122484dc414bc609ee0d88f165c19bf 100644 --- a/src/widgets/background.rs +++ b/src/widgets/background.rs @@ -6,14 +6,13 @@ use crate::{ on_event::OnEvent, prelude::WidgetContext, styles::{KStyle, RenderCommand, StyleProp}, - widget::{Widget, WidgetProps}, + widget::Widget, }; #[derive(Component, PartialEq, Clone, Default)] pub struct Background; impl Widget for Background {} -impl WidgetProps for Background {} #[derive(Bundle)] pub struct BackgroundBundle { diff --git a/src/widgets/button.rs b/src/widgets/button.rs index d882860074d11d30a3b77e35f4ad38b061ebbe15..f49779fae7c3f6508e1aac125184ae0f47108a2a 100644 --- a/src/widgets/button.rs +++ b/src/widgets/button.rs @@ -8,7 +8,7 @@ use crate::{ on_event::OnEvent, prelude::{KChildren, Units, WidgetContext}, styles::{Corner, KCursorIcon, KStyle, RenderCommand, StyleProp}, - widget::{Widget, WidgetProps}, + widget::Widget, }; #[derive(Component, PartialEq, Clone, Default)] @@ -36,7 +36,6 @@ impl Default for KButtonBundle { } impl Widget for KButton {} -impl WidgetProps for KButton {} pub fn button_render( In((widget_context, entity)): In<(WidgetContext, Entity)>, diff --git a/src/widgets/clip.rs b/src/widgets/clip.rs index 349c52b4059ccdbfda86be70aa6e0b94e5a945ff..b37dd16c50dbe523d6b5869dc1da08a757e7bea9 100644 --- a/src/widgets/clip.rs +++ b/src/widgets/clip.rs @@ -5,14 +5,13 @@ use crate::{ context::WidgetName, prelude::WidgetContext, styles::{KStyle, RenderCommand, StyleProp, Units}, - widget::{Widget, WidgetProps}, + widget::Widget, }; #[derive(Component, PartialEq, Clone, Default)] pub struct Clip; impl Widget for Clip {} -impl WidgetProps for Clip {} #[derive(Bundle)] pub struct ClipBundle { diff --git a/src/widgets/element.rs b/src/widgets/element.rs index e55646e1ac68416f29e5d2f889e54cc89469edf1..86c4c5d07d32f4b778111c38a12b1921a1521ba6 100644 --- a/src/widgets/element.rs +++ b/src/widgets/element.rs @@ -6,14 +6,13 @@ use crate::{ on_event::OnEvent, prelude::WidgetContext, styles::{KStyle, RenderCommand, StyleProp}, - widget::{Widget, WidgetProps}, + widget::Widget, }; #[derive(Component, PartialEq, Clone, Default)] pub struct Element; impl Widget for Element {} -impl WidgetProps for Element {} #[derive(Bundle)] pub struct ElementBundle { diff --git a/src/widgets/image.rs b/src/widgets/image.rs index 7d7a97bdeddb2256d1af24f20b66b8133cc0a9ec..321a4ea60bc1a066c95a4a125e98c8c10179f51d 100644 --- a/src/widgets/image.rs +++ b/src/widgets/image.rs @@ -4,14 +4,13 @@ use crate::{ context::{Mounted, WidgetName}, prelude::WidgetContext, styles::{KStyle, RenderCommand, StyleProp}, - widget::{Widget, WidgetProps}, + widget::Widget, }; #[derive(Component, PartialEq, Clone, Default)] pub struct Image(pub Handle<bevy::prelude::Image>); impl Widget for Image {} -impl WidgetProps for Image {} #[derive(Bundle)] pub struct ImageBundle { diff --git a/src/widgets/nine_patch.rs b/src/widgets/nine_patch.rs index 65b02d972000d4cfe0640166b956af26f3d86917..9fb7fea5c9031e576e06bba75f8eb8ab54d5c721 100644 --- a/src/widgets/nine_patch.rs +++ b/src/widgets/nine_patch.rs @@ -5,7 +5,7 @@ use crate::{ context::WidgetName, prelude::WidgetContext, styles::{Edge, KStyle, RenderCommand, StyleProp}, - widget::{Widget, WidgetProps}, + widget::Widget, }; #[derive(Component, PartialEq, Clone, Default, Debug)] @@ -17,7 +17,6 @@ pub struct NinePatch { } impl Widget for NinePatch {} -impl WidgetProps for NinePatch {} #[derive(Bundle)] pub struct NinePatchBundle { diff --git a/src/widgets/scroll/scroll_bar.rs b/src/widgets/scroll/scroll_bar.rs index 37f856a13a9e9d36d4f558cfd78e60f04c334c7a..790faba4ee976860612850df9133604cd3ba491b 100644 --- a/src/widgets/scroll/scroll_bar.rs +++ b/src/widgets/scroll/scroll_bar.rs @@ -8,7 +8,7 @@ use crate::{ on_event::OnEvent, prelude::{KChildren, WidgetContext}, styles::{Corner, Edge, KStyle, PositionType, RenderCommand, Units}, - widget::{Widget, WidgetProps}, + widget::Widget, widget_state::WidgetState, widgets::{BackgroundBundle, ClipBundle}, }; @@ -35,7 +35,6 @@ pub struct ScrollBarProps { } impl Widget for ScrollBarProps {} -impl WidgetProps for ScrollBarProps {} #[derive(Bundle)] pub struct ScrollBarBundle { diff --git a/src/widgets/scroll/scroll_box.rs b/src/widgets/scroll/scroll_box.rs index 1721d653eb97126a53512c1c2d1fa57750fbe8f6..e42332bd24b90f8da50ba5f4f10ebc8c52d071ce 100644 --- a/src/widgets/scroll/scroll_box.rs +++ b/src/widgets/scroll/scroll_box.rs @@ -11,7 +11,7 @@ use crate::{ on_layout::OnLayout, prelude::{constructor, rsx, WidgetContext}, styles::{KStyle, LayoutType, PositionType, RenderCommand, Units}, - widget::{Widget, WidgetProps}, + widget::Widget, widget_state::WidgetState, widgets::{ scroll::{ @@ -54,7 +54,6 @@ pub struct ScrollBoxProps { } impl Widget for ScrollBoxProps {} -impl WidgetProps for ScrollBoxProps {} #[derive(Bundle)] pub struct ScrollBoxBundle { diff --git a/src/widgets/scroll/scroll_content.rs b/src/widgets/scroll/scroll_content.rs index 6898e877918f87d99753ac59ac94c22886f85440..e41c038b35f059f076db8e0fd5a0b2b94b0a1a2e 100644 --- a/src/widgets/scroll/scroll_content.rs +++ b/src/widgets/scroll/scroll_content.rs @@ -8,7 +8,7 @@ use crate::{ on_layout::OnLayout, prelude::WidgetContext, styles::{KStyle, LayoutType, RenderCommand, Units}, - widget::{Widget, WidgetProps}, + widget::Widget, }; use super::scroll_context::ScrollContext; @@ -17,7 +17,6 @@ use super::scroll_context::ScrollContext; pub struct ScrollContentProps; impl Widget for ScrollContentProps {} -impl WidgetProps for ScrollContentProps {} #[derive(Bundle)] pub struct ScrollContentBundle { diff --git a/src/widgets/scroll/scroll_context.rs b/src/widgets/scroll/scroll_context.rs index 2f1947075ab4e6a76dcde46bc9f5ffdf87595cdf..09a0bb58aa2dad6dc1ab4363345bec7116a57266 100644 --- a/src/widgets/scroll/scroll_context.rs +++ b/src/widgets/scroll/scroll_context.rs @@ -1,11 +1,8 @@ use bevy::prelude::{Bundle, Commands, Component, Entity, In, Query, Vec2}; use crate::{ - children::KChildren, - context::WidgetName, - prelude::WidgetContext, - styles::KStyle, - widget::{Widget, WidgetProps}, + children::KChildren, context::WidgetName, prelude::WidgetContext, styles::KStyle, + widget::Widget, }; /// Context data provided by a [`ScrollBox`](crate::ScrollBox) widget @@ -140,7 +137,6 @@ pub struct ScrollContextProvider { } impl Widget for ScrollContextProvider {} -impl WidgetProps for ScrollContextProvider {} #[derive(Bundle)] pub struct ScrollContextProviderBundle { diff --git a/src/widgets/text.rs b/src/widgets/text.rs index 13b307dce0335ac8e27946f739f632db8db7cf39..7cb20700e8c518ff2b047b6a4f8f91531baf421e 100644 --- a/src/widgets/text.rs +++ b/src/widgets/text.rs @@ -5,7 +5,7 @@ use crate::{ context::WidgetName, prelude::WidgetContext, styles::{KCursorIcon, KStyle, RenderCommand, StyleProp}, - widget::{Widget, WidgetProps}, + widget::Widget, }; #[derive(Component, Debug, PartialEq, Clone)] @@ -44,7 +44,6 @@ impl Default for TextProps { } impl Widget for TextProps {} -impl WidgetProps for TextProps {} #[derive(Bundle)] pub struct TextWidgetBundle { diff --git a/src/widgets/text_box.rs b/src/widgets/text_box.rs index d101027cbb7c39b1b2c6315685c7ad5d8cbb33f0..f775de459949c088e2e50c32544b19ec08e38864 100644 --- a/src/widgets/text_box.rs +++ b/src/widgets/text_box.rs @@ -9,7 +9,7 @@ use crate::{ on_layout::OnLayout, prelude::{KChildren, OnChange, WidgetContext}, styles::{Corner, KStyle, RenderCommand, StyleProp, Units}, - widget::{Widget, WidgetProps}, + widget::Widget, widget_state::WidgetState, widgets::{ text::{TextProps, TextWidgetBundle}, @@ -40,7 +40,6 @@ pub struct TextBoxState { pub struct TextBoxValue(pub String); impl Widget for TextBoxProps {} -impl WidgetProps for TextBoxProps {} /// A widget that displays a text input field /// diff --git a/src/widgets/texture_atlas.rs b/src/widgets/texture_atlas.rs index c9f7cb290b0f57f3c2569f1b4ab71a2eee33ed14..0df6efed82ae14ec5a2b16ec0aeafd02e40d923e 100644 --- a/src/widgets/texture_atlas.rs +++ b/src/widgets/texture_atlas.rs @@ -4,7 +4,7 @@ use crate::{ context::{Mounted, WidgetName}, prelude::WidgetContext, styles::{KStyle, RenderCommand, StyleProp}, - widget::{Widget, WidgetProps}, + widget::Widget, }; /// A widget that renders a texture atlas @@ -33,7 +33,6 @@ pub struct TextureAtlas { } impl Widget for TextureAtlas {} -impl WidgetProps for TextureAtlas {} #[derive(Bundle)] pub struct TextureAtlasBundle { diff --git a/src/widgets/window.rs b/src/widgets/window.rs index 77244e410b08ac73a38231720393d5d43250c4fd..bcbdec501fd005dff9b4224674eae5fbd9890f1c 100644 --- a/src/widgets/window.rs +++ b/src/widgets/window.rs @@ -12,7 +12,7 @@ use crate::{ on_event::OnEvent, prelude::WidgetContext, styles::{Corner, Edge, KCursorIcon, KStyle, PositionType, RenderCommand, StyleProp, Units}, - widget::{Widget, WidgetProps}, + widget::Widget, widget_state::WidgetState, }; @@ -43,7 +43,6 @@ pub struct KWindowState { } impl Widget for KWindow {} -impl WidgetProps for KWindow {} #[derive(Bundle)] pub struct WindowBundle {