diff --git a/src/styles/units.rs b/src/styles/units.rs index eab69b5c06676b93eaf48c4db45d1a4c75b06da1..439ab70acb6e1202cf4c5b9d3622e9ef8dba4037 100644 --- a/src/styles/units.rs +++ b/src/styles/units.rs @@ -1,22 +1,17 @@ use bevy::reflect::{FromReflect, Reflect}; /// The layout type determines how nodes will be positioned when directed by the parent -#[derive(Debug, FromReflect, Reflect, Clone, Copy, PartialEq)] +#[derive(Default, Debug, FromReflect, Reflect, Clone, Copy, PartialEq)] pub enum LayoutType { /// Stack child elements horizontally Row, + #[default] /// Stack child elements vertically Column, /// Position child elements into specified rows and columns Grid, } -impl Default for LayoutType { - fn default() -> Self { - LayoutType::Column - } -} - impl From<LayoutType> for morphorm::LayoutType { fn from(val: LayoutType) -> Self { match val { @@ -28,20 +23,15 @@ impl From<LayoutType> for morphorm::LayoutType { } /// The position type determines whether a node will be positioned in-line with its siblings or seperate -#[derive(Debug, Reflect, FromReflect, Clone, Copy, PartialEq)] +#[derive(Default, Debug, Reflect, FromReflect, Clone, Copy, PartialEq)] pub enum KPositionType { /// Node is positioned relative to parent but ignores its siblings SelfDirected, + #[default] /// Node is positioned relative to parent and in-line with siblings ParentDirected, } -impl Default for KPositionType { - fn default() -> Self { - KPositionType::ParentDirected - } -} - impl From<KPositionType> for morphorm::PositionType { fn from(val: KPositionType) -> Self { match val { @@ -52,7 +42,7 @@ impl From<KPositionType> for morphorm::PositionType { } /// Units which describe spacing and size -#[derive(Debug, FromReflect, Reflect, Clone, Copy, PartialEq)] +#[derive(Default, Debug, FromReflect, Reflect, Clone, Copy, PartialEq)] pub enum Units { /// A number of pixels Pixels(f32), @@ -60,16 +50,11 @@ pub enum Units { Percentage(f32), /// A factor of the remaining free space Stretch(f32), + #[default] /// Automatically determine the value Auto, } -impl Default for Units { - fn default() -> Self { - Units::Auto - } -} - impl From<Units> for morphorm::Units { fn from(val: Units) -> Self { match val { diff --git a/src/widgets/scroll/scroll_context.rs b/src/widgets/scroll/scroll_context.rs index 71bbd6071c06e20e08ec9f708d3b927318884853..3e8b645ed5dd55e817de03c1a500383fc67d6852 100644 --- a/src/widgets/scroll/scroll_context.rs +++ b/src/widgets/scroll/scroll_context.rs @@ -26,20 +26,15 @@ pub struct ScrollContext { } #[non_exhaustive] -#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)] pub enum ScrollMode { /// Clamps the scroll offset to stay within the scroll range + #[default] Clamped, /// Allows infinite scrolling Infinite, } -impl Default for ScrollMode { - fn default() -> Self { - ScrollMode::Clamped - } -} - impl ScrollContext { /// Get the current x-axis scroll offset pub fn scroll_x(&self) -> f32 {