From 75a56767830f980bfc43f29fe93659f1eaef30dd Mon Sep 17 00:00:00 2001 From: StarToaster <startoaster23@gmail.com> Date: Mon, 24 Oct 2022 00:04:55 -0400 Subject: [PATCH] Removed unnecessary WidgetProp trait. --- examples/context.rs | 3 --- examples/demo.rs | 1 - examples/quads.rs | 2 -- examples/simple_state.rs | 1 - examples/tabs/tab.rs | 6 ++---- examples/tabs/tab_button.rs | 3 +-- examples/tabs/tab_context.rs | 1 - examples/text.rs | 1 - examples/text_box.rs | 1 - examples/todo/input.rs | 1 - examples/todo/items.rs | 1 - examples/todo/todo.rs | 2 +- examples/vec.rs | 1 - src/context.rs | 3 +-- src/widget.rs | 19 ++++--------------- src/widgets/app.rs | 3 +-- src/widgets/background.rs | 3 +-- src/widgets/button.rs | 3 +-- src/widgets/clip.rs | 3 +-- src/widgets/element.rs | 3 +-- src/widgets/image.rs | 3 +-- src/widgets/nine_patch.rs | 3 +-- src/widgets/scroll/scroll_bar.rs | 3 +-- src/widgets/scroll/scroll_box.rs | 3 +-- src/widgets/scroll/scroll_content.rs | 3 +-- src/widgets/scroll/scroll_context.rs | 8 ++------ src/widgets/text.rs | 3 +-- src/widgets/text_box.rs | 3 +-- src/widgets/texture_atlas.rs | 3 +-- src/widgets/window.rs | 3 +-- 30 files changed, 25 insertions(+), 71 deletions(-) diff --git a/examples/context.rs b/examples/context.rs index 3c921c7..adde9d0 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 96e2a20..8c704f1 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 d59e9cc..0d9e7c4 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 3e90b32..c32fc25 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 9041a30..9367d61 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 a11df53..017cf70 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 64fb0e6..671bb5e 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 6356897..bcd8282 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 987311b..c5ad6b1 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 c89225f..8687c84 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 3acd87d..fc839e0 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 442c42b..bd5ca71 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 c12dedd..bb6df14 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 b1143a8..237cb5f 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 851a1da..c29b149 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 47995ed..606a210 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 0bcbaaa..166c4e1 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 d882860..f49779f 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 349c52b..b37dd16 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 e55646e..86c4c5d 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 7d7a97b..321a4ea 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 65b02d9..9fb7fea 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 37f856a..790faba 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 1721d65..e42332b 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 6898e87..e41c038 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 2f19470..09a0bb5 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 13b307d..7cb2070 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 d101027..f775de4 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 c9f7cb2..0df6efe 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 77244e4..bcbdec5 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 { -- GitLab